Spaces:
No application file
No application file
Create simple_mcp_server.py
Browse files- simple_mcp_server.py +31 -0
simple_mcp_server.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# simple_mcp_server.py - for testing
|
| 2 |
+
from mcp.server.fastmcp import FastMCP
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
logging.basicConfig(level=logging.INFO)
|
| 7 |
+
logger = logging.getLogger(__name__)
|
| 8 |
+
|
| 9 |
+
config = {
|
| 10 |
+
"mcp_port": 8000,
|
| 11 |
+
"host": "0.0.0.0"
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
mcp_app = FastMCP(name="simple-ppt-test", host=config["host"], port=config["mcp_port"], stateless_http=True)
|
| 15 |
+
|
| 16 |
+
@mcp_app.tool()
|
| 17 |
+
def test_connection() -> dict:
|
| 18 |
+
"""Test if MCP connection works"""
|
| 19 |
+
return {
|
| 20 |
+
"status": "success",
|
| 21 |
+
"message": "MCP server is responding correctly",
|
| 22 |
+
"server": "Hugging Face Space"
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
if __name__ == "__main__":
|
| 26 |
+
logger.info("Starting simple MCP test server...")
|
| 27 |
+
try:
|
| 28 |
+
mcp_app.run(transport="streamable-http")
|
| 29 |
+
except Exception as e:
|
| 30 |
+
logger.error(f"Server failed to start: {str(e)}")
|
| 31 |
+
raise
|