Skip to content

Add MCP server configuration support for agent tools#2

Merged
ligon merged 2 commits intomainfrom
claude/repo-specific-mcp-tools-KFVPY
Apr 5, 2026
Merged

Add MCP server configuration support for agent tools#2
ligon merged 2 commits intomainfrom
claude/repo-specific-mcp-tools-KFVPY

Conversation

@ligon
Copy link
Copy Markdown
Owner

@ligon ligon commented Apr 5, 2026

Summary

This PR adds support for configuring Model Context Protocol (MCP) servers in sucoder, enabling agents to access external tools and services like GitHub, web fetching, and databases. MCP servers can be defined globally or per-mirror in the configuration and are passed to the agent via a generated .sucoder-mcp.json file.

Key Changes

  • New McpServerConfig dataclass in config.py to represent individual MCP server definitions with command, args, and environment variables
  • Configuration parsing for mcp_servers at both global and per-mirror levels, with per-mirror settings overriding global defaults (matching the pattern used for skills)
  • MCP config flag template (mcp_config) added to AgentFlagTemplates with Claude profile defaulting to --mcp-config {path}
  • MCP file generation in mirror.py via _resolve_mcp_config() method that:
    • Generates .sucoder-mcp.json in the mirror with proper MCP server format
    • Adds the file to git exclude to prevent accidental commits
    • Returns the path for use in agent launch flags
  • Agent launch integration to include --mcp-config flag when MCP servers are configured
  • Flag template merging updated to include mcp_config in the three-level merge (per-mirror > global > profile)
  • Comprehensive validation for MCP server configurations with clear error messages
  • Repository-shipped .mcp.json with three default servers (github, fetch, memory) encrypted with git-crypt for token security
  • Documentation in README covering MCP setup, git-crypt usage, and configuration examples

Implementation Details

  • MCP servers are optional; when none are configured, no config file is generated and no flag is added
  • The generated .sucoder-mcp.json omits empty env objects to keep the file clean
  • Idempotent exclude file handling prevents duplicate entries when _resolve_mcp_config() is called multiple times
  • Global MCP servers are inherited by mirrors unless the mirror explicitly defines its own (full replacement, not merge)
  • The .mcp.json file is encrypted with git-crypt to protect sensitive tokens like GITHUB_TOKEN

https://claude.ai/code/session_01A6XWH93fYXRoUycoR5EvpU

Test added 2 commits April 5, 2026 12:17
Allow LLM agents to access MCP (Model Context Protocol) servers
configured either per-repo (.mcp.json, discovered natively by Claude)
or via sucoder's config.yaml (mcp_servers key at global or per-mirror
level). Config-level servers are written to .sucoder-mcp.json in the
mirror and passed via --mcp-config flag.

- Add McpServerConfig dataclass and mcp_servers field to MirrorSettings/Config
- Add mcp_config flag template to AgentFlagTemplates and Claude profile
- Add _resolve_mcp_config() to generate .sucoder-mcp.json with git exclude
- Add _parse_mcp_servers() for YAML config parsing with validation
- Add comprehensive tests for config parsing and mirror integration

https://claude.ai/code/session_01A6XWH93fYXRoUycoR5EvpU
Ship a .mcp.json so CLI-launched agents get GitHub access, web fetch,
and persistent memory — capabilities the web UI provides automatically
but the CLI does not. The file is marked for git-crypt encryption
(.gitattributes) since it will contain a GITHUB_TOKEN.

- Add .mcp.json with three MCP servers (github, fetch, memory)
- Add .gitattributes marking .mcp.json for git-crypt
- Update README.org: add MCP section with setup instructions,
  add mcp_config row to flag template table, add git-crypt and
  node/npx to requirements

https://claude.ai/code/session_01A6XWH93fYXRoUycoR5EvpU
@ligon ligon merged commit e1464f0 into main Apr 5, 2026
4 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.

1 participant