Spaces:
Running
Running
Merge pull request #477 from mcw0933/main
Browse filesdoc(asgi): Change custom route example to PlainTextResponse
docs/deployment/asgi.mdx
CHANGED
|
@@ -43,7 +43,7 @@ http_app = mcp.http_app()
|
|
| 43 |
sse_app = mcp.http_app(transport="sse")
|
| 44 |
```
|
| 45 |
|
| 46 |
-
Both approaches return a Starlette application that can be integrated with other ASGI-compatible web frameworks.
|
| 47 |
|
| 48 |
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:
|
| 49 |
|
|
@@ -199,13 +199,13 @@ In addition to adding your FastMCP server to an existing ASGI app, you can also
|
|
| 199 |
```python
|
| 200 |
from fastmcp import FastMCP
|
| 201 |
from starlette.requests import Request
|
| 202 |
-
from starlette.responses import
|
| 203 |
|
| 204 |
mcp = FastMCP("MyServer")
|
| 205 |
|
| 206 |
@mcp.custom_route("/health", methods=["GET"])
|
| 207 |
-
async def health_check(request: Request) ->
|
| 208 |
-
return
|
| 209 |
```
|
| 210 |
|
| 211 |
-
These routes will be included in the FastMCP app when mounted in your web application.
|
|
|
|
| 43 |
sse_app = mcp.http_app(transport="sse")
|
| 44 |
```
|
| 45 |
|
| 46 |
+
Both approaches return a Starlette application that can be integrated with other ASGI-compatible web frameworks.
|
| 47 |
|
| 48 |
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:
|
| 49 |
|
|
|
|
| 199 |
```python
|
| 200 |
from fastmcp import FastMCP
|
| 201 |
from starlette.requests import Request
|
| 202 |
+
from starlette.responses import PlainTextResponse
|
| 203 |
|
| 204 |
mcp = FastMCP("MyServer")
|
| 205 |
|
| 206 |
@mcp.custom_route("/health", methods=["GET"])
|
| 207 |
+
async def health_check(request: Request) -> PlainTextResponse:
|
| 208 |
+
return PlainTextResponse("OK")
|
| 209 |
```
|
| 210 |
|
| 211 |
+
These routes will be included in the FastMCP app when mounted in your web application.
|
docs/deployment/running-server.mdx
CHANGED
|
@@ -29,7 +29,7 @@ def hello(name: str) -> str:
|
|
| 29 |
if __name__ == "__main__":
|
| 30 |
mcp.run()
|
| 31 |
```
|
| 32 |
-
You can now run this MCP server by executing `python my_server.py`.
|
| 33 |
|
| 34 |
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.
|
| 35 |
|
|
@@ -260,13 +260,13 @@ You can also add custom web routes to your FastMCP server, which will be exposed
|
|
| 260 |
```python
|
| 261 |
from fastmcp import FastMCP
|
| 262 |
from starlette.requests import Request
|
| 263 |
-
from starlette.responses import
|
| 264 |
|
| 265 |
mcp = FastMCP("MyServer")
|
| 266 |
|
| 267 |
@mcp.custom_route("/health", methods=["GET"])
|
| 268 |
-
async def health_check(request: Request) ->
|
| 269 |
-
return
|
| 270 |
|
| 271 |
if __name__ == "__main__":
|
| 272 |
mcp.run()
|
|
|
|
| 29 |
if __name__ == "__main__":
|
| 30 |
mcp.run()
|
| 31 |
```
|
| 32 |
+
You can now run this MCP server by executing `python my_server.py`.
|
| 33 |
|
| 34 |
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.
|
| 35 |
|
|
|
|
| 260 |
```python
|
| 261 |
from fastmcp import FastMCP
|
| 262 |
from starlette.requests import Request
|
| 263 |
+
from starlette.responses import PlainTextResponse
|
| 264 |
|
| 265 |
mcp = FastMCP("MyServer")
|
| 266 |
|
| 267 |
@mcp.custom_route("/health", methods=["GET"])
|
| 268 |
+
async def health_check(request: Request) -> PlainTextResponse:
|
| 269 |
+
return PlainTextResponse("OK")
|
| 270 |
|
| 271 |
if __name__ == "__main__":
|
| 272 |
mcp.run()
|