-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (30 loc) · 943 Bytes
/
app.py
File metadata and controls
39 lines (30 loc) · 943 Bytes
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
"""
Hugging Face Spaces entry point for OpenPIV MCP Server.
This mounts the MCP server as a Starlette app for Hugging Face Spaces.
API Endpoint:
/mcp - MCP Streamable HTTP endpoint
/health - Health check endpoint (JSON)
Usage with MCP client:
URL: https://alexliberzon-openpiv-mcp.hf.space/mcp
"""
import os
import sys
# Add src directory to Python path for imports
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
# Get configuration from environment
HOST = os.environ.get("HOST", "0.0.0.0")
PORT = int(os.environ.get("PORT", 7860))
if __name__ == "__main__":
from openpiv_mcp import mcp
# Get the MCP HTTP app
app = mcp.streamable_http_app()
# Run with uvicorn
# Use h11 (HTTP/1.1) for better compatibility with HF Spaces proxy
import uvicorn
uvicorn.run(
app,
host=HOST,
port=PORT,
forwarded_allow_ips="*",
http="h11",
)