Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
# server.py
|
|
|
|
| 2 |
from mcp.server.fastmcp import FastMCP
|
| 3 |
-
import argparse
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
mcp = FastMCP("OnBase", port=
|
| 9 |
|
| 10 |
@mcp.tool()
|
| 11 |
def get_document_info(id: int):
|
|
@@ -13,13 +13,17 @@ def get_document_info(id: int):
|
|
| 13 |
return {
|
| 14 |
"doc_id": id,
|
| 15 |
"doc_name": "Document Name",
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
if __name__ == "__main__":
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
print(f'Check "http://localhost:{port}/sse" for the server status')
|
| 23 |
-
|
| 24 |
-
# En Spaces siempre usaremos SSE
|
| 25 |
-
mcp.run("sse")
|
|
|
|
| 1 |
# server.py
|
| 2 |
+
from fastapi import APIRouter
|
| 3 |
from mcp.server.fastmcp import FastMCP
|
|
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
# Crea un router de FastAPI en lugar de montar toda la aplicaci贸n
|
| 7 |
+
router = APIRouter()
|
| 8 |
+
mcp = FastMCP("OnBase", port=7860)
|
| 9 |
|
| 10 |
@mcp.tool()
|
| 11 |
def get_document_info(id: int):
|
|
|
|
| 13 |
return {
|
| 14 |
"doc_id": id,
|
| 15 |
"doc_name": "Document Name",
|
| 16 |
+
"doc_type": "Document Type",
|
| 17 |
+
"doc_size": 123456,
|
| 18 |
+
"doc_date": "2023-10-01",
|
| 19 |
+
"doc_author": "Author Name",
|
| 20 |
+
"doc_description": "Document description goes here.",
|
| 21 |
+
"doc_tags": ["tag1", "tag2", "tag3"],
|
| 22 |
}
|
| 23 |
|
| 24 |
+
# Asigna el router de FastMCP a nuestra variable router
|
| 25 |
+
router.include_router(mcp.router)
|
| 26 |
+
|
| 27 |
if __name__ == "__main__":
|
| 28 |
+
import uvicorn
|
| 29 |
+
uvicorn.run(mcp.app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|