Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
f7b7ab6
1
Parent(s): 87be398
Update client features
Browse files- docs/clients/client.mdx +1 -1
- docs/clients/logging.mdx +1 -1
- docs/clients/progress.mdx +1 -1
- docs/clients/roots.mdx +1 -1
- docs/clients/sampling.mdx +21 -24
- docs/docs.json +1 -1
docs/clients/client.mdx
CHANGED
|
@@ -182,7 +182,7 @@ async with client:
|
|
| 182 |
|
| 183 |
Explore the detailed documentation for each operation type:
|
| 184 |
|
| 185 |
-
### Core
|
| 186 |
- **[Tools](/clients/tools)** - Execute server-side functions and handle results
|
| 187 |
- **[Resources](/clients/resources)** - Access static and templated resources
|
| 188 |
- **[Prompts](/clients/prompts)** - Work with message templates and argument serialization
|
|
|
|
| 182 |
|
| 183 |
Explore the detailed documentation for each operation type:
|
| 184 |
|
| 185 |
+
### Core Operations
|
| 186 |
- **[Tools](/clients/tools)** - Execute server-side functions and handle results
|
| 187 |
- **[Resources](/clients/resources)** - Access static and templated resources
|
| 188 |
- **[Prompts](/clients/prompts)** - Work with message templates and argument serialization
|
docs/clients/logging.mdx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
title: Server Logging
|
| 3 |
sidebarTitle: Logging
|
| 4 |
description: Learn how to receive and handle log messages from MCP servers.
|
| 5 |
-
icon:
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
|
|
|
| 2 |
title: Server Logging
|
| 3 |
sidebarTitle: Logging
|
| 4 |
description: Learn how to receive and handle log messages from MCP servers.
|
| 5 |
+
icon: receipt
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
docs/clients/progress.mdx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
title: Progress Monitoring
|
| 3 |
sidebarTitle: Progress
|
| 4 |
description: Learn how to handle progress notifications from long-running server operations.
|
| 5 |
-
icon:
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
|
|
|
| 2 |
title: Progress Monitoring
|
| 3 |
sidebarTitle: Progress
|
| 4 |
description: Learn how to handle progress notifications from long-running server operations.
|
| 5 |
+
icon: bars-progress
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
docs/clients/roots.mdx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
title: Client Roots
|
| 3 |
sidebarTitle: Roots
|
| 4 |
description: Learn how to provide local context to MCP servers.
|
| 5 |
-
icon: tree
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
|
|
|
| 2 |
title: Client Roots
|
| 3 |
sidebarTitle: Roots
|
| 4 |
description: Learn how to provide local context to MCP servers.
|
| 5 |
+
icon: folder-tree
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
docs/clients/sampling.mdx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
title: LLM Sampling
|
| 3 |
sidebarTitle: Sampling
|
| 4 |
description: Learn how to handle server-initiated LLM sampling requests.
|
| 5 |
-
icon:
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
|
@@ -40,15 +40,31 @@ client = Client(
|
|
| 40 |
|
| 41 |
## Handler Parameters
|
| 42 |
|
| 43 |
-
The sampling handler receives:
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
- **`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
## Basic Example
|
| 50 |
|
| 51 |
```python
|
|
|
|
|
|
|
|
|
|
| 52 |
async def basic_sampling_handler(
|
| 53 |
messages: list[SamplingMessage],
|
| 54 |
params: SamplingParams,
|
|
@@ -73,22 +89,3 @@ client = Client(
|
|
| 73 |
)
|
| 74 |
```
|
| 75 |
|
| 76 |
-
## Accessing Parameters
|
| 77 |
-
|
| 78 |
-
```python
|
| 79 |
-
async def parameter_handler(
|
| 80 |
-
messages: list[SamplingMessage],
|
| 81 |
-
params: SamplingParams,
|
| 82 |
-
context: RequestContext
|
| 83 |
-
) -> str:
|
| 84 |
-
# Available parameters from the server
|
| 85 |
-
system_prompt = params.systemPrompt
|
| 86 |
-
max_tokens = params.maxTokens
|
| 87 |
-
temperature = params.temperature
|
| 88 |
-
top_p = params.topP
|
| 89 |
-
stop_sequences = params.stopSequences
|
| 90 |
-
|
| 91 |
-
# Use these parameters with your LLM service
|
| 92 |
-
return "Generated response"
|
| 93 |
-
```
|
| 94 |
-
|
|
|
|
| 2 |
title: LLM Sampling
|
| 3 |
sidebarTitle: Sampling
|
| 4 |
description: Learn how to handle server-initiated LLM sampling requests.
|
| 5 |
+
icon: robot
|
| 6 |
---
|
| 7 |
|
| 8 |
import { VersionBadge } from '/snippets/version-badge.mdx'
|
|
|
|
| 40 |
|
| 41 |
## Handler Parameters
|
| 42 |
|
| 43 |
+
The sampling handler receives three parameters:
|
| 44 |
|
| 45 |
+
### SamplingMessage
|
| 46 |
+
|
| 47 |
+
- **`role`**: Message role (e.g., "user", "assistant", "system")
|
| 48 |
+
- **`content`**: Message content (usually has `.text` attribute)
|
| 49 |
+
|
| 50 |
+
### SamplingParams
|
| 51 |
+
|
| 52 |
+
- **`systemPrompt`**: System prompt string (optional)
|
| 53 |
+
- **`maxTokens`**: Maximum tokens to generate (optional)
|
| 54 |
+
- **`temperature`**: Sampling temperature (optional)
|
| 55 |
+
- **`topP`**: Top-p sampling parameter (optional)
|
| 56 |
+
- **`stopSequences`**: List of stop sequences (optional)
|
| 57 |
+
|
| 58 |
+
### RequestContext
|
| 59 |
+
|
| 60 |
+
- **`request_id`**: Unique identifier for the sampling request
|
| 61 |
|
| 62 |
## Basic Example
|
| 63 |
|
| 64 |
```python
|
| 65 |
+
from fastmcp import Client
|
| 66 |
+
from fastmcp.client.sampling import SamplingMessage, SamplingParams, RequestContext
|
| 67 |
+
|
| 68 |
async def basic_sampling_handler(
|
| 69 |
messages: list[SamplingMessage],
|
| 70 |
params: SamplingParams,
|
|
|
|
| 89 |
)
|
| 90 |
```
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/docs.json
CHANGED
|
@@ -95,7 +95,7 @@
|
|
| 95 |
"pages": [
|
| 96 |
"clients/client",
|
| 97 |
{
|
| 98 |
-
"group": "Core
|
| 99 |
"icon": "handshake",
|
| 100 |
"pages": [
|
| 101 |
"clients/tools",
|
|
|
|
| 95 |
"pages": [
|
| 96 |
"clients/client",
|
| 97 |
{
|
| 98 |
+
"group": "Core Operations",
|
| 99 |
"icon": "handshake",
|
| 100 |
"pages": [
|
| 101 |
"clients/tools",
|