feat: make MCP servers conditional in agent mode (#513)

* feat: make MCP servers conditional in agent mode

In agent mode, MCP servers (github_comment, github_ci) are now only included
when explicitly requested via allowedTools, rather than being auto-provisioned.

This change gives agent mode workflows complete control over which MCP
servers are included, preventing unwanted automatic provisioning of GitHub
integration tools.

Changes:
- Add agent mode detection in prepareMcpConfig
- Make github_comment server conditional based on allowedTools in agent mode
- Make github_ci server conditional based on allowedTools in agent mode
- Tag mode behavior remains unchanged (auto-inclusion)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: update agent mode test for conditional MCP behavior

Updated test expectation to match the new conditional MCP server behavior
where agent mode only includes MCP config when servers are actually needed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Kashyap Murali <13315300+katchu11@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
kashyap murali
2025-08-29 16:40:14 -07:00
committed by GitHub
parent 1f8cfe7658
commit 45408b4058
2 changed files with 46 additions and 20 deletions

View File

@@ -161,9 +161,11 @@ describe("Agent Mode", () => {
// Note: We can't easily test file creation in this unit test,
// but we can verify the method completes without errors
// Agent mode now includes MCP config even with empty user args
// With our conditional MCP logic, agent mode with no allowed tools
// should not include any MCP config
const callArgs = setOutputSpy.mock.calls[0];
expect(callArgs[0]).toBe("claude_args");
expect(callArgs[1]).toContain("--mcp-config");
// Should be empty or just whitespace when no MCP servers are included
expect(callArgs[1]).not.toContain("--mcp-config");
});
});