Skip to content

Commit b5f287d

Browse files
committed
fix: don't expose MCP command strings in system prompt
Commands may contain credentials or sensitive env values. Only expose server names to the model, not the full command strings.
1 parent ed1de83 commit b5f287d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/system-prompt.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ You are in a git worktree at ${workspacePath}
6363
/**
6464
* Build MCP servers context XML block.
6565
* Only included when at least one MCP server is configured.
66+
* Note: We only expose server names, not commands, to avoid leaking secrets.
6667
*/
6768
function buildMCPContext(mcpServers: MCPServerMap): string {
68-
const entries = Object.entries(mcpServers);
69-
if (entries.length === 0) return "";
69+
const names = Object.keys(mcpServers);
70+
if (names.length === 0) return "";
7071

71-
const serverList = entries.map(([name, command]) => `- ${name}: \`${command}\``).join("\n");
72+
const serverList = names.map((name) => `- ${name}`).join("\n");
7273

7374
return `
7475
<mcp>

src/node/services/systemMessage.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ You are in a git worktree at ${workspacePath}
8282
/**
8383
* Build MCP servers context XML block.
8484
* Only included when at least one MCP server is configured.
85+
* Note: We only expose server names, not commands, to avoid leaking secrets.
8586
*/
8687
function buildMCPContext(mcpServers: MCPServerMap): string {
87-
const entries = Object.entries(mcpServers);
88-
if (entries.length === 0) return "";
88+
const names = Object.keys(mcpServers);
89+
if (names.length === 0) return "";
8990

90-
const serverList = entries.map(([name, command]) => `- ${name}: \`${command}\``).join("\n");
91+
const serverList = names.map((name) => `- ${name}`).join("\n");
9192

9293
return `
9394
<mcp>

0 commit comments

Comments
 (0)