mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
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:
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user