Jeremiah Lowin commited on
Commit
3d3b461
·
2 Parent(s): 401e5ce06e8678

Merge branch 'main' into protocol-update

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .github/release.yml +11 -2
  2. CLAUDE.md +2 -1
  3. README.md +1 -1
  4. docs/.cursor/rules/mintlify.mdc +364 -0
  5. docs/changelog.mdx +97 -0
  6. docs/clients/client.mdx +1 -1
  7. docs/clients/logging.mdx +22 -9
  8. docs/clients/progress.mdx +21 -10
  9. docs/clients/sampling.mdx +83 -22
  10. docs/clients/transports.mdx +4 -4
  11. docs/{style.css → css/banner.css} +0 -52
  12. docs/css/python-sdk.css +3 -0
  13. docs/css/style.css +13 -0
  14. docs/css/version-badge.css +39 -0
  15. docs/deployment/running-server.mdx +8 -5
  16. docs/docs.json +34 -8
  17. docs/getting-started/installation.mdx +3 -2
  18. docs/integrations/anthropic.mdx +5 -5
  19. docs/integrations/chatgpt.mdx +158 -0
  20. docs/integrations/claude-code.mdx +60 -0
  21. docs/integrations/claude-desktop.mdx +9 -5
  22. docs/integrations/gemini.mdx +1 -1
  23. docs/integrations/openai.mdx +5 -5
  24. docs/patterns/cli.mdx +9 -8
  25. docs/python-sdk/fastmcp-cli-claude.mdx +2 -2
  26. docs/python-sdk/fastmcp-cli-cli.mdx +27 -5
  27. docs/python-sdk/fastmcp-cli-run.mdx +6 -6
  28. docs/python-sdk/fastmcp-client-auth-bearer.mdx +2 -2
  29. docs/python-sdk/fastmcp-client-auth-oauth.mdx +9 -9
  30. docs/python-sdk/fastmcp-client-client.mdx +42 -42
  31. docs/python-sdk/fastmcp-client-logging.mdx +1 -1
  32. docs/python-sdk/fastmcp-client-oauth_callback.mdx +5 -5
  33. docs/python-sdk/fastmcp-client-roots.mdx +2 -2
  34. docs/python-sdk/fastmcp-client-sampling.mdx +1 -1
  35. docs/python-sdk/fastmcp-client-transports.mdx +88 -87
  36. docs/python-sdk/fastmcp-exceptions.mdx +9 -9
  37. docs/python-sdk/fastmcp-prompts-prompt.mdx +7 -7
  38. docs/python-sdk/fastmcp-prompts-prompt_manager.mdx +4 -4
  39. docs/python-sdk/fastmcp-resources-resource.mdx +8 -8
  40. docs/python-sdk/fastmcp-resources-resource_manager.mdx +7 -7
  41. docs/python-sdk/fastmcp-resources-template.mdx +11 -11
  42. docs/python-sdk/fastmcp-resources-types.mdx +9 -9
  43. docs/python-sdk/fastmcp-server-auth-auth.mdx +1 -1
  44. docs/python-sdk/fastmcp-server-auth-providers-bearer.mdx +6 -6
  45. docs/python-sdk/fastmcp-server-auth-providers-bearer_env.mdx +2 -2
  46. docs/python-sdk/fastmcp-server-auth-providers-in_memory.mdx +1 -1
  47. docs/python-sdk/fastmcp-server-context.mdx +8 -8
  48. docs/python-sdk/fastmcp-server-dependencies.mdx +3 -3
  49. docs/python-sdk/fastmcp-server-http.mdx +8 -8
  50. docs/python-sdk/fastmcp-server-middleware-__init__.mdx +8 -0
.github/release.yml CHANGED
@@ -9,7 +9,7 @@ changelog:
9
  - feature
10
  exclude:
11
  labels:
12
- - breaking change
13
 
14
  - title: Enhancements 🔧
15
  labels:
@@ -17,22 +17,31 @@ changelog:
17
  exclude:
18
  labels:
19
  - breaking change
 
20
 
21
  - title: Fixes 🐞
22
  labels:
23
  - bug
24
  exclude:
25
  labels:
26
- - breaking change
27
 
28
  - title: Breaking Changes 🛫
29
  labels:
30
  - breaking change
 
 
 
31
 
32
  - title: Docs 📚
33
  labels:
34
  - documentation
35
 
 
 
 
 
 
36
  - title: Dependencies 📦
37
  labels:
38
  - dependencies
 
9
  - feature
10
  exclude:
11
  labels:
12
+ - contrib
13
 
14
  - title: Enhancements 🔧
15
  labels:
 
17
  exclude:
18
  labels:
19
  - breaking change
20
+ - contrib
21
 
22
  - title: Fixes 🐞
23
  labels:
24
  - bug
25
  exclude:
26
  labels:
27
+ - contrib
28
 
29
  - title: Breaking Changes 🛫
30
  labels:
31
  - breaking change
32
+ exclude:
33
+ labels:
34
+ - contrib
35
 
36
  - title: Docs 📚
37
  labels:
38
  - documentation
39
 
40
+ - title: Examples & Contrib 💡
41
+ labels:
42
+ - example
43
+ - contrib
44
+
45
  - title: Dependencies 📦
46
  labels:
47
  - dependencies
CLAUDE.md CHANGED
@@ -32,4 +32,5 @@ async with Client(transport=StreamableHttpTransport(server_url)) as client:
32
  ## Development Workflow
33
 
34
  - You must always run pre-commit if you open a PR, because it is run as part of a required check.
35
- - When opening PRs, apply labels appropriately for bugs/breaking changes/enhancements/features. Generally, improvements are enhancements (not features) unless told otherwise.
 
 
32
  ## Development Workflow
33
 
34
  - You must always run pre-commit if you open a PR, because it is run as part of a required check.
