Skip to content

[Feature] Support for project-level MCP configuration files (.mcp.json) #268

Closed

Description

@Avtrkrb

Description

Add support for project-level MCP server configuration files (.mcp.json, mcp.json) that can be located in project root directories or within .nanocoder/ and .claude/ directories. This would enable team collaboration on MCP server setups while maintaining security for sensitive credentials.

Use Case

Problem

Currently, Nanocoder only supports MCP server configuration through the global agents.config.json file. This creates challenges for:

  1. Team Collaboration: Teams cannot easily share MCP server configurations for specific projects
  2. Environment Separation: Different projects require different MCP server setups, but this isn't easily achievable
  3. Security Concerns: Sensitive credentials must be shared or managed separately from project configuration
  4. Version Control: MCP server configurations cannot be version-controlled with project code

Real-world Scenario

A development team working on multiple projects needs:

  • Project A: Filesystem + GitHub MCP servers with specific directory access
  • Project B: Filesystem + Context7 + custom internal tools
  • Project C: Limited MCP access for security reasons

Currently, this requires manual configuration switching or complex global config management.

Proposed Solution

1. Configuration File Support

Support the following configuration file locations (in priority order):

  1. Project root:

    • .mcp.json (primary, follows Claude Code convention)
    • mcp.json (alternative)
  2. Tool-specific directories:

    • .nanocoder/mcp.json
    • .claude/mcp.json (for compatibility with Claude Code projects)

2. Configuration Format

{
  "mcpServers": {
    "filesystem": {
      "transport": "stdio",
      "command": "npx",
      "args": ["@modelcontextprotocol/server-filesystem", "./src"],
      "description": "Project filesystem access"
    },
    "github": {
      "transport": "stdio",
      "command": "npx",
      "args": ["@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "$GITHUB_TOKEN"  // Reference to env var
      }
    }
  }
}

3. Configuration Priority & Merging

Implement a hierarchical configuration system:

  1. Project-level (highest priority): .mcp.json or .nanocoder/mcp.json
  2. User-level: agents.config.json in user config directory
  3. Local overrides: .nanocoder/mcp.local.json (gitignored)

4. Security Features

  • Environment variable references: Support $VAR_NAME and ${VAR_NAME} syntax
  • Sensitive data handling: Automatically exclude files with credentials from version control
  • Validation warnings: Alert users when sensitive data is detected in project configs

5. Integration with Existing System

  • Maintain backward compatibility with current agents.config.json approach
  • Provide clear documentation on configuration precedence
  • Add configuration validation and error handling

Alternatives Considered

  1. Status Quo: Continue using only agents.config.json

    • ❌ Doesn't solve team collaboration issues
    • ❌ No project-specific MCP configurations
  2. Extend agents.config.json: Add project-specific sections

    • ❌ Mixes global and project configuration
    • ❌ Less intuitive for team collaboration
  3. Use separate directory: Only support .nanocoder/mcp.json

    • ❌ Less discoverable than root-level files
    • ❌ Doesn't follow established patterns from other tools

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • This feature aligns with the project's goals (local-first AI assistance)
  • Research conducted on Claude Code and Gemini CLI MCP configuration approaches

Industry Standards Research

Based on analysis of competing tools:

Claude Code:

  • ✅ Supports .mcp.json in project root
  • ✅ Project-level MCP server configurations
  • ✅ Team collaboration via version-controlled configs

Gemini CLI:

  • ❌ No dedicated .mcp.json support
  • ✅ Project-level MCP in .gemini/settings.json
  • ❌ Mixed configuration approach

Current Nanocoder:

  • ❌ No project-level MCP configuration files
  • ✅ Supports CWD-based agents.config.json
  • ❌ Limited team collaboration features

Implementation Notes

Suggested Implementation Approach

  1. Configuration Loading:
// Priority order for MCP configuration loading
function loadMCPConfig(): MCPServerConfig[] {
  const locations = [
    '.mcp.json',
    'mcp.json',
    '.nanocoder/mcp.json',
    '.claude/mcp.json',
    'agents.config.json' // Current approach
  ];

  for (const location of locations) {
    const config = tryLoadConfig(location);
    if (config) return config;
  }

  return [];
}
  1. Configuration Merging:
  • Project-level configs override user-level configs
  • Local configs (.local.json) override all others
  • Provide clear warnings about configuration conflicts
  1. Security Enhancements:
  • Auto-generate .gitignore entries for sensitive files
  • Add validation for hardcoded credentials
  • Support environment variable references with fallback values
  1. User Experience:
  • Add /mcp config command to show active configuration sources
  • Provide configuration validation feedback
  • Document configuration precedence clearly

Benefits

  1. Team Collaboration: Teams can commit .mcp.json to version control
  2. Project Isolation: Each project can have its own MCP server setup
  3. Security: Sensitive credentials remain in user-specific configs
  4. Compatibility: Follows established patterns from Claude Code
  5. Flexibility: Multiple configuration locations for different use cases

Migration Path

  1. Backward Compatibility: Existing agents.config.json continues to work
  2. Gradual Adoption: Teams can adopt project-level configs incrementally
  3. Clear Documentation: Provide migration guides and best practices

Activity

  1. added
    enhancement
    on Jan 5, 2026
  2. added theissue type on Jan 5, 2026
  3. changed the issue type fromtoon Jan 5, 2026
  4. changed the issue type fromtoon Jan 5, 2026
  5. self-assigned this
    on Jan 8, 2026
  6. will-lamerton commented on Jan 12, 2026

    @will-lamerton
    Member

    Closed. Will be in the next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions