Unable to Pass Authorization Header from AI Agent → MCP Client → MCP Server Tool

Problem

I’m using the AI Agent with MCP Client → MCP Server setup.
I want to forward the Authorization header (from an incoming webhook) to my HTTP tools hosted on the MCP Server.

Despite updating the AI Agent’s System Prompt to include the Authorization inside the query object, the header is not included in the MCP Client’s tool input.

Flow

Webhook → AI Agent (user prompt: {{$json.body.query}})

System Prompt:
As per user query {{ $json.body.query }}, decide which tool to invoke.
Pass the Authorization header from the webhook like below to tools like MCP client.
{
“query”: {
“Authorization”: “{{ $json.headers.authorization }}”
}
}


MCP Client → MCP Server Tool

n8n version - running using docker , version 1.94.1

Operating system: Ubuntu 24.04

Hi there, could you please the whole workflow JSON so that it’s easier to understand what is going on?

Please check below agent - mcp client json

I think the issue might be due to the fact that the “System Message” input field in the AI Agent is in fixed mode, not expression. Because of this {{ $json.body.query }} and {{ $json.headers.authorization }} are not replaced by the values from the webhook, but instead are left as regular strings. Try switching to expression mode and see if that helps.

Also, if you are using the “Code Tool” in the MCP Server you can turn on “Specify Input Schema” in the options to specify that the tool expects the authorization parameter, which would help the LLM actually pass it down.

Hope this helps!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.