Spaces:
Sleeping
Sleeping
File size: 985 Bytes
17f830b d611f61 17f830b 8428125 17f830b ab7f674 17f830b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from fastapi import FastAPI, UploadFile, File, Form
from fastapi_mcp import FastApiMCP
app = FastAPI(title="test fastapi mcp")
@app.get("/")
async def root():
"""Root endpoint to confirm the API is running."""
return {"message": "Welcome to the FAST API MCP integration!"}
@app.get("/greet")
async def root():
"""Root endpoint to confirm the API is running."""
return {"message": "Good day ! this greet endpoint with mcp server feel free to add more api endpoints and usecases"}
# Initialize MCP server
mcp = FastApiMCP(
app,
name="FAST API MCP ",
description="FAST API MCP Intergration test in hf",
)
mcp.mount()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
# working below code
# from fastapi import FastAPI
# app = FastAPI()
# @app.get("/")
# def read_root():
# return {"Hello": "World"}
# @app.get("/greet")
# def read_root():
# return {"Hello User! ": "Welcome to new application"}
|