This commit is contained in:
Jon Michael Aanes 2025-06-18 22:14:20 +02:00
parent 3d6c45f2b4
commit a317d1aaef

View File

@ -2,6 +2,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import StreamingResponse
from fastapi.encoders import jsonable_encoder
import uvicorn
from . import tools
@ -26,7 +27,22 @@ app.add_middleware(
allow_headers=["*"],
)
for tool in tools.get_tools():
def setup_mcp():
try:
from fastapi_mcp import FastApiMCP
mcp = FastApiMCP(app)
mcp.mount()
print('MCP mounted')
except ImportError:
print('MCP could not be mounted')
def setup_tools():
for tool in tools.get_tools():
component, method = tool.__name__.split('.')
path = f'/{component}/{method}'
app.get(path, response_model=None,tags=[component])(tool)
if __name__ == "__main__":
setup_tools()
setup_mcp()
uvicorn.run(app, host="0.0.0.0", port=8000)