fastmcp 0.3.0__py3-none-any.whl → 0.3.1__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/cli.py CHANGED
@@ -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(__name__)
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
- print(f"Successfully installed {name} in Claude app")
355
+ logger.info(f"Successfully installed {name} in Claude app")
356
356
  else:
357
- print(f"Failed to install {name} in Claude app")
357
+ logger.error(f"Failed to install {name} in Claude app")
358
358
  sys.exit(1)
fastmcp/server.py CHANGED
@@ -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(env_prefix="FASTMCP_")
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: The name of the logger, which will be prefixed with 'FastMCP.'
13
+ name: the name of the logger, which will be prefixed with 'FastMCP.'
12
14
 
13
15
  Returns:
14
- A configured logger instance
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: The log level to use
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
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fastmcp
3
- Version: 0.3.0
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
  [![Tests](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml/badge.svg)](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
31
31
  [![License](https://img.shields.io/github/license/jlowin/fastmcp.svg)](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 is a high-level, intuitive framework for building [Model Context Protocol (MCP)](https://modelcontextprotocol.io) servers with Python. While MCP is a powerful protocol that enables LLMs to interact with local data and tools in a secure, standardized way, the specification can be cumbersome to implement directly. FastMCP lets you build fully compliant MCP servers in the most Pythonic way possible - in many cases, simply decorating a function is all that's required.
37
+ FastMCP makes building MCP servers simple and intuitive. Create tools, expose resources, and define prompts with clean, Pythonic code:
36
38
 
37
- 🚧 *Note: FastMCP is under active development, as is the low-level MCP Python SDK* 🏗️
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
- ![MCP Inspector](docs/images/mcp-inspector.png)
135
+ ![MCP Inspector](/docs/assets/demo-inspector.png)
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,9 +1,9 @@
1
1
  fastmcp/__init__.py,sha256=Y5dHGBwyQPgNP5gzOyNIItefvMZ3vJLdom1oV8A1u_k,248
2
2
  fastmcp/exceptions.py,sha256=K0rCgXsUVlws39hz98Tb4BBf_BzIql_zXFZgqbkNTiE,348
3
- fastmcp/server.py,sha256=gZCl4ppLWYjM4L6MXJxr-jh9ngjHjaFSFTLpofmgtmA,21987
3
+ fastmcp/server.py,sha256=JttRzt1bnJGBU8mL4Bo764WHFXQ09QqKc_CUT3390WM,21997
4
4
  fastmcp/cli/__init__.py,sha256=7hrwtCHX9nMd9qcz7R_JFSoqbL71fC35cBLXBS430mg,88
5
5
  fastmcp/cli/claude.py,sha256=hId0cTmAfCrav72Hg5LeO0SPPNyEVtIOcoKVAy8gD3k,3390
6
- fastmcp/cli/cli.py,sha256=Mru5j0_apXBnLBEd6DMICGPUk52DN3eyjSc1B973M2M,10028
6
+ fastmcp/cli/cli.py,sha256=0r9_HR_wayV5MZARS02ZO1RnRCT8roxdY1CGGYzPNqo,10044
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
@@ -17,10 +17,10 @@ fastmcp/tools/__init__.py,sha256=ZboxhyMJDl87Svjov8YwNYwNZi55P9VhmpTjBZLesnk,96
17
17
  fastmcp/tools/base.py,sha256=JPdTx8SAl5pKsHyIVxnsLG88f3fbjnopDTOAZ_PoVQE,2585
18
18
  fastmcp/tools/tool_manager.py,sha256=PT6XHcQWzhdC6kfdsJaddRn7VLps4nAs5FMG8l1j8Zc,1617
19
19
  fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
20
- fastmcp/utilities/logging.py,sha256=t2w5bwtrkxHxioWSy5vY8esxLQxyxN8tfFZ1FI3Cb6E,704
20
+ fastmcp/utilities/logging.py,sha256=VLJdNc0tIYoQZmpobehLUnWrQz7NXnuwSqrDlFt2RF0,738
21
21
  fastmcp/utilities/types.py,sha256=jFlZMZsKrJg4NWc1vTBIILLoHpTVwSd-vxO7ycoRuig,1718
22
- fastmcp-0.3.0.dist-info/METADATA,sha256=Nu76qWE1nxUHiHF4pczCTMUl8C2hKpXfIeo2Sp1UHxo,11452
23
- fastmcp-0.3.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
24
- fastmcp-0.3.0.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
25
- fastmcp-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
- fastmcp-0.3.0.dist-info/RECORD,,
22
+ fastmcp-0.3.1.dist-info/METADATA,sha256=PdOwJThIuqGDpSExh8dUsYyxUQBq0rw5MnOV3an2aTs,12108
23
+ fastmcp-0.3.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
24
+ fastmcp-0.3.1.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
25
+ fastmcp-0.3.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
+ fastmcp-0.3.1.dist-info/RECORD,,