mirror of
https://github.com/open-webui/open-terminal.git
synced 2026-07-09 16:09:14 +00:00
FastMCP.from_fastapi() uses an internal httpx client to call the FastAPI routes. Without auth headers, every tool call (run_command, read_file, etc.) hits the verify_api_key guard and returns 401. Fixes tool calls returning: 'HTTP error 401: Unauthorized - Invalid API key'
15 lines
No EOL
353 B
Python
15 lines
No EOL
353 B
Python
"""MCP server — exposes every FastAPI endpoint as an MCP tool."""
|
|
|
|
from fastmcp import FastMCP
|
|
from open_terminal.main import app
|
|
from open_terminal.env import API_KEY
|
|
|
|
mcp = FastMCP.from_fastapi(
|
|
app=app,
|
|
name="Open Terminal",
|
|
httpx_client_kwargs={
|
|
"headers": {
|
|
"Authorization": f"Bearer {API_KEY}",
|
|
}
|
|
},
|
|
) |