Skip to content

Commit fbe33b4

Browse files
committed
update docs
1 parent a30ae5d commit fbe33b4

File tree

4 files changed

+94
-223
lines changed

4 files changed

+94
-223
lines changed

CONTRIBUTING.md

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,58 @@
22

33
First off, thank you for considering contributing to FastAPI-MCP!
44

5-
## Development Process
6-
7-
1. Fork the repository
8-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
9-
3. Make your changes
10-
4. Run the tests (`pytest`)
11-
5. Format your code (`black .` and `isort .`)
12-
6. Commit your changes (`git commit -m 'Add some amazing feature'`)
13-
7. Push to the branch (`git push origin feature/amazing-feature`)
14-
8. Open a Pull Request
5+
## Development Setup
156

16-
## Setting Up Development Environment
7+
1. Make sure you have Python 3.10+ installed
8+
2. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) (recommended) or pip
9+
3. Fork the repository
10+
4. Clone your fork and set up the development environment:
1711

1812
```bash
1913
# Clone your fork
20-
git clone https://github.com/tadata-org/fastapi_mcp
14+
git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
2115
cd fastapi-mcp
2216

23-
# Create a virtual environment
24-
python -m venv venv
25-
source venv/bin/activate # On Windows: venv\Scripts\activate
17+
# Create a virtual environment with uv (recommended)
18+
uv venv
19+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
2620

27-
# Install development dependencies
28-
pip install -e ".[dev]"
21+
# Install development dependencies with uv
22+
uv add -e ".[dev]"
23+
24+
# Alternatively, using pip
25+
# python -m venv venv
26+
# source venv/bin/activate # On Windows: venv\Scripts\activate
27+
# pip install -e ".[dev]"
2928
```
3029

30+
## Development Process
31+
32+
1. Fork the repository
33+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
34+
3. Make your changes
35+
4. Run type checking (`uv run mypy .`)
36+
5. Run the tests (`uv run pytest`)
37+
6. Format your code (`uv run ruff check .` and `uv run ruff format .`)
38+
7. Commit your changes (`git commit -m 'Add some amazing feature'`)
39+
8. Push to the branch (`git push origin feature/amazing-feature`)
40+
9. Open a Pull Request
41+
3142
## Code Style
3243

3344
We use the following tools to ensure code quality:
3445

35-
- **Black** for code formatting
36-
- **isort** for import sorting
3746
- **ruff** for linting
3847
- **mypy** for type checking
3948

4049
Please make sure your code passes all checks before submitting a pull request:
4150

4251
```bash
43-
black .
44-
isort .
52+
# Using uv
53+
uv run ruff check .
54+
uv run mypy .
55+
56+
# Or directly if tools are installed
4557
ruff check .
4658
mypy .
4759
```
@@ -51,9 +63,23 @@ mypy .
5163
We use pytest for testing. Please write tests for any new features and ensure all tests pass:
5264

5365
```bash
66+
# Using uv
67+
uv run pytest
68+
69+
# Or directly
5470
pytest
5571
```
5672

73+
## Project Architecture
74+
75+
FastAPI-MCP uses a direct integration approach to add MCP functionality to FastAPI applications:
76+
77+
1. The `server.py` module handles creating and mounting MCP servers to FastAPI apps
78+
2. The `http_tools.py` module converts FastAPI endpoints to MCP tools
79+
3. All integration happens at runtime - there is no code generation involved
80+
81+
When contributing, please keep this architecture in mind and ensure your changes maintain the seamless integration experience.
82+
5783
## Pull Request Process
5884

5985
1. Ensure your code follows the style guidelines of the project

INSTALL.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

README.md

Lines changed: 47 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,85 +16,72 @@ A zero-configuration tool for integrating Model Context Protocol (MCP) servers w
1616

1717
## Installation
1818

