Skip to content

Commit 9514163

Browse files
author
Shira Ayal
authored
Merge pull request #110 from shira-ayal/mintlify-docs
Mintlify docs
2 parents 4a6c4a5 + 8be91bf commit 9514163

18 files changed

+488
-221
lines changed

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
</div>
1313

14+
1415
<p align="center"><a href="https://github.com/tadata-org/fastapi_mcp"><img src="https://github.com/user-attachments/assets/b205adc6-28c0-4e3c-a68b-9c1a80eb7d0c" alt="fastapi-mcp-usage" height="400"/></a></p>
1516

1617

@@ -65,15 +66,7 @@ That's it! Your auto-generated MCP server is now available at `https://app.base.
6566

6667
## Documentation, Examples and Advanced Usage
6768

68-
FastAPI-MCP provides comprehensive documentation in the `docs` folder:
69-
- [Best Practices](docs/00_BEST_PRACTICES.md) - Essential guidelines for converting APIs to MCP tools safely and effectively
70-
- [FAQ](docs/00_FAQ.md) - Frequently asked questions about usage, development and support
71-
- [Tool Naming](docs/01_tool_naming.md) - Best practices for naming your MCP tools using operation IDs
72-
- [Connecting to MCP Server](docs/02_connecting_to_the_mcp_server.md) - How to connect various MCP clients like Cursor and Claude Desktop
73-
- [Authentication and Authorization](docs/03_authentication_and_authorization.md) - How to authenticate and authorize your MCP tools
74-
- [Advanced Usage](docs/04_advanced_usage.md) - Advanced features like custom schemas, endpoint filtering, and separate deployment
75-
76-
Check out the [examples directory](examples) for code samples demonstrating these features in action.
69+
FastAPI-MCP provides [comprehensive documentation](https://fastapi-mcp.tadata.com/). Additionaly, check out the [examples directory](examples) for code samples demonstrating these features in action.
7770

7871
## FastAPI-first Approach
7972

@@ -83,7 +76,7 @@ FastAPI-MCP is designed as a native extension of FastAPI, not just a converter t
8376

8477
- **ASGI transport**: Communicates directly with your FastAPI app using its ASGI interface, eliminating the need for HTTP calls from the MCP to your API
8578

86-
- **Unified infrastructure**: Your FastAPI app doesn't need to run separately from the MCP server (though [separate deployment](docs/04_advanced_usage.md#deploying-separately-from-original-fastapi-app) is also supported)
79+
- **Unified infrastructure**: Your FastAPI app doesn't need to run separately from the MCP server (though [separate deployment](https://fastapi-mcp.tadata.com/advanced/deploy#deploying-separately-from-original-fastapi-app) is also supported)
8780

8881
This design philosophy ensures minimum friction when adding MCP capabilities to your existing FastAPI services.
8982

docs/02_connecting_to_the_mcp_server.md

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

docs/04_advanced_usage.md

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

docs/03_authentication_and_authorization.md renamed to docs/advanced/auth.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Authentication and Authorization
1+
---
2+
title: Authentication & Authorization
3+
icon: key
4+
---
25

36
FastAPI-MCP supports authentication and authorization using your existing FastAPI dependencies.
47

@@ -12,7 +15,7 @@ If you just want to be able to pass a valid authorization header, without suppor
1215

1316
You just need to make sure your MCP client is sending it:
1417

15-
```json
18+
```json {8-9, 13}
1619
{
1720
"mcpServers": {
1821
"remote-example": {
@@ -35,7 +38,7 @@ This is enough to pass the authorization header to your FastAPI endpoints.
3538

3639
Optionally, if you want your MCP server to reject requests without an authorization header, you can add a dependency:
3740

38-
```python
41+
```python {1-2, 7-9}
3942
from fastapi import Depends
4043
from fastapi_mcp import FastApiMCP, AuthConfig
4144

@@ -49,15 +52,15 @@ mcp = FastApiMCP(
4952
mcp.mount()
5053
```
5154

52-
For a complete working example of authorization header, check out the [auth_example_token_passthrough.py](/examples/08_auth_example_token_passthrough.py) in the examples folder.
55+
For a complete working example of authorization header, check out the [Token Passthrough Example](https://github.com/tadata-org/fastapi_mcp/blob/main/examples/08_auth_example_token_passthrough.py) in the examples folder.
5356

5457
## OAuth Flow
5558

5659
FastAPI-MCP supports the full OAuth 2 flow, compliant with [MCP Spec 2025-03-26](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization).
5760

5861
It would look something like this:
5962

60-
```python
63+
```python {7-16}
6164
from fastapi import Depends
6265
from fastapi_mcp import FastApiMCP, AuthConfig
6366

@@ -102,7 +105,7 @@ You can use it with any OAuth provider that supports the OAuth 2 spec. See expla
102105

103106
If you already have a properly configured OAuth server that works with MCP clients, or if you want full control over the metadata, you can provide your own OAuth metadata directly:
104107

105-
```python
108+
```python {9, 22}
106109
from fastapi import Depends
107110
from fastapi_mcp import FastApiMCP, AuthConfig
108111

@@ -140,7 +143,7 @@ For this to work, you have to make sure mcp-remote is running [on a fixed port](
140143

141144
## Working Example with Auth0
142145

143-
For a complete working example of OAuth integration with Auth0, check out the [auth_example_auth0.py](/examples/09_auth_example_auth0.py) in the examples folder. This example demonstrates the simple case of using Auth0 as an OAuth provider, with a working example of the OAuth flow.
146+
For a complete working example of OAuth integration with Auth0, check out the [Auth0 Example](https://github.com/tadata-org/fastapi_mcp/blob/main/examples/09_auth_example_auth0.py) in the examples folder. This example demonstrates the simple case of using Auth0 as an OAuth provider, with a working example of the OAuth flow.
144147

145148
For it to work, you need an .env file in the root of the project with the following variables:
146149

@@ -221,5 +224,4 @@ Proxies solve several problems:
221224

222225
Normally, mcp-remote will start on a random port, making it impossible to configure the OAuth provider's callback URL properly.
223226

224-
225-
You have to make sure mcp-remote is running on a fixed port, for example `8080`, and then configure the callback URL to `http://127.0.0.1:8080/oauth/callback` in your OAuth provider.
227+
You have to make sure mcp-remote is running on a fixed port, for example `8080`, and then configure the callback URL to `http://127.0.0.1:8080/oauth/callback` in your OAuth provider.

docs/advanced/deploy.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Deploying the Server
3+
icon: play
4+
---
5+
6+
## Deploying separately from original FastAPI app
7+
8+
You are not limited to serving the MCP on the same FastAPI app from which it was created.
9+
10+
You can create an MCP server from one FastAPI app, and mount it to a different app:
11+
12+
```python {9, 15, }
13+
from fastapi import FastAPI
14+
from fastapi_mcp import FastApiMCP
15+
16+
# Your API app
17+
api_app = FastAPI()
18+
# ... define your API endpoints on api_app ...
19+
20+
# A separate app for the MCP server
21+
mcp_app = FastAPI()
22+
23+
# Create MCP server from the API app
24+
mcp = FastApiMCP(api_app)
25+
26+
# Mount the MCP server to the separate app
27+
mcp.mount(mcp_app)
28+
```
29+
30+
Then, you can run both apps separately:
31+
32+
```bash
33+
uvicorn main:api_app --host api-host --port 8001
34+
uvicorn main:mcp_app --host mcp-host --port 8000
35+
```

docs/advanced/refresh.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Refreshing the Server
3+
description: Adding endpoints after MCP server creation
4+
icon: arrows-rotate
5+
---
6+
7+
If you add endpoints to your FastAPI app after creating the MCP server, you'll need to refresh the server to include them:
8+
9+
```python {9-12, 15}
10+
from fastapi import FastAPI
11+
from fastapi_mcp import FastApiMCP
12+
13+
app = FastAPI()
14+
15+
mcp = FastApiMCP(app)
16+
mcp.mount()
17+
18+
# Add new endpoints after MCP server creation
19+
@app.get("/new/endpoint/", operation_id="new_endpoint")
20+
async def new_endpoint():
21+
return {"message": "Hello, world!"}
22+
23+
# Refresh the MCP server to include the new endpoint
24+
mcp.setup_server()
25+
```

docs/advanced/transport.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Transport
3+
description: How to communicate with the FastAPI app
4+
icon: car
5+
---
6+
7+
FastAPI-MCP uses ASGI transport by default, which means it communicates directly with your FastAPI app without making HTTP requests. This is more efficient and doesn't require a base URL.
8+
9+
It's not even necessary that the FastAPI server will run.
10+
11+
If you need to specify a custom base URL or use a different transport method, you can provide your own `httpx.AsyncClient`:
12+
13+
```python {7-10, 14}
14+
import httpx
15+
from fastapi import FastAPI
16+
from fastapi_mcp import FastApiMCP
17+
18+
app = FastAPI()
19+
20+
custom_client = httpx.AsyncClient(
21+
base_url="https://api.example.com",
22+
timeout=30.0
23+
)
24+
25+
mcp = FastApiMCP(
26+
app,
27+
http_client=custom_client
28+
)
29+
30+
mcp.mount()
31+
```

0 commit comments

Comments
 (0)