Update client features

This commit is contained in:
Jeremiah Lowin 2025-06-22 13:30:25 -04:00
commit 3d2e2a5954
6 changed files with 26 additions and 29 deletions

View file

@ -182,7 +182,7 @@ async with client:
Explore the detailed documentation for each operation type:
### Core Interactions
### Core Operations
- **[Tools](/clients/tools)** - Execute server-side functions and handle results
- **[Resources](/clients/resources)** - Access static and templated resources
- **[Prompts](/clients/prompts)** - Work with message templates and argument serialization

View file

@ -2,7 +2,7 @@
title: Server Logging
sidebarTitle: Logging
description: Learn how to receive and handle log messages from MCP servers.
icon: file-text
icon: receipt
---
import { VersionBadge } from '/snippets/version-badge.mdx'

View file

@ -2,7 +2,7 @@
title: Progress Monitoring
sidebarTitle: Progress
description: Learn how to handle progress notifications from long-running server operations.
icon: chart-line
icon: bars-progress
---
import { VersionBadge } from '/snippets/version-badge.mdx'

View file

@ -2,7 +2,7 @@
title: Client Roots
sidebarTitle: Roots
description: Learn how to provide local context to MCP servers.
icon: tree
icon: folder-tree
---
import { VersionBadge } from '/snippets/version-badge.mdx'

View file

@ -2,7 +2,7 @@
title: LLM Sampling
sidebarTitle: Sampling
description: Learn how to handle server-initiated LLM sampling requests.
icon: brain
icon: robot
---
import { VersionBadge } from '/snippets/version-badge.mdx'
@ -40,15 +40,31 @@ client = Client(
## Handler Parameters
The sampling handler receives:
The sampling handler receives three parameters:
- **`messages`**: List of `SamplingMessage` objects representing the conversation
- **`params`**: `SamplingParams` object with generation parameters (systemPrompt, maxTokens, temperature, etc.)
- **`context`**: `RequestContext` object with request metadata
### SamplingMessage
- **`role`**: Message role (e.g., "user", "assistant", "system")
- **`content`**: Message content (usually has `.text` attribute)
### SamplingParams
- **`systemPrompt`**: System prompt string (optional)
- **`maxTokens`**: Maximum tokens to generate (optional)
- **`temperature`**: Sampling temperature (optional)
- **`topP`**: Top-p sampling parameter (optional)
- **`stopSequences`**: List of stop sequences (optional)
### RequestContext
- **`request_id`**: Unique identifier for the sampling request
## Basic Example
```python
from fastmcp import Client
from fastmcp.client.sampling import SamplingMessage, SamplingParams, RequestContext
async def basic_sampling_handler(
messages: list[SamplingMessage],
params: SamplingParams,
@ -73,22 +89,3 @@ client = Client(
)
```
## Accessing Parameters
```python
async def parameter_handler(
messages: list[SamplingMessage],
params: SamplingParams,
context: RequestContext
) -> str:
# Available parameters from the server
system_prompt = params.systemPrompt
max_tokens = params.maxTokens
temperature = params.temperature
top_p = params.topP
stop_sequences = params.stopSequences
# Use these parameters with your LLM service
return "Generated response"
```

View file

@ -95,7 +95,7 @@
"pages": [
"clients/client",
{
"group": "Core Interactions",
"group": "Core Operations",
"icon": "handshake",
"pages": [
"clients/tools",