Spaces:
Running
Running
mcp change
Browse files
app.py
CHANGED
|
@@ -321,16 +321,53 @@ async def list_docs():
|
|
| 321 |
|
| 322 |
return {"documents": docs_data}
|
| 323 |
|
| 324 |
-
@app.get("/mcp
|
| 325 |
async def mcp_sse():
|
| 326 |
-
"""SSE endpoint for
|
| 327 |
async def event_generator():
|
| 328 |
-
# Send initial
|
| 329 |
-
yield f"data: {json.dumps({'type': '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
|
| 331 |
# Keep connection alive
|
| 332 |
while True:
|
| 333 |
-
await asyncio.sleep(30)
|
| 334 |
yield f"data: {json.dumps({'type': 'heartbeat', 'timestamp': asyncio.get_event_loop().time()})}\n\n"
|
| 335 |
|
| 336 |
return StreamingResponse(
|
|
|
|
| 321 |
|
| 322 |
return {"documents": docs_data}
|
| 323 |
|
| 324 |
+
@app.get("/mcp")
|
| 325 |
async def mcp_sse():
|
| 326 |
+
"""MCP SSE endpoint for mcp-remote"""
|
| 327 |
async def event_generator():
|
| 328 |
+
# Send initial MCP server info
|
| 329 |
+
yield f"data: {json.dumps({'type': 'mcp_server', 'name': 'mcp-docs-server', 'version': '1.0.0'})}\n\n"
|
| 330 |
+
|
| 331 |
+
# Send available tools
|
| 332 |
+
tools = [
|
| 333 |
+
{
|
| 334 |
+
"name": "search_docs",
|
| 335 |
+
"description": "Search through MCP documentation chunks",
|
| 336 |
+
"inputSchema": {
|
| 337 |
+
"type": "object",
|
| 338 |
+
"properties": {
|
| 339 |
+
"query": {"type": "string", "description": "Search query"},
|
| 340 |
+
"limit": {"type": "integer", "description": "Maximum number of results", "default": 5}
|
| 341 |
+
},
|
| 342 |
+
"required": ["query"]
|
| 343 |
+
}
|
| 344 |
+
},
|
| 345 |
+
{
|
| 346 |
+
"name": "get_chunk",
|
| 347 |
+
"description": "Get a specific documentation chunk by ID",
|
| 348 |
+
"inputSchema": {
|
| 349 |
+
"type": "object",
|
| 350 |
+
"properties": {
|
| 351 |
+
"chunk_id": {"type": "string", "description": "Chunk ID to retrieve"}
|
| 352 |
+
},
|
| 353 |
+
"required": ["chunk_id"]
|
| 354 |
+
}
|
| 355 |
+
},
|
| 356 |
+
{
|
| 357 |
+
"name": "list_docs",
|
| 358 |
+
"description": "List all available documents",
|
| 359 |
+
"inputSchema": {
|
| 360 |
+
"type": "object",
|
| 361 |
+
"properties": {}
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
]
|
| 365 |
+
|
| 366 |
+
yield f"data: {json.dumps({'type': 'tools', 'tools': tools})}\n\n"
|
| 367 |
|
| 368 |
# Keep connection alive
|
| 369 |
while True:
|
| 370 |
+
await asyncio.sleep(30)
|
| 371 |
yield f"data: {json.dumps({'type': 'heartbeat', 'timestamp': asyncio.get_event_loop().time()})}\n\n"
|
| 372 |
|
| 373 |
return StreamingResponse(
|