diff --git a/fastapi_mcp/server.py b/fastapi_mcp/server.py index f5c4fc6..2cb1125 100644 --- a/fastapi_mcp/server.py +++ b/fastapi_mcp/server.py @@ -375,6 +375,8 @@ async def _execute_api_tool( Returns: The result as MCP content types """ + logger.debug(f"FastAPI-MCP: Received call_tool request. Tool: {tool_name}, Arguments: {json.dumps(arguments)}") + if tool_name not in operation_map: raise Exception(f"Unknown tool: {tool_name}") @@ -413,6 +415,13 @@ async def _execute_api_tool( elif "authorization" in http_request_info.headers: headers["Authorization"] = http_request_info.headers["authorization"] + # NEW: Check arguments for a user_access_token if Authorization header is still missing + if "Authorization" not in headers and arguments and "user_access_token" in arguments: + token = arguments.pop("user_access_token", None) # Remove it from arguments so it doesn't become body + if token: + headers["Authorization"] = f"Bearer {token}" + logger.debug("Set Authorization header from 'user_access_token' in tool arguments.") + body = arguments if arguments else None try: