MCP Client Tool - Bearer Auth variable

Describe the problem/error/question

I have a MCP Client node (the official one) that needs to pass a Bearer token to the MCP server.
This works if I configure the Bearer Auth credentials with a hardcoded token value.

However, the tokens are shortlived and therefore I have a HTTP Request node previously in my flow that fetches a valid token. I need to pass that to the MCP Client, but it seems like no variables are addressable from within the Bearer Auth credentials configuration.

How can I design this?

Please share your workflow

Share the output returned by the last node

{
“nodes”: [
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “a086d6f2-21d6-4f26-91a6-76e3247c70af”,
“options”: {}
},
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 2.1,
“position”: [
-1088,
-80
],
“id”: “70c33e8e-de11-4d4c-9c98-4d4490af9373”,
“name”: “Webhook”,
“webhookId”: “a086d6f2-21d6-4f26-91a6-76e3247c70af”
},
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
-896,
-336
],
“id”: “51aa8b0c-133f-4dd3-95ef-4f4bb0e660a1”,
“name”: “When clicking ‘Execute workflow’”
},
{
“parameters”: {
“promptType”: “define”,
“text”: “my user prompt”,
“options”: {
“systemMessage”: “my system prompt”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 2.2,
“position”: [
-272,
-176
],
“id”: “6dd994cc-c7f4-4647-ba18-16241eafcd8e”,
“name”: “AI Agent”
},
{
“parameters”: {
“model”: “gpt-5-mini”,
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatAzureOpenAi”,
“typeVersion”: 1,
“position”: [
-352,
96
],
“id”: “a72d466a-6a6e-4d2a-87b6-644a08e49a73”,
“name”: “Azure OpenAI Chat Model”,
“credentials”: {
“azureOpenAiApi”: {
“id”: “if7W6KFJ4XAuKe8g”,
“name”: “Azure Open AI account”
}
}
},
{
“parameters”: {
“method”: “POST”,
“url”: “= Sign in to your account ”,
“sendBody”: true,
“contentType”: “form-urlencoded”,
“bodyParameters”: {
“parameters”: [
{
“name”: “grant_type”,
“value”: “client_credentials”
},
{
“name”: “client_id”,
“value”: “id”
},
{
“name”: “scope”,
“value”: “myScope”
},
{
“name”: “client_secret”,
“value”: “secret”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-592,
-176
],
“id”: “572c808e-50b1-481e-93fc-11007739edae”,
“name”: “FetchToken”
},
{
“parameters”: {
“endpointUrl”: “=https://myMcp.azurewebsites.net/mcp”,
“authentication”: “bearerAuth”,
“include”: “selected”,
“includeTools”: [
“getCustomer”,
“getCustomers”
],
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.mcpClientTool”,
“typeVersion”: 1.2,
“position”: [
416,
-32
],
“id”: “d45a7688-9233-4a46-8c6a-6de70c0497d4”,
“name”: “MCP Client”,
“credentials”: {
“httpBearerAuth”: {
“id”: “aIAPREzFGi9bfuJa”,
“name”: “Bearer Auth account”
}
}
}
],
“connections”: {
“Webhook”: {
“main”: [
[
{
“node”: “FetchToken”,
“type”: “main”,
“index”: 0
}
]
]
},
“When clicking ‘Execute workflow’”: {
“main”: [
[
{
“node”: “FetchToken”,
“type”: “main”,
“index”: 0
}
]
]
},
“Azure OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“FetchToken”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“MCP Client”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “a57de4457f5f868f5f1bf166f34ec2ac9a812b8310a891b7097fecd926909776”
}
}

Information on your n8n setup

  • n8n version: 1.115.3
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system:

You can use expressions within credentials to read the output from previous nodes

1 Like

Great. I was just missing first() to get the right data

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