Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

doc(asgi): Change custom route example to PlainTextResponse

Matt C. Wilson6a7e4e25f32d
diff --git a/docs/deployment/asgi.mdx b/docs/deployment/asgi.mdx
index f676ff68a..fe613fd1b 100644
--- a/docs/deployment/asgi.mdx
+++ b/docs/deployment/asgi.mdx
@@ -43,7 +43,7 @@ http_app = mcp.http_app()
sse_app = mcp.http_app(transport="sse")
```
-Both approaches return a Starlette application that can be integrated with other ASGI-compatible web frameworks.
+Both approaches return a Starlette application that can be integrated with other ASGI-compatible web frameworks.
The MCP server's endpoint is mounted at the root path `/mcp` for Streamable HTTP transport, and `/sse` for SSE transport, though you can change these paths by passing a `path` argument to the `http_app()` method:
@@ -199,13 +199,13 @@ In addition to adding your FastMCP server to an existing ASGI app, you can also
```python
from fastmcp import FastMCP
from starlette.requests import Request
-from starlette.responses import JSONResponse
+from starlette.responses import PlainTextResponse
mcp = FastMCP("MyServer")
@mcp.custom_route("/health", methods=["GET"])
-async def health_check(request: Request) -> JSONResponse:
- return JSONResponse({"status": "healthy"})
+async def health_check(request: Request) -> PlainTextResponse:
+ return PlainTextResponse("OK")
```
-These routes will be included in the FastMCP app when mounted in your web application.
\ No newline at end of file
+These routes will be included in the FastMCP app when mounted in your web application.
\ No newline at end of file
diff --git a/docs/deployment/running-server.mdx b/docs/deployment/running-server.mdx
index 516846ae4..64f31d134 100644
--- a/docs/deployment/running-server.mdx
+++ b/docs/deployment/running-server.mdx
@@ -29,7 +29,7 @@ def hello(name: str) -> str:
if __name__ == "__main__":
mcp.run()
```
-You can now run this MCP server by executing `python my_server.py`.
+You can now run this MCP server by executing `python my_server.py`.
MCP servers can be run with a variety of different transport options, depending on your application's requirements. The `run()` method can take a `transport` argument and other transport-specific keyword arguments to configure how the server operates.
@@ -260,13 +260,13 @@ You can also add custom web routes to your FastMCP server, which will be exposed
```python
from fastmcp import FastMCP
from starlette.requests import Request
-from starlette.responses import JSONResponse
+from starlette.responses import PlainTextResponse
mcp = FastMCP("MyServer")
@mcp.custom_route("/health", methods=["GET"])
-async def health_check(request: Request) -> JSONResponse:
- return JSONResponse({"status": "healthy"})
+async def health_check(request: Request) -> PlainTextResponse:
+ return PlainTextResponse("OK")return JSONResponse({"status": "healthy"})
if __name__ == "__main__":
mcp.run()