35
+ - When opening PRs, apply labels appropriately for bugs/breaking changes/enhancements/features. Generally, improvements are enhancements (not features) unless told otherwise.
36
+ - NEVER modify files in docs/python-sdk/**, as they are auto-generated.
README.md CHANGED
@@ -349,7 +349,7 @@ mcp.run(transport="stdio") # Default, so transport argument is optional
349
  **Streamable HTTP**: Recommended for web deployments.
350
 
351
  ```python
352
- mcp.run(transport="streamable-http", host="127.0.0.1", port=8000, path="/mcp")
353
  ```
354
 
355
  **SSE**: For compatibility with existing SSE clients.
 
349
  **Streamable HTTP**: Recommended for web deployments.
350
 
351
  ```python
352
+ mcp.run(transport="http", host="127.0.0.1", port=8000, path="/mcp")
353
  ```
354
 
355
  **SSE**: For compatibility with existing SSE clients.
docs/.cursor/rules/mintlify.mdc ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ description:
3
+ globs: *.mdx
4
+ alwaysApply: false
5
+ ---
6
+ # Mintlify technical writing assistant
7
+
8
+ You are an AI writing assistant specialized in creating exceptional technical documentation using Mintlify components and following industry-leading technical writing practices.
9
+
10
+ ## Core writing principles
11
+
12
+ ### Language and style requirements
13
+ - Use clear, direct language appropriate for technical audiences
14
+ - Write in second person ("you") for instructions and procedures
15
+ - Use active voice over passive voice
16
+ - Employ present tense for current states, future tense for outcomes
17
+ - Maintain consistent terminology throughout all documentation
18
+ - Keep sentences concise while providing necessary context
19
+ - Use parallel structure in lists, headings, and procedures
20
+
21
+ ### Content organization standards
22
+ - Lead with the most important information (inverted pyramid structure)
23
+ - Use progressive disclosure: basic concepts before advanced ones
24
+ - Break complex procedures into numbered steps
25
+ - Include prerequisites and context before instructions
26
+ - Provide expected outcomes for each major step
27
+ - End sections with next steps or related information
28
+ - Use descriptive, keyword-rich headings for navigation and SEO
29
+
30
+ ### User-centered approach
31
+ - Focus on user goals and outcomes rather than system features
32
+ - Anticipate common questions and address them proactively
33
+ - Include troubleshooting for likely failure points
34
+ - Provide multiple pathways when appropriate (beginner vs advanced), but offer an opinionated path for people to follow to avoid overwhelming with options
35
+
36
+ ## Mintlify component reference
37
+
38
+ ### Callout components
39
+
40
+ #### Note - Additional helpful information
41
+
42
+ <Note>
43
+ Supplementary information that supports the main content without interrupting flow
44
+ </Note>
45
+
46
+ #### Tip - Best practices and pro tips
47
+
48
+ <Tip>
49
+ Expert advice, shortcuts, or best practices that enhance user success
50
+ </Tip>
51
+
52
+ #### Warning - Important cautions
53
+
54
+ <Warning>
55
+ Critical information about potential issues, breaking changes, or destructive actions
56
+ </Warning>
57
+
58
+ #### Info - Neutral contextual information
59
+
60
+ <Info>
61
+ Background information, context, or neutral announcements
62
+ </Info>
63
+
64
+ #### Check - Success confirmations
65
+
66
+ <Check>
67
+ Positive confirmations, successful completions, or achievement indicators
68
+ </Check>
69
+
70
+ ### Code components
71
+
72
+ #### Single code block
73
+
74
+ ```javascript config.js
75
+ const apiConfig = {
76
+ baseURL: 'https://api.example.com',
77
+ timeout: 5000,
78
+ headers: {
79
+ 'Authorization': `Bearer ${process.env.API_TOKEN}`
80
+ }
81
+ };
82
+ ```
83
+
84
+ #### Code group with multiple languages
85
+
86
+ <CodeGroup>
87
+ ```javascript Node.js
88
+ const response = await fetch('/api/endpoint', {
89
+ headers: { Authorization: `Bearer ${apiKey}` }
90
+ });
91
+ ```
92
+
93
+ ```python Python
94
+ import requests
95
+ response = requests.get('/api/endpoint',
96
+ headers={'Authorization': f'Bearer {api_key}'})
97
+ ```
98
+
99
+ ```curl cURL
100
+ curl -X GET '/api/endpoint' \
101
+ -H 'Authorization: Bearer YOUR_API_KEY'
102
+ ```
103
+ </CodeGroup>
104
+
105
+ #### Request/Response examples
106
+
107
+ <RequestExample>
108
+ ```bash cURL
109
+ curl -X POST 'https://api.example.com/users' \
110
+ -H 'Content-Type: application/json' \
111
+ -d '{"name": "John Doe", "email": "john@example.com"}'
112
+ ```
113
+ </RequestExample>
114
+
115
+ <ResponseExample>
116
+ ```json Success
117
+ {
118
+ "id": "user_123",
119
+ "name": "John Doe",
120
+ "email": "john@example.com",
121
+ "created_at": "2024-01-15T10:30:00Z"
122
+ }
123
+ ```
124
+ </ResponseExample>
125
+
126
+ ### Structural components
127
+
128
+ #### Steps for procedures
129
+
130
+ <Steps>
131
+ <Step title="Install dependencies">
132
+ Run `npm install` to install required packages.
133
+
134
+ <Check>
135
+ Verify installation by running `npm list`.
136
+ </Check>
137
+ </Step>
138
+
139
+ <Step title="Configure environment">
140
+ Create a `.env` file with your API credentials.
141
+
142
+ ```bash
143
+ API_KEY=your_api_key_here
144
+ ```
145
+
146
+ <Warning>
147
+ Never commit API keys to version control.
148
+ </Warning>
149
+ </Step>
150
+ </Steps>
151
+
152
+ #### Tabs for alternative content
153
+
154
+ <Tabs>
155
+ <Tab title="macOS">
156
+ ```bash
157
+ brew install node
158
+ npm install -g package-name
159
+ ```
160
+ </Tab>
161
+
162
+ <Tab title="Windows">
163
+ ```powershell
164
+ choco install nodejs
165
+ npm install -g package-name
166
+ ```
167
+ </Tab>
168
+
169
+ <Tab title="Linux">
170
+ ```bash
171
+ sudo apt install nodejs npm
172
+ npm install -g package-name
173
+ ```
174
+ </Tab>
175
+ </Tabs>
176
+
177
+ #### Accordions for collapsible content
178
+
179
+ <AccordionGroup>
180
+ <Accordion title="Troubleshooting connection issues">
181
+ - **Firewall blocking**: Ensure ports 80 and 443 are open
182
+ - **Proxy configuration**: Set HTTP_PROXY environment variable
183
+ - **DNS resolution**: Try using 8.8.8.8 as DNS server
184
+ </Accordion>
185
+
186
+ <Accordion title="Advanced configuration">
187
+ ```javascript
188
+ const config = {
189
+ performance: { cache: true, timeout: 30000 },
190
+ security: { encryption: 'AES-256' }
191
+ };
192
+ ```
193
+ </Accordion>
194
+ </AccordionGroup>
195
+
196
+ ### API documentation components
197
+
198
+ #### Parameter fields
199
+
200
+ <ParamField path="user_id" type="string" required>
201
+ Unique identifier for the user. Must be a valid UUID v4 format.
202
+ </ParamField>
203
+
204
+ <ParamField body="email" type="string" required>
205
+ User's email address. Must be valid and unique within the system.
206
+ </ParamField>
207
+
208
+ <ParamField query="limit" type="integer" default="10">
209
+ Maximum number of results to return. Range: 1-100.
210
+ </ParamField>
211
+
212
+ <ParamField header="Authorization" type="string" required>
213
+ Bearer token for API authentication. Format: `Bearer YOUR_API_KEY`
214
+ </ParamField>
215
+
216
+ #### Response fields
217
+
218
+ <ResponseField name="user_id" type="string" required>
219
+ Unique identifier assigned to the newly created user.
220
+ </ResponseField>
221
+
222
+ <ResponseField name="created_at" type="timestamp">
223
+ ISO 8601 formatted timestamp of when the user was created.
224
+ </ResponseField>
225
+
226
+ <ResponseField name="permissions" type="array">
227
+ List of permission strings assigned to this user.
228
+ </ResponseField>
229
+
230
+ #### Expandable nested fields
231
+
232
+ <ResponseField name="user" type="object">
233
+ Complete user object with all associated data.
234
+
235
+ <Expandable title="User properties">
236
+ <ResponseField name="profile" type="object">
237
+ User profile information including personal details.
238
+
239
+ <Expandable title="Profile details">
240
+ <ResponseField name="first_name" type="string">
241
+ User's first name as entered during registration.
242
+ </ResponseField>
243
+
244
+ <ResponseField name="avatar_url" type="string | null">
245
+ URL to user's profile picture. Returns null if no avatar is set.
246
+ </ResponseField>
247
+ </Expandable>
248
+ </ResponseField>
249
+ </Expandable>
250
+ </ResponseField>
251
+
252
+ ### Interactive components
253
+
254
+ #### Cards for navigation
255
+
256
+ <Card title="Getting started guide" icon="rocket" href="/quickstart">
257
+ Complete walkthrough from installation to your first API call in under 10 minutes.
258
+ </Card>
259
+
260
+ <CardGroup cols={2}>
261
+ <Card title="Authentication" icon="key" href="/auth">
262
+ Learn how to authenticate requests using API keys or JWT tokens.
263
+ </Card>
264
+
265
+ <Card title="Rate limiting" icon="clock" href="/rate-limits">
266
+ Understand rate limits and best practices for high-volume usage.
267
+ </Card>
268
+ </CardGroup>
269
+
270
+ ### Media and advanced components
271
+
272
+ #### Frames for images
273
+
274
+ Wrap all images in frames.
275
+
276
+ <Frame>
277
+ <img src="/images/dashboard.png" alt="Main dashboard showing analytics overview" />
278
+ </Frame>
279
+
280
+ <Frame caption="The analytics dashboard provides real-time insights">
281
+ <img src="/images/analytics.png" alt="Analytics dashboard with charts" />
282
+ </Frame>
283
+
284
+ #### Tooltips and updates
285
+
286
+ <Tooltip tip="Application Programming Interface - protocols for building software">
287
+ API
288
+ </Tooltip>
289
+
290
+ <Update label="Version 2.1.0" description="Released March 15, 2024">
291
+ ## New features
292
+ - Added bulk user import functionality
293
+ - Improved error messages with actionable suggestions
294
+
295
+ ## Bug fixes
296
+ - Fixed pagination issue with large datasets
297
+ - Resolved authentication timeout problems
298
+ </Update>
299
+
300
+ ## Required page structure
301
+
302
+ Every documentation page must begin with YAML frontmatter:
303
+
304
+ ```yaml
305
+ ---
306
+ title: "Clear, specific, keyword-rich title"
307
+ description: "Concise description explaining page purpose and value"
308
+ ---
309
+ ```
310
+
311
+ ## Content quality standards
312
+
313
+ ### Code examples requirements
314
+ - Always include complete, runnable examples that users can copy and execute
315
+ - Show proper error handling and edge case management
316
+ - Use realistic data instead of placeholder values
317
+ - Include expected outputs and results for verification
318
+ - Test all code examples thoroughly before publishing
319
+ - Specify language and include filename when relevant
320
+ - Add explanatory comments for complex logic
321
+
322
+ ### API documentation requirements
323
+ - Document all parameters including optional ones with clear descriptions
324
+ - Show both success and error response examples with realistic data
325
+ - Include rate limiting information with specific limits
326
+ - Provide authentication examples showing proper format
327
+ - Explain all HTTP status codes and error handling
328
+ - Cover complete request/response cycles
329
+
330
+ ### Accessibility requirements
331
+ - Include descriptive alt text for all images and diagrams
332
+ - Use specific, actionable link text instead of "click here"
333
+ - Ensure proper heading hierarchy starting with H2
334
+ - Provide keyboard navigation considerations
335
+ - Use sufficient color contrast in examples and visuals
336
+ - Structure content for easy scanning with headers and lists
337
+
338
+ ## AI assistant instructions
339
+
340
+ ### Component selection logic
341
+ - Use **Steps** for procedures, tutorials, setup guides, and sequential instructions
342
+ - Use **Tabs** for platform-specific content or alternative approaches
343
+ - Use **CodeGroup** when showing the same concept in multiple languages
344
+ - Use **Accordions** for supplementary information that might interrupt flow
345
+ - Use **Cards and CardGroup** for navigation, feature overviews, and related resources
346
+ - Use **RequestExample/ResponseExample** specifically for API endpoint documentation
347
+ - Use **ParamField** for API parameters, **ResponseField** for API responses
348
+ - Use **Expandable** for nested object properties or hierarchical information
349
+
350
+ ### Quality assurance checklist
351
+ - Verify all code examples are syntactically correct and executable
352
+ - Test all links to ensure they are functional and lead to relevant content
353
+ - Validate Mintlify component syntax with all required properties
354
+ - Confirm proper heading hierarchy with H2 for main sections, H3 for subsections
355
+ - Ensure content flows logically from basic concepts to advanced topics
356
+ - Check for consistency in terminology, formatting, and component usage
357
+
358
+ ### Error prevention strategies
359
+ - Always include realistic error handling in code examples
360
+ - Provide dedicated troubleshooting sections for complex procedures
361
+ - Explain prerequisites clearly before beginning instructions
362
+ - Include verification and testing steps with expected outcomes
363
+ - Add appropriate warnings for destructive or security-sensitive actions
364
+ - Validate all technical information through testing before publication
docs/changelog.mdx CHANGED
@@ -2,6 +2,103 @@
2
  icon: "list-check"
3
  ---
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  <Update label="v2.8.0" description="2024-06-10">
6
 
7
  ## [v2.8.0: Transform and Roll Out](https://github.com/jlowin/fastmcp/releases/tag/v2.8.0)
 
2
  icon: "list-check"
3
  ---
4
 
5
+ <Update label="v2.9.0" description="2024-06-23">
6
+
7
+ ## [v2.9.0: Stuck in the Middleware With You](https://github.com/jlowin/fastmcp/releases/tag/v2.9.0)
8
+
9
+ FastMCP 2.9 introduces two important features that push beyond the basic MCP protocol: MCP Middleware and server-side type conversion.
10
+
11
+ ### MCP Middleware
12
+ MCP middleware lets you intercept and modify requests and responses at the protocol level, giving you powerful capabilities for logging, authentication, validation, and more. This is particularly useful for building production-ready MCP servers that need sophisticated request handling.
13
+
14
+ ### Server-side Type Conversion
15
+ This release also introduces server-side type conversion for prompt arguments, ensuring that data is properly formatted before being passed to your functions. This reduces the burden on individual tools and prompts to handle type validation and conversion.
16
+
17
+ ## What's Changed
18
+ ### New Features 🎉
19
+ * Add File utility for binary data by [@gorocode](https://github.com/gorocode) in [#843](https://github.com/jlowin/fastmcp/pull/843)
20
+ * Consolidate prefix logic into FastMCP methods by [@jlowin](https://github.com/jlowin) in [#861](https://github.com/jlowin/fastmcp/pull/861)
21
+ * Add MCP Middleware by [@jlowin](https://github.com/jlowin) in [#870](https://github.com/jlowin/fastmcp/pull/870)
22
+ * Implement server-side type conversion for prompt arguments by [@jlowin](https://github.com/jlowin) in [#908](https://github.com/jlowin/fastmcp/pull/908)
23
+ ### Enhancements 🔧
24
+ * Fix tool description indentation issue by [@zfflxx](https://github.com/zfflxx) in [#845](https://github.com/jlowin/fastmcp/pull/845)
25
+ * Add version parameter to FastMCP constructor by [@mkyutani](https://github.com/mkyutani) in [#842](https://github.com/jlowin/fastmcp/pull/842)
26
+ * Update version to not be positional by [@jlowin](https://github.com/jlowin) in [#848](https://github.com/jlowin/fastmcp/pull/848)
27
+ * Add key to component by [@jlowin](https://github.com/jlowin) in [#869](https://github.com/jlowin/fastmcp/pull/869)
28
+ * Add session_id property to Context for data sharing by [@jlowin](https://github.com/jlowin) in [#881](https://github.com/jlowin/fastmcp/pull/881)
29
+ * Fix CORS documentation example by [@jlowin](https://github.com/jlowin) in [#895](https://github.com/jlowin/fastmcp/pull/895)
30
+ ### Fixes 🐞
31
+ * "report_progress missing passing related_request_id causes notifications not working" by [@alexsee](https://github.com/alexsee) in [#838](https://github.com/jlowin/fastmcp/pull/838)
32
+ * Fix JWT issuer validation to support string values per RFC 7519 by [@jlowin](https://github.com/jlowin) in [#892](https://github.com/jlowin/fastmcp/pull/892)
33
+ * Fix BearerAuthProvider audience type annotations by [@jlowin](https://github.com/jlowin) in [#894](https://github.com/jlowin/fastmcp/pull/894)
34
+ ### Docs 📚
35
+ * Add CLAUDE.md development guidelines by [@jlowin](https://github.com/jlowin) in [#880](https://github.com/jlowin/fastmcp/pull/880)
36
+ * Update context docs for session_id property by [@jlowin](https://github.com/jlowin) in [#882](https://github.com/jlowin/fastmcp/pull/882)
37
+ * Add API reference by [@zzstoatzz](https://github.com/zzstoatzz) in [#893](https://github.com/jlowin/fastmcp/pull/893)
38
+ * Fix API ref rendering by [@zzstoatzz](https://github.com/zzstoatzz) in [#900](https://github.com/jlowin/fastmcp/pull/900)
39
+ * Simplify docs nav by [@jlowin](https://github.com/jlowin) in [#902](https://github.com/jlowin/fastmcp/pull/902)
40
+ * Add fastmcp inspect command by [@jlowin](https://github.com/jlowin) in [#904](https://github.com/jlowin/fastmcp/pull/904)
41
+ * Update client docs by [@jlowin](https://github.com/jlowin) in [#912](https://github.com/jlowin/fastmcp/pull/912)
42
+ * Update docs nav by [@jlowin](https://github.com/jlowin) in [#913](https://github.com/jlowin/fastmcp/pull/913)
43
+ * Update integration documentation for Claude Desktop, ChatGPT, and Claude Code by [@jlowin](https://github.com/jlowin) in [#915](https://github.com/jlowin/fastmcp/pull/915)
44
+ * Add http as an alias for streamable http by [@jlowin](https://github.com/jlowin) in [#917](https://github.com/jlowin/fastmcp/pull/917)
45
+ * Clean up parameter documentation by [@jlowin](https://github.com/jlowin) in [#918](https://github.com/jlowin/fastmcp/pull/918)
46
+ * Add middleware examples for timing, logging, rate limiting, and error handling by [@jlowin](https://github.com/jlowin) in [#919](https://github.com/jlowin/fastmcp/pull/919)
47
+ * ControlFlow → FastMCP rename by [@jlowin](https://github.com/jlowin) in [#922](https://github.com/jlowin/fastmcp/pull/922)
48
+ ### Examples & Contrib 💡
49
+ * Add contrib.mcp_mixin support for annotations by [@rsp2k](https://github.com/rsp2k) in [#860](https://github.com/jlowin/fastmcp/pull/860)
50
+ * Add ATProto (Bluesky) MCP Server Example by [@zzstoatzz](https://github.com/zzstoatzz) in [#916](https://github.com/jlowin/fastmcp/pull/916)
51
+ * Fix path in atproto example pyproject by [@zzstoatzz](https://github.com/zzstoatzz) in [#920](https://github.com/jlowin/fastmcp/pull/920)
52
+ * Remove uv source in example by [@zzstoatzz](https://github.com/zzstoatzz) in [#921](https://github.com/jlowin/fastmcp/pull/921)
53
+
54
+ ## New Contributors
55
+ * [@alexsee](https://github.com/alexsee) made their first contribution in [#838](https://github.com/jlowin/fastmcp/pull/838)
56
+ * [@zfflxx](https://github.com/zfflxx) made their first contribution in [#845](https://github.com/jlowin/fastmcp/pull/845)
57
+ * [@mkyutani](https://github.com/mkyutani) made their first contribution in [#842](https://github.com/jlowin/fastmcp/pull/842)
58
+ * [@gorocode](https://github.com/gorocode) made their first contribution in [#843](https://github.com/jlowin/fastmcp/pull/843)
59
+ * [@rsp2k](https://github.com/rsp2k) made their first contribution in [#860](https://github.com/jlowin/fastmcp/pull/860)
60
+ * [@owtaylor](https://github.com/owtaylor) made their first contribution in [#897](https://github.com/jlowin/fastmcp/pull/897)
61
+ * [@Jason-CKY](https://github.com/Jason-CKY) made their first contribution in [#906](https://github.com/jlowin/fastmcp/pull/906)
62
+
63
+ **Full Changelog**: [v2.8.1...v2.9.0](https://github.com/jlowin/fastmcp/compare/v2.8.1...v2.9.0)
64
+
65
+ </Update>
66
+
67
+ <Update label="v2.8.1" description="2024-06-15">
68
+
69
+ ## [v2.8.1: Sound Judgement](https://github.com/jlowin/fastmcp/releases/tag/v2.8.1)
70
+
71
+ 2.8.1 introduces audio support, as well as minor fixes and updates for deprecated features.
72
+
73
+ ### Audio Support
74
+ This release adds support for audio content in MCP tools and resources, expanding FastMCP's multimedia capabilities beyond text and images.
75
+
76
+ ## What's Changed
77
+ ### New Features 🎉
78
+ * Add audio support by [@jlowin](https://github.com/jlowin) in [#833](https://github.com/jlowin/fastmcp/pull/833)
79
+ ### Enhancements 🔧
80
+ * Add flag for disabling deprecation warnings by [@jlowin](https://github.com/jlowin) in [#802](https://github.com/jlowin/fastmcp/pull/802)
81
+ * Add examples to Tool Arg Param transformation by [@strawgate](https://github.com/strawgate) in [#806](https://github.com/jlowin/fastmcp/pull/806)
82
+ ### Fixes 🐞
83
+ * Restore .settings access as deprecated by [@jlowin](https://github.com/jlowin) in [#800](https://github.com/jlowin/fastmcp/pull/800)
84
+ * Ensure handling of false http kwargs correctly; removed unused kwarg by [@jlowin](https://github.com/jlowin) in [#804](https://github.com/jlowin/fastmcp/pull/804)
85
+ * Bump mcp 1.9.4 by [@jlowin](https://github.com/jlowin) in [#835](https://github.com/jlowin/fastmcp/pull/835)
86
+ ### Docs 📚
87
+ * Update changelog for 2.8.0 by [@jlowin](https://github.com/jlowin) in [#794](https://github.com/jlowin/fastmcp/pull/794)
88
+ * Update welcome docs by [@jlowin](https://github.com/jlowin) in [#808](https://github.com/jlowin/fastmcp/pull/808)
89
+ * Update headers in docs by [@jlowin](https://github.com/jlowin) in [#809](https://github.com/jlowin/fastmcp/pull/809)
90
+ * Add MCP group to tutorials by [@jlowin](https://github.com/jlowin) in [#810](https://github.com/jlowin/fastmcp/pull/810)
91
+ * Add Community section to documentation by [@zzstoatzz](https://github.com/zzstoatzz) in [#819](https://github.com/jlowin/fastmcp/pull/819)
92
+ * Add 2.8 update by [@jlowin](https://github.com/jlowin) in [#821](https://github.com/jlowin/fastmcp/pull/821)
93
+ * Embed YouTube videos in community showcase by [@zzstoatzz](https://github.com/zzstoatzz) in [#820](https://github.com/jlowin/fastmcp/pull/820)
94
+ ### Other Changes 🦾
95
+ * Ensure http args are passed through by [@jlowin](https://github.com/jlowin) in [#803](https://github.com/jlowin/fastmcp/pull/803)
96
+ * Fix install link in readme by [@jlowin](https://github.com/jlowin) in [#836](https://github.com/jlowin/fastmcp/pull/836)
97
+
98
+ **Full Changelog**: [v2.8.0...v2.8.1](https://github.com/jlowin/fastmcp/compare/v2.8.0...v2.8.1)
99
+
100
+ </Update>
101
+
102
  <Update label="v2.8.0" description="2024-06-10">
103
 
104
  ## [v2.8.0: Transform and Roll Out](https://github.com/jlowin/fastmcp/releases/tag/v2.8.0)
docs/clients/client.mdx CHANGED
@@ -102,7 +102,7 @@ config = {
102
  "mcpServers": {
103
  "server_name": {
104
  # Remote HTTP/SSE server
105
- "transport": "streamable-http", # or "sse"
106
  "url": "https://api.example.com/mcp",
107
  "headers": {"Authorization": "Bearer token"},
108
  "auth": "oauth" # or bearer token string
 
102
  "mcpServers": {
103
  "server_name": {
104
  # Remote HTTP/SSE server
105
+ "transport": "http", # or "sse"
106
  "url": "https://api.example.com/mcp",
107
  "headers": {"Authorization": "Bearer token"},
108
  "auth": "oauth" # or bearer token string
docs/clients/logging.mdx CHANGED
@@ -11,7 +11,7 @@ import { VersionBadge } from '/snippets/version-badge.mdx'
11
 
12
  MCP servers can emit log messages to clients. The client can handle these logs through a log handler callback.
13
 
14
- ## Setting Up Log Handling
15
 
16
  Provide a `log_handler` function when creating the client:
17
 
@@ -31,13 +31,27 @@ client = Client(
31
  )
32
  ```
33
 
34
- ## LogMessage Structure
35
 
36
- The `log_handler` receives a `LogMessage` object with:
37
 
38
- - **`level`**: Log level (e.g., "debug", "info", "warning", "error")
39
- - **`logger`**: Logger name (optional, may be None)
40
- - **`data`**: The actual log message content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  ```python
43
  async def detailed_log_handler(message: LogMessage):
@@ -51,13 +65,12 @@ async def detailed_log_handler(message: LogMessage):
51
 
52
  ## Default Log Handling
53
 
54
- If you don't provide a custom `log_handler`, FastMCP uses a default handler that emits DEBUG level logs:
55
 
56
  ```python
57
- # Without custom handler - uses default DEBUG logging
58
  client = Client("my_mcp_server.py")
59
 
60
  async with client:
61
- # Server logs will be emitted at DEBUG level
62
  await client.call_tool("some_tool")
63
  ```
 
11
 
12
  MCP servers can emit log messages to clients. The client can handle these logs through a log handler callback.
13
 
14
+ ## Log Handler
15
 
16
  Provide a `log_handler` function when creating the client:
17
 
 
31
  )
32
  ```
33
 
34
+ ### Handler Parameters
35
 
36
+ The `log_handler` is called every time a log message is received. It receives a `LogMessage` object:
37
 
38
+ <Card icon="code" title="Log Handler Parameters">
39
+ <ResponseField name="LogMessage" type="Log Message Object">
40
+ <Expandable title="attributes">
41
+ <ResponseField name="level" type='Literal["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]'>
42
+ The log level
43
+ </ResponseField>
44
+
45
+ <ResponseField name="logger" type="str | None">
46
+ The logger name (optional, may be None)
47
+ </ResponseField>
48
+
49
+ <ResponseField name="data" type="Any">
50
+ The actual log message content
51
+ </ResponseField>
52
+ </Expandable>
53
+ </ResponseField>
54
+ </Card>
55
 
56
  ```python
57
  async def detailed_log_handler(message: LogMessage):
 
65
 
66
  ## Default Log Handling
67
 
68
+ If you don't provide a custom `log_handler`, FastMCP uses a default handler that emits a DEBUG-level FastMCP log for every log message received from the server, which is useful for visibility without polluting your own logs.
69
 
70
  ```python
 
71
  client = Client("my_mcp_server.py")
72
 
73
  async with client:
74
+ # Server logs will be emitted at DEBUG level automatically
75
  await client.call_tool("some_tool")
76
  ```
docs/clients/progress.mdx CHANGED
@@ -11,7 +11,7 @@ import { VersionBadge } from '/snippets/version-badge.mdx'
11
 
12
  MCP servers can report progress during long-running operations. The client can receive these updates through a progress handler.
13
 
14
- ## Setting Up Progress Handling
15
 
16
  Set a progress handler when creating the client:
17
 
@@ -35,6 +35,26 @@ client = Client(
35
  )
36
  ```
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  ## Per-Call Progress Handler
39
 
40
  Override the progress handler for specific tool calls:
@@ -48,12 +68,3 @@ async with client:
48
  progress_handler=my_progress_handler
49
  )
50
  ```
51
-
52
- ## Handler Parameters
53
-
54
- The progress handler receives:
55
-
56
- - **`progress`** (float): Current progress value
57
- - **`total`** (float | None): Expected total value (may be None)
58
- - **`message`** (str | None): Optional status message (may be None)
59
-
 
11
 
12
  MCP servers can report progress during long-running operations. The client can receive these updates through a progress handler.
13
 
14
+ ## Progress Handler
15
 
16
  Set a progress handler when creating the client:
17
 
 
35
  )
36
  ```
37
 
38
+ ### Handler Parameters
39
+
40
+ The progress handler receives three parameters:
41
+
42
+
43
+ <Card icon="code" title="Progress Handler Parameters">
44
+ <ResponseField name="progress" type="float">
45
+ Current progress value
46
+ </ResponseField>
47
+
48
+ <ResponseField name="total" type="float | None">
49
+ Expected total value (may be None)
50
+ </ResponseField>
51
+
52
+ <ResponseField name="message" type="str | None">
53
+ Optional status message (may be None)
54
+ </ResponseField>
55
+ </Card>
56
+
57
+
58
  ## Per-Call Progress Handler
59
 
60
  Override the progress handler for specific tool calls:
 
68
  progress_handler=my_progress_handler
69
  )
70
  ```
 
 
 
 
 
 
 
 
 
docs/clients/sampling.mdx CHANGED
@@ -5,13 +5,13 @@ description: Handle server-initiated LLM sampling requests.
5
  icon: robot
6
  ---
7
 
8
- import { VersionBadge } from '/snippets/version-badge.mdx'
9
 
10
  <VersionBadge version="2.0.0" />
11
 
12
  MCP servers can request LLM completions from clients. The client handles these requests through a sampling handler callback.
13
 
14
- ## Setting Up Sampling Handling
15
 
16
  Provide a `sampling_handler` function when creating the client:
17
 
@@ -38,26 +38,88 @@ client = Client(
38
  )
39
  ```
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
 
@@ -75,10 +137,10 @@ async def basic_sampling_handler(
75
  for message in messages:
76
  content = message.content.text if hasattr(message.content, 'text') else str(message.content)
77
  conversation.append(f"{message.role}: {content}")
78
-
79
  # Use the system prompt if provided
80
  system_prompt = params.systemPrompt or "You are a helpful assistant."
81
-
82
  # Here you would integrate with your preferred LLM service
83
  # This is just a placeholder response
84
  return f"Response based on conversation: {' | '.join(conversation)}"
@@ -88,4 +150,3 @@ client = Client(
88
  sampling_handler=basic_sampling_handler
89
  )
90
  ```
91
-
 
5
  icon: robot
6
  ---
7
 
8
+ import { VersionBadge } from "/snippets/version-badge.mdx";
9
 
10
  <VersionBadge version="2.0.0" />
11
 
12
  MCP servers can request LLM completions from clients. The client handles these requests through a sampling handler callback.
13
 
14
+ ## Sampling Handler
15
 
16
  Provide a `sampling_handler` function when creating the client:
17
 
 
38
  )
39
  ```
40
 
41
+ ### Handler Parameters
42
 
43
  The sampling handler receives three parameters:
44
 
45
+ <Card icon="code" title="Sampling Handler Parameters">
46
+ <ResponseField name="SamplingMessage" type="Sampling Message Object">
47
+ <Expandable title="attributes">
48
+ <ResponseField name="role" type='Literal["user", "assistant"]'>
49
+ The role of the message.
50
+ </ResponseField>
51
+
52
+ <ResponseField name="content" type="TextContent | ImageContent | AudioContent">
53
+ The content of the message.
54
+
55
+ TextContent is most common, and has a `.text` attribute.
56
+ </ResponseField>
57
+
58
+ </Expandable>
59
+ </ResponseField>
60
+ <ResponseField name="SamplingParams" type="Sampling Parameters Object">
61
+ <Expandable title="attributes">
62
+ <ResponseField name="messages" type="list[SamplingMessage]">
63
+ The messages to sample from
64
+ </ResponseField>
65
+
66
+ <ResponseField name="modelPreferences" type="ModelPreferences | None">
67
+ The server's preferences for which model to select. The client MAY ignore
68
+ these preferences.
69
+ <Expandable title="attributes">
70
+ <ResponseField name="hints" type="list[ModelHint] | None">
71
+ The hints to use for model selection.
72
+ </ResponseField>
73
+
74
+ <ResponseField name="costPriority" type="float | None">
75
+ The cost priority for model selection.
76
+ </ResponseField>
77
+
78
+ <ResponseField name="speedPriority" type="float | None">
79
+ The speed priority for model selection.
80
+ </ResponseField>
81
+
82
+ <ResponseField name="intelligencePriority" type="float | None">
83
+ The intelligence priority for model selection.
84
+ </ResponseField>
85
+ </Expandable>
86
+ </ResponseField>
87
+
88
+ <ResponseField name="systemPrompt" type="str | None">
89
+ An optional system prompt the server wants to use for sampling.
90
+ </ResponseField>
91
+
92
+ <ResponseField name="includeContext" type="IncludeContext | None">
93
+ A request to include context from one or more MCP servers (including the caller), to
94
+ be attached to the prompt.
95
+ </ResponseField>
96
+
97
+ <ResponseField name="temperature" type="float | None">
98
+ The sampling temperature.
99
+ </ResponseField>
100
+
101
+ <ResponseField name="maxTokens" type="int">
102
+ The maximum number of tokens to sample.
103
+ </ResponseField>
104
+
105
+ <ResponseField name="stopSequences" type="list[str] | None">
106
+ The stop sequences to use for sampling.
107
+ </ResponseField>
108
+
109
+ <ResponseField name="metadata" type="dict[str, Any] | None">
110
+ Optional metadata to pass through to the LLM provider.
111
+ </ResponseField>
112
+ </Expandable>
113
+
114
+ </ResponseField>
115
+ <ResponseField name="RequestContext" type="Request Context Object">
116
+ <Expandable title="attributes">
117
+ <ResponseField name="request_id" type="RequestId">
118
+ Unique identifier for the MCP request
119
+ </ResponseField>
120
+ </Expandable>
121
+ </ResponseField>
122
+ </Card>
123
 
124
  ## Basic Example
125
 
 
137
  for message in messages:
138
  content = message.content.text if hasattr(message.content, 'text') else str(message.content)
139
  conversation.append(f"{message.role}: {content}")
140
+
141
  # Use the system prompt if provided
142
  system_prompt = params.systemPrompt or "You are a helpful assistant."
143
+
144
  # Here you would integrate with your preferred LLM service
145
  # This is just a placeholder response
146
  return f"Response based on conversation: {' | '.join(conversation)}"
 
150
  sampling_handler=basic_sampling_handler
151
  )
152
  ```
 
docs/clients/transports.mdx CHANGED
@@ -41,7 +41,7 @@ Streamable HTTP is the recommended transport for web-based deployments, providin
41
 
42
  - **Class:** `fastmcp.client.transports.StreamableHttpTransport`
43
  - **Inferred From:** URLs starting with `http://` or `https://` (default for HTTP URLs since v2.3.0) that do not contain `/sse/` in the path
44
- - **Server Compatibility:** Works with FastMCP servers running in `streamable-http` mode
45
 
46
  #### Basic Usage
47
 
@@ -150,7 +150,7 @@ client = Client(transport)
150
  - **Use Streamable HTTP when:**
151
  - Setting up new deployments (recommended default)
152
  - You need bidirectional streaming
153
- - You're connecting to FastMCP servers running in `streamable-http` mode
154
 
155
  - **Use SSE when:**
156
  - Connecting to legacy FastMCP servers running in `sse` mode
@@ -397,7 +397,7 @@ config = {
397
  # Remote HTTP server
398
  "weather": {
399
  "url": "https://weather-api.example.com/mcp",
400
- "transport": "streamable-http"
401
  },
402
  # Local stdio server
403
  "assistant": {
@@ -408,7 +408,7 @@ config = {
408
  # Another remote server
409
  "calendar": {
410
  "url": "https://calendar-api.example.com/mcp",
411
- "transport": "streamable-http"
412
  }
413
  }
414
  }
 
41
 
42
  - **Class:** `fastmcp.client.transports.StreamableHttpTransport`
43
  - **Inferred From:** URLs starting with `http://` or `https://` (default for HTTP URLs since v2.3.0) that do not contain `/sse/` in the path
44
+ - **Server Compatibility:** Works with FastMCP servers running in `http` mode
45
 
46
  #### Basic Usage
47
 
 
150
  - **Use Streamable HTTP when:**
151
  - Setting up new deployments (recommended default)
152
  - You need bidirectional streaming
153
+ - You're connecting to FastMCP servers running in `http` mode
154
 
155
  - **Use SSE when:**
156
  - Connecting to legacy FastMCP servers running in `sse` mode
 
397
  # Remote HTTP server
398
  "weather": {
399
  "url": "https://weather-api.example.com/mcp",
400
+ "transport": "http"
401
  },
402
  # Local stdio server
403
  "assistant": {
 
408
  # Another remote server
409
  "calendar": {
410
  "url": "https://calendar-api.example.com/mcp",
411
+ "transport": "http"
412
  }
413
  }
414
  }
docs/{style.css → css/banner.css} RENAMED
@@ -1,17 +1,3 @@
1
- /* Code highlighting -- target only inline code elements, not code blocks */
2
- p code:not(pre code),
3
- table code:not(pre code),
4
- li code:not(pre code),
5
- h1 code:not(pre code),
6
- h2 code:not(pre code),
7
- h3 code:not(pre code),
8
- h4 code:not(pre code),
9
- h5 code:not(pre code),
10
- h6 code:not(pre code) {
11
- color: #f72585 !important;
12
- background-color: rgba(247, 37, 133, 0.09);
13
- }
14
-
15
  /* Banner styling -- improve readability with better contrast */
