Skip to content

feat: merge default config files#250

Open
haosenwang1018 wants to merge 1 commit intophilschmid:mainfrom
haosenwang1018:feat/merge-default-configs
Open

feat: merge default config files#250
haosenwang1018 wants to merge 1 commit intophilschmid:mainfrom
haosenwang1018:feat/merge-default-configs

Conversation

@haosenwang1018
Copy link
Copy Markdown

Summary

  • merge all discovered default mcp_servers.json files instead of stopping at the first hit
  • keep explicit -c/--config and MCP_CONFIG_PATH behavior unchanged (single file)
  • add tests for merged default configs and same-name override precedence

Problem

Issue #28 points out that mcp-cli currently stops at the first config file it finds. That makes it impossible to combine a project-local MCP setup with personal/user-level MCP servers.

Fix

When no explicit config path is provided, loadConfig() now loads every existing default config path and merges them from lowest priority to highest priority:

  • ~/.config/mcp/mcp_servers.json
  • ~/.mcp_servers.json
  • ./mcp_servers.json

This preserves the current precedence model while allowing project configs to extend or override user configs. Explicit -c/--config and MCP_CONFIG_PATH still load exactly one file, as before.

Fixes #28

Validation

  • git diff --check
  • npx tsc --noEmit
  • bun test tests/config.test.ts
  • bun test tests/client.test.ts
  • bun test tests/output.test.ts
  • npx @biomejs/biome check src/config.ts tests/config.test.ts README.md

Signed-off-by: haosenwang1018 <haosenwang1018@users.noreply.github.com>
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.

merge of MCP configuration files

1 participant