Skip to content

feat: MCP server support and GitHub code review#35

Merged
whiteboardmonk merged 8 commits into
mainfrom
feature/mcp-server-support
Dec 3, 2025
Merged

feat: MCP server support and GitHub code review#35
whiteboardmonk merged 8 commits into
mainfrom
feature/mcp-server-support

Conversation

@whiteboardmonk

Copy link
Copy Markdown
Owner

Summary

  • add MCP permission propagation and auto-allow per server
  • standardize GitHub PAT handling for MCP (GITHUB_PERSONAL_ACCESS_TOKEN)
  • builder/UI support for permission modes and MCP configs; update docs/changelog

Resolves: #22

Core Infrastructure (Phases 1-3):
- Fix provider bug: MCP servers now passed to containers
- Add mcp_servers and mcp_env fields to ProviderConfig
- Update Docker and Fly providers to merge MCP env vars
- Update Container Manager to pass MCP config through stack

Auto-Allow MCP Tools:
- Add model_validator to auto-enable ListMcpResources/ReadMcpResource
- Existing validator already allows all mcp__* tools
- No need to explicitly list MCP tools in allowed_tools

Launch-Time Credentials:
- Add mcp_env field to LaunchRequest model
- Pass through session_manager and container_manager
- Merge with config-defined env vars in providers
- Example: {"github": {"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_..."}}

This enables MCP servers (GitHub, filesystem, etc.) to work
with runtime credentials provided at agent launch time.

Breaking Change: None (backward compatible)
Testing: Existing tests pass, MCP integration pending
- Specialized for GitHub PR reviews
- Focus on code quality, security, performance, testing, architecture
- Uses GitHub MCP server with launch-time token
- Auto-allows MCP tools (no explicit listing needed)
- Resource limits: 1 CPU, 2GB RAM, 5GB storage
Added comprehensive documentation for Model Context Protocol (MCP) integration:

- Updated README with github-code-review preset
- Added MCP launch examples with mcp_env parameter
- Documented auto-allow MCP tools feature
- Updated configs/README with detailed MCP section
- Added CHANGELOG entry for unreleased MCP features

Key Documentation Updates:
- 5 preset configurations (added github-code-review)
- Runtime credential injection via mcp_env
- Environment variable merging in providers
- Auto-enable ListMcpResources and ReadMcpResource
- Launch examples with GitHub token

Related to feature/mcp-server-support implementation
Fixed JSON serialization error when launching agents with MCP servers.

Problem:
- McpStdioServerConfig (Pydantic model) cannot be directly JSON serialized
- Error: "Object of type McpStdioServerConfig is not JSON serializable"

Solution:
- Convert Pydantic models to dicts using model_dump() before JSON serialization
- Applied to both Docker and Fly providers
- Handles both Pydantic v1 (dict()) and v2 (model_dump())

Changes:
- docker_provider.py: Convert mcp_servers to dicts before adding to agent_config_dict
- fly_provider.py: Same fix for Fly Machines provider
- Both providers: Also convert when iterating for env var substitution

Fixes launch errors for github-code-review and any agents with MCP servers
Added comprehensive UI support for MCP server credentials at launch time.

Changes:

1. MCPServerEditor Component:
   - Fixed "Add MCP Server" button to use platform gray style (bg-gray-700)
   - Added environment variables editor with textarea input
   - Support for ${PLACEHOLDER} syntax with helpful tooltip
   - Shows placeholder hint in textarea

2. McpCredentialsModal Component (NEW):
   - Modal dialog for entering MCP credentials at agent launch
   - Auto-detects required credentials from config mcp_servers
   - Password input fields for each credential
   - Shows placeholder expectations (e.g., ${GITHUB_TOKEN})
   - Validation for required fields
   - "Skip" option to launch without credentials (for testing)
   - Helpful tip about credential lifecycle

3. Launch Flow Updated:
   - Detects agents with has_mcp_servers flag
   - Fetches full config to get MCP server details
   - Shows credentials modal before launching
   - Passes mcp_env to launch API
   - Direct launch for agents without MCP servers

4. API Client Updates:
   - Added mcp_env field to LaunchAgentRequest type
   - Supports nested credentials: { server: { KEY: "value" } }

5. Dashboard Updates:
   - Added github-code-review to PRESET_ICONS
   - Integrated McpCredentialsModal component
   - Split launch logic into handleLaunchAgent + doLaunchAgent

User Experience:
- Click agent with MCP badge → Modal appears
- Enter credentials → Launch with credentials
- Or skip → Launch without (will fail at runtime)
- Clear error messages if validation fails

Example: Launching github-code-review now prompts for GITHUB_PERSONAL_ACCESS_TOKEN
Fixed TypeScript compilation errors that appeared after merging main into
feature/mcp-server-support branch.

Issues fixed:
1. Template literal syntax error with GITHUB_TOKEN placeholder
   - Changed from: ${`${GITHUB_TOKEN}`}
   - Changed to: {'${GITHUB_TOKEN}'}

2. Type guard for env property access
   - Added check: server.type !== 'sse' && server.type !== 'http'
   - The env property only exists on McpStdioServerConfig
   - SSE and HTTP server types don't have env property

3. Type assertion for handleUpdateServer
   - Added: as McpServerConfig to ensure type safety
   - Only updates env for stdio server types

Changes:
- src/agcluster/container/ui/components/builder/MCPServerEditor.tsx

Result:
- npx tsc --noEmit: PASSED
- npm run lint: PASSED
@whiteboardmonk whiteboardmonk merged commit 3a0315a into main Dec 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add MCP Server Support with Launch-Time Credentials

1 participant