Skip to content

Commit 92cb0b0

Browse files
committed
update readme and changelog
1 parent 8840f95 commit 92cb0b0

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
🚀 FastApiMCP now works with ASGI-transport by default.
11+
12+
This means the `base_url` argument is redundant, and thus has been removed.
13+
14+
You can still set up an explicit base URL using the `http_client` argument, and injecting your own `httpx.AsyncClient` if necessary.
15+
16+
### Removed
17+
- ⚠️ Breaking Change: Removed `base_url` argument since it's not used anymore by the MCP transport.
18+
19+
### Fixed
20+
- 🐛 Fix short timeout issue (#71), increasing the default timeout to 10
21+
22+
823
## [0.2.0]
924

1025
### Changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- **Preserving schemas** of your request models and response models
2424
- **Preserve documentation** of all your endpoints, just as it is in Swagger
2525
- **Flexible deployment** - Mount your MCP server to the same app, or deploy separately
26+
- **ASGI transport** - Uses FastAPI's ASGI interface directly by default for efficient communication
2627

2728
## Installation
2829

@@ -202,6 +203,35 @@ async def new_endpoint():
202203
mcp.setup_server()
203204
```
204205

206+
### Communication with the FastAPI App
207+
208+
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.
209+
210+
It's not even necessary that the FastAPI server will run. See the examples folder for more.
211+
212+
If you need to specify a custom base URL or use a different transport method, you can provide your own `httpx.AsyncClient`:
213+
214+
```python
215+
import httpx
216+
from fastapi import FastAPI
217+
from fastapi_mcp import FastApiMCP
218+
219+
app = FastAPI()
220+
221+
# Use a custom HTTP client with a specific base URL
222+
custom_client = httpx.AsyncClient(
223+
base_url="https://api.example.com",
224+
timeout=30.0
225+
)
226+
227+
mcp = FastApiMCP(
228+
app,
229+
http_client=custom_client
230+
)
231+
232+
mcp.mount()
233+
```
234+
205235
## Examples
206236

207237
See the [examples](examples) directory for complete examples.

README_zh-CN.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- **保留模式** - 保留您的请求模型和响应模型的模式
2323
- **保留文档** - 保留所有端点的文档,就像在 Swagger 中一样
2424
- **灵活部署** - 将 MCP 服务器挂载到同一应用,或单独部署
25+
- **ASGI 传输** - 默认使用 FastAPI 的 ASGI 接口直接通信,提高效率
2526

2627
## 安装
2728

@@ -201,6 +202,33 @@ async def new_endpoint():
201202
mcp.setup_server()
202203
```
203204

205+
### 与 FastAPI 应用的通信
206+
207+
FastAPI-MCP 默认使用 ASGI 传输,这意味着它直接与您的 FastAPI 应用通信,而不需要发送 HTTP 请求。这样更高效,也不需要基础 URL。
208+
209+
如果您需要指定自定义基础 URL 或使用不同的传输方法,您可以提供自己的 `httpx.AsyncClient`
210+
211+
```python
212+
import httpx
213+
from fastapi import FastAPI
214+
from fastapi_mcp import FastApiMCP
215+
216+
app = FastAPI()
217+
218+
# 使用带有特定基础 URL 的自定义 HTTP 客户端
219+
custom_client = httpx.AsyncClient(
220+
base_url="https://api.example.com",
221+
timeout=30.0
222+
)
223+
224+
mcp = FastApiMCP(
225+
app,
226+
http_client=custom_client
227+
)
228+
229+
mcp.mount()
230+
```
231+
204232
## 示例
205233

206234
请参阅 [examples](examples) 目录以获取完整示例。

0 commit comments

Comments
 (0)