mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-19 14:54:24 +01:00
docs: Update README.md to include FastMCP
Update the README.md to include FastMCP as the recommended way to build MCP servers. FastMCP is a high-level, Pythonic interface that makes it easy to build MCP servers with minimal boilerplate. The low-level implementation is still available for more control. 🤖 Generated with Claude CLI. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
35
README.md
35
README.md
@@ -71,18 +71,35 @@ Connections between clients and servers are established through transports like
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### Creating a Server
|
### FastMCP
|
||||||
|
|
||||||
MCP servers follow a decorator approach to register handlers for MCP primitives like resources, prompts, and tools. The goal is to provide a simple interface for exposing capabilities to LLM clients.
|
The fastest way to build MCP servers is with FastMCP, which provides a high-level, Pythonic interface:
|
||||||
|
|
||||||
**example_server.py**
|
```python
|
||||||
|
from fastmcp import FastMCP
|
||||||
|
|
||||||
|
mcp = FastMCP("Demo")
|
||||||
|
|
||||||
|
@mcp.tool()
|
||||||
|
def add(a: int, b: int) -> int:
|
||||||
|
"""Add two numbers"""
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
@mcp.resource("greeting://{name}")
|
||||||
|
def get_greeting(name: str) -> str:
|
||||||
|
"""Get a personalized greeting"""
|
||||||
|
return f"Hello, {name}!"
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
For more information about FastMCP, see the [FastMCP documentation](https://github.com/jlowin/fastmcp).
|
||||||
|
|
||||||
|
### Low-Level Implementation
|
||||||
|
|
||||||
|
For more control, you can use the low-level MCP implementation directly. This gives you full access to the protocol and allows you to customize every aspect of your server:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# /// script
|
|
||||||
# dependencies = [
|
|
||||||
# "mcp"
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
from mcp.server import Server, NotificationOptions
|
from mcp.server import Server, NotificationOptions
|
||||||
from mcp.server.models import InitializationOptions
|
from mcp.server.models import InitializationOptions
|
||||||
import mcp.server.stdio
|
import mcp.server.stdio
|
||||||
|
|||||||
Reference in New Issue
Block a user