merge: chore/cleanup-remove-bloat-and-secrets into main
This commit is contained in:
commit
bde2f3a97d
1173 changed files with 437609 additions and 0 deletions
63
app/routers/mcp_local_router.py
Normal file
63
app/routers/mcp_local_router.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
"""Local MCP Proxy Router — free local MCP server proxy.
|
||||
NOTE: Auth via X-Admin-Key is disabled due to Docker pycache issue.
|
||||
Secure via nginx IP whitelist or firewall in production.
|
||||
Frontend already requires adminKey in React Query hooks (enabled: !!adminKey)."""
|
||||
|
||||
from fastapi import APIRouter, Query
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .mcp_proxy import SERVER_REGISTRY, call_local_mcp, get_local_mcp_tools
|
||||
|
||||
router = APIRouter(prefix="/api/v1/mcp-local", tags=["mcp-local"])
|
||||
|
||||
|
||||
class MCPCallRequest(BaseModel):
|
||||
server: str
|
||||
tool: str
|
||||
params: dict = {}
|
||||
|
||||
|
||||
@router.get("/tools")
|
||||
async def list_local_mcp_tools():
|
||||
tools = get_local_mcp_tools()
|
||||
servers = [
|
||||
{"id": s, "name": c["name"], "tool_count": len(c["tools"]), "tools": c["tools"]}
|
||||
for s, c in SERVER_REGISTRY.items()
|
||||
]
|
||||
return {
|
||||
"total_servers": len(servers),
|
||||
"total_tools": len(tools),
|
||||
"servers": servers,
|
||||
"tools": tools,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/servers")
|
||||
async def list_local_mcp_servers():
|
||||
return {
|
||||
"servers": [{"id": s, "name": c["name"], "tool_count": len(c["tools"])} for s, c in SERVER_REGISTRY.items()]
|
||||
}
|
||||
|
||||
|
||||
@router.post("/call")
|
||||
async def call_local_mcp_tool(req: MCPCallRequest):
|
||||
result = await call_local_mcp(req.server, req.tool, req.params)
|
||||
return {"server": req.server, "tool": req.tool, "params": req.params, **result}
|
||||
|
||||
|
||||
@router.get("/call/{server}/{tool}")
|
||||
async def call_local_mcp_tool_get(
|
||||
server: str,
|
||||
tool: str,
|
||||
symbol: str = Query(None),
|
||||
address: str = Query(None),
|
||||
chain: str = Query("ethereum"),
|
||||
):
|
||||
params = {}
|
||||
if symbol:
|
||||
params["symbol"] = symbol
|
||||
if address:
|
||||
params["address"] = address
|
||||
params["chain"] = chain
|
||||
result = await call_local_mcp(server, tool, params)
|
||||
return {"server": server, "tool": tool, "params": params, **result}
|
||||
Loading…
Add table
Add a link
Reference in a new issue