LibreChat/api/server/services
Danny Avila fb3b299de6
🪪 feat: Add Agent Identity to Provider and MCP Header Templates (#18113)
* feat: resolve executing agent ids in MCP header templates

* test: preserve MCP config source literal types

* 🪪 feat: Forward the Active Agent Id in Request Header Placeholders

A gateway in front of LibreChat sees the user, the conversation and the
message, but not which agent is running — so it cannot attribute spend per
agent, apply per-agent limits, or tell agent traffic from plain chat. Adds
`{{LIBRECHAT_AGENT_ID}}` as its own namespace beside the user / body / OpenID
ones, resolving wherever the existing request placeholders already work.

The value is the primary agent's, derived once per run, so subagent steps and
auxiliary calls (summarization, titles, activity labels, memory extraction)
forward the id of the turn they belong to rather than their own. Only
persisted agents resolve: ephemeral ids embed user-authored preset text that
is unsafe in a header value, so ephemeral runs and non-agent requests resolve
to an empty value rather than forwarding literal template text.

No behaviour change unless the placeholder is configured. The MCP surface
(#14303) is not covered — its connection classification derives from
`ALLOWED_BODY_FIELDS`, so a new namespace needs a follow-up.

(cherry picked from commit 8a3f1016f0)

* test: cover shared provider and MCP agent header resolution

* docs: clarify absent agent placeholder resolution

* fix: preserve agent header boundaries across transport lifecycles

* fix: retain Google header provenance during agent resolution

---------

Co-authored-by: Jiří Krejčí <51734696+krejcji@users.noreply.github.com>
2026-11-13 13:02:39 -05:00
..
__tests__ 🚪 fix: Refuse Interactive MCP Sign-in on Remote Agent API Runs (#18058) 2026-11-11 20:56:17 -05:00
Agents 🌐 feat: Wire Responses and Channel Lifecycle APIs (#17611) 2026-11-10 21:04:03 -08:00
Artifacts
Config 📦 feat: Package Shared Slack Workspace Deployments (#17815) 2026-11-10 21:04:10 -08:00
Endpoints fix: Guard Mongo Cleanup In Api Services Tests (#17990) 2026-11-11 11:10:39 +01:00
Files fix: Guard Mongo Cleanup In Api Services Tests (#17990) 2026-11-11 11:10:39 +01:00
MCP 🔐 fix: Fence ACL Viewers and Surface Revocation Failures When Removing Shared MCP Servers (#17506) 2026-10-28 00:37:07 +01:00
Runs 🗑️ fix: Drain Assistants Runs Before Erasing the Account (#17937) 2026-11-09 15:35:31 +01:00
Schedules 🪸 refactor: Separate Shared-Link and Schedule Persistence (#18031) 2026-11-10 15:44:13 -05:00
Skills 🔌 feat: Integrate Durable Skill Lifecycle Across Writers and Routes (#17043) 2026-10-16 09:05:05 -07:00
start 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
Threads fix: Guard Mongo Cleanup In Api Services Tests (#17990) 2026-11-11 11:10:39 +01:00
Tools 🚪 fix: Refuse Interactive MCP Sign-in on Remote Agent API Runs (#18058) 2026-11-11 20:56:17 -05:00
ActionService.js 🫢 fix: Keep OAuth Credentials Out of Logs (#17409) 2026-10-24 09:43:06 +02:00
ActionService.spec.js 🫢 fix: Keep OAuth Credentials Out of Logs (#17409) 2026-10-24 09:43:06 +02:00
AssistantService.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
AuthService.js 📪 fix: Require Email Delivery for Password Reset Links (#17823) 2026-11-09 08:27:33 -05:00
AuthService.spec.js 📪 fix: Require Email Delivery for Password Reset Links (#17823) 2026-11-09 08:27:33 -05:00
ChannelAuthority.js 🔗 fix: Update Slack Account Linking in Place (#18039) 2026-11-10 21:04:12 -08:00
ChannelAuthority.spec.js 👤 feat: Link and Revoke Personal Channel Accounts (#17615) 2026-11-10 21:04:04 -08:00
Channels.js 🧹 refactor: Consolidate Channel and Response Contracts (#17705) 2026-11-10 21:04:06 -08:00
Channels.spec.js 🌐 feat: Connect Organization Slack Workspaces to Agents (#17811) 2026-11-10 21:04:10 -08:00
createRunBody.js
createRunBody.spec.js
GraphApiService.js 🥸 fix: Resolve Directory Principals Through Trusted Integration Data (#17825) 2026-11-10 09:22:08 -05:00
GraphApiService.spec.js fix: Guard Mongo Cleanup In Api Services Tests (#17990) 2026-11-11 11:10:39 +01:00
GraphTokenService.js
initializeMCPs.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeMCPs.plugins.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeMCPs.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeOAuthReconnectManager.js 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
initializeOAuthReconnectManager.spec.js 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
LangfusePromptSync.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
LangfusePromptSync.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
MCP.js 🪪 feat: Add Agent Identity to Provider and MCP Header Templates (#18113) 2026-11-13 13:02:39 -05:00
MCP.spec.js 🪪 feat: Add Agent Identity to Provider and MCP Header Templates (#18113) 2026-11-13 13:02:39 -05:00
MCPAuthorizationFenceRetry.js
MCPAuthorizationFenceRetry.spec.js
MCPRequestContext.js
OboPolicyService.js
OboTokenService.js 🙈 fix: Mask Emails and Drop Personal Identifiers From Logs (#17048) 2026-10-15 15:54:27 +02:00
OboTokenService.spec.js
OpenIDRefreshFlight.js
OpenIDRefreshFlight.spec.js
OpenIDRefreshRecovery.js 🔐 fix: Retire Credentials by Their Committing Write and on Opt-In 2FA (#17504) 2026-11-05 22:53:11 +01:00
OpenIDSessionRefresh.js
OpenIDSessionRefresh.spec.js 🪪 fix: Boot-Paint a Cached Theme Only for Its Signed-In Owner (#16926) 2026-10-14 11:08:53 +02:00
PermissionService.js 🥸 fix: Resolve Directory Principals Through Trusted Integration Data (#17825) 2026-11-10 09:22:08 -05:00
PermissionService.spec.js fix: Guard Mongo Cleanup In Api Services Tests (#17990) 2026-11-11 11:10:39 +01:00
PluginService.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
PluginService.spec.js 🔐 fix: Encrypt User Plugin Credentials With Random-IV v3 Format (#16996) 2026-10-12 16:33:08 +02:00
Prompts.consumers.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
Prompts.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
Prompts.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
RefreshTokenBridge.js
RefreshTokenBridge.spec.js
Responses.js ⏯️ feat: Review and Stop Background Responses (#17613) 2026-11-10 21:04:04 -08:00
Responses.spec.js ⏯️ feat: Review and Stop Background Responses (#17613) 2026-11-10 21:04:04 -08:00
SlackDispatch.js 🌐 feat: Connect Organization Slack Workspaces to Agents (#17811) 2026-11-10 21:04:10 -08:00
SlackWorkspaceBindings.js 👥 fix: Let Members Connect Agents to Slack Workspaces (#17835) 2026-11-10 21:04:11 -08:00
SlackWorkspaces.js 🔌 feat: Add Tenant-Owned Slack Installation Storage and OAuth (#17810) 2026-11-10 21:04:09 -08:00
systemGrant.spec.js fix: Guard Mongo Cleanup In Api Services Tests (#17990) 2026-11-11 11:10:39 +01:00
ToolService.js 🚪 fix: Refuse Interactive MCP Sign-in on Remote Agent API Runs (#18058) 2026-11-11 20:56:17 -05:00
twoFactorService.js
twoFactorService.spec.js 🗃️ refactor: Remove Dead Data Schemas Methods and Data Provider Exports (#17113) 2026-10-15 12:23:29 +02:00