fastmcp 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastmcp/cli/claude.py +29 -8
- fastmcp/cli/cli.py +15 -12
- fastmcp/resources/base.py +12 -19
- fastmcp/server.py +7 -0
- {fastmcp-0.3.2.dist-info → fastmcp-0.3.4.dist-info}/METADATA +176 -68
- {fastmcp-0.3.2.dist-info → fastmcp-0.3.4.dist-info}/RECORD +9 -9
- {fastmcp-0.3.2.dist-info → fastmcp-0.3.4.dist-info}/WHEEL +0 -0
- {fastmcp-0.3.2.dist-info → fastmcp-0.3.4.dist-info}/entry_points.txt +0 -0
- {fastmcp-0.3.2.dist-info → fastmcp-0.3.4.dist-info}/licenses/LICENSE +0 -0
fastmcp/cli/claude.py
CHANGED
|
@@ -41,14 +41,31 @@ def update_claude_config(
|
|
|
41
41
|
with_packages: Optional list of additional packages to install
|
|
42
42
|
env_vars: Optional dictionary of environment variables. These are merged with
|
|
43
43
|
any existing variables, with new values taking precedence.
|
|
44
|
+
|
|
45
|
+
Raises:
|
|
46
|
+
RuntimeError: If Claude Desktop's config directory is not found, indicating
|
|
47
|
+
Claude Desktop may not be installed or properly set up.
|
|
44
48
|
"""
|
|
45
49
|
config_dir = get_claude_config_path()
|
|
46
50
|
if not config_dir:
|
|
47
|
-
|
|
51
|
+
raise RuntimeError(
|
|
52
|
+
"Claude Desktop config directory not found. Please ensure Claude Desktop "
|
|
53
|
+
"is installed and has been run at least once to initialize its configuration."
|
|
54
|
+
)
|
|
48
55
|
|
|
49
56
|
config_file = config_dir / "claude_desktop_config.json"
|
|
50
57
|
if not config_file.exists():
|
|
51
|
-
|
|
58
|
+
try:
|
|
59
|
+
config_file.write_text("{}")
|
|
60
|
+
except Exception as e:
|
|
61
|
+
logger.error(
|
|
62
|
+
"Failed to create Claude config file",
|
|
63
|
+
extra={
|
|
64
|
+
"error": str(e),
|
|
65
|
+
"config_file": str(config_file),
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
return False
|
|
52
69
|
|
|
53
70
|
try:
|
|
54
71
|
config = json.loads(config_file.read_text())
|
|
@@ -68,16 +85,20 @@ def update_claude_config(
|
|
|
68
85
|
env_vars = existing_env
|
|
69
86
|
|
|
70
87
|
# Build uv run command
|
|
71
|
-
args = ["run"
|
|
88
|
+
args = ["run"]
|
|
89
|
+
|
|
90
|
+
# Collect all packages in a set to deduplicate
|
|
91
|
+
packages = {"fastmcp"}
|
|
92
|
+
if with_packages:
|
|
93
|
+
packages.update(pkg for pkg in with_packages if pkg)
|
|
94
|
+
|
|
95
|
+
# Add all packages with --with
|
|
96
|
+
for pkg in sorted(packages):
|
|
97
|
+
args.extend(["--with", pkg])
|
|
72
98
|
|
|
73
99
|
if with_editable:
|
|
74
100
|
args.extend(["--with-editable", str(with_editable)])
|
|
75
101
|
|
|
76
|
-
if with_packages:
|
|
77
|
-
for pkg in with_packages:
|
|
78
|
-
if pkg:
|
|
79
|
-
args.extend(["--with", pkg])
|
|
80
|
-
|
|
81
102
|
# Convert file path to absolute before adding to command
|
|
82
103
|
# Split off any :object suffix first
|
|
83
104
|
if ":" in file_spec:
|
fastmcp/cli/cli.py
CHANGED
|
@@ -193,6 +193,11 @@ def dev(
|
|
|
193
193
|
)
|
|
194
194
|
|
|
195
195
|
try:
|
|
196
|
+
# Import server to get dependencies
|
|
197
|
+
server = _import_server(file, server_object)
|
|
198
|
+
if hasattr(server, "dependencies"):
|
|
199
|
+
with_packages = list(set(with_packages + server.dependencies))
|
|
200
|
+
|
|
196
201
|
uv_cmd = _build_uv_command(file_spec, with_editable, with_packages)
|
|
197
202
|
# Run the MCP Inspector command
|
|
198
203
|
process = subprocess.run(
|
|
@@ -232,23 +237,16 @@ def run(
|
|
|
232
237
|
help="Transport protocol to use (stdio or sse)",
|
|
233
238
|
),
|
|
234
239
|
] = None,
|
|
235
|
-
with_editable: Annotated[
|
|
236
|
-
Optional[Path],
|
|
237
|
-
typer.Option(
|
|
238
|
-
"--with-editable",
|
|
239
|
-
"-e",
|
|
240
|
-
help="Directory containing pyproject.toml to install in editable mode",
|
|
241
|
-
exists=True,
|
|
242
|
-
file_okay=False,
|
|
243
|
-
resolve_path=True,
|
|
244
|
-
),
|
|
245
|
-
] = None,
|
|
246
240
|
) -> None:
|
|
247
241
|
"""Run a FastMCP server.
|
|
248
242
|
|
|
249
243
|
The server can be specified in two ways:
|
|
250
244
|
1. Module approach: server.py - runs the module directly, expecting a server.run() call
|
|
251
245
|
2. Import approach: server.py:app - imports and runs the specified server object
|
|
246
|
+
|
|
247
|
+
Note: This command runs the server directly. You are responsible for ensuring
|
|
248
|
+
all dependencies are available. For dependency management, use fastmcp install
|
|
249
|
+
or fastmcp dev instead.
|
|
252
250
|
"""
|
|
253
251
|
file, server_object = _parse_file_path(file_spec)
|
|
254
252
|
|
|
@@ -258,7 +256,6 @@ def run(
|
|
|
258
256
|
"file": str(file),
|
|
259
257
|
"server_object": server_object,
|
|
260
258
|
"transport": transport,
|
|
261
|
-
"with_editable": str(with_editable) if with_editable else None,
|
|
262
259
|
},
|
|
263
260
|
)
|
|
264
261
|
|
|
@@ -361,6 +358,7 @@ def install(
|
|
|
361
358
|
|
|
362
359
|
# Try to import server to get its name, but fall back to file name if dependencies missing
|
|
363
360
|
name = server_name
|
|
361
|
+
server = None
|
|
364
362
|
if not name:
|
|
365
363
|
try:
|
|
366
364
|
server = _import_server(file, server_object)
|
|
@@ -372,6 +370,11 @@ def install(
|
|
|
372
370
|
)
|
|
373
371
|
name = file.stem
|
|
374
372
|
|
|
373
|
+
# Get server dependencies if available
|
|
374
|
+
server_dependencies = getattr(server, "dependencies", []) if server else []
|
|
375
|
+
if server_dependencies:
|
|
376
|
+
with_packages = list(set(with_packages + server_dependencies))
|
|
377
|
+
|
|
375
378
|
# Process environment variables if provided
|
|
376
379
|
env_dict: Optional[Dict[str, str]] = None
|
|
377
380
|
if env_file or env_vars:
|
fastmcp/resources/base.py
CHANGED
|
@@ -1,34 +1,17 @@
|
|
|
1
1
|
"""Base classes and interfaces for FastMCP resources."""
|
|
2
2
|
|
|
3
3
|
import abc
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Union
|
|
5
5
|
|
|
6
6
|
from pydantic import (
|
|
7
7
|
AnyUrl,
|
|
8
8
|
BaseModel,
|
|
9
|
-
BeforeValidator,
|
|
10
9
|
ConfigDict,
|
|
11
10
|
Field,
|
|
12
11
|
FileUrl,
|
|
13
12
|
ValidationInfo,
|
|
14
13
|
field_validator,
|
|
15
14
|
)
|
|
16
|
-
from pydantic.networks import _BaseUrl # TODO: remove this once pydantic is updated
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def maybe_cast_str_to_any_url(x) -> AnyUrl:
|
|
20
|
-
if isinstance(x, FileUrl):
|
|
21
|
-
return x
|
|
22
|
-
elif isinstance(x, AnyUrl):
|
|
23
|
-
return x
|
|
24
|
-
elif isinstance(x, str):
|
|
25
|
-
if x.startswith("file://"):
|
|
26
|
-
return FileUrl(x)
|
|
27
|
-
return AnyUrl(x)
|
|
28
|
-
raise ValueError(f"Expected str or AnyUrl, got {type(x)}")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
LaxAnyUrl = Annotated[_BaseUrl | str, BeforeValidator(maybe_cast_str_to_any_url)]
|
|
32
15
|
|
|
33
16
|
|
|
34
17
|
class Resource(BaseModel, abc.ABC):
|
|
@@ -36,7 +19,8 @@ class Resource(BaseModel, abc.ABC):
|
|
|
36
19
|
|
|
37
20
|
model_config = ConfigDict(validate_default=True)
|
|
38
21
|
|
|
39
|
-
uri:
|
|
22
|
+
# uri: Annotated[AnyUrl, BeforeValidator(maybe_cast_str_to_any_url)] = Field(
|
|
23
|
+
uri: AnyUrl = Field(default=..., description="URI of the resource")
|
|
40
24
|
name: str | None = Field(description="Name of the resource", default=None)
|
|
41
25
|
description: str | None = Field(
|
|
42
26
|
description="Description of the resource", default=None
|
|
@@ -47,6 +31,15 @@ class Resource(BaseModel, abc.ABC):
|
|
|
47
31
|
pattern=r"^[a-zA-Z0-9]+/[a-zA-Z0-9\-+.]+$",
|
|
48
32
|
)
|
|
49
33
|
|
|
34
|
+
@field_validator("uri", mode="before")
|
|
35
|
+
def validate_uri(cls, uri: AnyUrl | str) -> AnyUrl:
|
|
36
|
+
if isinstance(uri, str):
|
|
37
|
+
# AnyUrl doesn't support triple-slashes, but files do ("file:///absolute/path")
|
|
38
|
+
if uri.startswith("file://"):
|
|
39
|
+
return FileUrl(uri)
|
|
40
|
+
return AnyUrl(uri)
|
|
41
|
+
return uri
|
|
42
|
+
|
|
50
43
|
@field_validator("name", mode="before")
|
|
51
44
|
@classmethod
|
|
52
45
|
def set_default_name(cls, name: str | None, info: ValidationInfo) -> str:
|
fastmcp/server.py
CHANGED
|
@@ -9,6 +9,7 @@ from itertools import chain
|
|
|
9
9
|
from typing import Any, Callable, Dict, Literal, Sequence
|
|
10
10
|
|
|
11
11
|
import pydantic_core
|
|
12
|
+
from pydantic import Field
|
|
12
13
|
import uvicorn
|
|
13
14
|
from mcp.server import Server as MCPServer
|
|
14
15
|
from mcp.server.sse import SseServerTransport
|
|
@@ -76,6 +77,11 @@ class Settings(BaseSettings):
|
|
|
76
77
|
# prompt settings
|
|
77
78
|
warn_on_duplicate_prompts: bool = True
|
|
78
79
|
|
|
80
|
+
dependencies: list[str] = Field(
|
|
81
|
+
default_factory=list,
|
|
82
|
+
description="List of dependencies to install in the server environment",
|
|
83
|
+
)
|
|
84
|
+
|
|
79
85
|
|
|
80
86
|
class FastMCP:
|
|
81
87
|
def __init__(self, name: str | None = None, **settings: Any):
|
|
@@ -90,6 +96,7 @@ class FastMCP:
|
|
|
90
96
|
self._prompt_manager = PromptManager(
|
|
91
97
|
warn_on_duplicate_prompts=self.settings.warn_on_duplicate_prompts
|
|
92
98
|
)
|
|
99
|
+
self.dependencies = self.settings.dependencies
|
|
93
100
|
|
|
94
101
|
# Set up MCP protocol handlers
|
|
95
102
|
self._setup_handlers()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: fastmcp
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A more ergonomic interface for MCP servers
|
|
5
5
|
Author: Jeremiah Lowin
|
|
6
6
|
License: Apache-2.0
|
|
@@ -27,11 +27,12 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
|
|
28
28
|
<div align="center">
|
|
29
29
|
|
|
30
|
+
<strong>The fast, Pythonic way to build MCP servers.</strong>
|
|
31
|
+
|
|
30
32
|
[](https://pypi.org/project/fastmcp)
|
|
31
33
|
[](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
|
|
32
34
|
[](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
|
|
33
35
|
|
|
34
|
-
The fast, Pythonic way to build MCP servers
|
|
35
36
|
|
|
36
37
|
</div>
|
|
37
38
|
|
|
@@ -85,24 +86,33 @@ FastMCP handles all the complex protocol details and server management, so you c
|
|
|
85
86
|
- [Prompts](#prompts)
|
|
86
87
|
- [Images](#images)
|
|
87
88
|
- [Context](#context)
|
|
88
|
-
- [
|
|
89
|
-
- [Development](#development)
|
|
90
|
-
|
|
91
|
-
- [
|
|
92
|
-
|
|
89
|
+
- [Running Your Server](#running-your-server)
|
|
90
|
+
- [Development Mode (Recommended for Building \& Testing)](#development-mode-recommended-for-building--testing)
|
|
91
|
+
- [Claude Desktop Integration (For Regular Use)](#claude-desktop-integration-for-regular-use)
|
|
92
|
+
- [Direct Execution (For Advanced Use Cases)](#direct-execution-for-advanced-use-cases)
|
|
93
|
+
- [Server Object Names](#server-object-names)
|
|
93
94
|
- [Examples](#examples)
|
|
94
95
|
- [Echo Server](#echo-server)
|
|
95
96
|
- [SQLite Explorer](#sqlite-explorer)
|
|
97
|
+
- [Contributing](#contributing)
|
|
98
|
+
- [Prerequisites](#prerequisites)
|
|
99
|
+
- [Installation](#installation-1)
|
|
100
|
+
- [Testing](#testing)
|
|
101
|
+
- [Formatting](#formatting)
|
|
102
|
+
- [Opening a Pull Request](#opening-a-pull-request)
|
|
96
103
|
|
|
97
104
|
## Installation
|
|
98
105
|
|
|
106
|
+
We strongly recommend installing FastMCP with [uv](https://docs.astral.sh/uv/), as it is required for deploying servers:
|
|
107
|
+
|
|
99
108
|
```bash
|
|
100
|
-
# We strongly recommend installing with uv
|
|
101
|
-
brew install uv # on macOS
|
|
102
109
|
uv pip install fastmcp
|
|
103
110
|
```
|
|
104
111
|
|
|
105
|
-
|
|
112
|
+
Note: on macOS, uv may need to be installed with Homebrew (`brew install uv`) in order to make it available to the Claude Desktop app.
|
|
113
|
+
|
|
114
|
+
Alternatively, to use the SDK without deploying, you may use pip:
|
|
115
|
+
|
|
106
116
|
```bash
|
|
107
117
|
pip install fastmcp
|
|
108
118
|
```
|
|
@@ -112,6 +122,8 @@ pip install fastmcp
|
|
|
112
122
|
Let's create a simple MCP server that exposes a calculator tool and some data:
|
|
113
123
|
|
|
114
124
|
```python
|
|
125
|
+
# server.py
|
|
126
|
+
|
|
115
127
|
from fastmcp import FastMCP
|
|
116
128
|
|
|
117
129
|
|
|
@@ -133,14 +145,12 @@ def get_greeting(name: str) -> str:
|
|
|
133
145
|
return f"Hello, {name}!"
|
|
134
146
|
```
|
|
135
147
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
1. Install it in [Claude Desktop](https://claude.ai/download):
|
|
148
|
+
You can install this server in [Claude Desktop](https://claude.ai/download) and interact with it right away by running:
|
|
139
149
|
```bash
|
|
140
150
|
fastmcp install server.py
|
|
141
151
|
```
|
|
142
152
|
|
|
143
|
-
|
|
153
|
+
Alternatively, you can test it with the MCP Inspector:
|
|
144
154
|
```bash
|
|
145
155
|
fastmcp dev server.py
|
|
146
156
|
```
|
|
@@ -171,10 +181,9 @@ from fastmcp import FastMCP
|
|
|
171
181
|
# Create a named server
|
|
172
182
|
mcp = FastMCP("My App")
|
|
173
183
|
|
|
174
|
-
#
|
|
175
|
-
mcp = FastMCP("My App",
|
|
184
|
+
# Specify dependencies for deployment and development
|
|
185
|
+
mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
|
|
176
186
|
```
|
|
177
|
-
*Note: All of the following code examples assume you've created a FastMCP server instance called `mcp`, as shown above.*
|
|
178
187
|
|
|
179
188
|
### Resources
|
|
180
189
|
|
|
@@ -303,84 +312,101 @@ The Context object provides:
|
|
|
303
312
|
- Resource access through `read_resource()`
|
|
304
313
|
- Request metadata via `request_id` and `client_id`
|
|
305
314
|
|
|
306
|
-
##
|
|
307
|
-
|
|
308
|
-
The FastMCP CLI helps you develop and deploy MCP servers.
|
|
315
|
+
## Running Your Server
|
|
309
316
|
|
|
310
|
-
|
|
317
|
+
There are three main ways to use your FastMCP server, each suited for different stages of development:
|
|
311
318
|
|
|
312
|
-
|
|
319
|
+
### Development Mode (Recommended for Building & Testing)
|
|
313
320
|
|
|
314
|
-
|
|
321
|
+
The fastest way to test and debug your server is with the MCP Inspector:
|
|
315
322
|
|
|
316
|
-
Test and debug your server with the MCP Inspector:
|
|
317
323
|
```bash
|
|
318
|
-
# Provide the fully qualified path to your server
|
|
319
|
-
fastmcp dev server.py:my_mcp_server
|
|
320
|
-
|
|
321
|
-
# Or just the file if your server is named 'mcp', 'server', or 'app'
|
|
322
324
|
fastmcp dev server.py
|
|
323
325
|
```
|
|
324
326
|
|
|
325
|
-
|
|
327
|
+
This launches a web interface where you can:
|
|
328
|
+
- Test your tools and resources interactively
|
|
329
|
+
- See detailed logs and error messages
|
|
330
|
+
- Monitor server performance
|
|
331
|
+
- Set environment variables for testing
|
|
326
332
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
333
|
+
During development, you can:
|
|
334
|
+
- Add dependencies with `--with`:
|
|
335
|
+
```bash
|
|
336
|
+
fastmcp dev server.py --with pandas --with numpy
|
|
337
|
+
```
|
|
338
|
+
- Mount your local code for live updates:
|
|
339
|
+
```bash
|
|
340
|
+
fastmcp dev server.py --with-editable .
|
|
341
|
+
```
|
|
330
342
|
|
|
331
|
-
|
|
332
|
-
fastmcp dev server.py --with-editable .
|
|
333
|
-
```
|
|
343
|
+
### Claude Desktop Integration (For Regular Use)
|
|
334
344
|
|
|
335
|
-
|
|
345
|
+
Once your server is ready, install it in Claude Desktop to use it with Claude:
|
|
336
346
|
|
|
337
|
-
The MCP Inspector runs servers in an isolated environment. Environment variables must be set through the Inspector UI and are not inherited from your system. The Inspector does not currently support setting environment variables via command line (see [Issue #94](https://github.com/modelcontextprotocol/inspector/issues/94)).
|
|
338
|
-
|
|
339
|
-
### Claude Desktop
|
|
340
|
-
|
|
341
|
-
Install your server in Claude Desktop:
|
|
342
347
|
```bash
|
|
343
|
-
# Basic usage (name is taken from your FastMCP instance)
|
|
344
348
|
fastmcp install server.py
|
|
349
|
+
```
|
|
345
350
|
|
|
346
|
-
|
|
347
|
-
|
|
351
|
+
Your server will run in an isolated environment with:
|
|
352
|
+
- Automatic installation of dependencies specified in your FastMCP instance:
|
|
353
|
+
```python
|
|
354
|
+
mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
|
|
355
|
+
```
|
|
356
|
+
- Custom naming via `--name`:
|
|
357
|
+
```bash
|
|
358
|
+
fastmcp install server.py --name "My Analytics Server"
|
|
359
|
+
```
|
|
360
|
+
- Environment variable management:
|
|
361
|
+
```bash
|
|
362
|
+
# Set variables individually
|
|
363
|
+
fastmcp install server.py -e API_KEY=abc123 -e DB_URL=postgres://...
|
|
364
|
+
|
|
365
|
+
# Or load from a .env file
|
|
366
|
+
fastmcp install server.py -f .env
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Direct Execution (For Advanced Use Cases)
|
|
370
|
+
|
|
371
|
+
For advanced scenarios like custom deployments or running without Claude, you can execute your server directly:
|
|
348
372
|
|
|
349
|
-
|
|
350
|
-
fastmcp
|
|
373
|
+
```python
|
|
374
|
+
from fastmcp import FastMCP
|
|
375
|
+
|
|
376
|
+
mcp = FastMCP("My App")
|
|
377
|
+
|
|
378
|
+
if __name__ == "__main__":
|
|
379
|
+
mcp.run()
|
|
351
380
|
```
|
|
352
381
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
382
|
+
Run it with:
|
|
383
|
+
```bash
|
|
384
|
+
# Using the FastMCP CLI
|
|
385
|
+
fastmcp run server.py
|
|
357
386
|
|
|
358
|
-
|
|
387
|
+
# Or with Python/uv directly
|
|
388
|
+
python server.py
|
|
389
|
+
uv run python server.py
|
|
390
|
+
```
|
|
359
391
|
|
|
360
|
-
Claude Desktop runs servers in an isolated environment. Environment variables from your system are NOT automatically available to the server - you must explicitly provide them during installation:
|
|
361
392
|
|
|
362
|
-
|
|
363
|
-
# Single env var
|
|
364
|
-
fastmcp install server.py -e API_KEY=abc123
|
|
393
|
+
Note: When running directly, you are responsible for ensuring all dependencies are available in your environment. Any dependencies specified on the FastMCP instance are ignored.
|
|
365
394
|
|
|
366
|
-
|
|
367
|
-
|
|
395
|
+
Choose this method when you need:
|
|
396
|
+
- Custom deployment configurations
|
|
397
|
+
- Integration with other services
|
|
398
|
+
- Direct control over the server lifecycle
|
|
368
399
|
|
|
369
|
-
|
|
370
|
-
fastmcp install server.py -f .env
|
|
371
|
-
```
|
|
400
|
+
### Server Object Names
|
|
372
401
|
|
|
373
|
-
|
|
402
|
+
All FastMCP commands will look for a server object called `mcp`, `app`, or `server` in your file. If you have a different object name or multiple servers in one file, use the syntax `server.py:my_server`:
|
|
374
403
|
|
|
375
404
|
```bash
|
|
376
|
-
#
|
|
377
|
-
fastmcp
|
|
405
|
+
# Using a standard name
|
|
406
|
+
fastmcp run server.py
|
|
378
407
|
|
|
379
|
-
#
|
|
380
|
-
fastmcp
|
|
381
|
-
|
|
382
|
-
# Third install - FOO gets new value, others preserved
|
|
383
|
-
fastmcp install server.py -e FOO=newvalue
|
|
408
|
+
# Using a custom name
|
|
409
|
+
fastmcp run server.py:my_custom_server
|
|
384
410
|
```
|
|
385
411
|
|
|
386
412
|
## Examples
|
|
@@ -449,3 +475,85 @@ Schema:
|
|
|
449
475
|
|
|
450
476
|
What insights can you provide about the structure and relationships?"""
|
|
451
477
|
```
|
|
478
|
+
|
|
479
|
+
## Contributing
|
|
480
|
+
|
|
481
|
+
<details>
|
|
482
|
+
|
|
483
|
+
<summary><h3>Open Developer Guide</h3></summary>
|
|
484
|
+
|
|
485
|
+
### Prerequisites
|
|
486
|
+
|
|
487
|
+
FastMCP requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
|
|
488
|
+
|
|
489
|
+
### Installation
|
|
490
|
+
|
|
491
|
+
Create a fork of this repository, then clone it:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
git clone https://github.com/YouFancyUserYou/fastmcp.git
|
|
495
|
+
cd fastmcp
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Next, create a virtual environment and install FastMCP:
|
|
499
|
+
|
|
500
|
+
```bash
|
|
501
|
+
uv venv
|
|
502
|
+
source .venv/bin/activate
|
|
503
|
+
uv sync --frozen --all-extras --dev
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
### Testing
|
|
509
|
+
|
|
510
|
+
Please make sure to test any new functionality. Your tests should be simple and atomic and anticipate change rather than cement complex patterns.
|
|
511
|
+
|
|
512
|
+
Run tests from the root directory:
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
pytest -vv
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
### Formatting
|
|
520
|
+
|
|
521
|
+
FastMCP enforces a variety of required formats, which you can automatically enforce with pre-commit.
|
|
522
|
+
|
|
523
|
+
Install the pre-commit hooks:
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
pre-commit install
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
The hooks will now run on every commit (as well as on every PR). To run them manually:
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
pre-commit run --all-files
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### Opening a Pull Request
|
|
536
|
+
|
|
537
|
+
Fork the repository and create a new branch:
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
git checkout -b my-branch
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
Make your changes and commit them:
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
```bash
|
|
547
|
+
git add . && git commit -m "My changes"
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
Push your changes to your fork:
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
git push origin my-branch
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Feel free to reach out in a GitHub issue or discussion if you have any questions!
|
|
558
|
+
|
|
559
|
+
</details>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
fastmcp/__init__.py,sha256=Y5dHGBwyQPgNP5gzOyNIItefvMZ3vJLdom1oV8A1u_k,248
|
|
2
2
|
fastmcp/exceptions.py,sha256=K0rCgXsUVlws39hz98Tb4BBf_BzIql_zXFZgqbkNTiE,348
|
|
3
|
-
fastmcp/server.py,sha256=
|
|
3
|
+
fastmcp/server.py,sha256=V6BaciC5u9g_XzbvPkafjGO8OtEBPGy_KlV535Au0do,22234
|
|
4
4
|
fastmcp/cli/__init__.py,sha256=7hrwtCHX9nMd9qcz7R_JFSoqbL71fC35cBLXBS430mg,88
|
|
5
|
-
fastmcp/cli/claude.py,sha256=
|
|
6
|
-
fastmcp/cli/cli.py,sha256=
|
|
5
|
+
fastmcp/cli/claude.py,sha256=5SoVEsA_PnOyOe2bcItvfcCwuhfX6W99TP1nXahLIJE,4442
|
|
6
|
+
fastmcp/cli/cli.py,sha256=Ub2iNwnCVRO4TbC6Rr_1xOeTKnDN-9XE1z1O1yZatbg,11664
|
|
7
7
|
fastmcp/prompts/__init__.py,sha256=4BsMxoYolpoxg74xkkkzCFL8vvdkLVJ5cIPNs1ND1Jo,99
|
|
8
8
|
fastmcp/prompts/base.py,sha256=WaSsfyFSsUPUbcApkGy3Pm-Ne-Gk-5ZwU3efqRYn1mQ,4996
|
|
9
9
|
fastmcp/prompts/manager.py,sha256=EkexOB_N4QNtC-UlZmIcWcau91ceO2O1K4_kD75pA_A,1485
|
|
10
10
|
fastmcp/prompts/prompt_manager.py,sha256=5uR14gsi7l0YHwbxFH7N5b_ACHHRWyTtBAH3R0-G5rk,1129
|
|
11
11
|
fastmcp/resources/__init__.py,sha256=9QShop6ckX3Khh3BQLZNkB6R2ZhwskAcnh7-sIuX-W8,464
|
|
12
|
-
fastmcp/resources/base.py,sha256=
|
|
12
|
+
fastmcp/resources/base.py,sha256=inm2uhaE6KPQEsMd4SyDLbRIOjQrXahSn84RNT3Y6MY,1723
|
|
13
13
|
fastmcp/resources/resource_manager.py,sha256=b0PKpG-pKi7x2Yx-qaeknjv0mqL17zixSIYOz2V5G6o,3271
|
|
14
14
|
fastmcp/resources/templates.py,sha256=EmLlI-ddBBzSTAUiA6-knFnHCE3MPMW2ZoH9WswPKvI,2868
|
|
15
15
|
fastmcp/resources/types.py,sha256=ofE6bfeQQfPSmaWrLGDf3qjCP0kGjKmvupsHDYkSrj0,5658
|
|
@@ -19,8 +19,8 @@ fastmcp/tools/tool_manager.py,sha256=PT6XHcQWzhdC6kfdsJaddRn7VLps4nAs5FMG8l1j8Zc
|
|
|
19
19
|
fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
|
|
20
20
|
fastmcp/utilities/logging.py,sha256=VLJdNc0tIYoQZmpobehLUnWrQz7NXnuwSqrDlFt2RF0,738
|
|
21
21
|
fastmcp/utilities/types.py,sha256=jFlZMZsKrJg4NWc1vTBIILLoHpTVwSd-vxO7ycoRuig,1718
|
|
22
|
-
fastmcp-0.3.
|
|
23
|
-
fastmcp-0.3.
|
|
24
|
-
fastmcp-0.3.
|
|
25
|
-
fastmcp-0.3.
|
|
26
|
-
fastmcp-0.3.
|
|
22
|
+
fastmcp-0.3.4.dist-info/METADATA,sha256=-DqzP1SZTCU0qgtFZ7K3ABSaswQz9Q5ShWU-UwN_mkM,15260
|
|
23
|
+
fastmcp-0.3.4.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
24
|
+
fastmcp-0.3.4.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
|
|
25
|
+
fastmcp-0.3.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
26
|
+
fastmcp-0.3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|