fastmcp 0.3.2__tar.gz → 0.3.4__tar.gz
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-0.3.2 → fastmcp-0.3.4}/.github/workflows/run-tests.yml +11 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.gitignore +1 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/PKG-INFO +176 -68
- {fastmcp-0.3.2 → fastmcp-0.3.4}/README.md +175 -67
- {fastmcp-0.3.2 → fastmcp-0.3.4}/examples/screenshot.py +8 -8
- fastmcp-0.3.4/examples/text_me.py +71 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/cli/claude.py +29 -8
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/cli/cli.py +15 -12
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/resources/base.py +12 -19
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/server.py +7 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/test_cli.py +118 -42
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.github/ai-labeler.yml +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.github/release.yml +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.github/workflows/ai-labeler.yml +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.github/workflows/lint.yml +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.github/workflows/publish.yml +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.pre-commit-config.yaml +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/.python-version +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/LICENSE +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/docs/assets/demo-inspector.png +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/examples/desktop.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/examples/echo.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/examples/readme-quickstart.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/examples/simple_echo.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/pyproject.toml +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/cli/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/exceptions.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/prompts/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/prompts/base.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/prompts/manager.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/prompts/prompt_manager.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/resources/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/resources/resource_manager.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/resources/templates.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/resources/types.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/tools/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/tools/base.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/tools/tool_manager.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/utilities/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/utilities/logging.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/src/fastmcp/utilities/types.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/prompts/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/prompts/test_base.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/prompts/test_manager.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/resources/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/resources/test_file_resources.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/resources/test_function_resources.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/resources/test_resource_manager.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/resources/test_resource_template.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/resources/test_resources.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/servers/__init__.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/servers/test_file_server.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/test_server.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/tests/test_tool_manager.py +0 -0
- {fastmcp-0.3.2 → fastmcp-0.3.4}/uv.lock +0 -0
|
@@ -7,7 +7,18 @@ env:
|
|
|
7
7
|
on:
|
|
8
8
|
push:
|
|
9
9
|
branches: ["main"]
|
|
10
|
+
paths:
|
|
11
|
+
- "src/**"
|
|
12
|
+
- "tests/**"
|
|
13
|
+
- "uv.lock"
|
|
14
|
+
- "pyproject.toml"
|
|
10
15
|
pull_request:
|
|
16
|
+
paths:
|
|
17
|
+
- "src/**"
|
|
18
|
+
- "tests/**"
|
|
19
|
+
- "uv.lock"
|
|
20
|
+
- "pyproject.toml"
|
|
21
|
+
|
|
11
22
|
workflow_dispatch:
|
|
12
23
|
|
|
13
24
|
permissions:
|
|
@@ -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>
|