Spaces:
Running
Running
Merge pull request #154 from jlowin/broken-links
Browse files- .github/workflows/run-static.yml +12 -0
- docs/getting-started/quickstart.mdx +2 -2
- docs/servers/context.mdx +2 -2
- docs/servers/fastmcp.mdx +6 -10
- docs/servers/prompts.mdx +1 -1
- docs/servers/tools.mdx +1 -1
.github/workflows/run-static.yml
CHANGED
|
@@ -8,7 +8,19 @@ env:
|
|
| 8 |
on:
|
| 9 |
push:
|
| 10 |
branches: ["main"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
pull_request:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
workflow_dispatch:
|
| 13 |
|
| 14 |
permissions:
|
|
|
|
| 8 |
on:
|
| 9 |
push:
|
| 10 |
branches: ["main"]
|
| 11 |
+
paths:
|
| 12 |
+
- "src/**"
|
| 13 |
+
- "tests/**"
|
| 14 |
+
- "uv.lock"
|
| 15 |
+
- "pyproject.toml"
|
| 16 |
+
- ".github/workflows/**"
|
| 17 |
pull_request:
|
| 18 |
+
paths:
|
| 19 |
+
- "src/**"
|
| 20 |
+
- "tests/**"
|
| 21 |
+
- "uv.lock"
|
| 22 |
+
- "pyproject.toml"
|
| 23 |
+
- ".github/workflows/**"
|
| 24 |
workflow_dispatch:
|
| 25 |
|
| 26 |
permissions:
|
docs/getting-started/quickstart.mdx
CHANGED
|
@@ -5,7 +5,7 @@ icon: rocket
|
|
| 5 |
|
| 6 |
Welcome! This guide will help you quickly set up FastMCP and run your first MCP server.
|
| 7 |
|
| 8 |
-
If you haven't already installed FastMCP, follow the [installation instructions](/
|
| 9 |
|
| 10 |
## Creating a FastMCP Server
|
| 11 |
|
|
@@ -123,5 +123,5 @@ fastmcp run my_server.py:mcp
|
|
| 123 |
Note that FastMCP *does not* require the `__main__` block in the server file, and will ignore it if it is present. Instead, it looks for the server object provided in the CLI command (here, `mcp`). If no server object is provided, `fastmcp run` will automatically search for servers called "mcp", "app", or "server" in the file.
|
| 124 |
|
| 125 |
<Tip>
|
| 126 |
-
We pointed our client at the server file, which is recognized as a Python MCP server and executed with `python my_server.py` by default. This exceutes the `__main__` block of the server file. There are other ways to run the server, which are described in the [server configuration](/
|
| 127 |
</Tip>
|
|
|
|
| 5 |
|
| 6 |
Welcome! This guide will help you quickly set up FastMCP and run your first MCP server.
|
| 7 |
|
| 8 |
+
If you haven't already installed FastMCP, follow the [installation instructions](/getting-started/installation).
|
| 9 |
|
| 10 |
## Creating a FastMCP Server
|
| 11 |
|
|
|
|
| 123 |
Note that FastMCP *does not* require the `__main__` block in the server file, and will ignore it if it is present. Instead, it looks for the server object provided in the CLI command (here, `mcp`). If no server object is provided, `fastmcp run` will automatically search for servers called "mcp", "app", or "server" in the file.
|
| 124 |
|
| 125 |
<Tip>
|
| 126 |
+
We pointed our client at the server file, which is recognized as a Python MCP server and executed with `python my_server.py` by default. This exceutes the `__main__` block of the server file. There are other ways to run the server, which are described in the [server configuration](/servers/fastmcp#running-the-server) guide.
|
| 127 |
</Tip>
|
docs/servers/context.mdx
CHANGED
|
@@ -5,7 +5,7 @@ description: Access MCP capabilities like logging, progress, and resources withi
|
|
| 5 |
icon: rectangle-code
|
| 6 |
---
|
| 7 |
|
| 8 |
-
When defining FastMCP [
|
| 9 |
|
| 10 |
## What Is Context?
|
| 11 |
|
|
@@ -227,7 +227,7 @@ async def generate_example(concept: str, ctx: Context) -> str:
|
|
| 227 |
return f"```python\n{code_example}\n```"
|
| 228 |
```
|
| 229 |
|
| 230 |
-
See [Client Sampling](/
|
| 231 |
|
| 232 |
### Request Information
|
| 233 |
|
|
|
|
| 5 |
icon: rectangle-code
|
| 6 |
---
|
| 7 |
|
| 8 |
+
When defining FastMCP [tools](/servers/tools), your functions might need to interact with the underlying MCP session or access server capabilities. FastMCP provides the `Context` object for this purpose.
|
| 9 |
|
| 10 |
## What Is Context?
|
| 11 |
|
|
|
|
| 227 |
return f"```python\n{code_example}\n```"
|
| 228 |
```
|
| 229 |
|
| 230 |
+
See [Client Sampling](/clients/overview#llm-sampling) for more details on how clients handle these requests.
|
| 231 |
|
| 232 |
### Request Information
|
| 233 |
|
docs/servers/fastmcp.mdx
CHANGED
|
@@ -28,9 +28,9 @@ The `FastMCP` constructor accepts several arguments:
|
|
| 28 |
|
| 29 |
* `name`: (Optional) A human-readable name for your server. Defaults to "FastMCP".
|
| 30 |
* `instructions`: (Optional) Description of how to interact with this server. These instructions help clients understand the server's purpose and available functionality.
|
| 31 |
-
* `lifespan`: (Optional) An async context manager function for server startup and shutdown logic.
|
| 32 |
* `tags`: (Optional) A set of strings to tag the server itself.
|
| 33 |
-
* `**settings`: Keyword arguments corresponding to `ServerSettings`
|
| 34 |
|
| 35 |
## Components
|
| 36 |
|
|
@@ -47,7 +47,7 @@ def multiply(a: float, b: float) -> float:
|
|
| 47 |
return a * b
|
| 48 |
```
|
| 49 |
|
| 50 |
-
See [Tools](/
|
| 51 |
|
| 52 |
### Resources
|
| 53 |
|
|
@@ -60,7 +60,7 @@ def get_config() -> dict:
|
|
| 60 |
return {"theme": "dark", "version": "1.0"}
|
| 61 |
```
|
| 62 |
|
| 63 |
-
See [Resources & Templates](/
|
| 64 |
|
| 65 |
### Resource Templates
|
| 66 |
|
|
@@ -74,7 +74,7 @@ def get_user_profile(user_id: int) -> dict:
|
|
| 74 |
return {"id": user_id, "name": f"User {user_id}", "status": "active"}
|
| 75 |
```
|
| 76 |
|
| 77 |
-
See [Resources & Templates](/
|
| 78 |
|
| 79 |
### Prompts
|
| 80 |
|
|
@@ -88,7 +88,7 @@ def analyze_data(data_points: list[float]) -> str:
|
|
| 88 |
return f"Please analyze these data points: {formatted_data}"
|
| 89 |
```
|
| 90 |
|
| 91 |
-
See [Prompts](/
|
| 92 |
|
| 93 |
## Running the Server
|
| 94 |
|
|
@@ -186,9 +186,6 @@ fastmcp run my_server.py:mcp --transport sse --host 127.0.0.1 --port 8888
|
|
| 186 |
|
| 187 |
The CLI can dynamically find and run FastMCP server objects in your files, but including the `if __name__ == "__main__":` block ensures compatibility with all clients.
|
| 188 |
|
| 189 |
-
<Tip>
|
| 190 |
-
For more options, including how to set up your server's dependencies or use advanced configurations, see the [CLI Reference](/cli/overview).
|
| 191 |
-
</Tip>
|
| 192 |
|
| 193 |
## Mounting Subservers
|
| 194 |
|
|
@@ -299,4 +296,3 @@ print(mcp.settings.on_duplicate_tools) # Output: DuplicateBehavior.ERROR
|
|
| 299 |
|
| 300 |
All of these can be configured directly as parameters when creating the `FastMCP` instance.
|
| 301 |
|
| 302 |
-
See the [Configuration](/advanced/configuration) page for more details.
|
|
|
|
| 28 |
|
| 29 |
* `name`: (Optional) A human-readable name for your server. Defaults to "FastMCP".
|
| 30 |
* `instructions`: (Optional) Description of how to interact with this server. These instructions help clients understand the server's purpose and available functionality.
|
| 31 |
+
* `lifespan`: (Optional) An async context manager function for server startup and shutdown logic.
|
| 32 |
* `tags`: (Optional) A set of strings to tag the server itself.
|
| 33 |
+
* `**settings`: Keyword arguments corresponding to additional `ServerSettings` configuration
|
| 34 |
|
| 35 |
## Components
|
| 36 |
|
|
|
|
| 47 |
return a * b
|
| 48 |
```
|
| 49 |
|
| 50 |
+
See [Tools](/servers/tools) for detailed documentation.
|
| 51 |
|
| 52 |
### Resources
|
| 53 |
|
|
|
|
| 60 |
return {"theme": "dark", "version": "1.0"}
|
| 61 |
```
|
| 62 |
|
| 63 |
+
See [Resources & Templates](/servers/resources) for detailed documentation.
|
| 64 |
|
| 65 |
### Resource Templates
|
| 66 |
|
|
|
|
| 74 |
return {"id": user_id, "name": f"User {user_id}", "status": "active"}
|
| 75 |
```
|
| 76 |
|
| 77 |
+
See [Resources & Templates](/servers/resources) for detailed documentation.
|
| 78 |
|
| 79 |
### Prompts
|
| 80 |
|
|
|
|
| 88 |
return f"Please analyze these data points: {formatted_data}"
|
| 89 |
```
|
| 90 |
|
| 91 |
+
See [Prompts](/servers/prompts) for detailed documentation.
|
| 92 |
|
| 93 |
## Running the Server
|
| 94 |
|
|
|
|
| 186 |
|
| 187 |
The CLI can dynamically find and run FastMCP server objects in your files, but including the `if __name__ == "__main__":` block ensures compatibility with all clients.
|
| 188 |
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
## Mounting Subservers
|
| 191 |
|
|
|
|
| 296 |
|
| 297 |
All of these can be configured directly as parameters when creating the `FastMCP` instance.
|
| 298 |
|
|
|
docs/servers/prompts.mdx
CHANGED
|
@@ -195,7 +195,7 @@ Using the `ctx` parameter (based on its `Context` type hint), you can access:
|
|
| 195 |
- **LLM Sampling:** `ctx.sample(...)`
|
| 196 |
- **Request Info:** `ctx.request_id`, `ctx.client_id`
|
| 197 |
|
| 198 |
-
Refer to the [
|
| 199 |
|
| 200 |
## Server Behavior
|
| 201 |
|
|
|
|
| 195 |
- **LLM Sampling:** `ctx.sample(...)`
|
| 196 |
- **Request Info:** `ctx.request_id`, `ctx.client_id`
|
| 197 |
|
| 198 |
+
Refer to the [Context documentation](/servers/context) for more details on these capabilities.
|
| 199 |
|
| 200 |
## Server Behavior
|
| 201 |
|
docs/servers/tools.mdx
CHANGED
|
@@ -300,7 +300,7 @@ The Context object provides access to:
|
|
| 300 |
- **LLM Sampling**: `ctx.sample(...)`
|
| 301 |
- **Request Information**: `ctx.request_id`, `ctx.client_id`
|
| 302 |
|
| 303 |
-
For full documentation on the Context object and all its capabilities, see the [Context
|
| 304 |
|
| 305 |
## Server Behavior
|
| 306 |
|
|
|
|
| 300 |
- **LLM Sampling**: `ctx.sample(...)`
|
| 301 |
- **Request Information**: `ctx.request_id`, `ctx.client_id`
|
| 302 |
|
| 303 |
+
For full documentation on the Context object and all its capabilities, see the [Context documentation](/servers/context).
|
| 304 |
|
| 305 |
## Server Behavior
|
| 306 |
|