Publish curated Unraid-AppOps-Gateway source from a506550ef83ef2d81651e37c98a89f7ee330c730
This commit is contained in:
1 parent
2facb8de34
commit
767e66921e
68 files changed
+15924
-313
No files matched your search
+13
-3
@@ -73,6 +73,7 @@ from .mcp_server import (
|
||||
restore_tool_metrics,
|
||||
set_session_running,
|
||||
)
|
||||
from .runner_statistics_mcp import runner_statistics_mcp_http_app, run_runner_statistics_mcp
|
||||
from .services import knowledge_service
|
||||
from .services.discovery_scheduler import run_periodic_discovery
|
||||
from .services.maintenance_scheduler import (
|
||||
@@ -130,6 +131,7 @@ async def lifespan(_: FastAPI):
|
||||
if settings.mcp_enabled:
|
||||
await stack.enter_async_context(appops_mcp.session_manager.run())
|
||||
set_session_running(True)
|
||||
await stack.enter_async_context(run_runner_statistics_mcp())
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
@@ -182,6 +184,7 @@ class MachineBodyLimitMiddleware:
|
||||
method = str(scope.get("method", "GET")).upper()
|
||||
is_machine_post = method not in _SAFE_METHODS and (
|
||||
path == "/mcp" or path.startswith("/mcp/")
|
||||
or path == "/mcp-runner-statistics" or path.startswith("/mcp-runner-statistics/")
|
||||
or path == "/api/integrations/n8n" or path.startswith("/api/integrations/n8n/")
|
||||
)
|
||||
if scope["type"] != "http" or not is_machine_post:
|
||||
@@ -243,17 +246,23 @@ async def private_operator_boundary(request, call_next):
|
||||
is_api = path == "/api" or path.startswith("/api/")
|
||||
is_voice = path.startswith("/api/voice/")
|
||||
is_mcp = path == "/mcp" or path.startswith("/mcp/")
|
||||
is_runner_statistics_mcp = path == "/mcp-runner-statistics" or path.startswith("/mcp-runner-statistics/")
|
||||
is_n8n = path == "/api/integrations/n8n" or path.startswith("/api/integrations/n8n/")
|
||||
is_public_auth = request.method in _SAFE_METHODS and (
|
||||
path in {"/api/auth/session", "/api/auth/providers", "/api/health"}
|
||||
or path.startswith(("/api/auth/login/", "/api/auth/callback/"))
|
||||
)
|
||||
if is_mcp or is_n8n:
|
||||
if is_runner_statistics_mcp:
|
||||
try:
|
||||
require_service_request(request, "mcp_runner_statistics")
|
||||
except HTTPException as exc:
|
||||
return finalize_response(JSONResponse(status_code=exc.status_code, content={"detail": exc.detail}))
|
||||
elif is_mcp or is_n8n:
|
||||
try:
|
||||
require_service_request(request, "mcp" if is_mcp else "n8n")
|
||||
except HTTPException as exc:
|
||||
return finalize_response(JSONResponse(status_code=exc.status_code, content={"detail": exc.detail}))
|
||||
if is_mcp or is_n8n:
|
||||
if is_mcp or is_runner_statistics_mcp or is_n8n:
|
||||
content_length = request.headers.get("content-length")
|
||||
if content_length and content_length.isdigit() and int(content_length) > 1_048_576:
|
||||
return finalize_response(JSONResponse(status_code=413, content={"detail": "Request body exceeds 1 MiB limit"}))
|
||||
@@ -297,7 +306,7 @@ async def private_operator_boundary(request, call_next):
|
||||
response = await call_next(request)
|
||||
finally:
|
||||
actor_identity.reset(actor_token)
|
||||
if is_api:
|
||||
if is_api or is_runner_statistics_mcp:
|
||||
response.headers.setdefault("Cache-Control", "no-store")
|
||||
return finalize_response(response)
|
||||
|
||||
@@ -356,6 +365,7 @@ app.include_router(integrations_router)
|
||||
app.include_router(n8n_router)
|
||||
app.include_router(knowledge_router)
|
||||
app.mount("/mcp", mcp_http_app)
|
||||
app.mount("/mcp-runner-statistics", runner_statistics_mcp_http_app)
|
||||
|
||||
|
||||
@app.get('/api')
|
||||
|
||||
Reference in new issue
Block a user