-
Notifications
You must be signed in to change notification settings - Fork 882
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Some fastapi applications are secured with an API Key passed in HTTP headers (eg X-API-Key).
However currently these headers are stripped on tool use. Only "Authorization" is forwarded.
Describe the solution you'd like
Upon construction, headers to be preserved should be passed to FastApiMCP.
Proposing pull request...
Describe alternatives you've considered
Workaround is to use "Authorization" instead of "X-API-Key" in the fastapi application.
Additional context
The MCP server can be created like so:
mcp = FastApiMCP(
app,
auth_config=AuthConfig(
dependencies=[Depends(get_user)]
),
http_headers=["X-API-Key"],
include_operations=["say_hello"]
)The MCP server can then be added to a client like so:
{
"mcpServers": {
"local-mcp-server": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://localhost:8000/mcp",
"--header",
"X-API-Key:${API_KEY}"
],
"env": {
"API_KEY": "xxx"
}
}
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request