19-
You can install FastAPI-MCP directly from [PyPI](https://pypi.org/project/fastapi-mcp/):
19+
We recommend using [uv](https://docs.astral.sh/uv/), a fast Python package installer:
20+
21+
```bash
22+
uv add fastapi-mcp
23+
```
24+
25+
Alternatively, you can install with pip:
2026

2127
```bash
2228
pip install fastapi-mcp
2329
```
2430

2531
For detailed installation instructions and alternative methods, see [INSTALL.md](INSTALL.md).
2632

27-
## Usage
28-
29-
### Direct integration (Recommended)
33+
## Basic Usage
3034

3135
The simplest way to use FastAPI-MCP is to add an MCP server directly to your FastAPI application:
3236

3337
```python
3438
from fastapi import FastAPI
3539
from fastapi_mcp import add_mcp_server
3640

37-
# Create your FastAPI app
41+
# Your FastAPI app
3842
app = FastAPI()
3943

40-
# Define your endpoints...
41-
@app.get("/items/{item_id}")
42-
def read_item(item_id: int, q: str = None):
43-
"""Get details for a specific item"""
44-
return {"item_id": item_id, "q": q}
45-
46-
# Add an MCP server to your app
47-
mcp_server = add_mcp_server(
44+
# Mount the MCP server to your app
45+
add_mcp_server(
4846
app, # Your FastAPI app
4947
mount_path="/mcp", # Where to mount the MCP server
5048
name="My API MCP", # Name for the MCP server
51-
base_url="http://localhost:8000" # Base URL for API requests
5249
)
53-
54-
# Optionally add custom MCP tools
55-
@mcp_server.tool()
56-
async def get_item_count() -> int:
57-
"""Get the total number of items in the database."""
58-
return 42 # Your custom implementation
5950
```
6051

61-
Your FastAPI app will now have an MCP server mounted at the specified path, with all your API endpoints available as MCP tools.
52+
That's it! Your auto-generated MCP server is now available at `https://app.base.url/mcp`.
6253

63-
### Legacy CLI Usage
54+
## Advanced Usage
6455

65-
The CLI is still available for backward compatibility:
56+
FastAPI-MCP provides several ways to customize and control how your MCP server is created and configured. Here are some advanced usage patterns:
6657

67-
```bash
68-
# Generate an MCP server from a FastAPI app
69-
fastapi-mcp generate app.py
58+
```python
59+
from fastapi import FastAPI
60+
from fastapi_mcp import add_mcp_server
7061

71-
# Preview the generated server
72-
fastapi-mcp preview
62+
app = FastAPI()
7363

74-
# Run the generated server
75-
fastapi-mcp run
64+
mcp_server = add_mcp_server(
65+
app, # Your FastAPI app
66+
mount_path="/mcp", # Where to mount the MCP server
67+
name="My API MCP", # Name for the MCP server
68+
describe_all_responses=True, # False by default. Include all possible response schemas in tool descriptions, instead of just the successful response.
69+
describe_full_response_schema=True # False by default. Include full JSON schema in tool descriptions, instead of just an LLM-friendly response example.
70+
)
7671

77-
# Install the server for Claude
78-
fastapi-mcp install
72+
# Add custom tools in addition to existing APIs.
73+
@mcp_server.tool()
74+
async def get_server_time() -> str:
75+
"""Get the current server time."""
76+
from datetime import datetime
77+
return datetime.now().isoformat()
7978
```
8079

81-
## How It Works
82-
83-
FastAPI-MCP:
84-
85-
1. Takes your FastAPI application
86-
2. Creates an MCP server instance
87-
3. Mounts the MCP server to your FastAPI app
88-
4. Extracts endpoint information from your OpenAPI schema
89-
5. Creates MCP tools that make HTTP requests to your API endpoints
90-
6. Preserves documentation and type information
91-
7. Registers the tools with the MCP server
92-
9380
## Examples
9481

9582
See the [examples](examples) directory for complete examples.
9683

97-
### Simple direct integration example:
84+
### Simple integration example:
9885

9986
```python
10087
from fastapi import FastAPI
@@ -130,49 +117,30 @@ Once your FastAPI app with MCP integration is running, you can connect to it wit
130117
2. In Claude, use the URL of your MCP server endpoint (e.g., `http://localhost:8000/mcp`)
131118
3. Claude will discover all available tools and resources automatically
132119

133-
## Advanced Configuration
134-
135-
FastAPI-MCP provides several options for advanced configuration:
120+
## Development and Contributing
136121

137-
```python
138-
mcp_server = add_mcp_server(
139-
app,
140-
mount_path="/mcp",
141-
name="My Custom MCP Server",
142-
description="Custom description for the MCP server",
143-
capabilities={"streaming": True}, # Set MCP capabilities
144-
serve_tools=True, # Whether to serve API endpoints as MCP tools
145-
base_url="https://api.example.com" # Base URL for API requests
146-
)
147-
```
122+
If you're interested in contributing to FastAPI-MCP:
148123

149-
You can also create and mount an MCP server separately:
150-
151-
```python
152-
from fastapi_mcp import create_mcp_server, mount_mcp_server
153-
154-
# Create an MCP server
155-
mcp_server = create_mcp_server(app, name="My MCP Server")
124+
```bash
125+
# Clone the repository
126+
git clone https://github.com/tadata-org/fastapi_mcp.git
127+
cd fastapi_mcp
156128

157-
# Add custom tools
158-
@mcp_server.tool()
159-
async def custom_tool():
160-
return "Custom tool result"
129+
# Create a virtual environment and install dependencies with uv
130+
uv venv
131+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
132+
uv add -e ".[dev]"
161133

162-
# Mount the MCP server to the FastAPI app
163-
mount_mcp_server(app, mcp_server, mount_path="/mcp")
134+
# Run tests
135+
uv run pytest
164136
```
165137

138+
For more details about contributing, see [CONTRIBUTING.md](CONTRIBUTING.md).
139+
166140
## Requirements
167141

168142
- Python 3.10+
169-
- FastAPI 0.100.0+
170-
- Pydantic 2.0.0+
171-
- MCP 1.3.0+
172-
173-
## Contributing
174-
175-
Contributions are welcome! Please feel free to submit a pull request. See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
143+
- uv
176144

177145
## License
178146

0 commit comments

Comments
 (0)