fastmcp 0.3.1__tar.gz → 0.3.3__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.
Files changed (57) hide show
  1. {fastmcp-0.3.1 → fastmcp-0.3.3}/.github/workflows/run-tests.yml +11 -0
  2. {fastmcp-0.3.1 → fastmcp-0.3.3}/.gitignore +1 -0
  3. {fastmcp-0.3.1 → fastmcp-0.3.3}/PKG-INFO +197 -42
  4. {fastmcp-0.3.1 → fastmcp-0.3.3}/README.md +195 -41
  5. {fastmcp-0.3.1 → fastmcp-0.3.3}/examples/screenshot.py +8 -8
  6. fastmcp-0.3.3/examples/text_me.py +71 -0
  7. {fastmcp-0.3.1 → fastmcp-0.3.3}/pyproject.toml +1 -0
  8. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/cli/claude.py +33 -23
  9. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/cli/cli.py +68 -21
  10. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/server.py +7 -0
  11. fastmcp-0.3.3/tests/test_cli.py +291 -0
  12. {fastmcp-0.3.1 → fastmcp-0.3.3}/uv.lock +3 -1
  13. {fastmcp-0.3.1 → fastmcp-0.3.3}/.github/ai-labeler.yml +0 -0
  14. {fastmcp-0.3.1 → fastmcp-0.3.3}/.github/release.yml +0 -0
  15. {fastmcp-0.3.1 → fastmcp-0.3.3}/.github/workflows/ai-labeler.yml +0 -0
  16. {fastmcp-0.3.1 → fastmcp-0.3.3}/.github/workflows/lint.yml +0 -0
  17. {fastmcp-0.3.1 → fastmcp-0.3.3}/.github/workflows/publish.yml +0 -0
  18. {fastmcp-0.3.1 → fastmcp-0.3.3}/.pre-commit-config.yaml +0 -0
  19. {fastmcp-0.3.1 → fastmcp-0.3.3}/.python-version +0 -0
  20. {fastmcp-0.3.1 → fastmcp-0.3.3}/LICENSE +0 -0
  21. {fastmcp-0.3.1 → fastmcp-0.3.3}/docs/assets/demo-inspector.png +0 -0
  22. {fastmcp-0.3.1 → fastmcp-0.3.3}/examples/desktop.py +0 -0
  23. {fastmcp-0.3.1 → fastmcp-0.3.3}/examples/echo.py +0 -0
  24. {fastmcp-0.3.1 → fastmcp-0.3.3}/examples/readme-quickstart.py +0 -0
  25. {fastmcp-0.3.1 → fastmcp-0.3.3}/examples/simple_echo.py +0 -0
  26. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/__init__.py +0 -0
  27. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/cli/__init__.py +0 -0
  28. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/exceptions.py +0 -0
  29. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/prompts/__init__.py +0 -0
  30. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/prompts/base.py +0 -0
  31. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/prompts/manager.py +0 -0
  32. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/prompts/prompt_manager.py +0 -0
  33. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/resources/__init__.py +0 -0
  34. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/resources/base.py +0 -0
  35. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/resources/resource_manager.py +0 -0
  36. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/resources/templates.py +0 -0
  37. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/resources/types.py +0 -0
  38. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/tools/__init__.py +0 -0
  39. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/tools/base.py +0 -0
  40. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/tools/tool_manager.py +0 -0
  41. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/utilities/__init__.py +0 -0
  42. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/utilities/logging.py +0 -0
  43. {fastmcp-0.3.1 → fastmcp-0.3.3}/src/fastmcp/utilities/types.py +0 -0
  44. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/__init__.py +0 -0
  45. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/prompts/__init__.py +0 -0
  46. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/prompts/test_base.py +0 -0
  47. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/prompts/test_manager.py +0 -0
  48. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/resources/__init__.py +0 -0
  49. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/resources/test_file_resources.py +0 -0
  50. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/resources/test_function_resources.py +0 -0
  51. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/resources/test_resource_manager.py +0 -0
  52. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/resources/test_resource_template.py +0 -0
  53. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/resources/test_resources.py +0 -0
  54. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/servers/__init__.py +0 -0
  55. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/servers/test_file_server.py +0 -0
  56. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/test_server.py +0 -0
  57. {fastmcp-0.3.1 → fastmcp-0.3.3}/tests/test_tool_manager.py +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:
@@ -9,6 +9,7 @@ wheels/
9
9
  # Virtual environments
10
10
  .venv
11
11
  .DS_Store
12
+ .env
12
13
 
