fastmcp 0.3.0__tar.gz → 0.3.1__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.0 → fastmcp-0.3.1}/PKG-INFO +36 -14
- {fastmcp-0.3.0 → fastmcp-0.3.1}/README.md +35 -13
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/cli/cli.py +4 -4
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/server.py +5 -2
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/utilities/logging.py +6 -5
- {fastmcp-0.3.0 → fastmcp-0.3.1}/uv.lock +1 -1
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.github/ai-labeler.yml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.github/release.yml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.github/workflows/ai-labeler.yml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.github/workflows/lint.yml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.github/workflows/publish.yml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.github/workflows/run-tests.yml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.gitignore +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.pre-commit-config.yaml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/.python-version +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/LICENSE +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/docs/assets/demo-inspector.png +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/examples/desktop.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/examples/echo.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/examples/readme-quickstart.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/examples/screenshot.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/examples/simple_echo.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/pyproject.toml +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/cli/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/cli/claude.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/exceptions.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/prompts/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/prompts/base.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/prompts/manager.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/prompts/prompt_manager.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/resources/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/resources/base.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/resources/resource_manager.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/resources/templates.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/resources/types.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/tools/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/tools/base.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/tools/tool_manager.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/utilities/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/src/fastmcp/utilities/types.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/prompts/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/prompts/test_base.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/prompts/test_manager.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/resources/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/resources/test_file_resources.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/resources/test_function_resources.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/resources/test_resource_manager.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/resources/test_resource_template.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/resources/test_resources.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/servers/__init__.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/servers/test_file_server.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/test_server.py +0 -0
- {fastmcp-0.3.0 → fastmcp-0.3.1}/tests/test_tool_manager.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: fastmcp
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: A more ergonomic interface for MCP servers
|
|
5
5
|
Author: Jeremiah Lowin
|
|
6
6
|
License: Apache-2.0
|
|
@@ -22,7 +22,7 @@ Requires-Dist: ruff; extra == 'dev'
|
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
|
|
24
24
|
<!-- omit in toc -->
|
|
25
|
-
# FastMCP
|
|
25
|
+
# FastMCP 🚀
|
|
26
26
|
|
|
27
27
|
<div align="center">
|
|
28
28
|
|
|
@@ -30,17 +30,36 @@ Description-Content-Type: text/markdown
|
|
|
30
30
|
[](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
|
|
31
31
|
[](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
|
|
32
32
|
|
|
33
|
+
A fast, Pythonic way to build [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers
|
|
34
|
+
|
|
33
35
|
</div>
|
|
34
36
|
|
|
35
|
-
FastMCP
|
|
37
|
+
FastMCP makes building MCP servers simple and intuitive. Create tools, expose resources, and define prompts with clean, Pythonic code:
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
```python
|
|
40
|
+
from fastmcp import FastMCP
|
|
41
|
+
|
|
42
|
+
mcp = FastMCP("Demo 🚀")
|
|
43
|
+
|
|
44
|
+
@mcp.tool()
|
|
45
|
+
def add(a: int, b: int) -> int:
|
|
46
|
+
"""Add two numbers"""
|
|
47
|
+
return a + b
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
That's it! FastMCP handles all the complex protocol details and server management, so you can focus on building great tools. It's designed to be high-level and Pythonic - in most cases, decorating a function is all you need.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Key features:
|
|
54
|
+
* **Fast**: High-level interface means less code and faster development
|
|
55
|
+
* **Simple**: Build MCP servers with minimal boilerplate
|
|
56
|
+
* **Pythonic**: Feels natural to Python developers
|
|
57
|
+
* **Complete***: FastMCP aims to provide a full implementation of the core MCP specification
|
|
58
|
+
|
|
59
|
+
(\*emphasis on *aims*)
|
|
60
|
+
|
|
61
|
+
🚨 🚧 🏗️ *FastMCP is under active development, as is the MCP specification itself. Core features are working but some advanced capabilities are still in progress.*
|
|
38
62
|
|
|
39
|
-
Key features:
|
|
40
|
-
* **Intuitive**: Designed to feel familiar to Python developers, with powerful type hints and editor support
|
|
41
|
-
* **Simple**: Build compliant MCP servers with minimal boilerplate
|
|
42
|
-
* **Fast**: High-performance async implementation
|
|
43
|
-
* **Full-featured**: Complete implementation of the MCP specification
|
|
44
63
|
|
|
45
64
|
<!-- omit in toc -->
|
|
46
65
|
## Table of Contents
|
|
@@ -113,19 +132,21 @@ fastmcp install server.py
|
|
|
113
132
|
fastmcp dev server.py
|
|
114
133
|
```
|
|
115
134
|
|
|
116
|
-

|
|
117
136
|
|
|
118
137
|
## What is MCP?
|
|
119
138
|
|
|
120
139
|
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
|
|
121
140
|
|
|
122
|
-
- Expose data through **Resources** (like GET endpoints)
|
|
123
|
-
- Provide functionality through **Tools** (like POST endpoints)
|
|
141
|
+
- Expose data through **Resources** (think of these sort of like GET endpoints; they are used to load information into the LLM's context)
|
|
142
|
+
- Provide functionality through **Tools** (sort of like POST endpoints; they are used to execute code or otherwise produce a side effect)
|
|
124
143
|
- Define interaction patterns through **Prompts** (reusable templates for LLM interactions)
|
|
144
|
+
- And more!
|
|
145
|
+
|
|
146
|
+
There is a low-level [Python SDK](https://github.com/modelcontextprotocol/python-sdk) available for implementing the protocol directly, but FastMCP aims to make that easier by providing a high-level, Pythonic interface.
|
|
125
147
|
|
|
126
148
|
## Core Concepts
|
|
127
149
|
|
|
128
|
-
*Note: All code examples below assume you've created a FastMCP server instance called `mcp`.*
|
|
129
150
|
|
|
130
151
|
### Server
|
|
131
152
|
|
|
@@ -140,6 +161,7 @@ mcp = FastMCP("My App")
|
|
|
140
161
|
# Configure host/port for HTTP transport (optional)
|
|
141
162
|
mcp = FastMCP("My App", host="localhost", port=8000)
|
|
142
163
|
```
|
|
164
|
+
*Note: All of the following code examples assume you've created a FastMCP server instance called `mcp`, as shown above.*
|
|
143
165
|
|
|
144
166
|
### Resources
|
|
145
167
|
|
|
@@ -382,4 +404,4 @@ Schema:
|
|
|
382
404
|
{get_schema()}
|
|
383
405
|
|
|
384
406
|
What insights can you provide about the structure and relationships?"""
|
|
385
|
-
```
|
|
407
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- omit in toc -->
|
|
2
|
-
# FastMCP
|
|
2
|
+
# FastMCP 🚀
|
|
3
3
|
|
|
4
4
|
<div align="center">
|
|
5
5
|
|
|
@@ -7,17 +7,36 @@
|
|
|
7
7
|
[](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
|
|
8
8
|
[](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
|
|
9
9
|
|
|
10
|
+
A fast, Pythonic way to build [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers
|
|
11
|
+
|
|
10
12
|
</div>
|
|
11
13
|
|
|
12
|
-
FastMCP
|
|
14
|
+
FastMCP makes building MCP servers simple and intuitive. Create tools, expose resources, and define prompts with clean, Pythonic code:
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
```python
|
|
17
|
+
from fastmcp import FastMCP
|
|
18
|
+
|
|
19
|
+
mcp = FastMCP("Demo 🚀")
|
|
20
|
+
|
|
21
|
+
@mcp.tool()
|
|
22
|
+
def add(a: int, b: int) -> int:
|
|
23
|
+
"""Add two numbers"""
|
|
24
|
+
return a + b
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
That's it! FastMCP handles all the complex protocol details and server management, so you can focus on building great tools. It's designed to be high-level and Pythonic - in most cases, decorating a function is all you need.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Key features:
|
|
31
|
+
* **Fast**: High-level interface means less code and faster development
|
|
32
|
+
* **Simple**: Build MCP servers with minimal boilerplate
|
|
33
|
+
* **Pythonic**: Feels natural to Python developers
|
|
34
|
+
* **Complete***: FastMCP aims to provide a full implementation of the core MCP specification
|
|
35
|
+
|
|
36
|
+
(\*emphasis on *aims*)
|
|
37
|
+
|
|
38
|
+
🚨 🚧 🏗️ *FastMCP is under active development, as is the MCP specification itself. Core features are working but some advanced capabilities are still in progress.*
|
|
15
39
|
|
|
16
|
-
Key features:
|
|
17
|
-
* **Intuitive**: Designed to feel familiar to Python developers, with powerful type hints and editor support
|
|
18
|
-
* **Simple**: Build compliant MCP servers with minimal boilerplate
|
|
19
|
-
* **Fast**: High-performance async implementation
|
|
20
|
-
* **Full-featured**: Complete implementation of the MCP specification
|
|
21
40
|
|
|
22
41
|
<!-- omit in toc -->
|
|
23
42
|
## Table of Contents
|
|
@@ -90,19 +109,21 @@ fastmcp install server.py
|
|
|
90
109
|
fastmcp dev server.py
|
|
91
110
|
```
|
|
92
111
|
|
|
93
|
-

|
|
94
113
|
|
|
95
114
|
## What is MCP?
|
|
96
115
|
|
|
97
116
|
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
|
|
98
117
|
|
|
99
|
-
- Expose data through **Resources** (like GET endpoints)
|
|
100
|
-
- Provide functionality through **Tools** (like POST endpoints)
|
|
118
|
+
- Expose data through **Resources** (think of these sort of like GET endpoints; they are used to load information into the LLM's context)
|
|
119
|
+
- Provide functionality through **Tools** (sort of like POST endpoints; they are used to execute code or otherwise produce a side effect)
|
|
101
120
|
- Define interaction patterns through **Prompts** (reusable templates for LLM interactions)
|
|
121
|
+
- And more!
|
|
122
|
+
|
|
123
|
+
There is a low-level [Python SDK](https://github.com/modelcontextprotocol/python-sdk) available for implementing the protocol directly, but FastMCP aims to make that easier by providing a high-level, Pythonic interface.
|
|
102
124
|
|
|
103
125
|
## Core Concepts
|
|
104
126
|
|
|
105
|
-
*Note: All code examples below assume you've created a FastMCP server instance called `mcp`.*
|
|
106
127
|
|
|
107
128
|
### Server
|
|
108
129
|
|
|
@@ -117,6 +138,7 @@ mcp = FastMCP("My App")
|
|
|
117
138
|
# Configure host/port for HTTP transport (optional)
|
|
118
139
|
mcp = FastMCP("My App", host="localhost", port=8000)
|
|
119
140
|
```
|
|
141
|
+
*Note: All of the following code examples assume you've created a FastMCP server instance called `mcp`, as shown above.*
|
|
120
142
|
|
|
121
143
|
### Resources
|
|
122
144
|
|
|
@@ -359,4 +381,4 @@ Schema:
|
|
|
359
381
|
{get_schema()}
|
|
360
382
|
|
|
361
383
|
What insights can you provide about the structure and relationships?"""
|
|
362
|
-
```
|
|
384
|
+
```
|
|
@@ -13,7 +13,7 @@ from typing_extensions import Annotated
|
|
|
13
13
|
from ..utilities.logging import get_logger
|
|
14
14
|
from . import claude
|
|
15
15
|
|
|
16
|
-
logger = get_logger(
|
|
16
|
+
logger = get_logger("cli")
|
|
17
17
|
|
|
18
18
|
app = typer.Typer(
|
|
19
19
|
name="fastmcp",
|
|
@@ -263,7 +263,7 @@ def run(
|
|
|
263
263
|
|
|
264
264
|
except Exception as e:
|
|
265
265
|
logger.error(
|
|
266
|
-
"Failed to run server",
|
|
266
|
+
f"Failed to run server: {e}",
|
|
267
267
|
extra={
|
|
268
268
|
"file": str(file),
|
|
269
269
|
"error": str(e),
|
|
@@ -352,7 +352,7 @@ def install(
|
|
|
352
352
|
with_packages=with_packages,
|
|
353
353
|
force=force,
|
|
354
354
|
):
|
|
355
|
-
|
|
355
|
+
logger.info(f"Successfully installed {name} in Claude app")
|
|
356
356
|
else:
|
|
357
|
-
|
|
357
|
+
logger.error(f"Failed to install {name} in Claude app")
|
|
358
358
|
sys.exit(1)
|
|
@@ -53,7 +53,11 @@ class Settings(BaseSettings):
|
|
|
53
53
|
For example, FASTMCP_DEBUG=true will set debug=True.
|
|
54
54
|
"""
|
|
55
55
|
|
|
56
|
-
model_config: SettingsConfigDict = SettingsConfigDict(
|
|
56
|
+
model_config: SettingsConfigDict = SettingsConfigDict(
|
|
57
|
+
env_prefix="FASTMCP_",
|
|
58
|
+
env_file=".env",
|
|
59
|
+
extra="ignore",
|
|
60
|
+
)
|
|
57
61
|
|
|
58
62
|
# Server settings
|
|
59
63
|
debug: bool = False
|
|
@@ -400,7 +404,6 @@ class FastMCP:
|
|
|
400
404
|
async def run_stdio_async(self) -> None:
|
|
401
405
|
"""Run the server using stdio transport."""
|
|
402
406
|
async with stdio_server() as (read_stream, write_stream):
|
|
403
|
-
logger.info(f'Starting "{self.name}"...')
|
|
404
407
|
await self._mcp_server.run(
|
|
405
408
|
read_stream,
|
|
406
409
|
write_stream,
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from typing import Literal
|
|
5
5
|
|
|
6
|
+
from rich.logging import RichHandler
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
def get_logger(name: str) -> logging.Logger:
|
|
8
10
|
"""Get a logger nested under FastMCP namespace.
|
|
9
11
|
|
|
10
12
|
Args:
|
|
11
|
-
name:
|
|
13
|
+
name: the name of the logger, which will be prefixed with 'FastMCP.'
|
|
12
14
|
|
|
13
15
|
Returns:
|
|
14
|
-
|
|
16
|
+
a configured logger instance
|
|
15
17
|
"""
|
|
16
18
|
return logging.getLogger(f"FastMCP.{name}")
|
|
17
19
|
|
|
@@ -22,9 +24,8 @@ def configure_logging(
|
|
|
22
24
|
"""Configure logging for FastMCP.
|
|
23
25
|
|
|
24
26
|
Args:
|
|
25
|
-
level:
|
|
27
|
+
level: the log level to use
|
|
26
28
|
"""
|
|
27
29
|
logging.basicConfig(
|
|
28
|
-
level=level,
|
|
29
|
-
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
30
|
+
level=level, format="%(message)s", handlers=[RichHandler(rich_tracebacks=True)]
|
|
30
31
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|