fix: resolve §§secret() placeholders in MCP server env/headers config#1150
Closed
kundeng wants to merge 3 commits intoagent0ai:mainfrom
Closed
fix: resolve §§secret() placeholders in MCP server env/headers config#1150kundeng wants to merge 3 commits intoagent0ai:mainfrom
kundeng wants to merge 3 commits intoagent0ai:mainfrom
Conversation
The secrets management system (usr/secrets.env + §§secret(KEY) placeholders)
was only wired up for tool call arguments via _10_unmask_secrets.py, but not
for MCP server startup configuration.
This patch resolves §§secret() placeholders in:
- MCPClientLocal: stdio server env dict
- MCPClientRemote: SSE/HTTP server url and headers dict
Users can now reference secrets in MCP server config like:
{"env": {"API_TOKEN": "§§secret(MY_API_TOKEN)"}}
Fixes #1148
The args array for local MCP servers (e.g. mcp-remote --header) can contain secret references. Resolve them alongside env vars.
The section sign (§§) is difficult to type on most keyboards. Accept $$secret(KEY) as an equivalent alternative. The canonical output/display format remains §§secret(KEY).
WingedGuardian
added a commit
to WingedGuardian/agent-zero
that referenced
this pull request
Mar 1, 2026
…tent Cherry-picked from community PRs: - agent0ai#1149 (kundeng): Handle structuredContent in MCP tool responses - agent0ai#1150 (kundeng): Resolve §§secret()/$$secret() in MCP server env/headers/url Co-Authored-By: Claude Opus 4.6 <[email protected]>
Nafania
added a commit
to Nafania/agent-zero
that referenced
this pull request
Mar 31, 2026
- #3: duplicate response loop breaker (breaks after 3 identical responses) - #4: dynamic output truncation threshold based on context window size - #2: resolve §§secret() / $$secret() placeholders in MCP server env/args/url/headers - #19: scheduler update_task tool method + prompt documentation Already applied (verified, skipping): #22 parallel MCP init, agent0ai#62 context window optimization Upstream: PR agent0ai#1265, PR agent0ai#857, PR agent0ai#1150, PR agent0ai#1105 Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The secrets management system (
usr/secrets.env+§§secret(KEY)placeholders +SecretsManager.replace_placeholders()) was only wired up for tool call arguments via_10_unmask_secrets.py— not for MCP server startup configuration.This means
§§secret(MY_KEY)in an MCP server'senvdict (stdio) orheaders/url(SSE/HTTP) was passed as a literal string instead of being resolved to the actual secret value.Changes
Resolve
§§secret()placeholders before passing config to the MCP SDK:Stdio servers (
MCPClientLocal._create_stdio_transport):SSE/HTTP servers (
MCPClientRemote._create_stdio_transport):§§secret()inserver.url§§secret()inserver.headersdict valuessse_client()andstreamablehttp_client()Usage
Users can now configure MCP servers with secret references:
{ "mcpServers": { "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "my-se "m an "my-se_p "my-se "my-se "my-se "my-se "my-se "my-se "my-se � only adds resolution when `§§secret()` patterns are present ---------ea---------ea---------ea---------ea---------ea---------ea------secrets in output - Affected file: `python/hel- Affected file: `y`- Affected f8