16
  #banner {
17
  background: #f1f5f9 !important;
@@ -79,41 +65,3 @@ h6 code:not(pre code) {
79
  color: #f1f5f9 !important;
80
  }
81
 
82
- /* Version badge -- display a badge with the current version of the documentation */
83
- .version-badge {
84
- display: inline-block;
85
- align-items: center;
86
- gap: 0.3em;
87
- font-size: 1em;
88
- margin-top: 0px;
89
- margin-bottom: 0px;
90
- padding-top: 6px;
91
- padding-bottom: 6px;
92
- padding-left: 20px;
93
- padding-right: 20px;
94
- font-family: "Inter", sans-serif;
95
- color: #ff5400;
96
- background: #fef2f2;
97
- border: 1px solid rgba(220, 38, 38, 0.3);
98
- border-radius: 12px;
99
- box-shadow: none;
100
- vertical-align: middle;
101
- position: relative;
102
- transition: box-shadow 0.2s, transform 0.15s;
103
- }
104
-
105
- .version-badge-container {
106
- margin: 0;
107
- padding: 0;
108
- }
109
-
110
- .version-badge:hover {
111
- box-shadow: 0 2px 8px 0 rgba(160, 132, 252, 0.1);
112
- transform: translateY(-1px) scale(1.03);
113
- }
114
-
115
- .dark .version-badge {
116
- color: #f1f5f9;
117
- background: #334155;
118
- border: 1px solid #64748b;
119
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  /* Banner styling -- improve readability with better contrast */
2
  #banner {
3
  background: #f1f5f9 !important;
 
65
  color: #f1f5f9 !important;
66
  }
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/css/python-sdk.css ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ a:has(svg.icon) {
2
+ border: none !important;
3
+ }
docs/css/style.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Code highlighting -- target only inline code elements, not code blocks */
2
+ p code:not(pre code),
3
+ table code:not(pre code),
4
+ li code:not(pre code),
5
+ h1 code:not(pre code),
6
+ h2 code:not(pre code),
7
+ h3 code:not(pre code),
8
+ h4 code:not(pre code),
9
+ h5 code:not(pre code),
10
+ h6 code:not(pre code) {
11
+ color: #f72585 !important;
12
+ background-color: rgba(247, 37, 133, 0.09);
13
+ }
docs/css/version-badge.css ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Version badge -- display a badge with the current version of the documentation */
2
+ .version-badge {
3
+ display: inline-block;
4
+ align-items: center;
5
+ gap: 0.3em;
6
+ font-size: 1em;
7
+ margin-top: 0px;
8
+ margin-bottom: 0px;
9
+ padding-top: 6px;
10
+ padding-bottom: 6px;
11
+ padding-left: 20px;
12
+ padding-right: 20px;
13
+ font-family: "Inter", sans-serif;
14
+ color: #ff5400;
15
+ background: #fef2f2;
16
+ border: 1px solid rgba(220, 38, 38, 0.3);
17
+ border-radius: 12px;
18
+ box-shadow: none;
19
+ vertical-align: middle;
20
+ position: relative;
21
+ transition: box-shadow 0.2s, transform 0.15s;
22
+ }
23
+
24
+ .version-badge-container {
25
+ margin: 0;
26
+ padding: 0;
27
+ }
28
+
29
+ .version-badge:hover {
30
+ box-shadow: 0 2px 8px 0 rgba(160, 132, 252, 0.1);
31
+ transform: translateY(-1px) scale(1.03);
32
+ }
33
+
34
+ .dark .version-badge {
35
+ color: #f1f5f9;
36
+ background: #334155;
37
+ border: 1px solid #64748b;
38
+ }
39
+
docs/deployment/running-server.mdx CHANGED
@@ -105,7 +105,7 @@ When using Stdio transport, you will typically *not* run the server yourself as
105
 
106
  Streamable HTTP is a modern, efficient transport for exposing your MCP server via HTTP. It is the recommended transport for web-based deployments.
107
 
108
- To run a server using Streamable HTTP, you can use the `run()` method with the `transport` argument set to `"streamable-http"`. This will start a Uvicorn server on the default host (`127.0.0.1`), port (`8000`), and path (`/mcp/`).
109
  <CodeGroup>
110
  ```python {6} server.py
111
  from fastmcp import FastMCP
@@ -113,7 +113,7 @@ from fastmcp import FastMCP
113
  mcp = FastMCP()
114
 
115
  if __name__ == "__main__":
116
- mcp.run(transport="streamable-http")
117
  ```
118
  ```python {5} client.py
119
  import asyncio
@@ -128,6 +128,10 @@ if __name__ == "__main__":
128
  ```
129
  </CodeGroup>
130
 
 
 
 
 
131
  To customize the host, port, path, or log level, provide appropriate keyword arguments to the `run()` method.
132
 
133
  <CodeGroup>
@@ -138,7 +142,7 @@ mcp = FastMCP()
138
 
139
  if __name__ == "__main__":
140
  mcp.run(
141
- transport="streamable-http",
142
  host="127.0.0.1",
143
  port=4200,
144
  path="/my-custom-path",
@@ -158,7 +162,6 @@ if __name__ == "__main__":
158
  ```
159
  </CodeGroup>
160
 
161
-
162
  ### SSE
163
 
164
  <Warning>
@@ -250,7 +253,7 @@ def hello(name: str) -> str:
250
 
251
  async def main():
252
  # Use run_async() in async contexts
253
- await mcp.run_async(transport="streamable-http")
254
 
255
  if __name__ == "__main__":
256
  asyncio.run(main())
 
105
 
106
  Streamable HTTP is a modern, efficient transport for exposing your MCP server via HTTP. It is the recommended transport for web-based deployments.
107
 
108
+ To run a server using Streamable HTTP, you can use the `run()` method with the `transport` argument set to `"http"`. This will start a Uvicorn server on the default host (`127.0.0.1`), port (`8000`), and path (`/mcp/`).
109
  <CodeGroup>
110
  ```python {6} server.py
111
  from fastmcp import FastMCP
 
113
  mcp = FastMCP()
114
 
115
  if __name__ == "__main__":
116
+ mcp.run(transport="http")
117
  ```
118
  ```python {5} client.py
119
  import asyncio
 
128
  ```
129
  </CodeGroup>
130
 
131
+ <Tip>
132
+ For backward compatibility, wherever `"http"` is accepted as a transport name, you can also pass `"streamable-http"` as a fully supported alias. This is particularly useful when upgrading from FastMCP 1.x in the official Python SDK and FastMCP \<= 2.9, where `"streamable-http"` was the standard name.
133
+ </Tip>
134
+
135
  To customize the host, port, path, or log level, provide appropriate keyword arguments to the `run()` method.
136
 
137
  <CodeGroup>
 
142
 
143
  if __name__ == "__main__":
144
  mcp.run(
145
+ transport="http",
146
  host="127.0.0.1",
147
  port=4200,
148
  path="/my-custom-path",
 
162
  ```
163
  </CodeGroup>
164
 
 
165
  ### SSE
166
 
167
  <Warning>
 
253
 
254
  async def main():
255
  # Use run_async() in async contexts
256
+ await mcp.run_async(transport="http")
257
 
258
  if __name__ == "__main__":
259
  asyncio.run(main())
docs/docs.json CHANGED
@@ -76,7 +76,9 @@
76
  {
77
  "group": "Authentication",
78
  "icon": "shield-check",
79
- "pages": ["servers/auth/bearer"]
 
 
80
  },
81
  "servers/middleware",
82
  "servers/openapi",
@@ -85,7 +87,10 @@
85
  {
86
  "group": "Deployment",
87
  "icon": "upload",
88
- "pages": ["deployment/running-server", "deployment/asgi"]
 
 
 
89
  }
90
  ]
91
  },
@@ -116,7 +121,10 @@
116
  {
117
  "group": "Authentication",
118
  "icon": "user-shield",
119
- "pages": ["clients/auth/oauth", "clients/auth/bearer"]
 
 
 
120
  }
121
  ]
122
  },
@@ -124,9 +132,11 @@
124
  "group": "Integrations",
125
  "pages": [
126
  "integrations/anthropic",
 
 
127
  "integrations/claude-desktop",
128
- "integrations/openai",
129
  "integrations/gemini",
 
130
  "integrations/contrib"
131
  ]
132
  },
@@ -153,13 +163,17 @@
153
  },
154
  {
155
  "anchor": "What's New",
156
- "pages": ["updates", "changelog"]
 
 
 
157
  },
158
-
159
  {
160
  "anchor": "Community",
161
  "icon": "users",
162
- "pages": ["community/showcase"]
 
 
163
  }
164
  ]
165
  },
@@ -243,7 +257,17 @@
243
  "python-sdk/fastmcp-server-context",
244
  "python-sdk/fastmcp-server-dependencies",
245
  "python-sdk/fastmcp-server-http",
246
- "python-sdk/fastmcp-server-middleware",
 
 
 
 
 
 
 
 
 
 
247
  "python-sdk/fastmcp-server-openapi",
248
  "python-sdk/fastmcp-server-proxy",
249
  "python-sdk/fastmcp-server-server"
@@ -266,10 +290,12 @@
266
  "python-sdk/fastmcp-utilities-components",
267
  "python-sdk/fastmcp-utilities-exceptions",
268
  "python-sdk/fastmcp-utilities-http",
 
269
  "python-sdk/fastmcp-utilities-json_schema",
270
  "python-sdk/fastmcp-utilities-logging",
271
  "python-sdk/fastmcp-utilities-mcp_config",
272
  "python-sdk/fastmcp-utilities-openapi",
 
273
  "python-sdk/fastmcp-utilities-types"
274
  ]
275
  }
 
76
  {
77
  "group": "Authentication",
78
  "icon": "shield-check",
79
+ "pages": [
80
+ "servers/auth/bearer"
81
+ ]
82
  },
83
  "servers/middleware",
84
  "servers/openapi",
 
87
  {
88
  "group": "Deployment",
89
  "icon": "upload",
90
+ "pages": [
91
+ "deployment/running-server",
92
+ "deployment/asgi"
93
+ ]
94
  }
95
  ]
96
  },
 
121
  {
122
  "group": "Authentication",
123
  "icon": "user-shield",
124
+ "pages": [
125
+ "clients/auth/oauth",
126
+ "clients/auth/bearer"
127
+ ]
128
  }
129
  ]
130
  },
 
132
  "group": "Integrations",
133
  "pages": [
134
  "integrations/anthropic",
135
+ "integrations/chatgpt",
136
+ "integrations/claude-code",
137
  "integrations/claude-desktop",
 
138
  "integrations/gemini",
139
+ "integrations/openai",
140
  "integrations/contrib"
141
  ]
142
  },
 
163
  },
164
  {
165
  "anchor": "What's New",
166
+ "pages": [
167
+ "updates",
168
+ "changelog"
169
+ ]
170
  },
 
171
  {
172
  "anchor": "Community",
173
  "icon": "users",
174
+ "pages": [
175
+ "community/showcase"
176
+ ]
177
  }
178
  ]
179
  },
 
257
  "python-sdk/fastmcp-server-context",
258
  "python-sdk/fastmcp-server-dependencies",
259
  "python-sdk/fastmcp-server-http",
260
+ {
261
+ "group": "middleware",
262
+ "pages": [
263
+ "python-sdk/fastmcp-server-middleware-__init__",
264
+ "python-sdk/fastmcp-server-middleware-error_handling",
265
+ "python-sdk/fastmcp-server-middleware-logging",
266
+ "python-sdk/fastmcp-server-middleware-middleware",
267
+ "python-sdk/fastmcp-server-middleware-rate_limiting",
268
+ "python-sdk/fastmcp-server-middleware-timing"
269
+ ]
270
+ },
271
  "python-sdk/fastmcp-server-openapi",
272
  "python-sdk/fastmcp-server-proxy",
273
  "python-sdk/fastmcp-server-server"
 
290
  "python-sdk/fastmcp-utilities-components",
291
  "python-sdk/fastmcp-utilities-exceptions",
292
  "python-sdk/fastmcp-utilities-http",
293
+ "python-sdk/fastmcp-utilities-inspect",
294
  "python-sdk/fastmcp-utilities-json_schema",
295
  "python-sdk/fastmcp-utilities-logging",
296
  "python-sdk/fastmcp-utilities-mcp_config",
297
  "python-sdk/fastmcp-utilities-openapi",
298
+ "python-sdk/fastmcp-utilities-tests",
299
  "python-sdk/fastmcp-utilities-types"
300
  ]
301
  }
docs/getting-started/installation.mdx CHANGED
@@ -47,7 +47,7 @@ FastMCP root path: ~/Developer/fastmcp
47
  Upgrading from the official MCP SDK's FastMCP 1.0 to FastMCP 2.0 is generally straightforward. The core server API is highly compatible, and in many cases, changing your import statement from `from mcp.server.fastmcp import FastMCP` to `from fastmcp import FastMCP` will be sufficient.
48
 
49
 
50
- ```python {1-5}
51
  # Before
52
  # from mcp.server.fastmcp import FastMCP
53
 
@@ -56,8 +56,9 @@ from fastmcp import FastMCP
56
 
57
  mcp = FastMCP("My MCP Server")
58
  ```
 
59
  <Warning>
60
- Prior to `fastmcp==2.3.0` and `mcp==1.8.0`, the 2.x API always mirrored the 1.0 API. However, as the projects diverge, this can not be guaranteed. You may see deprecation warnings if you attempt to use 1.0 APIs in FastMCP 2.x. Please refer to this documentation for details on new capabilities.
61
  </Warning>
62
 
63
  ## Versioning and Breaking Changes
 
47
  Upgrading from the official MCP SDK's FastMCP 1.0 to FastMCP 2.0 is generally straightforward. The core server API is highly compatible, and in many cases, changing your import statement from `from mcp.server.fastmcp import FastMCP` to `from fastmcp import FastMCP` will be sufficient.
48
 
49
 
50
+ ```python {5}
51
  # Before
52
  # from mcp.server.fastmcp import FastMCP
53
 
 
56
 
57
  mcp = FastMCP("My MCP Server")
58
  ```
59
+
60
  <Warning>
61
+ Prior to `fastmcp==2.3.0` and `mcp==1.8.0`, the 2.x API always mirrored the official 1.0 API. However, as the projects diverge, this can not be guaranteed. You may see deprecation warnings if you attempt to use 1.0 APIs in FastMCP 2.x. Please refer to this documentation for details on new capabilities.
62
  </Warning>
63
 
64
  ## Versioning and Breaking Changes
docs/integrations/anthropic.mdx CHANGED
@@ -31,7 +31,7 @@ def roll_dice(n_dice: int) -> list[int]:
31
  return [random.randint(1, 6) for _ in range(n_dice)]
32
 
33
  if __name__ == "__main__":
34
- mcp.run(transport="sse", port=8000)
35
  ```
36
 
37
  ## Deploy the Server
@@ -70,7 +70,7 @@ You'll also need to authenticate with Anthropic. You can do this by setting the
70
  export ANTHROPIC_API_KEY="your-api-key"
71
  ```
72
 
73
- Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/sse` as the endpoint because we deployed an SSE server with the default path; you may need to use a different endpoint if you customized your server's deployment. **At this time you must also include the `extra_headers` parameter with the `anthropic-beta` header.**
74
 
75
  ```python {5, 13-22}
76
  import anthropic
