Repository navigation
Description
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:
- Team Collaboration: Teams cannot easily share MCP server configurations for specific projects
- Environment Separation: Different projects require different MCP server setups, but this isn't easily achievable
- Security Concerns: Sensitive credentials must be shared or managed separately from project configuration
- 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):
-
Project root:
.mcp.json(primary, follows Claude Code convention)mcp.json(alternative)
-
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:
- Project-level (highest priority):
.mcp.jsonor.nanocoder/mcp.json - User-level:
agents.config.jsonin user config directory - Local overrides:
.nanocoder/mcp.local.json(gitignored)
4. Security Features
- Environment variable references: Support
$VAR_NAMEand${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.jsonapproach - Provide clear documentation on configuration precedence
- Add configuration validation and error handling
Alternatives Considered
-
Status Quo: Continue using only
agents.config.json- ❌ Doesn't solve team collaboration issues
- ❌ No project-specific MCP configurations
-
Extend agents.config.json: Add project-specific sections
- ❌ Mixes global and project configuration
- ❌ Less intuitive for team collaboration
-
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.jsonin project root - ✅ Project-level MCP server configurations
- ✅ Team collaboration via version-controlled configs
Gemini CLI:
- ❌ No dedicated
.mcp.jsonsupport - ✅ 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
- 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 [];
}- Configuration Merging:
- Project-level configs override user-level configs
- Local configs (
.local.json) override all others - Provide clear warnings about configuration conflicts
- Security Enhancements:
- Auto-generate
.gitignoreentries for sensitive files - Add validation for hardcoded credentials
- Support environment variable references with fallback values
- User Experience:
- Add
/mcp configcommand to show active configuration sources - Provide configuration validation feedback
- Document configuration precedence clearly
Benefits
- Team Collaboration: Teams can commit
.mcp.jsonto version control - Project Isolation: Each project can have its own MCP server setup
- Security: Sensitive credentials remain in user-specific configs
- Compatibility: Follows established patterns from Claude Code
- Flexibility: Multiple configuration locations for different use cases
Migration Path
- Backward Compatibility: Existing
agents.config.jsoncontinues to work - Gradual Adoption: Teams can adopt project-level configs incrementally
- Clear Documentation: Provide migration guides and best practices
Activity
will-lamerton commentedon Jan 12, 2026
Closed. Will be in the next release!