13
14
 
14
15
  src/fastmcp/_version.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fastmcp
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: A more ergonomic interface for MCP servers
5
5
  Author: Jeremiah Lowin
6
6
  License: Apache-2.0
@@ -9,6 +9,7 @@ Requires-Dist: httpx>=0.26.0
9
9
  Requires-Dist: mcp<2.0.0,>=1.0.0
10
10
  Requires-Dist: pydantic-settings>=2.6.1
11
11
  Requires-Dist: pydantic<3.0.0,>=2.5.3
12
+ Requires-Dist: python-dotenv>=1.0.1
12
13
  Requires-Dist: typer>=0.9.0
13
14
  Provides-Extra: dev
14
15
  Requires-Dist: copychat>=0.5.2; extra == 'dev'
@@ -26,28 +27,39 @@ Description-Content-Type: text/markdown
26
27
 
27
28
  <div align="center">
28
29
 
30
+ <strong>The fast, Pythonic way to build MCP servers.</strong>
31
+
29
32
  [![PyPI - Version](https://img.shields.io/pypi/v/fastmcp.svg)](https://pypi.org/project/fastmcp)
30
33
  [![Tests](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml/badge.svg)](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
31
34
  [![License](https://img.shields.io/github/license/jlowin/fastmcp.svg)](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
32
35
 
33
- A fast, Pythonic way to build [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers
34
36
 
35
37
  </div>
36
38
 
37
- FastMCP makes building MCP servers simple and intuitive. Create tools, expose resources, and define prompts with clean, Pythonic code:
39
+ [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers are a new, standardized way to provide context and tools to your LLMs, and FastMCP makes building MCP servers simple and intuitive. Create tools, expose resources, and define prompts with clean, Pythonic code:
38
40
 
39
41
  ```python
42
+ # demo.py
43
+
40
44
  from fastmcp import FastMCP
41
45
 
46
+
42
47
  mcp = FastMCP("Demo 🚀")
43
48
 
49
+
44
50
  @mcp.tool()
45
51
  def add(a: int, b: int) -> int:
46
52
  """Add two numbers"""
47
53
  return a + b
48
54
  ```
49
55
 
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.
56
+ That's it! Give Claude access to the server by running:
57
+
58
+ ```bash
59
+ fastmcp install demo.py
60
+ ```
61
+
62
+ 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
63
 
52
64
 
53
65
  ### Key features:
@@ -74,22 +86,33 @@ That's it! FastMCP handles all the complex protocol details and server managemen
74
86
  - [Prompts](#prompts)
75
87
  - [Images](#images)
76
88
  - [Context](#context)
77
- - [Deployment](#deployment)
78
- - [Development](#development)
79
- - [Claude Desktop](#claude-desktop)
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)
80
94
  - [Examples](#examples)
81
95
  - [Echo Server](#echo-server)
82
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)
83
103
 
84
104
  ## Installation
85
105
 
106
+ We strongly recommend installing FastMCP with [uv](https://docs.astral.sh/uv/), as it is required for deploying servers:
107
+
86
108
  ```bash
87
- # We strongly recommend installing with uv
88
- brew install uv # on macOS
89
109
  uv pip install fastmcp
90
110
  ```
91
111
 
92
- Or with pip:
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
+
93
116
  ```bash
94
117
  pip install fastmcp
95
118
  ```
@@ -160,8 +183,10 @@ mcp = FastMCP("My App")
160
183
 
161
184
  # Configure host/port for HTTP transport (optional)
162
185
  mcp = FastMCP("My App", host="localhost", port=8000)
186
+
187
+ # Specify dependencies for deployment and development
188
+ mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
163
189
  ```
164
- *Note: All of the following code examples assume you've created a FastMCP server instance called `mcp`, as shown above.*
165
190
 
166
191
  ### Resources
167
192
 
@@ -290,59 +315,107 @@ The Context object provides:
290
315
  - Resource access through `read_resource()`
291
316
  - Request metadata via `request_id` and `client_id`
292
317
 
293
- ## Deployment
294
-
295
- The FastMCP CLI helps you develop and deploy MCP servers.
318
+ ## Running Your Server
296
319
 
297
- Note that for all deployment commands, you are expected to provide the fully qualified path to your server object. For example, if you have a file `server.py` that contains a FastMCP server named `my_server`, you would provide `path/to/server.py:my_server`.
320
+ There are three main ways to use your FastMCP server, each suited for different stages of development:
298
321
 
299
- If your server variable has one of the standard names (`mcp`, `server`, or `app`), you can omit the server name from the path and just provide the file: `path/to/server.py`.
322
+ ### Development Mode (Recommended for Building & Testing)
300
323
 
301
- ### Development
324
+ The fastest way to test and debug your server is with the MCP Inspector:
302
325
 
303
- Test and debug your server with the MCP Inspector:
304
326
  ```bash
305
- # Provide the fully qualified path to your server
306
- fastmcp dev server.py:my_mcp_server
307
-
308
- # Or just the file if your server is named 'mcp', 'server', or 'app'
309
327
  fastmcp dev server.py
310
328
  ```
311
329
 
312
- Your server is run in an isolated environment, so you'll need to indicate any dependencies with the `--with` flag. FastMCP is automatically included. If you are working on a uv project, you can use the `--with-editable` flag to mount your current directory:
330
+ This launches a web interface where you can:
331
+ - Test your tools and resources interactively
332
+ - See detailed logs and error messages
333
+ - Monitor server performance
334
+ - Set environment variables for testing
313
335
 
314
- ```bash
315
- # With additional packages
316
- fastmcp dev server.py --with pandas --with numpy
336
+ During development, you can:
337
+ - Add dependencies with `--with`:
338
+ ```bash
339
+ fastmcp dev server.py --with pandas --with numpy
340
+ ```
341
+ - Mount your local code for live updates:
342
+ ```bash
343
+ fastmcp dev server.py --with-editable .
344
+ ```
317
345
 
318
- # Using your project's dependencies and up-to-date code
319
- fastmcp dev server.py --with-editable .
320
- ```
346
+ ### Claude Desktop Integration (For Regular Use)
321
347
 
322
- ### Claude Desktop
348
+ Once your server is ready, install it in Claude Desktop to use it with Claude:
323
349
 
324
- Install your server in Claude Desktop:
325
350
  ```bash
326
- # Basic usage (name is taken from your FastMCP instance)
327
351
  fastmcp install server.py
352
+ ```
353
+
354
+ Your server will run in an isolated environment with:
355
+ - Automatic installation of dependencies specified in your FastMCP instance:
356
+ ```python
357
+ mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
358
+ ```
359
+ - Custom naming via `--name`:
360
+ ```bash
361
+ fastmcp install server.py --name "My Analytics Server"
362
+ ```
363
+ - Environment variable management:
364
+ ```bash
365
+ # Set variables individually
366
+ fastmcp install server.py -e API_KEY=abc123 -e DB_URL=postgres://...
367
+
368
+ # Or load from a .env file
369
+ fastmcp install server.py -f .env
370
+ ```
371
+
372
+ ### Direct Execution (For Advanced Use Cases)
373
+
374
+ For advanced scenarios like custom deployments or running without Claude, you can execute your server directly:
375
+
376
+ ```python
377
+ from fastmcp import FastMCP
328
378
 
329
- # With a custom name
330
- fastmcp install server.py --name "My Server"
379
+ mcp = FastMCP("My App")
380
+
381
+ if __name__ == "__main__":
382
+ mcp.run()
383
+ ```
331
384
 
332
- # With dependencies
333
- fastmcp install server.py --with pandas --with numpy
385
+ Run it with:
386
+ ```bash
387
+ # Using the FastMCP CLI
388
+ fastmcp run server.py
334
389
 
335
- # Replace an existing server
336
- fastmcp install server.py --force
390
+ # Or with Python/uv directly
391
+ python server.py
392
+ uv run python server.py
337
393
  ```
338
394
 
339
- The server name in Claude will be:
340
- 1. The `--name` parameter if provided
341
- 2. The `name` from your FastMCP instance
342
- 3. The filename if the server can't be imported
395
+
396
+ 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.
397
+
398
+ Choose this method when you need:
399
+ - Custom deployment configurations
400
+ - Integration with other services
401
+ - Direct control over the server lifecycle
402
+
403
+ ### Server Object Names
404
+
405
+ 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`:
406
+
407
+ ```bash
408
+ # Using a standard name
409
+ fastmcp run server.py
410
+
411
+ # Using a custom name
412
+ fastmcp run server.py:my_custom_server
413
+ ```
343
414
 
344
415
  ## Examples
345
416
 
417
+ Here are a few examples of FastMCP servers. For more, see the `examples/` directory.
418
+
346
419
  ### Echo Server
347
420
  A simple server demonstrating resources, tools, and prompts:
348
421
 
@@ -405,3 +478,85 @@ Schema:
405
478
 
406
479
  What insights can you provide about the structure and relationships?"""
407
480
  ```
481
+
482
+ ## Contributing
483
+
484
+ <details>
485
+
486
+ <summary><h3>Open Developer Guide</h3></summary>
487
+
488
+ ### Prerequisites
489
+
490
+ FastMCP requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
491
+
492
+ ### Installation
493
+
494
+ Create a fork of this repository, then clone it:
495
+
496
+ ```bash
497
+ git clone https://github.com/YouFancyUserYou/fastmcp.git
498
+ cd fastmcp
499
+ ```
500
+
501
+ Next, create a virtual environment and install FastMCP:
502
+
503
+ ```bash
504
+ uv venv
505
+ source .venv/bin/activate
506
+ uv sync --frozen --all-extras --dev
507
+ ```
508
+
509
+
510
+
511
+ ### Testing
512
+
513
+ Please make sure to test any new functionality. Your tests should be simple and atomic and anticipate change rather than cement complex patterns.
514
+
515
+ Run tests from the root directory:
516
+
517
+
518
+ ```bash
519
+ pytest -vv
520
+ ```
521
+
522
+ ### Formatting
523
+
524
+ FastMCP enforces a variety of required formats, which you can automatically enforce with pre-commit.
525
+
526
+ Install the pre-commit hooks:
527
+
528
+ ```bash
529
+ pre-commit install
530
+ ```
531
+
532
+ The hooks will now run on every commit (as well as on every PR). To run them manually:
533
+
534
+ ```bash
535
+ pre-commit run --all-files
536
+ ```
537
+
538
+ ### Opening a Pull Request
539
+
540
+ Fork the repository and create a new branch:
541
+
542
+ ```bash
543
+ git checkout -b my-branch
544
+ ```
545
+
546
+ Make your changes and commit them:
547
+
548
+
549
+ ```bash
550
+ git add . && git commit -m "My changes"
551
+ ```
552
+
553
+ Push your changes to your fork:
554
+
555
+
556
+ ```bash
557
+ git push origin my-branch
558
+ ```
559
+
560
+ Feel free to reach out in a GitHub issue or discussion if you have any questions!
561
+
562
+ </details>
@@ -3,28 +3,39 @@
3
3
 
4
4
  <div align="center">
5
5
 
6
+ <strong>The fast, Pythonic way to build MCP servers.</strong>
7
+
6
8
  [![PyPI - Version](https://img.shields.io/pypi/v/fastmcp.svg)](https://pypi.org/project/fastmcp)
7
9
  [![Tests](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml/badge.svg)](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
8
10
  [![License](https://img.shields.io/github/license/jlowin/fastmcp.svg)](https://github.com/jlowin/fastmcp/blob/main/LICENSE)
9
11
 
10
- A fast, Pythonic way to build [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers
11
12
 
12
13
  </div>
13
14
 
14
- FastMCP makes building MCP servers simple and intuitive. Create tools, expose resources, and define prompts with clean, Pythonic code:
15
+ [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers are a new, standardized way to provide context and tools to your LLMs, and FastMCP makes building MCP servers simple and intuitive. Create tools, expose resources, and define prompts with clean, Pythonic code:
15
16
 
16
17
  ```python
18
+ # demo.py
19
+
17
20
  from fastmcp import FastMCP
18
21
 
22
+
19
23
  mcp = FastMCP("Demo 🚀")
20
24
 
25
+
21
26
  @mcp.tool()
22
27
  def add(a: int, b: int) -> int:
23
28
  """Add two numbers"""
24
29
  return a + b
25
30
  ```
26
31
 
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.
32
+ That's it! Give Claude access to the server by running:
33
+
34
+ ```bash
35
+ fastmcp install demo.py
36
+ ```
37
+
38
+ 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
39
 
29
40
 
30
41
  ### Key features:
@@ -51,22 +62,33 @@ That's it! FastMCP handles all the complex protocol details and server managemen
51
62
  - [Prompts](#prompts)
52
63
  - [Images](#images)
53
64
  - [Context](#context)
54
- - [Deployment](#deployment)
55
- - [Development](#development)
56
- - [Claude Desktop](#claude-desktop)
65
+ - [Running Your Server](#running-your-server)
66
+ - [Development Mode (Recommended for Building \& Testing)](#development-mode-recommended-for-building--testing)
67
+ - [Claude Desktop Integration (For Regular Use)](#claude-desktop-integration-for-regular-use)
68
+ - [Direct Execution (For Advanced Use Cases)](#direct-execution-for-advanced-use-cases)
69
+ - [Server Object Names](#server-object-names)
57
70
  - [Examples](#examples)
58
71
  - [Echo Server](#echo-server)
59
72
  - [SQLite Explorer](#sqlite-explorer)
73
+ - [Contributing](#contributing)
74
+ - [Prerequisites](#prerequisites)
75
+ - [Installation](#installation-1)
76
+ - [Testing](#testing)
77
+ - [Formatting](#formatting)
78
+ - [Opening a Pull Request](#opening-a-pull-request)
60
79
 
61
80
  ## Installation
62
81
 
82
+ We strongly recommend installing FastMCP with [uv](https://docs.astral.sh/uv/), as it is required for deploying servers:
83
+
63
84
  ```bash
64
- # We strongly recommend installing with uv
65
- brew install uv # on macOS
66
85
  uv pip install fastmcp
67
86
  ```
68
87
 
69
- Or with pip:
88
+ 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.
89
+
90
+ Alternatively, to use the SDK without deploying, you may use pip:
91
+
70
92
  ```bash
71
93
  pip install fastmcp
72
94
  ```
@@ -137,8 +159,10 @@ mcp = FastMCP("My App")
137
159
 
138
160
  # Configure host/port for HTTP transport (optional)
139
161
  mcp = FastMCP("My App", host="localhost", port=8000)
162
+
163
+ # Specify dependencies for deployment and development
164
+ mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
140
165
  ```
141
- *Note: All of the following code examples assume you've created a FastMCP server instance called `mcp`, as shown above.*
142
166
 
143
167
  ### Resources
144
168
 
@@ -267,59 +291,107 @@ The Context object provides:
267
291
  - Resource access through `read_resource()`
268
292
  - Request metadata via `request_id` and `client_id`
269
293
 
270
- ## Deployment
271
-
272
- The FastMCP CLI helps you develop and deploy MCP servers.
294
+ ## Running Your Server
273
295
 
274
- Note that for all deployment commands, you are expected to provide the fully qualified path to your server object. For example, if you have a file `server.py` that contains a FastMCP server named `my_server`, you would provide `path/to/server.py:my_server`.
296
+ There are three main ways to use your FastMCP server, each suited for different stages of development:
275
297
 
276
- If your server variable has one of the standard names (`mcp`, `server`, or `app`), you can omit the server name from the path and just provide the file: `path/to/server.py`.
298
+ ### Development Mode (Recommended for Building & Testing)
277
299
 
278
- ### Development
300
+ The fastest way to test and debug your server is with the MCP Inspector:
279
301
 
280
- Test and debug your server with the MCP Inspector:
281
302
  ```bash
282
- # Provide the fully qualified path to your server
283
- fastmcp dev server.py:my_mcp_server
284
-
285
- # Or just the file if your server is named 'mcp', 'server', or 'app'
286
303
  fastmcp dev server.py
287
304
  ```
288
305
 
289
- Your server is run in an isolated environment, so you'll need to indicate any dependencies with the `--with` flag. FastMCP is automatically included. If you are working on a uv project, you can use the `--with-editable` flag to mount your current directory:
306
+ This launches a web interface where you can:
307
+ - Test your tools and resources interactively
308
+ - See detailed logs and error messages
309
+ - Monitor server performance
310
+ - Set environment variables for testing
290
311
 
291
- ```bash
292
- # With additional packages
293
- fastmcp dev server.py --with pandas --with numpy
312
+ During development, you can:
313
+ - Add dependencies with `--with`:
314
+ ```bash
315
+ fastmcp dev server.py --with pandas --with numpy
316
+ ```
317
+ - Mount your local code for live updates:
318
+ ```bash
319
+ fastmcp dev server.py --with-editable .
320
+ ```
294
321
 
295
- # Using your project's dependencies and up-to-date code
296
- fastmcp dev server.py --with-editable .
297
- ```
322
+ ### Claude Desktop Integration (For Regular Use)
298
323
 
299
- ### Claude Desktop
324
+ Once your server is ready, install it in Claude Desktop to use it with Claude:
300
325
 
301
- Install your server in Claude Desktop:
302
326
  ```bash
303
- # Basic usage (name is taken from your FastMCP instance)
304
327
  fastmcp install server.py
328
+ ```
329
+
330
+ Your server will run in an isolated environment with:
331
+ - Automatic installation of dependencies specified in your FastMCP instance:
332
+ ```python
333
+ mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
334
+ ```
335
+ - Custom naming via `--name`:
336
+ ```bash
337
+ fastmcp install server.py --name "My Analytics Server"
338
+ ```
339
+ - Environment variable management:
340
+ ```bash
341
+ # Set variables individually
342
+ fastmcp install server.py -e API_KEY=abc123 -e DB_URL=postgres://...
343
+
344
+ # Or load from a .env file
345
+ fastmcp install server.py -f .env
346
+ ```
347
+
348
+ ### Direct Execution (For Advanced Use Cases)
349
+
350
+ For advanced scenarios like custom deployments or running without Claude, you can execute your server directly:
351
+
352
+ ```python
353
+ from fastmcp import FastMCP
305
354
 
306
- # With a custom name
307
- fastmcp install server.py --name "My Server"
355
+ mcp = FastMCP("My App")
356
+
357
+ if __name__ == "__main__":
358
+ mcp.run()
359
+ ```
308
360
 
309
- # With dependencies
310
- fastmcp install server.py --with pandas --with numpy
361
+ Run it with:
362
+ ```bash
363
+ # Using the FastMCP CLI
364
+ fastmcp run server.py
311
365
 
312
- # Replace an existing server
313
- fastmcp install server.py --force
366
+ # Or with Python/uv directly
367
+ python server.py
368
+ uv run python server.py
314
369
  ```
315
370
 
316
- The server name in Claude will be:
317
- 1. The `--name` parameter if provided
318
- 2. The `name` from your FastMCP instance
319
- 3. The filename if the server can't be imported
371
+
372
+ 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.
373
+
374
+ Choose this method when you need:
375
+ - Custom deployment configurations
376
+ - Integration with other services
377
+ - Direct control over the server lifecycle
378
+
379
+ ### Server Object Names
380
+
381
+ 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`:
382
+
383
+ ```bash
384
+ # Using a standard name
385
+ fastmcp run server.py
386
+
387
+ # Using a custom name
388
+ fastmcp run server.py:my_custom_server
389
+ ```
320
390
 
321
391
  ## Examples
322
392
 
393
+ Here are a few examples of FastMCP servers. For more, see the `examples/` directory.
394
+
323
395
  ### Echo Server
324
396
  A simple server demonstrating resources, tools, and prompts:
325
397
 
@@ -382,3 +454,85 @@ Schema:
382
454
 
383
455
  What insights can you provide about the structure and relationships?"""
384
456
  ```
457
+
458
+ ## Contributing
459
+
460
+ <details>
461
+
462
+ <summary><h3>Open Developer Guide</h3></summary>
463
+
464
+ ### Prerequisites
465
+
466
+ FastMCP requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
467
+
468
+ ### Installation
469
+
470
+ Create a fork of this repository, then clone it:
471
+
472
+ ```bash
473
+ git clone https://github.com/YouFancyUserYou/fastmcp.git
474
+ cd fastmcp
475
+ ```
476
+
477
+ Next, create a virtual environment and install FastMCP:
478
+
479
+ ```bash
480
+ uv venv
481
+ source .venv/bin/activate
482
+ uv sync --frozen --all-extras --dev
483
+ ```
484
+
485
+
486
+
487
+ ### Testing
488
+
489
+ Please make sure to test any new functionality. Your tests should be simple and atomic and anticipate change rather than cement complex patterns.
490
+
491
+ Run tests from the root directory:
492
+
493
+
494
+ ```bash
495
+ pytest -vv
496
+ ```
497
+
498
+ ### Formatting
499
+
500
+ FastMCP enforces a variety of required formats, which you can automatically enforce with pre-commit.
501
+
502
+ Install the pre-commit hooks:
503
+
504
+ ```bash
505
+ pre-commit install
506
+ ```
507
+
508
+ The hooks will now run on every commit (as well as on every PR). To run them manually:
509
+
510
+ ```bash
511
+ pre-commit run --all-files
512
+ ```
513
+
514
+ ### Opening a Pull Request
515
+
516
+ Fork the repository and create a new branch:
517
+
518
+ ```bash
519
+ git checkout -b my-branch
520
+ ```
521
+
522
+ Make your changes and commit them:
523
+
524
+
525
+ ```bash
526
+ git add . && git commit -m "My changes"
527
+ ```
528
+
529
+ Push your changes to your fork:
530
+
531
+
532
+ ```bash
533
+ git push origin my-branch
534
+ ```
535
+
536
+ Feel free to reach out in a GitHub issue or discussion if you have any questions!
537
+
538
+ </details>