@@ -88,7 +88,7 @@ response = client.beta.messages.create(
88
  mcp_servers=[
89
  {
90
  "type": "url",
91
- "url": f"{url}/sse",
92
  "name": "dice-server",
93
  }
94
  ],
@@ -175,7 +175,7 @@ def roll_dice(n_dice: int) -> list[int]:
175
 
176
  if __name__ == "__main__":
177
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
178
- mcp.run(transport="sse", port=8000)
179
  ```
180
 
181
  ### Client Authentication
@@ -213,7 +213,7 @@ response = client.beta.messages.create(
213
  mcp_servers=[
214
  {
215
  "type": "url",
216
- "url": f"{url}/sse",
217
  "name": "dice-server",
218
  "authorization_token": access_token
219
  }
 
31
  return [random.randint(1, 6) for _ in range(n_dice)]
32
 
33
  if __name__ == "__main__":
34
+ mcp.run(transport="http", port=8000)
35
  ```
36
 
37
  ## Deploy the Server
 
70
  export ANTHROPIC_API_KEY="your-api-key"
71
  ```
72
 
73
+ Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/mcp/` as the endpoint because we deployed a streamable-HTTP server with the default path; you may need to use a different endpoint if you customized your server's deployment. **At this time you must also include the `extra_headers` parameter with the `anthropic-beta` header.**
74
 
75
  ```python {5, 13-22}
76
  import anthropic
 
88
  mcp_servers=[
89
  {
90
  "type": "url",
91
+ "url": f"{url}/mcp/",
92
  "name": "dice-server",
93
  }
94
  ],
 
175
 
176
  if __name__ == "__main__":
177
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
178
+ mcp.run(transport="http", port=8000)
179
  ```
180
 
181
  ### Client Authentication
 
213
  mcp_servers=[
214
  {
215
  "type": "url",
216
+ "url": f"{url}/mcp/",
217
  "name": "dice-server",
218
  "authorization_token": access_token
219
  }
docs/integrations/chatgpt.mdx ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: ChatGPT + FastMCP
3
+ sidebarTitle: ChatGPT
4
+ description: Connect FastMCP servers to ChatGPT Deep Research
5
+ icon: message-smile
6
+ tag: NEW
7
+ ---
8
+
9
+ ChatGPT supports MCP servers through remote HTTP connections, allowing you to extend ChatGPT's capabilities with custom tools and knowledge from your FastMCP servers.
10
+
11
+ <Note>
12
+ MCP integration with ChatGPT is currently limited to **Deep Research** functionality and is not available for general chat. This feature is available for ChatGPT Pro, Team, Enterprise, and Edu users.
13
+ </Note>
14
+
15
+ <Tip>
16
+ OpenAI's official MCP documentation and examples are built with **FastMCP v2**! Check out their [sample MCP server](https://github.com/openai/mcp-server-sample) which demonstrates FastMCP in action.
17
+ </Tip>
18
+
19
+ ## Deep Research
20
+
21
+ ChatGPT's Deep Research feature requires MCP servers to be internet-accessible HTTP endpoints with **exactly two specific tools**:
22
+
23
+ - **`search`**: For searching through your resources and returning matching IDs
24
+ - **`fetch`**: For retrieving the full content of specific resources by ID
25
+
26
+ <Warning>
27
+ If your server doesn't implement both `search` and `fetch` tools with the correct signatures, ChatGPT will show the error: "This MCP server doesn't implement our specification". Both tools are required.
28
+ </Warning>
29
+
30
+ ### Tool Descriptions Matter
31
+
32
+ Since ChatGPT needs to understand how to use your tools effectively, **write detailed tool descriptions**. The description teaches ChatGPT how to form queries, what parameters to use, and what to expect from your data. Poor descriptions lead to poor search results.
33
+
34
+ ### Create a Server
35
+
36
+ A Deep Research-compatible server must implement these two required tools:
37
+
38
+ - **`search(query: str)`** - Takes a query of any kind and returns matching record IDs
39
+ - **`fetch(id: str)`** - Takes an ID and returns the record
40
+
41
+ **Critical**: Write detailed docstrings for both tools. These descriptions teach ChatGPT how to use your tools effectively. Poor descriptions lead to poor search results.
42
+
43
+ The `search` tool should take a query (of any kind!) and return IDs. The `fetch` tool should take an ID and return the record.
44
+
45
+ Here's a reference server implementation you can adapt (see also [OpenAI's sample server](https://github.com/openai/mcp-server-sample) for comparison):
46
+
47
+ ```python server.py [expandable]
48
+ import json
49
+ from pathlib import Path
50
+ from dataclasses import dataclass
51
+ from fastmcp import FastMCP
52
+
53
+ @dataclass
54
+ class Record:
55
+ id: str
56
+ title: str
57
+ text: str
58
+ metadata: dict
59
+
60
+ def create_server(
61
+ records_path: Path | str,
62
+ name: str | None = None,
63
+ instructions: str | None = None,
64
+ ) -> FastMCP:
65
+ """Create a FastMCP server that can search and fetch records from a JSON file."""
66
+ records = json.loads(Path(records_path).read_text())
67
+
68
+ RECORDS = [Record(**r) for r in records]
69
+ LOOKUP = {r.id: r for r in RECORDS}
70
+
71
+ mcp = FastMCP(name=name or "Deep Research MCP", instructions=instructions)
72
+
73
+ @mcp.tool()
74
+ async def search(query: str):
75
+ """
76
+ Simple unranked keyword search across title, text, and metadata.
77
+ Searches for any of the query terms in the record content.
78
+ Returns a list of matching record IDs for ChatGPT to fetch.
79
+ """
80
+ toks = query.lower().split()
81
+ ids = []
82
+ for r in RECORDS:
83
+ record_txt = " ".join(
84
+ [r.title, r.text, " ".join(r.metadata.values())]
85
+ ).lower()
86
+ if any(t in record_txt for t in toks):
87
+ ids.append(r.id)
88
+
89
+ return {"ids": ids}
90
+
91
+ @mcp.tool()
92
+ async def fetch(id: str):
93
+ """
94
+ Fetch a record by ID.
95
+ Returns the complete record data for ChatGPT to analyze and cite.
96
+ """
97
+ if id not in LOOKUP:
98
+ raise ValueError(f"Unknown record ID: {id}")
99
+ return LOOKUP[id]
100
+
101
+ return mcp
102
+
103
+ if __name__ == "__main__":
104
+ mcp = create_server("path/to/records.json")
105
+ mcp.run(transport="http", port=8000)
106
+ ```
107
+
108
+ ### Deploy the Server
109
+
110
+ Your server must be deployed to a public URL in order for ChatGPT to access it.
111
+
112
+ For development, you can use tools like `ngrok` to temporarily expose a locally-running server to the internet. We'll do that for this example (you may need to install `ngrok` and create a free account), but you can use any other method to deploy your server.
113
+
114
+ Assuming you saved the above code as `server.py`, you can run the following two commands in two separate terminals to deploy your server and expose it to the internet:
115
+
116
+ <CodeGroup>
117
+ ```bash FastMCP server
118
+ python server.py
119
+ ```
120
+
121
+ ```bash ngrok
122
+ ngrok http 8000
123
+ ```
124
+ </CodeGroup>
125
+
126
+ <Warning>
127
+ This exposes your unauthenticated server to the internet. Only run this command in a safe environment if you understand the risks.
128
+ </Warning>
129
+
130
+ ### Connect to ChatGPT
131
+
132
+ Replace `https://your-server-url.com` with the actual URL of your server (such as your ngrok URL).
133
+
134
+ 1. Open ChatGPT and go to **Settings** → **Connectors**
135
+ 2. Click **Add custom connector**
136
+ 3. Enter your server details:
137
+ - **Name**: Library Catalog
138
+ - **URL**: Your server URL (e.g., `https://abc123.ngrok.io`)
139
+ - **Description**: A library catalog for searching and retrieving books
140
+
141
+ #### Test the Connection
142
+
143
+ 1. Start a new chat in ChatGPT
144
+ 2. Click **Tools** → **Run deep research**
145
+ 3. Select your **Library Catalog** connector as a source
146
+ 4. Ask questions like:
147
+ - "Search for Python programming books"
148
+ - "Find books about AI and machine learning"
149
+ - "Show me books by the Python Software Foundation"
150
+
151
+ ChatGPT will use your server's search and fetch tools to find relevant information and cite the sources in its response.
152
+
153
+ ### Troubleshooting
154
+
155
+ #### "This MCP server doesn't implement our specification"
156
+
157
+
158
+ If you get this error, it most likely means that your server doesn't implement the required tools (`search` and `fetch`). To correct it, ensure that your server meets the service requirements.
docs/integrations/claude-code.mdx ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Claude Code + FastMCP
3
+ sidebarTitle: Claude Code
4
+ description: Connect FastMCP servers to Claude Code
5
+ icon: message-smile
6
+ tag: NEW
7
+ ---
8
+
9
+ Claude Code supports MCP servers through multiple transport methods, allowing you to extend Claude's capabilities with custom tools, resources, and prompts from your FastMCP servers.
10
+
11
+ <Note>
12
+ Claude Code supports both local and remote MCP servers with flexible configuration options. See the [Claude Code MCP documentation](https://docs.anthropic.com/en/docs/claude-code/mcp) for other transport methods.
13
+ </Note>
14
+
15
+ <Tip>
16
+ Claude Code provides built-in MCP management commands to easily add, configure, and authenticate your FastMCP servers.
17
+ </Tip>
18
+
19
+ ## Create a Server
20
+
21
+ You can create FastMCP servers using STDIO transport, remote HTTP servers, or local HTTP servers. This example shows one common approach: running an HTTP server locally for development.
22
+
23
+ ```python server.py
24
+ import random
25
+ from fastmcp import FastMCP
26
+
27
+ mcp = FastMCP(name="Dice Roller")
28
+
29
+ @mcp.tool
30
+ def roll_dice(n_dice: int) -> list[int]:
31
+ """Roll `n_dice` 6-sided dice and return the results."""
32
+ return [random.randint(1, 6) for _ in range(n_dice)]
33
+
34
+ if __name__ == "__main__":
35
+ mcp.run(transport="http", port=8000)
36
+ ```
37
+
38
+ ## Connect to Claude Code
39
+
40
+ Start your server and add it to Claude Code:
41
+
42
+ ```bash
43
+ # Start your server first
44
+ python server.py
45
+ ```
46
+
47
+ Then add it to Claude Code:
48
+ ```bash
49
+ claude mcp add dice --transport http http://localhost:8000/mcp/
50
+ ```
51
+
52
+ ## Using Your Server
53
+
54
+ Once connected, Claude Code will automatically discover and use your server's tools when relevant:
55
+
56
+ ```
57
+ Roll some dice for me
58
+ ```
59
+
60
+ Claude will call your `roll_dice` tool and provide the results. If your server provides resources, you can reference them with `@` mentions like `@dice:file://path/to/resource`.
docs/integrations/claude-desktop.mdx CHANGED
@@ -2,11 +2,15 @@
2
  title: Claude Desktop + FastMCP
3
  sidebarTitle: Claude Desktop
4
  description: Call FastMCP servers from Claude Desktop
5
- icon: desktop
6
  ---
7
 
8
 
9
- Claude Desktop supports MCP servers through local STDIO connections, allowing you to extend Claude's capabilities with custom tools, resources, and prompts from your FastMCP servers.
 
 
 
 
10
 
11
  <Note>
12
  This guide focuses specifically on using FastMCP servers with Claude Desktop. For general Claude Desktop MCP setup and official examples, see the [official Claude Desktop quickstart guide](https://modelcontextprotocol.io/quickstart/user).
@@ -15,10 +19,10 @@ This guide focuses specifically on using FastMCP servers with Claude Desktop. Fo
15
 
16
  ## Requirements
17
 
18
- Claude Desktop requires MCP servers to run locally using STDIO transport. This means your server will communicate with Claude through standard input/output rather than HTTP.
19
 
20
  <Tip>
21
- If you need to connect to remote servers, you can create a **proxy server** that runs locally via STDIO and forwards requests to remote HTTP servers. See the [Proxy Servers](#proxy-servers) section below.
22
  </Tip>
23
 
24
  ## Create a Server
@@ -181,7 +185,7 @@ Claude Desktop runs servers in a completely isolated environment with no access
181
  ## Remote Servers
182
 
183
 
184
- Claude Desktop only supports local STDIO servers, but FastMCP can create a proxy server that forwards requests to a remote HTTP server. You can install the proxy server in Claude Desktop.
185
 
186
  Create a proxy server that connects to a remote HTTP server:
187
 
 
2
  title: Claude Desktop + FastMCP
3
  sidebarTitle: Claude Desktop
4
  description: Call FastMCP servers from Claude Desktop
5
+ icon: message-smile
6
  ---
7
 
8
 
9
+ Claude Desktop supports MCP servers through local STDIO connections and remote servers (beta), allowing you to extend Claude's capabilities with custom tools, resources, and prompts from your FastMCP servers.
10
+
11
+ <Note>
12
+ Remote MCP server support is currently in beta and available for users on Claude Pro, Max, Team, and Enterprise plans (as of June 2025). Most users will still need to use local STDIO connections.
13
+ </Note>
14
 
15
  <Note>
16
  This guide focuses specifically on using FastMCP servers with Claude Desktop. For general Claude Desktop MCP setup and official examples, see the [official Claude Desktop quickstart guide](https://modelcontextprotocol.io/quickstart/user).
 
19
 
20
  ## Requirements
21
 
22
+ Claude Desktop traditionally requires MCP servers to run locally using STDIO transport, where your server communicates with Claude through standard input/output rather than HTTP. However, users on certain plans now have access to remote server support as well.
23
 
24
  <Tip>
25
+ If you don't have access to remote server support or need to connect to remote servers, you can create a **proxy server** that runs locally via STDIO and forwards requests to remote HTTP servers. See the [Proxy Servers](#proxy-servers) section below.
26
  </Tip>
27
 
28
  ## Create a Server
 
185
  ## Remote Servers
186
 
187
 
188
+ Users on Claude Pro, Max, Team, and Enterprise plans have first-class remote server support via integrations. For other users, or as an alternative approach, FastMCP can create a proxy server that forwards requests to a remote HTTP server. You can install the proxy server in Claude Desktop.
189
 
190
  Create a proxy server that connects to a remote HTTP server:
191
 
docs/integrations/gemini.mdx CHANGED
@@ -99,7 +99,7 @@ from fastmcp import Client
99
  from fastmcp.client.auth import BearerAuth
100
 
101
  mcp_client = Client(
102
- "https://my-server.com/sse",
103
  auth=BearerAuth("<your-token>"),
104
  )
105
  ```
 
99
  from fastmcp.client.auth import BearerAuth
100
 
101
  mcp_client = Client(
102
+ "https://my-server.com/mcp/",
103
  auth=BearerAuth("<your-token>"),
104
  )
105
  ```
docs/integrations/openai.mdx CHANGED
@@ -38,7 +38,7 @@ def roll_dice(n_dice: int) -> list[int]:
38
  return [random.randint(1, 6) for _ in range(n_dice)]
39
 
40
  if __name__ == "__main__":
41
- mcp.run(transport="sse", port=8000)
42
  ```
43
 
44
  ### Deploy the Server
@@ -77,7 +77,7 @@ You'll also need to authenticate with OpenAI. You can do this by setting the `OP
77
  export OPENAI_API_KEY="your-api-key"
78
  ```
79
 
80
- Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/sse` as the endpoint because we deployed an SSE server with the default path; you may need to use a different endpoint if you customized your server's deployment.
81
 
82
  ```python {4, 11-16}
83
  from openai import OpenAI
@@ -93,7 +93,7 @@ resp = client.responses.create(
93
  {
94
  "type": "mcp",
95
  "server_label": "dice_server",
96
- "server_url": f"{url}/sse",
97
  "require_approval": "never",
98
  },
99
  ],
@@ -172,7 +172,7 @@ def roll_dice(n_dice: int) -> list[int]:
172
 
173
  if __name__ == "__main__":
174
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
175
- mcp.run(transport="sse", port=8000)
176
  ```
177
 
178
  #### Client Authentication
@@ -212,7 +212,7 @@ resp = client.responses.create(
212
  {
213
  "type": "mcp",
214
  "server_label": "dice_server",
215
- "server_url": f"{url}/sse",
216
  "require_approval": "never",
217
  "headers": {
218
  "Authorization": f"Bearer {access_token}"
 
38
  return [random.randint(1, 6) for _ in range(n_dice)]
39
 
40
  if __name__ == "__main__":
41
+ mcp.run(transport="http", port=8000)
42
  ```
43
 
44
  ### Deploy the Server
 
77
  export OPENAI_API_KEY="your-api-key"
78
  ```
79
 
80
+ Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/mcp/` as the endpoint because we deployed a streamable-HTTP server with the default path; you may need to use a different endpoint if you customized your server's deployment.
81
 
82
  ```python {4, 11-16}
83
  from openai import OpenAI
 
93
  {
94
  "type": "mcp",
95
  "server_label": "dice_server",
96
+ "server_url": f"{url}/mcp/",
97
  "require_approval": "never",
98
  },
99
  ],
 
172
 
173
  if __name__ == "__main__":
174
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
175
+ mcp.run(transport="http", port=8000)
176
  ```
177
 
178
  #### Client Authentication
 
212
  {
213
  "type": "mcp",
214
  "server_label": "dice_server",
215
+ "server_url": f"{url}/mcp/",
216
  "require_approval": "never",
217
  "headers": {
218
  "Authorization": f"Bearer {access_token}"
docs/patterns/cli.mdx CHANGED
@@ -42,11 +42,12 @@ This command runs the server directly in your current Python environment. You ar
42
 
43
  | Option | Flag | Description |
44
  | ------ | ---- | ----------- |
45
- | Transport | `--transport`, `-t` | Transport protocol to use (`stdio`, `streamable-http`, or `sse`) |
46
  | Host | `--host` | Host to bind to when using http transport (default: 127.0.0.1) |
47
  | Port | `--port`, `-p` | Port to bind to when using http transport (default: 8000) |
48
  | Log Level | `--log-level`, `-l` | Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
49
 
 
50
  #### Server Specification
51
  <VersionBadge version="2.3.5" />
52
 
@@ -79,14 +80,14 @@ if __name__ == "__main__":
79
  You can run it with Streamable HTTP transport regardless of what's in the `__main__` block:
80
 
81
  ```bash
82
- fastmcp run server.py --transport streamable-http --port 8000
83
  ```
84
 
85
  **Examples**
86
 
87
  ```bash
88
  # Run a local server with Streamable HTTP transport on a custom port
89
- fastmcp run server.py --transport streamable-http --port 8000
90
 
91
  # Connect to a remote server and proxy as a stdio server
92
  fastmcp run https://example.com/mcp-server
@@ -112,14 +113,14 @@ The `dev` command is a shortcut for testing a server over STDIO only. When the I
112
  1. Select "STDIO" from the transport dropdown
113
  2. Connect manually
114
 
115
- This command does not support HTTP testing. To test a server over HTTP:
116
- 1. Start your server manually with HTTP transport using either:
117
  ```bash
118
- fastmcp run server.py --transport streamable-http
119
  ```
120
- or
121
  ```bash
122
- python server.py # Assuming your __main__ block sets HTTP transport
123
  ```
124
  2. Open the MCP Inspector separately and connect to your running server
125
  </Warning>
 
42
 
43
  | Option | Flag | Description |
44
  | ------ | ---- | ----------- |
45
+ | Transport | `--transport`, `-t` | Transport protocol to use (`stdio`, `http`, or `sse`) |
46
  | Host | `--host` | Host to bind to when using http transport (default: 127.0.0.1) |
47
  | Port | `--port`, `-p` | Port to bind to when using http transport (default: 8000) |
48
  | Log Level | `--log-level`, `-l` | Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
49
 
50
+
51
  #### Server Specification
52
  <VersionBadge version="2.3.5" />
53
 
 
80
  You can run it with Streamable HTTP transport regardless of what's in the `__main__` block:
81
 
82
  ```bash
83
+ fastmcp run server.py --transport http --port 8000
84
  ```
85
 
86
  **Examples**
87
 
88
  ```bash
89
  # Run a local server with Streamable HTTP transport on a custom port
90
+ fastmcp run server.py --transport http --port 8000
91
 
92
  # Connect to a remote server and proxy as a stdio server
93
  fastmcp run https://example.com/mcp-server
 
113
  1. Select "STDIO" from the transport dropdown
114
  2. Connect manually
115
 
116
+ This command does not support HTTP testing. To test a server over Streamable HTTP or SSE:
117
+ 1. Start your server manually with the appropriate transport using either the command line:
118
  ```bash
119
+ fastmcp run server.py --transport http
120
  ```
121
+ or by setting the transport in your code:
122
  ```bash
123
+ python server.py # Assuming your __main__ block sets Streamable HTTP transport
124
  ```
125
  2. Open the MCP Inspector separately and connect to your running server
126
  </Warning>
docs/python-sdk/fastmcp-cli-claude.mdx CHANGED
@@ -10,7 +10,7 @@ Claude app integration utilities.
10
 
11
  ## Functions
12
 
13
- ### `get_claude_config_path`
14
 
15
  ```python
16
  get_claude_config_path() -> Path | None
@@ -20,7 +20,7 @@ get_claude_config_path() -> Path | None
20
  Get the Claude config directory based on platform.
21
 
22
 
23
- ### `update_claude_config`
24
 
25
  ```python
26
  update_claude_config(file_spec: str, server_name: str) -> bool
 
10
 
11
  ## Functions
12
 
13
+ ### `get_claude_config_path` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/claude.py#L14"><Icon icon="github" size="14" /></a></sup>
14
 
15
  ```python
16
  get_claude_config_path() -> Path | None
 
20
  Get the Claude config directory based on platform.
21
 
22
 
23
+ ### `update_claude_config` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/claude.py#L32"><Icon icon="github" size="14" /></a></sup>
24
 
25
  ```python
26
  update_claude_config(file_spec: str, server_name: str) -> bool
docs/python-sdk/fastmcp-cli-cli.mdx CHANGED
@@ -10,13 +10,13 @@ FastMCP CLI tools.
10
 
11
  ## Functions
12
 
13
- ### `version`
14
 
15
  ```python
16
  version(ctx: Context)
17
  ```
18
 
19
- ### `dev`
20
 
21
  ```python
22
  dev(server_spec: str = typer.Argument(..., help='Python file to run, optionally with :object suffix'), with_editable: Annotated[Path | None, typer.Option('--with-editable', '-e', help='Directory containing pyproject.toml to install in editable mode', exists=True, file_okay=False, resolve_path=True)] = None, with_packages: Annotated[list[str], typer.Option('--with', help='Additional packages to install')] = [], inspector_version: Annotated[str | None, typer.Option('--inspector-version', help='Version of the MCP Inspector to use')] = None, ui_port: Annotated[int | None, typer.Option('--ui-port', help='Port for the MCP Inspector UI')] = None, server_port: Annotated[int | None, typer.Option('--server-port', help='Port for the MCP Inspector Proxy server')] = None) -> None
@@ -26,10 +26,10 @@ dev(server_spec: str = typer.Argument(..., help='Python file to run, optionally
26
  Run a MCP server with the MCP Inspector.
27
 
28
 
29
- ### `run`
30
 
31
  ```python
32
- run(ctx: typer.Context, server_spec: str = typer.Argument(..., help='Python file, object specification (file:obj), or URL'), transport: Annotated[str | None, typer.Option('--transport', '-t', help='Transport protocol to use (stdio, streamable-http, or sse)')] = None, host: Annotated[str | None, typer.Option('--host', help='Host to bind to when using http transport (default: 127.0.0.1)')] = None, port: Annotated[int | None, typer.Option('--port', '-p', help='Port to bind to when using http transport (default: 8000)')] = None, log_level: Annotated[str | None, typer.Option('--log-level', '-l', help='Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)')] = None) -> None
33
  ```
34
 
35
 
@@ -51,7 +51,7 @@ Server arguments can be passed after -- :
51
  fastmcp run server.py -- --config config.json --debug
52
 
53
 
54
- ### `install`
55
 
56
  ```python
57
  install(server_spec: str = typer.Argument(..., help='Python file to run, optionally with :object suffix'), server_name: Annotated[str | None, typer.Option('--name', '-n', help="Custom name for the server (defaults to server's name attribute or file name)")] = None, with_editable: Annotated[Path | None, typer.Option('--with-editable', '-e', help='Directory containing pyproject.toml to install in editable mode', exists=True, file_okay=False, resolve_path=True)] = None, with_packages: Annotated[list[str], typer.Option('--with', help='Additional packages to install')] = [], env_vars: Annotated[list[str], typer.Option('--env-var', '-v', help='Environment variables in KEY=VALUE format')] = [], env_file: Annotated[Path | None, typer.Option('--env-file', '-f', help='Load environment variables from a .env file', exists=True, file_okay=True, dir_okay=False, resolve_path=True)] = None) -> None
@@ -63,3 +63,25 @@ Install a MCP server in the Claude desktop app.
63
  Environment variables are preserved once added and only updated if new values
64
  are explicitly provided.
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  ## Functions
12
 
13
+ ### `version` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L87"><Icon icon="github" size="14" /></a></sup>
14
 
15
  ```python
16
  version(ctx: Context)
17
  ```
18
 
19
+ ### `dev` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L110"><Icon icon="github" size="14" /></a></sup>
20
 
21
  ```python
22
  dev(server_spec: str = typer.Argument(..., help='Python file to run, optionally with :object suffix'), with_editable: Annotated[Path | None, typer.Option('--with-editable', '-e', help='Directory containing pyproject.toml to install in editable mode', exists=True, file_okay=False, resolve_path=True)] = None, with_packages: Annotated[list[str], typer.Option('--with', help='Additional packages to install')] = [], inspector_version: Annotated[str | None, typer.Option('--inspector-version', help='Version of the MCP Inspector to use')] = None, ui_port: Annotated[int | None, typer.Option('--ui-port', help='Port for the MCP Inspector UI')] = None, server_port: Annotated[int | None, typer.Option('--server-port', help='Port for the MCP Inspector Proxy server')] = None) -> None
 
26
  Run a MCP server with the MCP Inspector.
27
 
28
 
29
+ ### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L227"><Icon icon="github" size="14" /></a></sup>
30
 
31
  ```python
32
+ run(ctx: typer.Context, server_spec: str = typer.Argument(..., help='Python file, object specification (file:obj), or URL'), transport: Annotated[str | None, typer.Option('--transport', '-t', help='Transport protocol to use (stdio, http, or sse)')] = None, host: Annotated[str | None, typer.Option('--host', help='Host to bind to when using http transport (default: 127.0.0.1)')] = None, port: Annotated[int | None, typer.Option('--port', '-p', help='Port to bind to when using http transport (default: 8000)')] = None, log_level: Annotated[str | None, typer.Option('--log-level', '-l', help='Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)')] = None) -> None
33
  ```
34
 
35
 
 
51
  fastmcp run server.py -- --config config.json --debug
52
 
53
 
54
+ ### `install` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L313"><Icon icon="github" size="14" /></a></sup>
55
 
56
  ```python
57
  install(server_spec: str = typer.Argument(..., help='Python file to run, optionally with :object suffix'), server_name: Annotated[str | None, typer.Option('--name', '-n', help="Custom name for the server (defaults to server's name attribute or file name)")] = None, with_editable: Annotated[Path | None, typer.Option('--with-editable', '-e', help='Directory containing pyproject.toml to install in editable mode', exists=True, file_okay=False, resolve_path=True)] = None, with_packages: Annotated[list[str], typer.Option('--with', help='Additional packages to install')] = [], env_vars: Annotated[list[str], typer.Option('--env-var', '-v', help='Environment variables in KEY=VALUE format')] = [], env_file: Annotated[Path | None, typer.Option('--env-file', '-f', help='Load environment variables from a .env file', exists=True, file_okay=True, dir_okay=False, resolve_path=True)] = None) -> None
 
63
  Environment variables are preserved once added and only updated if new values
64
  are explicitly provided.
65
 
66
+
67
+ ### `inspect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L444"><Icon icon="github" size="14" /></a></sup>
68
+
69
+ ```python
70
+ inspect(server_spec: str = typer.Argument(..., help='Python file to inspect, optionally with :object suffix'), output: Annotated[Path, typer.Option('--output', '-o', help='Output file path for the JSON report (default: server-info.json)')] = Path('server-info.json')) -> None
71
+ ```
72
+
73
+
74
+ Inspect a FastMCP server and generate a JSON report.
75
+
76
+ This command analyzes a FastMCP server (v1.x or v2.x) and generates
77
+ a comprehensive JSON report containing information about the server's
78
+ name, instructions, version, tools, prompts, resources, templates,
79
+ and capabilities.
80
+
81
+ **Examples:**
82
+
83
+ fastmcp inspect server.py
84
+ fastmcp inspect server.py -o report.json
85
+ fastmcp inspect server.py:mcp -o analysis.json
86
+ fastmcp inspect path/to/server.py:app -o /tmp/server-info.json
87
+
docs/python-sdk/fastmcp-cli-run.mdx CHANGED
@@ -10,7 +10,7 @@ FastMCP run command implementation.
10
 
11
  ## Functions
12
 
13
- ### `is_url`
14
 
15
  ```python
16
  is_url(path: str) -> bool
@@ -20,7 +20,7 @@ is_url(path: str) -> bool
20
  Check if a string is a URL.
21
 
22
 
23
- ### `parse_file_path`
24
 
25
  ```python
26
  parse_file_path(server_spec: str) -> tuple[Path, str | None]
@@ -36,7 +36,7 @@ Parse a file path that may include a server object specification.
36
  - Tuple of (file_path, server_object)
37
 
38
 
39
- ### `import_server`
40
 
41
  ```python
42
  import_server(file: Path, server_object: str | None = None) -> Any
@@ -53,7 +53,7 @@ Import a MCP server from a file.
53
  - The server object
54
 
55
 
56
- ### `create_client_server`
57
 
58
  ```python
59
  create_client_server(url: str) -> Any
@@ -69,7 +69,7 @@ Create a FastMCP server from a client URL.
69
  - A FastMCP server instance
70
 
71
 
72
- ### `import_server_with_args`
73
 
74
  ```python
75
  import_server_with_args(file: Path, server_object: str | None = None, server_args: list[str] | None = None) -> Any
@@ -87,7 +87,7 @@ Import a server with optional command line arguments.
87
  - The imported server object
88
 
89
 
90
- ### `run_command`
91
 
92
  ```python
93
  run_command(server_spec: str, transport: str | None = None, host: str | None = None, port: int | None = None, log_level: str | None = None, server_args: list[str] | None = None) -> None
 
10
 
11
  ## Functions
12
 
13
+ ### `is_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L14"><Icon icon="github" size="14" /></a></sup>
14
 
15
  ```python
16
  is_url(path: str) -> bool
 
20
  Check if a string is a URL.
21
 
22
 
23
+ ### `parse_file_path` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L20"><Icon icon="github" size="14" /></a></sup>
24
 
25
  ```python
26
  parse_file_path(server_spec: str) -> tuple[Path, str | None]
 
36
  - Tuple of (file_path, server_object)
37
 
38
 
39
+ ### `import_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L51"><Icon icon="github" size="14" /></a></sup>
40
 
41
  ```python
42
  import_server(file: Path, server_object: str | None = None) -> Any
 
53
  - The server object
54
 
55
 
56
+ ### `create_client_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L121"><Icon icon="github" size="14" /></a></sup>
57
 
58
  ```python
59
  create_client_server(url: str) -> Any
 
69
  - A FastMCP server instance
70
 
71
 
72
+ ### `import_server_with_args` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L141"><Icon icon="github" size="14" /></a></sup>
73
 
74
  ```python
75
  import_server_with_args(file: Path, server_object: str | None = None, server_args: list[str] | None = None) -> Any
 
87
  - The imported server object
88
 
89
 
90
+ ### `run_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L165"><Icon icon="github" size="14" /></a></sup>
91
 
92
  ```python
93
  run_command(server_spec: str, transport: str | None = None, host: str | None = None, port: int | None = None, log_level: str | None = None, server_args: list[str] | None = None) -> None
docs/python-sdk/fastmcp-client-auth-bearer.mdx CHANGED
@@ -7,11 +7,11 @@ sidebarTitle: bearer
7
 
8
  ## Classes
9
 
10
- ### `BearerAuth`
11
 
12
  **Methods:**
13
 
14
- #### `auth_flow`
15
 
16
  ```python
17
  auth_flow(self, request)
 
7
 
8
  ## Classes
9
 
10
+ ### `BearerAuth` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/bearer.py#L11"><Icon icon="github" size="14" /></a></sup>
11
 
12
  **Methods:**
13
 
14
+ #### `auth_flow` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/bearer.py#L15"><Icon icon="github" size="14" /></a></sup>
15
 
16
  ```python
17
  auth_flow(self, request)
docs/python-sdk/fastmcp-client-auth-oauth.mdx CHANGED
@@ -7,13 +7,13 @@ sidebarTitle: oauth
7
 
8
  ## Functions
9
 
10
- ### `default_cache_dir`
11
 
12
  ```python
13
  default_cache_dir() -> Path
14
  ```
15
 
16
- ### `OAuth`
17
 
18
  ```python
19
  OAuth(mcp_url: str, scopes: str | list[str] | None = None, client_name: str = 'FastMCP Client', token_storage_cache_dir: Path | None = None, additional_client_metadata: dict[str, Any] | None = None) -> _MCPOAuthClientProvider
@@ -38,7 +38,7 @@ httpx.AsyncClient (or appropriate FastMCP client/transport instance)
38
 
39
  ## Classes
40
 
41
- ### `ServerOAuthMetadata`
42
 
43
 
44
  More flexible OAuth metadata model that accepts broader ranges of values
@@ -48,13 +48,13 @@ This handles real-world OAuth servers like PayPal that may support
48
  additional methods not in the MCP specification.
49
 
50
 
51
- ### `OAuthClientProvider`
52
 
53
 
54
  OAuth client provider with more flexible OAuth metadata discovery.
55
 
56
 
57
- ### `FileTokenStorage`
58
 
59
 
60
  File-based token storage implementation for OAuth credentials and tokens.
@@ -65,7 +65,7 @@ Each instance is tied to a specific server URL for proper token isolation.
65
 
66
  **Methods:**
67
 
68
- #### `get_base_url`
69
 
70
  ```python
71
  get_base_url(url: str) -> str
@@ -74,7 +74,7 @@ get_base_url(url: str) -> str
74
  Extract the base URL (scheme + host) from a URL.
75
 
76
 
77
- #### `get_cache_key`
78
 
79
  ```python
80
  get_cache_key(self) -> str
@@ -83,7 +83,7 @@ get_cache_key(self) -> str
83
  Generate a safe filesystem key from the server's base URL.
84
 
85
 
86
- #### `clear`
87
 
88
  ```python
89
  clear(self) -> None
@@ -92,7 +92,7 @@ clear(self) -> None
92
  Clear all cached data for this server.
93
 
94
 
95
- #### `clear_all`
96
 
97
  ```python
98
  clear_all(cls, cache_dir: Path | None = None) -> None
 
7
 
8
  ## Functions
9
 
10
+ ### `default_cache_dir` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L38"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  default_cache_dir() -> Path
14
  ```
15
 
16
+ ### `OAuth` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L295"><Icon icon="github" size="14" /></a></sup>
17
 
18
  ```python
19
  OAuth(mcp_url: str, scopes: str | list[str] | None = None, client_name: str = 'FastMCP Client', token_storage_cache_dir: Path | None = None, additional_client_metadata: dict[str, Any] | None = None) -> _MCPOAuthClientProvider
 
38
 
39
  ## Classes
40
 
41
+ ### `ServerOAuthMetadata` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L43"><Icon icon="github" size="14" /></a></sup>
42
 
43
 
44
  More flexible OAuth metadata model that accepts broader ranges of values
 
48
  additional methods not in the MCP specification.
49
 
50
 
51
+ ### `OAuthClientProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L68"><Icon icon="github" size="14" /></a></sup>
52
 
53
 
54
  OAuth client provider with more flexible OAuth metadata discovery.
55
 
56
 
57
+ ### `FileTokenStorage` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L116"><Icon icon="github" size="14" /></a></sup>
58
 
59
 
60
  File-based token storage implementation for OAuth credentials and tokens.
 
65
 
66
  **Methods:**
67
 
68
+ #### `get_base_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L131"><Icon icon="github" size="14" /></a></sup>
69
 
70
  ```python
71
  get_base_url(url: str) -> str
 
74
  Extract the base URL (scheme + host) from a URL.
75
 
76
 
77
+ #### `get_cache_key` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L136"><Icon icon="github" size="14" /></a></sup>
78
 
79
  ```python
80
  get_cache_key(self) -> str
 
83
  Generate a safe filesystem key from the server's base URL.
84
 
85
 
86
+ #### `clear` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L208"><Icon icon="github" size="14" /></a></sup>
87
 
88
  ```python
89
  clear(self) -> None
 
92
  Clear all cached data for this server.
93
 
94
 
95
+ #### `clear_all` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/auth/oauth.py#L217"><Icon icon="github" size="14" /></a></sup>
96
 
97
  ```python
98
  clear_all(cls, cache_dir: Path | None = None) -> None
docs/python-sdk/fastmcp-client-client.mdx CHANGED
@@ -7,48 +7,48 @@ sidebarTitle: client
7
 
8
  ## Classes
9
 
10
- ### `Client`
11
-
12
-
13
-
14
- MCP client that delegates connection management to a Transport instance.
15
-
16
- The Client class is responsible for MCP protocol logic, while the Transport
17
- handles connection establishment and management. Client provides methods for
18
- working with resources, prompts, tools and other MCP capabilities.
19
-
20
- Args:
21
- transport: Connection source specification, which can be:
22
- - ClientTransport: Direct transport instance
23
- - FastMCP: In-process FastMCP server
24
- - AnyUrl | str: URL to connect to
25
- - Path: File path for local socket
26
- - MCPConfig: MCP server configuration
27
- - dict: Transport configuration
28
- roots: Optional RootsList or RootsHandler for filesystem access
29
- sampling_handler: Optional handler for sampling requests
30
- log_handler: Optional handler for log messages
31
- message_handler: Optional handler for protocol messages
32
- progress_handler: Optional handler for progress notifications
33
- timeout: Optional timeout for requests (seconds or timedelta)
34
- init_timeout: Optional timeout for initial connection (seconds or timedelta).
35
- Set to 0 to disable. If None, uses the value in the FastMCP global settings.
36
-
37
- Examples:
38
- ```python # Connect to FastMCP server client =
39
- Client("http://localhost:8080")
40
-
41
- async with client:
42
- # List available resources resources = await client.list_resources()
 
 
 
 
43
 
44
- # Call a tool result = await client.call_tool("my_tool", {"param":
45
- "value"})
46
- ```
47
-
48
 
49
  **Methods:**
50
 
51
- #### `session`
52
 
53
  ```python
54
  session(self) -> ClientSession
@@ -57,7 +57,7 @@ session(self) -> ClientSession
57
  Get the current active session. Raises RuntimeError if not connected.
58
 
59
 
60
- #### `initialize_result`
61
 
62
  ```python
63
  initialize_result(self) -> mcp.types.InitializeResult
@@ -66,7 +66,7 @@ initialize_result(self) -> mcp.types.InitializeResult
66
  Get the result of the initialization request.
67
 
68
 
69
- #### `set_roots`
70
 
71
  ```python
72
  set_roots(self, roots: RootsList | RootsHandler) -> None
@@ -75,7 +75,7 @@ set_roots(self, roots: RootsList | RootsHandler) -> None
75
  Set the roots for the client. This does not automatically call `send_roots_list_changed`.
76
 
77
 
78
- #### `set_sampling_callback`
79
 
80
  ```python
81
  set_sampling_callback(self, sampling_callback: SamplingHandler) -> None
@@ -84,7 +84,7 @@ set_sampling_callback(self, sampling_callback: SamplingHandler) -> None
84
  Set the sampling callback for the client.
85
 
86
 
87
- #### `is_connected`
88
 
89
  ```python
90
  is_connected(self) -> bool
 
7
 
8
  ## Classes
9
 
10
+ ### `Client` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L60"><Icon icon="github" size="14" /></a></sup>
11
+
12
+
13
+ MCP client that delegates connection management to a Transport instance.
14
+
15
+ The Client class is responsible for MCP protocol logic, while the Transport
16
+ handles connection establishment and management. Client provides methods for
17
+ working with resources, prompts, tools and other MCP capabilities.
18
+
19
+ **Args:**
20
+ - `transport`: Connection source specification, which can be\:
21
+ - ClientTransport\: Direct transport instance
22
+ - FastMCP\: In-process FastMCP server
23
+ - AnyUrl | str\: URL to connect to
24
+ - Path\: File path for local socket
25
+ - MCPConfig\: MCP server configuration
26
+ - dict\: Transport configuration
27
+ - `roots`: Optional RootsList or RootsHandler for filesystem access
28
+ - `sampling_handler`: Optional handler for sampling requests
29
+ - `log_handler`: Optional handler for log messages
30
+ - `message_handler`: Optional handler for protocol messages
31
+ - `progress_handler`: Optional handler for progress notifications
32
+ - `timeout`: Optional timeout for requests (seconds or timedelta)
33
+ - `init_timeout`: Optional timeout for initial connection (seconds or timedelta).
34
+ Set to 0 to disable. If None, uses the value in the FastMCP global settings.
35
+
36
+ **Examples:**
37
+
38
+ ```python # Connect to FastMCP server client =
39
+ Client("http://localhost:8080")
40
+
41
+ async with client:
42
+ # List available resources resources = await client.list_resources()
43
+
44
+ # Call a tool result = await client.call_tool("my_tool", {"param":
45
+ "value"})
46
+ ```
47
 
 
 
 
 
48
 
49
  **Methods:**
50
 
51
+ #### `session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L207"><Icon icon="github" size="14" /></a></sup>
52
 
53
  ```python
54
  session(self) -> ClientSession
 
57
  Get the current active session. Raises RuntimeError if not connected.
58
 
59
 
60
+ #### `initialize_result` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L217"><Icon icon="github" size="14" /></a></sup>
61
 
62
  ```python
63
  initialize_result(self) -> mcp.types.InitializeResult
 
66
  Get the result of the initialization request.
67
 
68
 
69
+ #### `set_roots` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L225"><Icon icon="github" size="14" /></a></sup>
70
 
71
  ```python
72
  set_roots(self, roots: RootsList | RootsHandler) -> None
 
75
  Set the roots for the client. This does not automatically call `send_roots_list_changed`.
76
 
77
 
78
+ #### `set_sampling_callback` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L229"><Icon icon="github" size="14" /></a></sup>
79
 
80
  ```python
81
  set_sampling_callback(self, sampling_callback: SamplingHandler) -> None
 
84
  Set the sampling callback for the client.
85
 
86
 
87
+ #### `is_connected` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L235"><Icon icon="github" size="14" /></a></sup>
88
 
89
  ```python
90
  is_connected(self) -> bool
docs/python-sdk/fastmcp-client-logging.mdx CHANGED
@@ -7,7 +7,7 @@ sidebarTitle: logging
7
 
8
  ## Functions
9
 
10
- ### `create_log_callback`
11
 
12
  ```python
13
  create_log_callback(handler: LogHandler | None = None) -> LoggingFnT
 
7
 
8
  ## Functions
9
 
10
+ ### `create_log_callback` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/logging.py#L20"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  create_log_callback(handler: LogHandler | None = None) -> LoggingFnT
docs/python-sdk/fastmcp-client-oauth_callback.mdx CHANGED
@@ -15,7 +15,7 @@ and display styled responses to users.
15
 
16
  ## Functions
17
 
18
- ### `create_callback_html`
19
 
20
  ```python
21
  create_callback_html(message: str, is_success: bool = True, title: str = 'FastMCP OAuth', server_url: str | None = None) -> str
@@ -25,7 +25,7 @@ create_callback_html(message: str, is_success: bool = True, title: str = 'FastMC
25
  Create a styled HTML response for OAuth callbacks.
26
 
27
 
28
- ### `create_oauth_callback_server`
29
 
30
  ```python
31
  create_oauth_callback_server(port: int, callback_path: str = '/callback', server_url: str | None = None, response_future: asyncio.Future | None = None) -> Server
@@ -46,17 +46,17 @@ Create an OAuth callback server.
46
 
47
  ## Classes
48
 
49
- ### `CallbackResponse`
50
 
51
  **Methods:**
52
 
53
- #### `from_dict`
54
 
55
  ```python
56
  from_dict(cls, data: dict[str, str]) -> CallbackResponse
57
  ```
58
 
59
- #### `to_dict`
60
 
61
  ```python
62
  to_dict(self) -> dict[str, str]
 
15
 
16
  ## Functions
17
 
18
+ ### `create_callback_html` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/oauth_callback.py#L25"><Icon icon="github" size="14" /></a></sup>
19
 
20
  ```python
21
  create_callback_html(message: str, is_success: bool = True, title: str = 'FastMCP OAuth', server_url: str | None = None) -> str
 
25
  Create a styled HTML response for OAuth callbacks.
26
 
27
 
28
+ ### `create_oauth_callback_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/oauth_callback.py#L197"><Icon icon="github" size="14" /></a></sup>
29
 
30
  ```python
31
  create_oauth_callback_server(port: int, callback_path: str = '/callback', server_url: str | None = None, response_future: asyncio.Future | None = None) -> Server
 
46
 
47
  ## Classes
48
 
49
+ ### `CallbackResponse` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/oauth_callback.py#L183"><Icon icon="github" size="14" /></a></sup>
50
 
51
  **Methods:**
52
 
53
+ #### `from_dict` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/oauth_callback.py#L190"><Icon icon="github" size="14" /></a></sup>
54
 
55
  ```python
56
  from_dict(cls, data: dict[str, str]) -> CallbackResponse
57
  ```
58
 
59
+ #### `to_dict` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/oauth_callback.py#L193"><Icon icon="github" size="14" /></a></sup>
60
 
61
  ```python
62
  to_dict(self) -> dict[str, str]
docs/python-sdk/fastmcp-client-roots.mdx CHANGED
@@ -7,13 +7,13 @@ sidebarTitle: roots
7
 
8
  ## Functions
9
 
10
- ### `convert_roots_list`
11
 
12
  ```python
13
  convert_roots_list(roots: RootsList) -> list[mcp.types.Root]
14
  ```
15
 
16
- ### `create_roots_callback`
17
 
18
  ```python
19
  create_roots_callback(handler: RootsList | RootsHandler) -> ListRootsFnT
 
7
 
8
  ## Functions
9
 
10
+ ### `convert_roots_list` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/roots.py#L19"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  convert_roots_list(roots: RootsList) -> list[mcp.types.Root]
14
  ```
15
 
16
+ ### `create_roots_callback` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/roots.py#L33"><Icon icon="github" size="14" /></a></sup>
17
 
18
  ```python
19
  create_roots_callback(handler: RootsList | RootsHandler) -> ListRootsFnT
docs/python-sdk/fastmcp-client-sampling.mdx CHANGED
@@ -7,7 +7,7 @@ sidebarTitle: sampling
7
 
8
  ## Functions
9
 
10
- ### `create_sampling_callback`
11
 
12
  ```python
13
  create_sampling_callback(sampling_handler: SamplingHandler) -> SamplingFnT
 
7
 
8
  ## Functions
9
 
10
+ ### `create_sampling_callback` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/sampling.py#L25"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  create_sampling_callback(sampling_handler: SamplingHandler) -> SamplingFnT
docs/python-sdk/fastmcp-client-transports.mdx CHANGED
@@ -7,63 +7,63 @@ sidebarTitle: transports
7
 
8
  ## Functions
9
 
10
- ### `infer_transport`
11
 
12
  ```python
13
  infer_transport(transport: ClientTransport | FastMCP | FastMCP1Server | AnyUrl | Path | MCPConfig | dict[str, Any] | str) -> ClientTransport
14
  ```
15
 
16
 
 
17
 
18
- Infer the appropriate transport type from the given transport argument.
 
 
19
 
20
- This function attempts to infer the correct transport type from the provided
21
- argument, handling various input types and converting them to the appropriate
22
- ClientTransport subclass.
 
 
 
23
 
24
- The function supports these input types:
25
- - ClientTransport: Used directly without modification
26
- - FastMCP or FastMCP1Server: Creates an in-memory FastMCPTransport
27
- - Path or str (file path): Creates PythonStdioTransport (.py) or NodeStdioTransport (.js)
28
- - AnyUrl or str (URL): Creates StreamableHttpTransport (default) or SSETransport (for /sse endpoints)
29
- - MCPConfig or dict: Creates MCPConfigTransport, potentially connecting to multiple servers
30
 
31
- For HTTP URLs, they are assumed to be Streamable HTTP URLs unless they end in `/sse`.
 
 
 
 
32
 
33
- For MCPConfig with multiple servers, a composite client is created where each server
34
- is mounted with its name as prefix. This allows accessing tools and resources from multiple
35
- servers through a single unified client interface, using naming patterns like
36
- `servername_toolname` for tools and `protocol://servername/path` for resources.
37
- If the MCPConfig contains only one server, a direct connection is established without prefixing.
38
 
39
- Examples:
40
- ```python
41
- # Connect to a local Python script
42
- transport = infer_transport("my_script.py")
43
-
44
- # Connect to a remote server via HTTP
45
- transport = infer_transport("http://example.com/mcp")
 
 
 
 
 
 
 
 
 
46
 
47
- # Connect to multiple servers using MCPConfig
48
- config = {
49
- "mcpServers": {
50
- "weather": {"url": "http://weather.example.com/mcp"},
51
- "calendar": {"url": "http://calendar.example.com/mcp"}
52
- }
53
- }
54
- transport = infer_transport(config)
55
- ```
56
-
57
 
58
  ## Classes
59
 
60
- ### `SessionKwargs`
61
 
62
 
63
  Keyword arguments for the MCP ClientSession constructor.
64
 
65
 
66
- ### `ClientTransport`
67
 
68
 
69
  Abstract base class for different MCP client transport mechanisms.
@@ -72,25 +72,25 @@ A Transport is responsible for establishing and managing connections
72
  to an MCP server, and providing a ClientSession within an async context.
73
 
74
 
75
- ### `WSTransport`
76
 
77
 
78
  Transport implementation that connects to an MCP server via WebSockets.
79
 
80
 
81
- ### `SSETransport`
82
 
83
 
84
  Transport implementation that connects to an MCP server via Server-Sent Events.
85
 
86
 
87
- ### `StreamableHttpTransport`
88
 
89
 
90
  Transport implementation that connects to an MCP server via Streamable HTTP Requests.
91
 
92
 
93
- ### `StdioTransport`
94
 
95
 
96
  Base transport for connecting to an MCP server via subprocess with stdio.
@@ -99,37 +99,37 @@ This is a base class that can be subclassed for specific command-based
99
  transports like Python, Node, Uvx, etc.
100
 
101
 
102
- ### `PythonStdioTransport`
103
 
104
 
105
  Transport for running Python scripts.
106
 
107
 
108
- ### `FastMCPStdioTransport`
109
 
110
 
111
  Transport for running FastMCP servers using the FastMCP CLI.
112
 
113
 
114
- ### `NodeStdioTransport`
115
 
116
 
117
  Transport for running Node.js scripts.
118
 
119
 
120
- ### `UvxStdioTransport`
121
 
122
 
123
  Transport for running commands via the uvx tool.
124
 
125
 
126
- ### `NpxStdioTransport`
127
 
128
 
129
  Transport for running commands via the npx tool.
130
 
131
 
132
- ### `FastMCPTransport`
133
 
134
 
135
  In-memory transport for FastMCP servers.
@@ -140,52 +140,53 @@ servers from the low-level MCP SDK. This is particularly useful for unit
140
  tests or scenarios where client and server run in the same runtime.
141
 
142
 
143
- ### `MCPConfigTransport`
144
 
145
 
146
  Transport for connecting to one or more MCP servers defined in an MCPConfig.
147
 
148
- This transport provides a unified interface to multiple MCP servers defined in an MCPConfig
149
- object or dictionary matching the MCPConfig schema. It supports two key scenarios:
150
-
151
- 1. If the MCPConfig contains exactly one server, it creates a direct transport to that server.
152
- 2. If the MCPConfig contains multiple servers, it creates a composite client by mounting
153
- all servers on a single FastMCP instance, with each server's name used as its mounting prefix.
154
-
155
- In the multi-server case, tools are accessible with the prefix pattern `{server_name}_{tool_name}`
156
- and resources with the pattern `protocol://{server_name}/path/to/resource`.
157
-
158
- This is particularly useful for creating clients that need to interact with multiple specialized
159
- MCP servers through a single interface, simplifying client code.
160
-
161
- Examples:
162
- ```python
163
- from fastmcp import Client
164
- from fastmcp.utilities.mcp_config import MCPConfig
165
-
166
- # Create a config with multiple servers
167
- config = {
168
- "mcpServers": {
169
- "weather": {
170
- "url": "https://weather-api.example.com/mcp",
171
- "transport": "streamable-http"
172
- },
173
- "calendar": {
174
- "url": "https://calendar-api.example.com/mcp",
175
- "transport": "streamable-http"
176
- }
177
- }
178
  }
 
 
 
 
 
179
 
180
- # Create a client with the config
181
- client = Client(config)
 
 
182
 
183
- async with client:
184
- # Access tools with prefixes
185
- weather = await client.call_tool("weather_get_forecast", {"city": "London"})
186
- events = await client.call_tool("calendar_list_events", {"date": "2023-06-01"})
187
 
188
- # Access resources with prefixed URIs
189
- icons = await client.read_resource("weather://weather/icons/sunny")
190
- ```
191
-
 
7
 
8
  ## Functions
9
 
10
+ ### `infer_transport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L837"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  infer_transport(transport: ClientTransport | FastMCP | FastMCP1Server | AnyUrl | Path | MCPConfig | dict[str, Any] | str) -> ClientTransport
14
  ```
15
 
16
 
17
+ Infer the appropriate transport type from the given transport argument.
18
 
19
+ This function attempts to infer the correct transport type from the provided
20
+ argument, handling various input types and converting them to the appropriate
21
+ ClientTransport subclass.
22
 
23
+ The function supports these input types:
24
+ - ClientTransport: Used directly without modification
25
+ - FastMCP or FastMCP1Server: Creates an in-memory FastMCPTransport
26
+ - Path or str (file path): Creates PythonStdioTransport (.py) or NodeStdioTransport (.js)
27
+ - AnyUrl or str (URL): Creates StreamableHttpTransport (default) or SSETransport (for /sse endpoints)
28
+ - MCPConfig or dict: Creates MCPConfigTransport, potentially connecting to multiple servers
29
 
30
+ For HTTP URLs, they are assumed to be Streamable HTTP URLs unless they end in `/sse`.
 
 
 
 
 
31
 
32
+ For MCPConfig with multiple servers, a composite client is created where each server
33
+ is mounted with its name as prefix. This allows accessing tools and resources from multiple
34
+ servers through a single unified client interface, using naming patterns like
35
+ `servername_toolname` for tools and `protocol://servername/path` for resources.
36
+ If the MCPConfig contains only one server, a direct connection is established without prefixing.
37
 
38
+ **Examples:**
 
 
 
 
39
 
40
+ ```python
41
+ # Connect to a local Python script
42
+ transport = infer_transport("my_script.py")
43
+
44
+ # Connect to a remote server via HTTP
45
+ transport = infer_transport("http://example.com/mcp")
46
+
47
+ # Connect to multiple servers using MCPConfig
48
+ config = {
49
+ "mcpServers": {
50
+ "weather": {"url": "http://weather.example.com/mcp"},
51
+ "calendar": {"url": "http://calendar.example.com/mcp"}
52
+ }
53
+ }
54
+ transport = infer_transport(config)
55
+ ```
56
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  ## Classes
59
 
60
+ ### `SessionKwargs` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L52"><Icon icon="github" size="14" /></a></sup>
61
 
62
 
63
  Keyword arguments for the MCP ClientSession constructor.
64
 
65
 
66
+ ### `ClientTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L63"><Icon icon="github" size="14" /></a></sup>
67
 
68
 
69
  Abstract base class for different MCP client transport mechanisms.
 
72
  to an MCP server, and providing a ClientSession within an async context.
73
 
74
 
75
+ ### `WSTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L109"><Icon icon="github" size="14" /></a></sup>
76
 
77
 
78
  Transport implementation that connects to an MCP server via WebSockets.
79
 
80
 
81
+ ### `SSETransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L148"><Icon icon="github" size="14" /></a></sup>
82
 
83
 
84
  Transport implementation that connects to an MCP server via Server-Sent Events.
85
 
86
 
87
+ ### `StreamableHttpTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L223"><Icon icon="github" size="14" /></a></sup>
88
 
89
 
90
  Transport implementation that connects to an MCP server via Streamable HTTP Requests.
91
 
92
 
93
+ ### `StdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L299"><Icon icon="github" size="14" /></a></sup>
94
 
95
 
96
  Base transport for connecting to an MCP server via subprocess with stdio.
 
99
  transports like Python, Node, Uvx, etc.
100
 
101
 
102
+ ### `PythonStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L416"><Icon icon="github" size="14" /></a></sup>
103
 
104
 
105
  Transport for running Python scripts.
106
 
107
 
108
+ ### `FastMCPStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L462"><Icon icon="github" size="14" /></a></sup>
109
 
110
 
111
  Transport for running FastMCP servers using the FastMCP CLI.
112
 
113
 
114
+ ### `NodeStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L489"><Icon icon="github" size="14" /></a></sup>
115
 
116
 
117
  Transport for running Node.js scripts.
118
 
119
 
120
+ ### `UvxStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L531"><Icon icon="github" size="14" /></a></sup>
121
 
122
 
123
  Transport for running commands via the uvx tool.
124
 
125
 
126
+ ### `NpxStdioTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L597"><Icon icon="github" size="14" /></a></sup>
127
 
128
 
129
  Transport for running commands via the npx tool.
130
 
131
 
132
+ ### `FastMCPTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L659"><Icon icon="github" size="14" /></a></sup>
133
 
134
 
135
  In-memory transport for FastMCP servers.
 
140
  tests or scenarios where client and server run in the same runtime.
141
 
142
 
143
+ ### `MCPConfigTransport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/transports.py#L713"><Icon icon="github" size="14" /></a></sup>
144
 
145
 
146
  Transport for connecting to one or more MCP servers defined in an MCPConfig.
147
 
148
+ This transport provides a unified interface to multiple MCP servers defined in an MCPConfig
149
+ object or dictionary matching the MCPConfig schema. It supports two key scenarios:
150
+
151
+ 1. If the MCPConfig contains exactly one server, it creates a direct transport to that server.
152
+ 2. If the MCPConfig contains multiple servers, it creates a composite client by mounting
153
+ all servers on a single FastMCP instance, with each server's name used as its mounting prefix.
154
+
155
+ In the multi-server case, tools are accessible with the prefix pattern `{server_name}_{tool_name}`
156
+ and resources with the pattern `protocol://{server_name}/path/to/resource`.
157
+
158
+ This is particularly useful for creating clients that need to interact with multiple specialized
159
+ MCP servers through a single interface, simplifying client code.
160
+
161
+ **Examples:**
162
+
163
+ ```python
164
+ from fastmcp import Client
165
+ from fastmcp.utilities.mcp_config import MCPConfig
166
+
167
+ # Create a config with multiple servers
168
+ config = {
169
+ "mcpServers": {
170
+ "weather": {
171
+ "url": "https://weather-api.example.com/mcp",
172
+ "transport": "http"
173
+ },
174
+ "calendar": {
175
+ "url": "https://calendar-api.example.com/mcp",
176
+ "transport": "http"
 
177
  }
178
+ }
179
+ }
180
+
181
+ # Create a client with the config
182
+ client = Client(config)
183
 
184
+ async with client:
185
+ # Access tools with prefixes
186
+ weather = await client.call_tool("weather_get_forecast", {"city": "London"})
187
+ events = await client.call_tool("calendar_list_events", {"date": "2023-06-01"})
188
 
189
+ # Access resources with prefixed URIs
190
+ icons = await client.read_resource("weather://weather/icons/sunny")
191
+ ```
 
192
 
 
 
 
 
docs/python-sdk/fastmcp-exceptions.mdx CHANGED
@@ -10,55 +10,55 @@ Custom exceptions for FastMCP.
10
 
11
  ## Classes
12
 
13
- ### `FastMCPError`
14
 
15
 
16
  Base error for FastMCP.
17
 
18
 
19
- ### `ValidationError`
20
 
21
 
22
  Error in validating parameters or return values.
23
 
24
 
25
- ### `ResourceError`
26
 
27
 
28
  Error in resource operations.
29
 
30
 
31
- ### `ToolError`
32
 
33
 
34
  Error in tool operations.
35
 
36
 
37
- ### `PromptError`
38
 
39
 
40
  Error in prompt operations.
41
 
42
 
43
- ### `InvalidSignature`
44
 
45
 
46
  Invalid signature for use with FastMCP.
47
 
48
 
49
- ### `ClientError`
50
 
51
 
52
  Error in client operations.
53
 
54
 
55
- ### `NotFoundError`
56
 
57
 
58
  Object not found.
59
 
60
 
61
- ### `DisabledError`
62
 
63
 
64
  Object is disabled.
 
10
 
11
  ## Classes
12
 
13
+ ### `FastMCPError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L6"><Icon icon="github" size="14" /></a></sup>
14
 
15
 
16
  Base error for FastMCP.
17
 
18
 
19
+ ### `ValidationError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L10"><Icon icon="github" size="14" /></a></sup>
20
 
21
 
22
  Error in validating parameters or return values.
23
 
24
 
25
+ ### `ResourceError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L14"><Icon icon="github" size="14" /></a></sup>
26
 
27
 
28
  Error in resource operations.
29
 
30
 
31
+ ### `ToolError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L18"><Icon icon="github" size="14" /></a></sup>
32
 
33
 
34
  Error in tool operations.
35
 
36
 
37
+ ### `PromptError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L22"><Icon icon="github" size="14" /></a></sup>
38
 
39
 
40
  Error in prompt operations.
41
 
42
 
43
+ ### `InvalidSignature` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L26"><Icon icon="github" size="14" /></a></sup>
44
 
45
 
46
  Invalid signature for use with FastMCP.
47
 
48
 
49
+ ### `ClientError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L30"><Icon icon="github" size="14" /></a></sup>
50
 
51
 
52
  Error in client operations.
53
 
54
 
55
+ ### `NotFoundError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L34"><Icon icon="github" size="14" /></a></sup>
56
 
57
 
58
  Object not found.
59
 
60
 
61
+ ### `DisabledError` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/exceptions.py#L38"><Icon icon="github" size="14" /></a></sup>
62
 
63
 
64
  Object is disabled.
docs/python-sdk/fastmcp-prompts-prompt.mdx CHANGED
@@ -10,7 +10,7 @@ Base classes for FastMCP prompts.
10
 
11
  ## Functions
12
 
13
- ### `Message`
14
 
15
  ```python
16
  Message(content: str | MCPContent, role: Role | None = None, **kwargs: Any) -> PromptMessage
@@ -22,13 +22,13 @@ A user-friendly constructor for PromptMessage.
22
 
23
  ## Classes
24
 
25
- ### `PromptArgument`
26
 
27
 
28
  An argument that can be passed to a prompt.
29
 
30
 
31
- ### `Prompt`
32
 
33
 
34
  A prompt template that can be rendered with parameters.
@@ -36,7 +36,7 @@ A prompt template that can be rendered with parameters.
36
 
37
  **Methods:**
38
 
39
- #### `to_mcp_prompt`
40
 
41
  ```python
42
  to_mcp_prompt(self, **overrides: Any) -> MCPPrompt
@@ -45,7 +45,7 @@ to_mcp_prompt(self, **overrides: Any) -> MCPPrompt
45
  Convert the prompt to an MCP prompt.
46
 
47
 
48
- #### `from_function`
49
 
50
  ```python
51
  from_function(fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionPrompt
@@ -60,7 +60,7 @@ The function can return:
60
  - A sequence of any of the above
61
 
62
 
63
- ### `FunctionPrompt`
64
 
65
 
66
  A prompt that is a function.
@@ -68,7 +68,7 @@ A prompt that is a function.
68
 
69
  **Methods:**
70
 
71
- #### `from_function`
72
 
73
  ```python
74
  from_function(cls, fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionPrompt
 
10
 
11
  ## Functions
12
 
13
+ ### `Message` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L32"><Icon icon="github" size="14" /></a></sup>
14
 
15
  ```python
16
  Message(content: str | MCPContent, role: Role | None = None, **kwargs: Any) -> PromptMessage
 
22
 
23
  ## Classes
24
 
25
+ ### `PromptArgument` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L54"><Icon icon="github" size="14" /></a></sup>
26
 
27
 
28
  An argument that can be passed to a prompt.
29
 
30
 
31
+ ### `Prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L66"><Icon icon="github" size="14" /></a></sup>
32
 
33
 
34
  A prompt template that can be rendered with parameters.
 
36
 
37
  **Methods:**
38
 
39
+ #### `to_mcp_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L73"><Icon icon="github" size="14" /></a></sup>
40
 
41
  ```python
42
  to_mcp_prompt(self, **overrides: Any) -> MCPPrompt
 
45
  Convert the prompt to an MCP prompt.
46
 
47
 
48
+ #### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L91"><Icon icon="github" size="14" /></a></sup>
49
 
50
  ```python
51
  from_function(fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionPrompt
 
60
  - A sequence of any of the above
61
 
62
 
63
+ ### `FunctionPrompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L119"><Icon icon="github" size="14" /></a></sup>
64
 
65
 
66
  A prompt that is a function.
 
68
 
69
  **Methods:**
70
 
71
+ #### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L125"><Icon icon="github" size="14" /></a></sup>
72
 
73
  ```python
74
  from_function(cls, fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionPrompt
docs/python-sdk/fastmcp-prompts-prompt_manager.mdx CHANGED
@@ -7,7 +7,7 @@ sidebarTitle: prompt_manager
7
 
8
  ## Classes
9
 
10
- ### `PromptManager`
11
 
12
 
13
  Manages FastMCP prompts.
@@ -15,7 +15,7 @@ Manages FastMCP prompts.
15
 
16
  **Methods:**
17
 
18
- #### `mount`
19
 
20
  ```python
21
  mount(self, server: MountedServer) -> None
@@ -24,7 +24,7 @@ mount(self, server: MountedServer) -> None
24
  Adds a mounted server as a source for prompts.
25
 
26
 
27
- #### `add_prompt_from_fn`
28
 
29
  ```python
30
  add_prompt_from_fn(self, fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None) -> FunctionPrompt
@@ -33,7 +33,7 @@ add_prompt_from_fn(self, fn: Callable[..., PromptResult | Awaitable[PromptResult
33
  Create a prompt from a function.
34
 
35
 
36
- #### `add_prompt`
37
 
38
  ```python
39
  add_prompt(self, prompt: Prompt) -> Prompt
 
7
 
8
  ## Classes
9
 
10
+ ### `PromptManager` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt_manager.py#L21"><Icon icon="github" size="14" /></a></sup>
11
 
12
 
13
  Manages FastMCP prompts.
 
15
 
16
  **Methods:**
17
 
18
+ #### `mount` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt_manager.py#L45"><Icon icon="github" size="14" /></a></sup>
19
 
20
  ```python
21
  mount(self, server: MountedServer) -> None
 
24
  Adds a mounted server as a source for prompts.
25
 
26
 
27
+ #### `add_prompt_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt_manager.py#L114"><Icon icon="github" size="14" /></a></sup>
28
 
29
  ```python
30
  add_prompt_from_fn(self, fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None) -> FunctionPrompt
 
33
  Create a prompt from a function.
34
 
35
 
36
+ #### `add_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt_manager.py#L134"><Icon icon="github" size="14" /></a></sup>
37
 
38
  ```python
39
  add_prompt(self, prompt: Prompt) -> Prompt
docs/python-sdk/fastmcp-resources-resource.mdx CHANGED
@@ -10,7 +10,7 @@ Base classes and interfaces for FastMCP resources.
10
 
11
  ## Classes
12
 
13
- ### `Resource`
14
 
15
 
16
  Base class for all resources.
@@ -18,13 +18,13 @@ Base class for all resources.
18
 
19
  **Methods:**
20
 
21
- #### `from_function`
22
 
23
  ```python
24
  from_function(fn: Callable[[], Any], uri: str | AnyUrl, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResource
25
  ```
26
 
27
- #### `set_default_mime_type`
28
 
29
  ```python
30
  set_default_mime_type(cls, mime_type: str | None) -> str
@@ -33,7 +33,7 @@ set_default_mime_type(cls, mime_type: str | None) -> str
33
  Set default MIME type if not provided.
34
 
35
 
36
- #### `set_default_name`
37
 
38
  ```python
39
  set_default_name(self) -> Self
@@ -42,7 +42,7 @@ set_default_name(self) -> Self
42
  Set default name from URI if not provided.
43
 
44
 
45
- #### `to_mcp_resource`
46
 
47
  ```python
48
  to_mcp_resource(self, **overrides: Any) -> MCPResource
@@ -51,7 +51,7 @@ to_mcp_resource(self, **overrides: Any) -> MCPResource
51
  Convert the resource to an MCPResource.
52
 
53
 
54
- #### `key`
55
 
56
  ```python
57
  key(self) -> str
@@ -63,7 +63,7 @@ keys having a certain value, as the same tool loaded from different
63
  hierarchies of servers may have different keys.
64
 
65
 
66
- ### `FunctionResource`
67
 
68
 
69
  A resource that defers data loading by wrapping a function.
@@ -80,7 +80,7 @@ The function can return:
80
 
81
  **Methods:**
82
 
83
- #### `from_function`
84
 
85
  ```python
86
  from_function(cls, fn: Callable[[], Any], uri: str | AnyUrl, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResource
 
10
 
11
  ## Classes
12
 
13
+ ### `Resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L32"><Icon icon="github" size="14" /></a></sup>
14
 
15
 
16
  Base class for all resources.
 
18
 
19
  **Methods:**
20
 
21
+ #### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L48"><Icon icon="github" size="14" /></a></sup>
22
 
23
  ```python
24
  from_function(fn: Callable[[], Any], uri: str | AnyUrl, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResource
25
  ```
26
 
27
+ #### `set_default_mime_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L69"><Icon icon="github" size="14" /></a></sup>
28
 
29
  ```python
30
  set_default_mime_type(cls, mime_type: str | None) -> str
 
33
  Set default MIME type if not provided.
34
 
35
 
36
+ #### `set_default_name` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L76"><Icon icon="github" size="14" /></a></sup>
37
 
38
  ```python
39
  set_default_name(self) -> Self
 
42
  Set default name from URI if not provided.
43
 
44
 
45
+ #### `to_mcp_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L91"><Icon icon="github" size="14" /></a></sup>
46
 
47
  ```python
48
  to_mcp_resource(self, **overrides: Any) -> MCPResource
 
51
  Convert the resource to an MCPResource.
52
 
53
 
54
+ #### `key` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L105"><Icon icon="github" size="14" /></a></sup>
55
 
56
  ```python
57
  key(self) -> str
 
63
  hierarchies of servers may have different keys.
64
 
65
 
66
+ ### `FunctionResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L115"><Icon icon="github" size="14" /></a></sup>
67
 
68
 
69
  A resource that defers data loading by wrapping a function.
 
80
 
81
  **Methods:**
82
 
83
+ #### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource.py#L131"><Icon icon="github" size="14" /></a></sup>
84
 
85
  ```python
86
  from_function(cls, fn: Callable[[], Any], uri: str | AnyUrl, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResource
docs/python-sdk/fastmcp-resources-resource_manager.mdx CHANGED
@@ -10,7 +10,7 @@ Resource manager functionality.
10
 
11
  ## Classes
12
 
13
- ### `ResourceManager`
14
 
15
 
16
  Manages FastMCP resources.
@@ -18,7 +18,7 @@ Manages FastMCP resources.
18
 
19
  **Methods:**
20
 
21
- #### `mount`
22
 
23
  ```python
24
  mount(self, server: MountedServer) -> None
@@ -27,7 +27,7 @@ mount(self, server: MountedServer) -> None
27
  Adds a mounted server as a source for resources and templates.
28
 
29
 
30
- #### `add_resource_or_template_from_fn`
31
 
32
  ```python
33
  add_resource_or_template_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource | ResourceTemplate
@@ -48,7 +48,7 @@ Add a resource or template to the manager from a function.
48
  - returns the existing resource or template.
49
 
50
 
51
- #### `add_resource_from_fn`
52
 
53
  ```python
54
  add_resource_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource
@@ -69,7 +69,7 @@ Add a resource to the manager from a function.
69
  - returns the existing resource.
70
 
71
 
72
- #### `add_resource`
73
 
74
  ```python
75
  add_resource(self, resource: Resource) -> Resource
@@ -83,7 +83,7 @@ will be used as the storage key. To overwrite it, call
83
  Resource.with_key() before calling this method.
84
 
85
 
86
- #### `add_template_from_fn`
87
 
88
  ```python
89
  add_template_from_fn(self, fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> ResourceTemplate
@@ -92,7 +92,7 @@ add_template_from_fn(self, fn: Callable[..., Any], uri_template: str, name: str
92
  Create a template from a function.
93
 
94
 
95
- #### `add_template`
96
 
97
  ```python
98
  add_template(self, template: ResourceTemplate) -> ResourceTemplate
 
10
 
11
  ## Classes
12
 
13
+ ### `ResourceManager` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L28"><Icon icon="github" size="14" /></a></sup>
14
 
15
 
16
  Manages FastMCP resources.
 
18
 
19
  **Methods:**
20
 
21
+ #### `mount` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L60"><Icon icon="github" size="14" /></a></sup>
22
 
23
  ```python
24
  mount(self, server: MountedServer) -> None
 
27
  Adds a mounted server as a source for resources and templates.
28
 
29
 
30
+ #### `add_resource_or_template_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L182"><Icon icon="github" size="14" /></a></sup>
31
 
32
  ```python
33
  add_resource_or_template_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource | ResourceTemplate
 
48
  - returns the existing resource or template.
49
 
50
 
51
+ #### `add_resource_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L230"><Icon icon="github" size="14" /></a></sup>
52
 
53
  ```python
54
  add_resource_from_fn(self, fn: Callable[..., Any], uri: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> Resource
 
69
  - returns the existing resource.
70
 
71
 
72
+ #### `add_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L270"><Icon icon="github" size="14" /></a></sup>
73
 
74
  ```python
75
  add_resource(self, resource: Resource) -> Resource
 
83
  Resource.with_key() before calling this method.
84
 
85
 
86
+ #### `add_template_from_fn` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L292"><Icon icon="github" size="14" /></a></sup>
87
 
88
  ```python
89
  add_template_from_fn(self, fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None) -> ResourceTemplate
 
92
  Create a template from a function.
93
 
94
 
95
+ #### `add_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/resource_manager.py#L319"><Icon icon="github" size="14" /></a></sup>
96
 
97
  ```python
98
  add_template(self, template: ResourceTemplate) -> ResourceTemplate
docs/python-sdk/fastmcp-resources-template.mdx CHANGED
@@ -10,13 +10,13 @@ Resource template functionality.
10
 
11
  ## Functions
12
 
13
- ### `build_regex`
14
 
15
  ```python
16
  build_regex(template: str) -> re.Pattern
17
  ```
18
 
19
- ### `match_uri_template`
20
 
21
  ```python
22
  match_uri_template(uri: str, uri_template: str) -> dict[str, str] | None
@@ -24,7 +24,7 @@ match_uri_template(uri: str, uri_template: str) -> dict[str, str] | None
24
 
25
  ## Classes
26
 
27
- ### `ResourceTemplate`
28
 
29
 
30
  A template for dynamically creating resources.
@@ -32,13 +32,13 @@ A template for dynamically creating resources.
32
 
33
  **Methods:**
34
 
35
- #### `from_function`
36
 
37
  ```python
38
  from_function(fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResourceTemplate
39
  ```
40
 
41
- #### `set_default_mime_type`
42
 
43
  ```python
44
  set_default_mime_type(cls, mime_type: str | None) -> str
@@ -47,7 +47,7 @@ set_default_mime_type(cls, mime_type: str | None) -> str
47
  Set default MIME type if not provided.
48
 
49
 
50
- #### `matches`
51
 
52
  ```python
53
  matches(self, uri: str) -> dict[str, Any] | None
@@ -56,7 +56,7 @@ matches(self, uri: str) -> dict[str, Any] | None
56
  Check if URI matches template and extract parameters.
57
 
58
 
59
- #### `to_mcp_template`
60
 
61
  ```python
62
  to_mcp_template(self, **overrides: Any) -> MCPResourceTemplate
@@ -65,7 +65,7 @@ to_mcp_template(self, **overrides: Any) -> MCPResourceTemplate
65
  Convert the resource template to an MCPResourceTemplate.
66
 
67
 
68
- #### `from_mcp_template`
69
 
70
  ```python
71
  from_mcp_template(cls, mcp_template: MCPResourceTemplate) -> ResourceTemplate
@@ -74,7 +74,7 @@ from_mcp_template(cls, mcp_template: MCPResourceTemplate) -> ResourceTemplate
74
  Creates a FastMCP ResourceTemplate from a raw MCP ResourceTemplate object.
75
 
76
 
77
- #### `key`
78
 
79
  ```python
80
  key(self) -> str
@@ -86,7 +86,7 @@ keys having a certain value, as the same tool loaded from different
86
  hierarchies of servers may have different keys.
87
 
88
 
89
- ### `FunctionResourceTemplate`
90
 
91
 
92
  A template for dynamically creating resources.
@@ -94,7 +94,7 @@ A template for dynamically creating resources.
94
 
95
  **Methods:**
96
 
97
- #### `from_function`
98
 
99
  ```python
100
  from_function(cls, fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResourceTemplate
 
10
 
11
  ## Functions
12
 
13
+ ### `build_regex` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L28"><Icon icon="github" size="14" /></a></sup>
14
 
15
  ```python
16
  build_regex(template: str) -> re.Pattern
17
  ```
18
 
19
+ ### `match_uri_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L44"><Icon icon="github" size="14" /></a></sup>
20
 
21
  ```python
22
  match_uri_template(uri: str, uri_template: str) -> dict[str, str] | None
 
24
 
25
  ## Classes
26
 
27
+ ### `ResourceTemplate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L52"><Icon icon="github" size="14" /></a></sup>
28
 
29
 
30
  A template for dynamically creating resources.
 
32
 
33
  **Methods:**
34
 
35
+ #### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L69"><Icon icon="github" size="14" /></a></sup>
36
 
37
  ```python
38
  from_function(fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResourceTemplate
39
  ```
40
 
41
+ #### `set_default_mime_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L90"><Icon icon="github" size="14" /></a></sup>
42
 
43
  ```python
44
  set_default_mime_type(cls, mime_type: str | None) -> str
 
47
  Set default MIME type if not provided.
48
 
49
 
50
+ #### `matches` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L96"><Icon icon="github" size="14" /></a></sup>
51
 
52
  ```python
53
  matches(self, uri: str) -> dict[str, Any] | None
 
56
  Check if URI matches template and extract parameters.
57
 
58
 
59
+ #### `to_mcp_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L124"><Icon icon="github" size="14" /></a></sup>
60
 
61
  ```python
62
  to_mcp_template(self, **overrides: Any) -> MCPResourceTemplate
 
65
  Convert the resource template to an MCPResourceTemplate.
66
 
67
 
68
+ #### `from_mcp_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L135"><Icon icon="github" size="14" /></a></sup>
69
 
70
  ```python
71
  from_mcp_template(cls, mcp_template: MCPResourceTemplate) -> ResourceTemplate
 
74
  Creates a FastMCP ResourceTemplate from a raw MCP ResourceTemplate object.
75
 
76
 
77
+ #### `key` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L148"><Icon icon="github" size="14" /></a></sup>
78
 
79
  ```python
80
  key(self) -> str
 
86
  hierarchies of servers may have different keys.
87
 
88
 
89
+ ### `FunctionResourceTemplate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L158"><Icon icon="github" size="14" /></a></sup>
90
 
91
 
92
  A template for dynamically creating resources.
 
94
 
95
  **Methods:**
96
 
97
+ #### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/template.py#L179"><Icon icon="github" size="14" /></a></sup>
98
 
99
  ```python
100
  from_function(cls, fn: Callable[..., Any], uri_template: str, name: str | None = None, description: str | None = None, mime_type: str | None = None, tags: set[str] | None = None, enabled: bool | None = None) -> FunctionResourceTemplate
docs/python-sdk/fastmcp-resources-types.mdx CHANGED
@@ -10,19 +10,19 @@ Concrete resource implementations.
10
 
11
  ## Classes
12
 
13
- ### `TextResource`
14
 
15
 
16
  A resource that reads from a string.
17
 
18
 
19
- ### `BinaryResource`
20
 
21
 
22
  A resource that reads from bytes.
23
 
24
 
25
- ### `FileResource`
26
 
27
 
28
  A resource that reads from a file.
@@ -32,7 +32,7 @@ Set is_binary=True to read file as binary data instead of text.
32
 
33
  **Methods:**
34
 
35
- #### `validate_absolute_path`
36
 
37
  ```python
38
  validate_absolute_path(cls, path: Path) -> Path
@@ -41,7 +41,7 @@ validate_absolute_path(cls, path: Path) -> Path
41
  Ensure path is absolute.
42
 
43
 
44
- #### `set_binary_from_mime_type`
45
 
46
  ```python
47
  set_binary_from_mime_type(cls, is_binary: bool, info: ValidationInfo) -> bool
@@ -50,13 +50,13 @@ set_binary_from_mime_type(cls, is_binary: bool, info: ValidationInfo) -> bool
50
  Set is_binary based on mime_type if not explicitly set.
51
 
52
 
53
- ### `HttpResource`
54
 
55
 
56
  A resource that reads from an HTTP endpoint.
57
 
58
 
59
- ### `DirectoryResource`
60
 
61
 
62
  A resource that lists files in a directory.
@@ -64,7 +64,7 @@ A resource that lists files in a directory.
64
 
65
  **Methods:**
66
 
67
- #### `validate_absolute_path`
68
 
69
  ```python
70
  validate_absolute_path(cls, path: Path) -> Path
@@ -73,7 +73,7 @@ validate_absolute_path(cls, path: Path) -> Path
73
  Ensure path is absolute.
74
 
75
 
76
- #### `list_files`
77
 
78
  ```python
79
  list_files(self) -> list[Path]
 
10
 
11
  ## Classes
12
 
13
+ ### `TextResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L21"><Icon icon="github" size="14" /></a></sup>
14
 
15
 
16
  A resource that reads from a string.
17
 
18
 
19
+ ### `BinaryResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L31"><Icon icon="github" size="14" /></a></sup>
20
 
21
 
22
  A resource that reads from bytes.
23
 
24
 
25
+ ### `FileResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L41"><Icon icon="github" size="14" /></a></sup>
26
 
27
 
28
  A resource that reads from a file.
 
32
 
33
  **Methods:**
34
 
35
+ #### `validate_absolute_path` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L59"><Icon icon="github" size="14" /></a></sup>
36
 
37
  ```python
38
  validate_absolute_path(cls, path: Path) -> Path
 
41
  Ensure path is absolute.
42
 
43
 
44
+ #### `set_binary_from_mime_type` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L67"><Icon icon="github" size="14" /></a></sup>
45
 
46
  ```python
47
  set_binary_from_mime_type(cls, is_binary: bool, info: ValidationInfo) -> bool
 
50
  Set is_binary based on mime_type if not explicitly set.
51
 
52
 
53
+ ### `HttpResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L84"><Icon icon="github" size="14" /></a></sup>
54
 
55
 
56
  A resource that reads from an HTTP endpoint.
57
 
58
 
59
+ ### `DirectoryResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L100"><Icon icon="github" size="14" /></a></sup>
60
 
61
 
62
  A resource that lists files in a directory.
 
64
 
65
  **Methods:**
66
 
67
+ #### `validate_absolute_path` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L116"><Icon icon="github" size="14" /></a></sup>
68
 
69
  ```python
70
  validate_absolute_path(cls, path: Path) -> Path
 
73
  Ensure path is absolute.
74
 
75
 
76
+ #### `list_files` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/resources/types.py#L122"><Icon icon="github" size="14" /></a></sup>
77
 
78
  ```python
79
  list_files(self) -> list[Path]
docs/python-sdk/fastmcp-server-auth-auth.mdx CHANGED
@@ -7,4 +7,4 @@ sidebarTitle: auth
7
 
8
  ## Classes
9
 
10
- ### `OAuthProvider`
 
7
 
8
  ## Classes
9
 
10
+ ### `OAuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/auth.py#L14"><Icon icon="github" size="14" /></a></sup>
docs/python-sdk/fastmcp-server-auth-providers-bearer.mdx CHANGED
@@ -7,23 +7,23 @@ sidebarTitle: bearer
7
 
8
  ## Classes
9
 
10
- ### `JWKData`
11
 
12
 
13
  JSON Web Key data structure.
14
 
15
 
16
- ### `JWKSData`
17
 
18
 
19
  JSON Web Key Set data structure.
20
 
21
 
22
- ### `RSAKeyPair`
23
 
24
  **Methods:**
25
 
26
- #### `generate`
27
 
28
  ```python
29
  generate(cls) -> 'RSAKeyPair'
@@ -35,7 +35,7 @@ Generate an RSA key pair for testing.
35
  - (private_key_pem, public_key_pem)
36
 
37
 
38
- #### `create_token`
39
 
40
  ```python
41
  create_token(self, subject: str = 'fastmcp-user', issuer: str = 'https://fastmcp.example.com', audience: str | list[str] | None = None, scopes: list[str] | None = None, expires_in_seconds: int = 3600, additional_claims: dict[str, Any] | None = None, kid: str | None = None) -> str
@@ -57,7 +57,7 @@ Generate a test JWT token for testing purposes.
57
  - Signed JWT token string
58
 
59
 
60
- ### `BearerAuthProvider`
61
 
62
 
63
  Simple JWT Bearer Token validator for hosted MCP servers.
 
7
 
8
  ## Classes
9
 
10
+ ### `JWKData` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer.py#L29"><Icon icon="github" size="14" /></a></sup>
11
 
12
 
13
  JSON Web Key data structure.
14
 
15
 
16
+ ### `JWKSData` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer.py#L42"><Icon icon="github" size="14" /></a></sup>
17
 
18
 
19
  JSON Web Key Set data structure.
20
 
21
 
22
+ ### `RSAKeyPair` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer.py#L49"><Icon icon="github" size="14" /></a></sup>
23
 
24
  **Methods:**
25
 
26
+ #### `generate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer.py#L54"><Icon icon="github" size="14" /></a></sup>
27
 
28
  ```python
29
  generate(cls) -> 'RSAKeyPair'
 
35
  - (private_key_pem, public_key_pem)
36
 
37
 
38
+ #### `create_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer.py#L88"><Icon icon="github" size="14" /></a></sup>
39
 
40
  ```python
41
  create_token(self, subject: str = 'fastmcp-user', issuer: str = 'https://fastmcp.example.com', audience: str | list[str] | None = None, scopes: list[str] | None = None, expires_in_seconds: int = 3600, additional_claims: dict[str, Any] | None = None, kid: str | None = None) -> str
 
57
  - Signed JWT token string
58
 
59
 
60
+ ### `BearerAuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer.py#L149"><Icon icon="github" size="14" /></a></sup>
61
 
62
 
63
  Simple JWT Bearer Token validator for hosted MCP servers.
docs/python-sdk/fastmcp-server-auth-providers-bearer_env.mdx CHANGED
@@ -7,13 +7,13 @@ sidebarTitle: bearer_env
7
 
8
  ## Classes
9
 
10
- ### `EnvBearerAuthProviderSettings`
11
 
12
 
13
  Settings for the BearerAuthProvider.
14
 
15
 
16
- ### `EnvBearerAuthProvider`
17
 
18
 
19
  A BearerAuthProvider that loads settings from environment variables. Any
 
7
 
8
  ## Classes
9
 
10
+ ### `EnvBearerAuthProviderSettings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer_env.py#L8"><Icon icon="github" size="14" /></a></sup>
11
 
12
 
13
  Settings for the BearerAuthProvider.
14
 
15
 
16
+ ### `EnvBearerAuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer_env.py#L24"><Icon icon="github" size="14" /></a></sup>
17
 
18
 
19
  A BearerAuthProvider that loads settings from environment variables. Any
docs/python-sdk/fastmcp-server-auth-providers-in_memory.mdx CHANGED
@@ -7,7 +7,7 @@ sidebarTitle: in_memory
7
 
8
  ## Classes
9
 
10
- ### `InMemoryOAuthProvider`
11
 
12
 
13
  An in-memory OAuth provider for testing purposes.
 
7
 
8
  ## Classes
9
 
10
+ ### `InMemoryOAuthProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/in_memory.py#L31"><Icon icon="github" size="14" /></a></sup>
11
 
12
 
13
  An in-memory OAuth provider for testing purposes.
docs/python-sdk/fastmcp-server-context.mdx CHANGED
@@ -7,7 +7,7 @@ sidebarTitle: context
7
 
8
  ## Functions
9
 
10
- ### `set_context`
11
 
12
  ```python
13
  set_context(context: Context) -> Generator[Context, None, None]
@@ -15,7 +15,7 @@ set_context(context: Context) -> Generator[Context, None, None]
15
 
16
  ## Classes
17
 
18
- ### `Context`
19
 
20
 
21
  Context object providing access to MCP capabilities.
@@ -53,7 +53,7 @@ The context is optional - tools that don't need it can omit the parameter.
53
 
54
  **Methods:**
55
 
56
- #### `request_context`
57
 
58
  ```python
59
  request_context(self) -> RequestContext
@@ -64,7 +64,7 @@ Access to the underlying request context.
64
  If called outside of a request context, this will raise a ValueError.
65
 
66
 
67
- #### `client_id`
68
 
69
  ```python
70
  client_id(self) -> str | None
@@ -73,7 +73,7 @@ client_id(self) -> str | None
73
  Get the client ID if available.
74
 
75
 
76
- #### `request_id`
77
 
78
  ```python
79
  request_id(self) -> str
@@ -82,7 +82,7 @@ request_id(self) -> str
82
  Get the unique ID for this request.
83
 
84
 
85
- #### `session_id`
86
 
87
  ```python
88
  session_id(self) -> str | None
@@ -99,7 +99,7 @@ the same client session.
99
  - for stdio and in-memory transports which don't use session IDs.
100
 
101
 
102
- #### `session`
103
 
104
  ```python
105
  session(self)
@@ -108,7 +108,7 @@ session(self)
108
  Access to the underlying session for advanced usage.
109
 
110
 
111
- #### `get_http_request`
112
 
113
  ```python
114
  get_http_request(self) -> Request
 
7
 
8
  ## Functions
9
 
10
+ ### `set_context` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L36"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  set_context(context: Context) -> Generator[Context, None, None]
 
15
 
16
  ## Classes
17
 
18
+ ### `Context` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L45"><Icon icon="github" size="14" /></a></sup>
19
 
20
 
21
  Context object providing access to MCP capabilities.
 
53
 
54
  **Methods:**
55
 
56
+ #### `request_context` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L98"><Icon icon="github" size="14" /></a></sup>
57
 
58
  ```python
59
  request_context(self) -> RequestContext
 
64
  If called outside of a request context, this will raise a ValueError.
65
 
66
 
67
+ #### `client_id` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L168"><Icon icon="github" size="14" /></a></sup>
68
 
69
  ```python
70
  client_id(self) -> str | None
 
73
  Get the client ID if available.
74
 
75
 
76
+ #### `request_id` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L177"><Icon icon="github" size="14" /></a></sup>
77
 
78
  ```python
79
  request_id(self) -> str
 
82
  Get the unique ID for this request.
83
 
84
 
85
+ #### `session_id` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L182"><Icon icon="github" size="14" /></a></sup>
86
 
87
  ```python
88
  session_id(self) -> str | None
 
99
  - for stdio and in-memory transports which don't use session IDs.
100
 
101
 
102
+ #### `session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L213"><Icon icon="github" size="14" /></a></sup>
103
 
104
  ```python
105
  session(self)
 
108
  Access to the underlying session for advanced usage.
109
 
110
 
111
+ #### `get_http_request` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/context.py#L282"><Icon icon="github" size="14" /></a></sup>
112
 
113
  ```python
114
  get_http_request(self) -> Request
docs/python-sdk/fastmcp-server-dependencies.mdx CHANGED
@@ -7,19 +7,19 @@ sidebarTitle: dependencies
7
 
8
  ## Functions
9
 
10
- ### `get_context`
11
 
12
  ```python
13
  get_context() -> Context
14
  ```
15
 
16
- ### `get_http_request`
17
 
18
  ```python
19
  get_http_request() -> Request
20
  ```
21
 
22
- ### `get_http_headers`
23
 
24
  ```python
25
  get_http_headers(include_all: bool = False) -> dict[str, str]
 
7
 
8
  ## Functions
9
 
10
+ ### `get_context` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#L27"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  get_context() -> Context
14
  ```
15
 
16
+ ### `get_http_request` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#L39"><Icon icon="github" size="14" /></a></sup>
17
 
18
  ```python
19
  get_http_request() -> Request
20
  ```
21
 
22
+ ### `get_http_headers` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/dependencies.py#L48"><Icon icon="github" size="14" /></a></sup>
23
 
24
  ```python
25
  get_http_headers(include_all: bool = False) -> dict[str, str]
docs/python-sdk/fastmcp-server-http.mdx CHANGED
@@ -7,13 +7,13 @@ sidebarTitle: http
7
 
8
  ## Functions
9
 
10
- ### `set_http_request`
11
 
12
  ```python
13
  set_http_request(request: Request) -> Generator[Request, None, None]
14
  ```
15
 
16
- ### `setup_auth_middleware_and_routes`
17
 
18
  ```python
19
  setup_auth_middleware_and_routes(auth: OAuthProvider) -> tuple[list[Middleware], list[BaseRoute], list[str]]
@@ -29,7 +29,7 @@ Set up authentication middleware and routes if auth is enabled.
29
  - Tuple of (middleware, auth_routes, required_scopes)
30
 
31
 
32
- ### `create_base_app`
33
 
34
  ```python
35
  create_base_app(routes: list[BaseRoute], middleware: list[Middleware], debug: bool = False, lifespan: Callable | None = None) -> StarletteWithLifespan
@@ -48,7 +48,7 @@ Create a base Starlette app with common middleware and routes.
48
  - A Starlette application
49
 
50
 
51
- ### `create_sse_app`
52
 
53
  ```python
54
  create_sse_app(server: FastMCP[LifespanResultT], message_path: str, sse_path: str, auth: OAuthProvider | None = None, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
@@ -70,7 +70,7 @@ Returns:
70
  A Starlette application with RequestContextMiddleware
71
 
72
 
73
- ### `create_streamable_http_app`
74
 
75
  ```python
76
  create_streamable_http_app(server: FastMCP[LifespanResultT], streamable_http_path: str, event_store: EventStore | None = None, auth: OAuthProvider | None = None, json_response: bool = False, stateless_http: bool = False, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
@@ -96,17 +96,17 @@ Return an instance of the StreamableHTTP server app.
96
 
97
  ## Classes
98
 
99
- ### `StarletteWithLifespan`
100
 
101
  **Methods:**
102
 
103
- #### `lifespan`
104
 
105
  ```python
106
  lifespan(self) -> Lifespan
107
  ```
108
 
109
- ### `RequestContextMiddleware`
110
 
111
 
112
  Middleware that stores each request in a ContextVar
 
7
 
8
  ## Functions
9
 
10
+ ### `set_http_request` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L48"><Icon icon="github" size="14" /></a></sup>
11
 
12
  ```python
13
  set_http_request(request: Request) -> Generator[Request, None, None]
14
  ```
15
 
16
+ ### `setup_auth_middleware_and_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L72"><Icon icon="github" size="14" /></a></sup>
17
 
18
  ```python
19
  setup_auth_middleware_and_routes(auth: OAuthProvider) -> tuple[list[Middleware], list[BaseRoute], list[str]]
 
29
  - Tuple of (middleware, auth_routes, required_scopes)
30
 
31
 
32
+ ### `create_base_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L110"><Icon icon="github" size="14" /></a></sup>
33
 
34
  ```python
35
  create_base_app(routes: list[BaseRoute], middleware: list[Middleware], debug: bool = False, lifespan: Callable | None = None) -> StarletteWithLifespan
 
48
  - A Starlette application
49
 
50
 
51
+ ### `create_sse_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L138"><Icon icon="github" size="14" /></a></sup>
52
 
53
  ```python
54
  create_sse_app(server: FastMCP[LifespanResultT], message_path: str, sse_path: str, auth: OAuthProvider | None = None, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
 
70
  A Starlette application with RequestContextMiddleware
71
 
72
 
73
+ ### `create_streamable_http_app` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L246"><Icon icon="github" size="14" /></a></sup>
74
 
75
  ```python
76
  create_streamable_http_app(server: FastMCP[LifespanResultT], streamable_http_path: str, event_store: EventStore | None = None, auth: OAuthProvider | None = None, json_response: bool = False, stateless_http: bool = False, debug: bool = False, routes: list[BaseRoute] | None = None, middleware: list[Middleware] | None = None) -> StarletteWithLifespan
 
96
 
97
  ## Classes
98
 
99
+ ### `StarletteWithLifespan` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L41"><Icon icon="github" size="14" /></a></sup>
100
 
101
  **Methods:**
102
 
103
+ #### `lifespan` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L43"><Icon icon="github" size="14" /></a></sup>
104
 
105
  ```python
106
  lifespan(self) -> Lifespan
107
  ```
108
 
109
+ ### `RequestContextMiddleware` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/http.py#L56"><Icon icon="github" size="14" /></a></sup>
110
 
111
 
112
  Middleware that stores each request in a ContextVar
docs/python-sdk/fastmcp-server-middleware-__init__.mdx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: __init__
3
+ sidebarTitle: __init__
4
+ ---
5
+
6
+ # `fastmcp.server.middleware`
7
+
8
+ *This module is empty or contains only private/internal implementations.*