Jeremiah Lowin Claude commited on
Commit
87be398
·
1 Parent(s): ae32ca4

Update overview

Browse files

Co-Authored-By: Claude <claude@users.noreply.github.com>

docs/clients/client.mdx CHANGED
@@ -15,7 +15,6 @@ The `fastmcp.Client` is a **programmatic client** for interacting with any Model
15
  - **Building deterministic applications** that need reliable MCP interactions
16
  - **Creating the foundation for agentic or LLM-based clients** with structured, type-safe operations
17
 
18
- All client operations require using the `async with` context manager for proper connection lifecycle management.
19
 
20
  <Note>
21
  This is not an agentic client - it requires explicit function calls and provides direct control over all MCP operations. Use it as a building block for higher-level systems.
@@ -23,7 +22,7 @@ This is not an agentic client - it requires explicit function calls and provides
23
 
24
  ## Quick Start
25
 
26
- The client uses transport inference to automatically determine the connection method:
27
 
28
  ```python
29
  import asyncio
@@ -86,11 +85,37 @@ client_http = Client("https://api.example.com/mcp")
86
  For testing and development, always prefer the in-memory transport by passing a `FastMCP` server directly to the client. This eliminates network complexity and separate processes.
87
  </Tip>
88
 
89
- ## Multi-Server Clients
90
 
91
  <VersionBadge version="2.4.0" />
92
 
93
- Connect to multiple MCP servers through a single client using MCP configuration:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  ```python
96
  config = {
@@ -143,43 +168,14 @@ The client provides methods for all standard MCP operations:
143
  | **Prompts** | `list_prompts()`, `get_prompt()` | Retrieve message templates |
144
  | **Utility** | `ping()` | Test server connectivity |
145
 
146
- ### Quick Examples
147
-
148
- ```python
149
- async with client:
150
- # Tool operations
151
- tools = await client.list_tools()
152
- result = await client.call_tool("calculate", {"a": 5, "b": 3})
153
-
154
- # Resource operations
155
- resources = await client.list_resources()
156
- content = await client.read_resource("file:///config/settings.json")
157
-
158
- # Prompt operations
159
- prompts = await client.list_prompts()
160
- messages = await client.get_prompt("welcome", {"name": "Alice"})
161
- ```
162
 
163
- ## Advanced Configuration
164
-
165
- The client supports additional configuration for specialized use cases:
166
 
167
  ```python
168
- from fastmcp import Client
169
- from fastmcp.client.logging import LogMessage
170
-
171
- async def log_handler(message: LogMessage):
172
- print(f"Server log: {message.data}")
173
-
174
- async def progress_handler(progress: float, total: float | None, message: str | None):
175
- print(f"Progress: {progress}/{total} - {message}")
176
-
177
- client = Client(
178
- "my_mcp_server.py",
179
- log_handler=log_handler, # Handle server logs
180
- progress_handler=progress_handler, # Monitor long operations
181
- timeout=30.0 # Set request timeout
182
- )
183
  ```
184
 
185
  ## Next Steps
 
15
  - **Building deterministic applications** that need reliable MCP interactions
16
  - **Creating the foundation for agentic or LLM-based clients** with structured, type-safe operations
17
 
 
18
 
19
  <Note>
20
  This is not an agentic client - it requires explicit function calls and provides direct control over all MCP operations. Use it as a building block for higher-level systems.
 
22
 
23
  ## Quick Start
24
 
25
+ Note that all client operations require using the `async with` context manager for proper connection lifecycle management. The client uses transport inference to automatically determine the connection method.
26
 
27
  ```python
28
  import asyncio
 
85
  For testing and development, always prefer the in-memory transport by passing a `FastMCP` server directly to the client. This eliminates network complexity and separate processes.
86
  </Tip>
87
 
88
+ ## Configuration-Based Clients
89
 
90
  <VersionBadge version="2.4.0" />
91
 
92
+ Create clients from MCP configuration dictionaries, which can include multiple servers. While there is no official standard for MCP configuration format, FastMCP follows established conventions used by tools like Claude Desktop.
93
+
94
+ ### Configuration Format
95
+
96
+ ```python
97
+ config = {
98
+ "mcpServers": {
99
+ "server_name": {
100
+ # Remote HTTP/SSE server
101
+ "transport": "streamable-http", # or "sse"
102
+ "url": "https://api.example.com/mcp",
103
+ "headers": {"Authorization": "Bearer token"},
104
+ "auth": "oauth" # or bearer token string
105
+ },
106
+ "local_server": {
107
+ # Local stdio server
108
+ "transport": "stdio"
109
+ "command": "python",
110
+ "args": ["./server.py", "--verbose"],
111
+ "env": {"DEBUG": "true"},
112
+ "cwd": "/path/to/server",
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### Multi-Server Example
119
 
120
  ```python
121
  config = {
 
168
  | **Prompts** | `list_prompts()`, `get_prompt()` | Retrieve message templates |
169
  | **Utility** | `ping()` | Test server connectivity |
170
 
171
+ ### Server Connectivity
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
+ Use `ping()` to verify the server is reachable:
 
 
174
 
175
  ```python
176
+ async with client:
177
+ await client.ping()
178
+ print("Server is reachable")
 
 
 
 
 
 
 
 
 
 
 
 
179
  ```
180
 
181
  ## Next Steps
docs/clients/prompts.mdx CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Prompt Operations
3
  sidebarTitle: Prompts
4
  description: Learn how to list and use server-side prompts with automatic argument serialization.
5
- icon: message-square
6
  ---
7
 
8
  import { VersionBadge } from '/snippets/version-badge.mdx'
 
1
  ---
2
+ title: Prompts
3
  sidebarTitle: Prompts
4
  description: Learn how to list and use server-side prompts with automatic argument serialization.
5
+ icon: message-lines
6
  ---
7
 
8
  import { VersionBadge } from '/snippets/version-badge.mdx'
docs/servers/resources.mdx CHANGED
@@ -2,7 +2,7 @@
2
  title: Resources & Templates
3
  sidebarTitle: Resources
4
  description: Expose data sources and dynamic content generators to your MCP client.
5
- icon: database
6
  ---
7
 
8
  import { VersionBadge } from "/snippets/version-badge.mdx"
 
2
  title: Resources & Templates
3
  sidebarTitle: Resources
4
  description: Expose data sources and dynamic content generators to your MCP client.
5
+ icon: folder-open
6
  ---
7
 
8
  import { VersionBadge } from "/snippets/version-badge.mdx"