Skip to content

Commit 9208880

Browse files
authored
Doc site work (#5)
* site config (URL, site name, API ref tweaks) * Shard README into *.md in docs/ * minor quickstart tweak
1 parent 740434d commit 9208880

25 files changed

+16508
-23
lines changed

docs/asgi-integration.md

Lines changed: 762 additions & 0 deletions
Large diffs are not rendered by default.

docs/authentication.md

Lines changed: 596 additions & 0 deletions
Large diffs are not rendered by default.

docs/completions.md

Lines changed: 1053 additions & 0 deletions
Large diffs are not rendered by default.

docs/context.md

Lines changed: 654 additions & 0 deletions
Large diffs are not rendered by default.

docs/display-utilities.md

Lines changed: 1287 additions & 0 deletions
Large diffs are not rendered by default.

docs/elicitation.md

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

docs/images.md

Lines changed: 780 additions & 0 deletions
Large diffs are not rendered by default.

docs/index.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,82 @@
1-
# MCP Server
1+
# MCP Python SDK
22

3-
This is the MCP Server implementation in Python.
3+
A Python implementation of the Model Context Protocol (MCP) that enables applications to provide context for LLMs in a standardized way.
4+
5+
## Overview
6+
7+
The Model Context Protocol allows you to build servers that expose data and functionality to LLM applications securely. This Python SDK implements the full MCP specification with both high-level FastMCP and low-level server implementations.
8+
9+
### Key features
10+
11+
- **FastMCP server framework** - High-level, decorator-based server creation
12+
- **Multiple transports** - stdio, SSE, and Streamable HTTP support
13+
- **Type-safe development** - Full type hints and Pydantic integration
14+
- **Authentication support** - OAuth 2.1 resource server capabilities
15+
- **Rich tooling** - Built-in development and deployment utilities
16+
17+
## Quick start
18+
19+
Create a simple MCP server in minutes:
20+
21+
```python
22+
from mcp.server.fastmcp import FastMCP
23+
24+
# Create server
25+
mcp = FastMCP("Demo")
26+
27+
@mcp.tool()
28+
def add(a: int, b: int) -> int:
29+
"""Add two numbers"""
30+
return a + b
31+
32+
@mcp.resource("greeting://{name}")
33+
def get_greeting(name: str) -> str:
34+
"""Get a personalized greeting"""
35+
return f"Hello, {name}!"
36+
```
37+
38+
Install in Claude Desktop:
39+
40+
```bash
41+
uv run mcp install server.py
42+
```
43+
44+
## Documentation sections
45+
46+
### Getting started
47+
- **[Quickstart](quickstart.md)** - Build your first MCP server
48+
- **[Installation](installation.md)** - Setup and dependencies
49+
50+
### Core concepts
51+
- **[Servers](servers.md)** - Server creation and lifecycle management
52+
- **[Resources](resources.md)** - Exposing data to LLMs
53+
- **[Tools](tools.md)** - Creating LLM-callable functions
54+
- **[Prompts](prompts.md)** - Reusable interaction templates
55+
- **[Context](context.md)** - Request context and capabilities
56+
57+
### Advanced features
58+
- **[Images](images.md)** - Working with image data
59+
- **[Authentication](authentication.md)** - OAuth 2.1 implementation
60+
- **[Sampling](sampling.md)** - LLM text generation
61+
- **[Elicitation](elicitation.md)** - User input collection
62+
- **[Progress & logging](progress-logging.md)** - Status updates and notifications
63+
64+
### Transport & deployment
65+
- **[Running servers](running-servers.md)** - Development and production deployment
66+
- **[Streamable HTTP](streamable-http.md)** - Modern HTTP transport
67+
- **[ASGI integration](asgi-integration.md)** - Mounting to existing web servers
68+
69+
### Client development
70+
- **[Writing clients](writing-clients.md)** - MCP client implementation
71+
- **[OAuth for clients](oauth-clients.md)** - Client-side authentication
72+
- **[Display utilities](display-utilities.md)** - UI helper functions
73+
- **[Parsing results](parsing-results.md)** - Handling tool responses
74+
75+
### Advanced usage
76+
- **[Low-level server](low-level-server.md)** - Direct protocol implementation
77+
- **[Structured output](structured-output.md)** - Advanced type patterns
78+
- **[Completions](completions.md)** - Argument completion system
79+
80+
## API reference
81+
82+
Complete API documentation is auto-generated from the source code and available in the [API Reference](reference/) section.

docs/installation.md

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# Installation
2+
3+
Learn how to install and set up the MCP Python SDK for different use cases.
4+
5+
## Prerequisites
6+
7+
- **Python 3.10 or later**
8+
- **uv package manager** (recommended) or pip
9+
10+
### Installing uv
11+
12+
If you don't have uv installed:
13+
14+
```bash
15+
# macOS and Linux
16+
curl -LsSf https://astral.sh/uv/install.sh | sh
17+
18+
# Windows
19+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
20+
21+
# Or with pip
22+
pip install uv
23+
```
24+
25+
## Installation methods
26+
27+
### For new projects (recommended)
28+
29+
Create a new uv-managed project:
30+
31+
```bash
32+
uv init my-mcp-server
33+
cd my-mcp-server
34+
uv add "mcp[cli]"
35+
```
36+
37+
This creates a complete project structure with:
38+
- `pyproject.toml` - Project configuration
39+
- `src/` directory for your code
40+
- Virtual environment management
41+
42+
### Add to existing project
43+
44+
If you have an existing project:
45+
46+
```bash
47+
uv add "mcp[cli]"
48+
```
49+
50+
### Using pip
51+
52+
For projects that use pip:
53+
54+
```bash
55+
pip install "mcp[cli]"
56+
```
57+
58+
## Package variants
59+
60+
The MCP SDK offers different installation options:
61+
62+
### Core package
63+
```bash
64+
uv add mcp
65+
```
66+
67+
Includes:
68+
- Core MCP protocol implementation
69+
- FastMCP server framework
70+
- Client libraries
71+
- All transport types (stdio, SSE, Streamable HTTP)
72+
73+
### CLI tools
74+
```bash
75+
uv add "mcp[cli]"
76+
```
77+
78+
Adds CLI utilities for:
79+
- `mcp dev` - Development server with web inspector
80+
- `mcp install` - Claude Desktop integration
81+
- `mcp run` - Direct server execution
82+
83+
### Rich output
84+
```bash
85+
uv add "mcp[rich]"
86+
```
87+
88+
Adds enhanced terminal output with colors and formatting.
89+
90+
### WebSocket support
91+
```bash
92+
uv add "mcp[ws]"
93+
```
94+
95+
Adds WebSocket transport capabilities.
96+
97+
### All features
98+
```bash
99+
uv add "mcp[cli,rich,ws]"
100+
```
101+
102+
## Development setup
103+
104+
For contributing to the MCP SDK or advanced development:
105+
106+
```bash
107+
git clone https://github.com/modelcontextprotocol/python-sdk
108+
cd python-sdk
109+
uv sync --group docs --group dev
110+
```
111+
112+
This installs:
113+
- All dependencies
114+
- Development tools (ruff, pyright, pytest)
115+
- Documentation tools (mkdocs, mkdocs-material)
116+
117+
## Verify installation
118+
119+
Test your installation:
120+
121+
```bash
122+
# Check MCP CLI is available
123+
uv run mcp --help
124+
125+
# Create and test a simple server
126+
echo 'from mcp.server.fastmcp import FastMCP
127+
mcp = FastMCP("Test")
128+
@mcp.tool()
129+
def hello() -> str:
130+
return "Hello from MCP!"
131+
if __name__ == "__main__":
132+
mcp.run()' > test_server.py
133+
134+
# Test the server
135+
uv run mcp dev test_server.py
136+
```
137+
138+
If successful, you'll see the MCP Inspector web interface open.
139+
140+
## IDE integration
141+
142+
### VS Code
143+
144+
For the best development experience, install:
145+
146+
- **Python extension** - Python language support
147+
- **Pylance** - Advanced Python features
148+
- **Ruff** - Code formatting and linting
149+
150+
### Type checking
151+
152+
The MCP SDK includes comprehensive type hints. Enable strict type checking:
153+
154+
```bash
155+
# Check types
156+
uv run pyright
157+
158+
# In VS Code, add to settings.json:
159+
{
160+
"python.analysis.typeCheckingMode": "strict"
161+
}
162+
```
163+
164+
## Troubleshooting
165+
166+
### Common issues
167+
168+
**"mcp command not found"**
169+
- Ensure uv is in your PATH
170+
- Try `uv run mcp` instead of just `mcp`
171+
172+
**Import errors**
173+
- Verify installation: `uv run python -c "import mcp; print(mcp.__version__)"`
174+
- Check you're in the right directory/virtual environment
175+
176+
**Permission errors on Windows**
177+
- Run terminal as administrator for global installations
178+
- Use `--user` flag with pip if needed
179+
180+
**Python version conflicts**
181+
- Check version: `python --version`
182+
- Use specific Python: `uv python install 3.11` then `uv python use 3.11`
183+
184+
### Getting help
185+
186+
- **GitHub Issues**: [Report bugs and feature requests](https://github.com/modelcontextprotocol/python-sdk/issues)
187+
- **Discussions**: [Community support](https://github.com/modelcontextprotocol/python-sdk/discussions)
188+
- **Documentation**: [Official MCP docs](https://modelcontextprotocol.io)
189+
190+
## Next steps
191+
192+
- **[Build your first server](quickstart.md)** - Follow the quickstart guide
193+
- **[Learn core concepts](servers.md)** - Understand MCP fundamentals
194+
- **[Explore examples](https://github.com/modelcontextprotocol/python-sdk/tree/main/examples)** - See real-world implementations

0 commit comments

Comments
 (0)