Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Update client features

Jeremiah Lowin3d2e2a5954df
diff --git a/docs/clients/client.mdx b/docs/clients/client.mdx
index e69d45e42..d246c88fe 100644
--- a/docs/clients/client.mdx
+++ b/docs/clients/client.mdx
@@ -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
diff --git a/docs/clients/logging.mdx b/docs/clients/logging.mdx
index ff1a60893..a9ea86a48 100644
--- a/docs/clients/logging.mdx
+++ b/docs/clients/logging.mdx
@@ -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'
diff --git a/docs/clients/progress.mdx b/docs/clients/progress.mdx
index cb9ee0031..f8dd9db1c 100644
--- a/docs/clients/progress.mdx
+++ b/docs/clients/progress.mdx
@@ -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'
diff --git a/docs/clients/roots.mdx b/docs/clients/roots.mdx
index 2db66a37b..48c4aa258 100644
--- a/docs/clients/roots.mdx
+++ b/docs/clients/roots.mdx
@@ -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'
diff --git a/docs/clients/sampling.mdx b/docs/clients/sampling.mdx
index 887541698..0003999f4 100644
--- a/docs/clients/sampling.mdx
+++ b/docs/clients/sampling.mdx
@@ -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"
-```
-
diff --git a/docs/docs.json b/docs/docs.json
index 90f983e72..d35476ca6 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -95,7 +95,7 @@
"pages": [
"clients/client",
{
- "group": "Core Interactions",
+ "group": "Core Operations",
"icon": "handshake",
"pages": [
"clients/tools",