Repository navigation
feat: add MCP servers to agent mode - #379
km-anthropic wants to merge 5 commits into
Conversation
|
Claude finished @km-anthropic's task —— View job Code Review: feat: add MCP servers to agent mode
SummaryThis PR successfully enables full MCP server capabilities in agent mode by integrating the existing Positive Aspects1. Architecture & Design ✅
2. Code Quality ✅
3. Testing ✅
4. Documentation ✅
Technical AnalysisCore Changes AnalysisBefore: Agent mode used minimal MCP config with empty Key improvements in const mcpConfig = await prepareMcpConfig({
githubToken,
owner: context.repository.owner,
repo: context.repository.repo,
branch: "", // Agent mode doesn't use branches
baseBranch: "",
additionalMcpConfig,
claudeCommentId: undefined, // Agent mode doesn't track comments
allowedTools: [...baseTools, ...context.inputs.allowedTools],
context, // Now passes full context
});Type Safety ImprovementsThe // src/mcp/install-mcp-server.ts:118
if ('isPR' in context && context.isPR && hasActionsReadPermission) {This pattern safely handles the fact that Minor Suggestions1. Branch Handling ClarityThe empty strings for // Consider adding constants for clarity
const AGENT_MODE_BRANCH = ""; // Agent mode doesn't use branches
const AGENT_MODE_BASE_BRANCH = ""; // Agent mode doesn't track base branches2. Comment ConsistencyConsider adding a comment explaining why claudeCommentId: undefined, // Agent mode doesn't create tracking comments3. Type DocumentationThe Questions for Consideration
ConclusionThis is a well-executed PR that successfully addresses the stated goal. The implementation:
The changes enable powerful automation scenarios where bot actors can leverage Claude's full MCP toolset via Recommendation: APPROVE - This PR is ready for merge. The implementation is solid, well-tested, and addresses a legitimate need for enhanced automation capabilities. |
- Update agent mode to use prepareMcpConfig instead of empty config - Update prepareMcpConfig to accept both ParsedGitHubContext and AutomationContext - Add type guards for context-specific properties (isPR, entityNumber) - This enables bot actors to use full MCP capabilities via workflow_dispatch
bfb7c80 to
106183c
Compare
Remove the generatePrompt method from agent mode since it's not part of the Mode interface in the current main branch. Also remove unused PreparedContext import.
Resolved conflict by keeping both MCP server changes and generatePrompt method
Address review feedback by using isEntityContext() type guard instead of checking 'isPR' in context manually. This provides better type safety and uses the existing type guard infrastructure.
| REPO_OWNER: owner, | ||
| REPO_NAME: repo, | ||
| PR_NUMBER: context.entityNumber?.toString() || "", | ||
| PR_NUMBER: isEntityContext(context) |
There was a problem hiding this comment.
Unfortunately have to deal with PR Numbers (even though Agent Mode doesn't work with PR Events yet) because of the github actions MCP (that's one of the default ones)
Summary
prepareMcpConfigto handle both entity contexts (PRs/issues) and automation contexts (workflow_dispatch/schedule)Context
Agent mode was designed for automation events but had minimal MCP configuration. This limited its usefulness for scenarios where automated workflows need access to GitHub tools (comments, file operations, CI tools, etc).
Changes
prepareMcpConfiginstead of using an empty MCP configurationprepareMcpConfigto accept bothParsedGitHubContextandAutomationContexttypes'isPR' in context) to safely handle context-specific propertiesBenefits
allowed_toolsparameterTesting