Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- mcp_server_sse.py +32 -0
mcp_server_sse.py
CHANGED
|
@@ -572,6 +572,38 @@ async def health_check():
|
|
| 572 |
}
|
| 573 |
|
| 574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
if __name__ == "__main__":
|
| 576 |
import uvicorn
|
| 577 |
uvicorn.run(
|
|
|
|
| 572 |
}
|
| 573 |
|
| 574 |
|
| 575 |
+
@app.api_route("/api/{path:path}", methods=["GET", "POST", "PUT", "DELETE"])
|
| 576 |
+
async def redirect_old_api(path: str):
|
| 577 |
+
"""Handle old REST API endpoints with helpful message"""
|
| 578 |
+
return JSONResponse(
|
| 579 |
+
status_code=404,
|
| 580 |
+
content={
|
| 581 |
+
"error": "API endpoint not found",
|
| 582 |
+
"message": "This server now uses the MCP (Model Context Protocol).",
|
| 583 |
+
"migration_guide": {
|
| 584 |
+
"old_endpoint": f"/api/{path}",
|
| 585 |
+
"new_method": "Use MCP protocol via POST /message",
|
| 586 |
+
"documentation": "Visit / for setup instructions",
|
| 587 |
+
"example": {
|
| 588 |
+
"method": "POST",
|
| 589 |
+
"url": "/message",
|
| 590 |
+
"body": {
|
| 591 |
+
"jsonrpc": "2.0",
|
| 592 |
+
"id": 1,
|
| 593 |
+
"method": "tools/call",
|
| 594 |
+
"params": {
|
| 595 |
+
"name": "advanced_search_company",
|
| 596 |
+
"arguments": {"company_input": "Microsoft"}
|
| 597 |
+
}
|
| 598 |
+
}
|
| 599 |
+
}
|
| 600 |
+
},
|
| 601 |
+
"available_tools": "/tools",
|
| 602 |
+
"health_check": "/health"
|
| 603 |
+
}
|
| 604 |
+
)
|
| 605 |
+
|
| 606 |
+
|
| 607 |
if __name__ == "__main__":
|
| 608 |
import uvicorn
|
| 609 |
uvicorn.run(
|