fastmcp 0.3.4__tar.gz → 0.4.0__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.4.0/.github/ai-labeler.yml +87 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/.github/workflows/ai-labeler.yml +1 -0
- fastmcp-0.3.4/.github/workflows/lint.yml → fastmcp-0.4.0/.github/workflows/run-static.yml +6 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/.github/workflows/run-tests.yml +12 -5
- {fastmcp-0.3.4 → fastmcp-0.4.0}/.gitignore +1 -1
- fastmcp-0.4.0/LICENSE +21 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/PKG-INFO +37 -9
- {fastmcp-0.3.4 → fastmcp-0.4.0}/README.md +26 -8
- fastmcp-0.4.0/Windows_Notes.md +58 -0
- fastmcp-0.4.0/examples/complex_inputs.py +28 -0
- fastmcp-0.4.0/examples/memory.py +346 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/pyproject.toml +17 -5
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/cli/cli.py +56 -9
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/exceptions.py +4 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/prompts/base.py +29 -13
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/resources/base.py +5 -13
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/resources/templates.py +1 -1
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/resources/types.py +10 -1
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/server.py +7 -6
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/tools/base.py +19 -15
- fastmcp-0.4.0/src/fastmcp/utilities/func_metadata.py +205 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/utilities/logging.py +4 -1
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/utilities/types.py +3 -1
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/prompts/test_base.py +7 -6
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/resources/test_file_resources.py +15 -9
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/resources/test_function_resources.py +9 -8
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/resources/test_resource_manager.py +10 -9
- fastmcp-0.4.0/tests/resources/test_resource_template.py +181 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/resources/test_resources.py +9 -8
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/servers/test_file_server.py +4 -2
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/test_cli.py +100 -15
- fastmcp-0.4.0/tests/test_func_metadata.py +361 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/test_server.py +143 -80
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/test_tool_manager.py +69 -1
- {fastmcp-0.3.4 → fastmcp-0.4.0}/uv.lock +46 -1
- fastmcp-0.3.4/.github/ai-labeler.yml +0 -2
- fastmcp-0.3.4/LICENSE +0 -201
- fastmcp-0.3.4/tests/resources/test_resource_template.py +0 -238
- {fastmcp-0.3.4 → fastmcp-0.4.0}/.github/release.yml +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/.github/workflows/publish.yml +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/.pre-commit-config.yaml +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/.python-version +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/docs/assets/demo-inspector.png +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/examples/desktop.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/examples/echo.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/examples/readme-quickstart.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/examples/screenshot.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/examples/simple_echo.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/examples/text_me.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/cli/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/cli/claude.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/prompts/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/prompts/manager.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/prompts/prompt_manager.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/resources/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/resources/resource_manager.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/tools/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/tools/tool_manager.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/src/fastmcp/utilities/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/prompts/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/prompts/test_manager.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/resources/__init__.py +0 -0
- {fastmcp-0.3.4 → fastmcp-0.4.0}/tests/servers/__init__.py +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
instructions: |
|
|
2
|
+
Apply the minimal set of labels that accurately characterize the issue/PR:
|
|
3
|
+
- Use at most 1-2 labels unless there's a compelling reason for more. It's ok to use no labels.
|
|
4
|
+
- Prefer specific labels (bug, feature) over generic ones (question, help wanted)
|
|
5
|
+
- For PRs that fix bugs, use 'bug' not 'enhancement'
|
|
6
|
+
- Never combine: bug + enhancement, feature + enhancement. For these labels, only choose the most relevant one.
|
|
7
|
+
- Reserve 'question' and 'help wanted' for when they're the primary characteristic
|
|
8
|
+
|
|
9
|
+
labels:
|
|
10
|
+
- bug:
|
|
11
|
+
description: "Something isn't working as expected"
|
|
12
|
+
instructions: |
|
|
13
|
+
Apply when describing or fixing unexpected behavior:
|
|
14
|
+
- Issues: Clear error messages or unexpected outcomes
|
|
15
|
+
- PRs: Standalone fixes for broken functionality or closing bug reports.
|
|
16
|
+
Don't apply bug unless the issue or PR is predominantly about a specific bug.
|
|
17
|
+
|
|
18
|
+
- documentation:
|
|
19
|
+
description: "Improvements or additions to documentation"
|
|
20
|
+
instructions: |
|
|
21
|
+
Apply only when documentation is the primary focus:
|
|
22
|
+
- README updates
|
|
23
|
+
- Code comments and docstrings
|
|
24
|
+
- API documentation
|
|
25
|
+
- Usage examples
|
|
26
|
+
Don't apply for minor doc updates alongside code changes
|
|
27
|
+
|
|
28
|
+
- enhancement:
|
|
29
|
+
description: "Improvements to existing features"
|
|
30
|
+
instructions: |
|
|
31
|
+
Apply only for improvements to existing functionality:
|
|
32
|
+
- Performance improvements
|
|
33
|
+
- UI/UX improvements
|
|
34
|
+
- Expanded capabilities of existing features
|
|
35
|
+
Don't apply to:
|
|
36
|
+
- Bug fixes
|
|
37
|
+
- New features
|
|
38
|
+
- Minor tweaks
|
|
39
|
+
|
|
40
|
+
- feature:
|
|
41
|
+
description: "New functionality"
|
|
42
|
+
instructions: |
|
|
43
|
+
Apply only for net-new functionality:
|
|
44
|
+
- New API endpoints
|
|
45
|
+
- New commands or tools
|
|
46
|
+
- New user-facing capabilities
|
|
47
|
+
Don't apply to:
|
|
48
|
+
- Improvements to existing features (use enhancement)
|
|
49
|
+
- Bug fixes
|
|
50
|
+
|
|
51
|
+
- good first issue:
|
|
52
|
+
description: "Good for newcomers"
|
|
53
|
+
instructions: |
|
|
54
|
+
Apply very selectively to issues that are:
|
|
55
|
+
- Small in scope
|
|
56
|
+
- Well-documented
|
|
57
|
+
- Require minimal context
|
|
58
|
+
- Have clear success criteria
|
|
59
|
+
Don't apply if the task requires significant background knowledge
|
|
60
|
+
|
|
61
|
+
- help wanted:
|
|
62
|
+
description: "Extra attention is needed"
|
|
63
|
+
instructions: |
|
|
64
|
+
Apply only when it's the primary characteristic:
|
|
65
|
+
- Issue needs external expertise
|
|
66
|
+
- Current maintainers can't address it
|
|
67
|
+
- Additional contributors would be valuable
|
|
68
|
+
Don't apply just because an issue is open or needs work
|
|
69
|
+
|
|
70
|
+
- question:
|
|
71
|
+
description: "Further information is requested"
|
|
72
|
+
instructions: |
|
|
73
|
+
Apply only when the primary purpose is seeking information:
|
|
74
|
+
- Clarification needed before work can begin
|
|
75
|
+
- Architectural discussions
|
|
76
|
+
- Implementation strategy questions
|
|
77
|
+
Don't apply to:
|
|
78
|
+
- Bug reports that need more details
|
|
79
|
+
- Feature requests that need refinement
|
|
80
|
+
|
|
81
|
+
# These files will be included in the context if they exist
|
|
82
|
+
context-files:
|
|
83
|
+
- README.md
|
|
84
|
+
- CONTRIBUTING.md
|
|
85
|
+
- CODE_OF_CONDUCT.md
|
|
86
|
+
- .github/ISSUE_TEMPLATE/bug_report.md
|
|
87
|
+
- .github/ISSUE_TEMPLATE/feature_request.md
|
|
@@ -12,12 +12,14 @@ on:
|
|
|
12
12
|
- "tests/**"
|
|
13
13
|
- "uv.lock"
|
|
14
14
|
- "pyproject.toml"
|
|
15
|
+
- ".github/workflows/**"
|
|
15
16
|
pull_request:
|
|
16
17
|
paths:
|
|
17
18
|
- "src/**"
|
|
18
19
|
- "tests/**"
|
|
19
20
|
- "uv.lock"
|
|
20
21
|
- "pyproject.toml"
|
|
22
|
+
- ".github/workflows/**"
|
|
21
23
|
|
|
22
24
|
workflow_dispatch:
|
|
23
25
|
|
|
@@ -26,8 +28,13 @@ permissions:
|
|
|
26
28
|
|
|
27
29
|
jobs:
|
|
28
30
|
run_tests:
|
|
29
|
-
name: Run tests
|
|
30
|
-
runs-on:
|
|
31
|
+
name: "Run tests: Python ${{ matrix.python-version }} on ${{ matrix.os }}"
|
|
32
|
+
runs-on: ${{ matrix.os }}
|
|
33
|
+
strategy:
|
|
34
|
+
matrix:
|
|
35
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
36
|
+
python-version: ["3.10"]
|
|
37
|
+
fail-fast: false
|
|
31
38
|
|
|
32
39
|
steps:
|
|
33
40
|
- uses: actions/checkout@v4
|
|
@@ -35,11 +42,11 @@ jobs:
|
|
|
35
42
|
- name: Install uv
|
|
36
43
|
uses: astral-sh/setup-uv@v4
|
|
37
44
|
|
|
38
|
-
- name: Set up Python
|
|
39
|
-
run: uv python install
|
|
45
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
46
|
+
run: uv python install ${{ matrix.python-version }}
|
|
40
47
|
|
|
41
48
|
- name: Install FastMCP
|
|
42
|
-
run: uv sync --extra
|
|
49
|
+
run: uv sync --extra tests
|
|
43
50
|
|
|
44
51
|
- name: Run tests
|
|
45
52
|
run: uv run pytest -vv
|
fastmcp-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jeremiah Lowin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: fastmcp
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A more ergonomic interface for MCP servers
|
|
5
5
|
Author: Jeremiah Lowin
|
|
6
6
|
License: Apache-2.0
|
|
@@ -16,10 +16,20 @@ Requires-Dist: copychat>=0.5.2; extra == 'dev'
|
|
|
16
16
|
Requires-Dist: ipython>=8.12.3; extra == 'dev'
|
|
17
17
|
Requires-Dist: pdbpp>=0.10.3; extra == 'dev'
|
|
18
18
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
19
|
+
Requires-Dist: pyright>=1.1.389; extra == 'dev'
|
|
19
20
|
Requires-Dist: pytest-asyncio>=0.23.5; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest-flakefinder; extra == 'dev'
|
|
20
22
|
Requires-Dist: pytest-xdist>=3.6.1; extra == 'dev'
|
|
21
23
|
Requires-Dist: pytest>=8.3.3; extra == 'dev'
|
|
22
24
|
Requires-Dist: ruff; extra == 'dev'
|
|
25
|
+
Provides-Extra: tests
|
|
26
|
+
Requires-Dist: pre-commit; extra == 'tests'
|
|
27
|
+
Requires-Dist: pyright>=1.1.389; extra == 'tests'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23.5; extra == 'tests'
|
|
29
|
+
Requires-Dist: pytest-flakefinder; extra == 'tests'
|
|
30
|
+
Requires-Dist: pytest-xdist>=3.6.1; extra == 'tests'
|
|
31
|
+
Requires-Dist: pytest>=8.3.3; extra == 'tests'
|
|
32
|
+
Requires-Dist: ruff; extra == 'tests'
|
|
23
33
|
Description-Content-Type: text/markdown
|
|
24
34
|
|
|
25
35
|
<!-- omit in toc -->
|
|
@@ -236,6 +246,27 @@ async def fetch_weather(city: str) -> str:
|
|
|
236
246
|
return response.text
|
|
237
247
|
```
|
|
238
248
|
|
|
249
|
+
Complex input handling example:
|
|
250
|
+
```python
|
|
251
|
+
from pydantic import BaseModel, Field
|
|
252
|
+
from typing import Annotated
|
|
253
|
+
|
|
254
|
+
class ShrimpTank(BaseModel):
|
|
255
|
+
class Shrimp(BaseModel):
|
|
256
|
+
name: Annotated[str, Field(max_length=10)]
|
|
257
|
+
|
|
258
|
+
shrimp: list[Shrimp]
|
|
259
|
+
|
|
260
|
+
@mcp.tool()
|
|
261
|
+
def name_shrimp(
|
|
262
|
+
tank: ShrimpTank,
|
|
263
|
+
# You can use pydantic Field in function signatures for validation.
|
|
264
|
+
extra_names: Annotated[list[str], Field(max_length=10)],
|
|
265
|
+
) -> list[str]:
|
|
266
|
+
"""List all shrimp names in the tank"""
|
|
267
|
+
return [shrimp.name for shrimp in tank.shrimp] + extra_names
|
|
268
|
+
```
|
|
269
|
+
|
|
239
270
|
### Prompts
|
|
240
271
|
|
|
241
272
|
Prompts are reusable templates that help LLMs interact with your server effectively. They're like "best practices" encoded into your server. A prompt can be as simple as a string:
|
|
@@ -488,23 +519,20 @@ FastMCP requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
|
|
|
488
519
|
|
|
489
520
|
### Installation
|
|
490
521
|
|
|
491
|
-
|
|
522
|
+
For development, we recommend installing FastMCP with development dependencies, which includes various utilities the maintainers find useful.
|
|
492
523
|
|
|
493
524
|
```bash
|
|
494
|
-
git clone https://github.com/
|
|
525
|
+
git clone https://github.com/jlowin/fastmcp.git
|
|
495
526
|
cd fastmcp
|
|
527
|
+
uv sync --frozen --extra dev
|
|
496
528
|
```
|
|
497
529
|
|
|
498
|
-
|
|
530
|
+
For running tests only (e.g., in CI), you only need the testing dependencies:
|
|
499
531
|
|
|
500
532
|
```bash
|
|
501
|
-
uv
|
|
502
|
-
source .venv/bin/activate
|
|
503
|
-
uv sync --frozen --all-extras --dev
|
|
533
|
+
uv sync --frozen --extra tests
|
|
504
534
|
```
|
|
505
535
|
|
|
506
|
-
|
|
507
|
-
|
|
508
536
|
### Testing
|
|
509
537
|
|
|
510
538
|
Please make sure to test any new functionality. Your tests should be simple and atomic and anticipate change rather than cement complex patterns.
|
|
@@ -212,6 +212,27 @@ async def fetch_weather(city: str) -> str:
|
|
|
212
212
|
return response.text
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
+
Complex input handling example:
|
|
216
|
+
```python
|
|
217
|
+
from pydantic import BaseModel, Field
|
|
218
|
+
from typing import Annotated
|
|
219
|
+
|
|
220
|
+
class ShrimpTank(BaseModel):
|
|
221
|
+
class Shrimp(BaseModel):
|
|
222
|
+
name: Annotated[str, Field(max_length=10)]
|
|
223
|
+
|
|
224
|
+
shrimp: list[Shrimp]
|
|
225
|
+
|
|
226
|
+
@mcp.tool()
|
|
227
|
+
def name_shrimp(
|
|
228
|
+
tank: ShrimpTank,
|
|
229
|
+
# You can use pydantic Field in function signatures for validation.
|
|
230
|
+
extra_names: Annotated[list[str], Field(max_length=10)],
|
|
231
|
+
) -> list[str]:
|
|
232
|
+
"""List all shrimp names in the tank"""
|
|
233
|
+
return [shrimp.name for shrimp in tank.shrimp] + extra_names
|
|
234
|
+
```
|
|
235
|
+
|
|
215
236
|
### Prompts
|
|
216
237
|
|
|
217
238
|
Prompts are reusable templates that help LLMs interact with your server effectively. They're like "best practices" encoded into your server. A prompt can be as simple as a string:
|
|
@@ -464,23 +485,20 @@ FastMCP requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
|
|
|
464
485
|
|
|
465
486
|
### Installation
|
|
466
487
|
|
|
467
|
-
|
|
488
|
+
For development, we recommend installing FastMCP with development dependencies, which includes various utilities the maintainers find useful.
|
|
468
489
|
|
|
469
490
|
```bash
|
|
470
|
-
git clone https://github.com/
|
|
491
|
+
git clone https://github.com/jlowin/fastmcp.git
|
|
471
492
|
cd fastmcp
|
|
493
|
+
uv sync --frozen --extra dev
|
|
472
494
|
```
|
|
473
495
|
|
|
474
|
-
|
|
496
|
+
For running tests only (e.g., in CI), you only need the testing dependencies:
|
|
475
497
|
|
|
476
498
|
```bash
|
|
477
|
-
uv
|
|
478
|
-
source .venv/bin/activate
|
|
479
|
-
uv sync --frozen --all-extras --dev
|
|
499
|
+
uv sync --frozen --extra tests
|
|
480
500
|
```
|
|
481
501
|
|
|
482
|
-
|
|
483
|
-
|
|
484
502
|
### Testing
|
|
485
503
|
|
|
486
504
|
Please make sure to test any new functionality. Your tests should be simple and atomic and anticipate change rather than cement complex patterns.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Getting your development environment set up properly
|
|
2
|
+
To get your environment up and running properly, you'll need a slightly different set of commands that are windows specific:
|
|
3
|
+
```bash
|
|
4
|
+
uv venv
|
|
5
|
+
.venv\Scripts\activate
|
|
6
|
+
uv pip install -e ".[dev]"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
This will install the package in editable mode, and install the development dependencies.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Fixing `AttributeError: module 'collections' has no attribute 'Callable'`
|
|
13
|
+
- open `.venv\Lib\site-packages\pyreadline\py3k_compat.py`
|
|
14
|
+
- change `return isinstance(x, collections.Callable)` to
|
|
15
|
+
```
|
|
16
|
+
from collections.abc import Callable
|
|
17
|
+
return isinstance(x, Callable)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
# Helpful notes
|
|
21
|
+
For developing FastMCP
|
|
22
|
+
## Install local development version of FastMCP into a local FastMCP project server
|
|
23
|
+
- ensure
|
|
24
|
+
- change directories to your FastMCP Server location so you can install it in your .venv
|
|
25
|
+
- run `.venv\Scripts\activate` to activate your virtual environment
|
|
26
|
+
- Then run a series of commands to uninstall the old version and install the new
|
|
27
|
+
```bash
|
|
28
|
+
# First uninstall
|
|
29
|
+
uv pip uninstall fastmcp
|
|
30
|
+
|
|
31
|
+
# Clean any build artifacts in your fastmcp directory
|
|
32
|
+
cd C:\path\to\fastmcp
|
|
33
|
+
del /s /q *.egg-info
|
|
34
|
+
|
|
35
|
+
# Then reinstall in your weather project
|
|
36
|
+
cd C:\path\to\new\fastmcp_server
|
|
37
|
+
uv pip install --no-cache-dir -e C:\Users\justj\PycharmProjects\fastmcp
|
|
38
|
+
|
|
39
|
+
# Check that it installed properly and has the correct git hash
|
|
40
|
+
pip show fastmcp
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Running the FastMCP server with Inspector
|
|
44
|
+
MCP comes with a node.js application called Inspector that can be used to inspect the FastMCP server. To run the inspector, you'll need to install node.js and npm. Then you can run the following commands:
|
|
45
|
+
```bash
|
|
46
|
+
fastmcp dev server.py
|
|
47
|
+
```
|
|
48
|
+
This will launch a web app on http://localhost:5173/ that you can use to inspect the FastMCP server.
|
|
49
|
+
|
|
50
|
+
## If you start development before creating a fork - your get out of jail free card
|
|
51
|
+
- Add your fork as a new remote to your local repository `git remote add fork git@github.com:YOUR-USERNAME/REPOSITORY-NAME.git`
|
|
52
|
+
- This will add your repo, short named 'fork', as a remote to your local repository
|
|
53
|
+
- Verify that it was added correctly by running `git remote -v`
|
|
54
|
+
- Commit your changes
|
|
55
|
+
- Push your changes to your fork `git push fork <branch>`
|
|
56
|
+
- Create your pull request on GitHub
|
|
57
|
+
|
|
58
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FastMCP Complex inputs Example
|
|
3
|
+
|
|
4
|
+
Demonstrates validation via pydantic with complex models.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, Field
|
|
8
|
+
from typing import Annotated
|
|
9
|
+
from fastmcp.server import FastMCP
|
|
10
|
+
|
|
11
|
+
mcp = FastMCP("Shrimp Tank")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ShrimpTank(BaseModel):
|
|
15
|
+
class Shrimp(BaseModel):
|
|
16
|
+
name: Annotated[str, Field(max_length=10)]
|
|
17
|
+
|
|
18
|
+
shrimp: list[Shrimp]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@mcp.tool()
|
|
22
|
+
def name_shrimp(
|
|
23
|
+
tank: ShrimpTank,
|
|
24
|
+
# You can use pydantic Field in function signatures for validation.
|
|
25
|
+
extra_names: Annotated[list[str], Field(max_length=10)],
|
|
26
|
+
) -> list[str]:
|
|
27
|
+
"""List all shrimp names in the tank"""
|
|
28
|
+
return [shrimp.name for shrimp in tank.shrimp] + extra_names
|