Skip to content

Commit 3802d1f

Browse files
committed
use http transport in example 08
1 parent d7110cf commit 3802d1f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

examples/08_auth_example_token_passthrough.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
}
2222
```
2323
"""
24-
from examples.shared.apps.items import app # The FastAPI app
24+
25+
from examples.shared.apps.items import app # The FastAPI app
2526
from examples.shared.setup import setup_logging
2627

2728
from fastapi import Depends
@@ -34,11 +35,13 @@
3435
# Scheme for the Authorization header
3536
token_auth_scheme = HTTPBearer()
3637

38+
3739
# Create a private endpoint
3840
@app.get("/private")
39-
async def private(token = Depends(token_auth_scheme)):
41+
async def private(token=Depends(token_auth_scheme)):
4042
return token.credentials
4143

44+
4245
# Create the MCP server with the token auth scheme
4346
mcp = FastApiMCP(
4447
app,
@@ -49,10 +52,11 @@ async def private(token = Depends(token_auth_scheme)):
4952
)
5053

5154
# Mount the MCP server
52-
mcp.mount()
55+
mcp.mount_http()
56+
# mcp.mount_sse() # Or use SSE transport instead
5357

5458

5559
if __name__ == "__main__":
5660
import uvicorn
57-
58-
uvicorn.run(app, host="0.0.0.0", port=8000)
61+
62+
uvicorn.run(app, host="0.0.0.0", port=8000)

0 commit comments

Comments
 (0)