Upload 19 files
Browse files- ManimStudio_appSDK.mp4 +2 -2
- mcp_integration.py +23 -2
ManimStudio_appSDK.mp4
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b3a4496fca04f049b16faedbfa4916f2b87dfb95ebdf63d88f50fd1670a3ae5f
|
| 3 |
+
size 133
|
mcp_integration.py
CHANGED
|
@@ -3,6 +3,7 @@ MCP Integration for ChatGPT Apps SDK
|
|
| 3 |
This module adds MCP protocol support to the existing FastAPI application
|
| 4 |
"""
|
| 5 |
|
|
|
|
| 6 |
from typing import Any, Dict, List
|
| 7 |
from fastapi import APIRouter, Request
|
| 8 |
from fastapi.responses import JSONResponse, FileResponse
|
|
@@ -107,6 +108,26 @@ MANIM_TOOLS = [
|
|
| 107 |
]
|
| 108 |
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
@mcp_router.options("/mcp")
|
| 111 |
async def mcp_options():
|
| 112 |
"""Handle CORS preflight requests"""
|
|
@@ -154,8 +175,8 @@ async def mcp_endpoint(request: Request):
|
|
| 154 |
|
| 155 |
# List resources (UI components)
|
| 156 |
if method == "resources/list":
|
| 157 |
-
base_url = request
|
| 158 |
-
resource_url = f"{base_url}mcp/resources/video-player"
|
| 159 |
|
| 160 |
return {
|
| 161 |
"jsonrpc": "2.0",
|
|
|
|
| 3 |
This module adds MCP protocol support to the existing FastAPI application
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
import os
|
| 7 |
from typing import Any, Dict, List
|
| 8 |
from fastapi import APIRouter, Request
|
| 9 |
from fastapi.responses import JSONResponse, FileResponse
|
|
|
|
| 108 |
]
|
| 109 |
|
| 110 |
|
| 111 |
+
def _get_public_base_url(request: Request) -> str:
|
| 112 |
+
space_host = os.getenv("SPACE_HOST")
|
| 113 |
+
if space_host:
|
| 114 |
+
if space_host.startswith("http"):
|
| 115 |
+
return space_host.rstrip("/")
|
| 116 |
+
return f"https://{space_host}".rstrip("/")
|
| 117 |
+
|
| 118 |
+
forwarded_host = request.headers.get("x-forwarded-host")
|
| 119 |
+
forwarded_proto = request.headers.get("x-forwarded-proto")
|
| 120 |
+
if forwarded_host:
|
| 121 |
+
scheme = forwarded_proto or request.url.scheme
|
| 122 |
+
return f"{scheme}://{forwarded_host}".rstrip("/")
|
| 123 |
+
|
| 124 |
+
host = request.headers.get("host")
|
| 125 |
+
if request.url.scheme == "http" and host and host.endswith(".hf.space"):
|
| 126 |
+
return f"https://{host}".rstrip("/")
|
| 127 |
+
|
| 128 |
+
return str(request.base_url).rstrip("/")
|
| 129 |
+
|
| 130 |
+
|
| 131 |
@mcp_router.options("/mcp")
|
| 132 |
async def mcp_options():
|
| 133 |
"""Handle CORS preflight requests"""
|
|
|
|
| 175 |
|
| 176 |
# List resources (UI components)
|
| 177 |
if method == "resources/list":
|
| 178 |
+
base_url = _get_public_base_url(request)
|
| 179 |
+
resource_url = f"{base_url}/mcp/resources/video-player"
|
| 180 |
|
| 181 |
return {
|
| 182 |
"jsonrpc": "2.0",
|