Skip to content

Commit ad2e77d

Browse files
committed
Merge main branch with latest changes
- Resolved merge conflict in README.md - Integrated new Configuration File Resolution section - Maintained Kiro IDE support additions
2 parents cd728d8 + 4b0608f commit ad2e77d

3 files changed

Lines changed: 39 additions & 7 deletions

File tree

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ MCP CLI simplifies managing MCP server configurations through a YAML-based appro
2020

2121
### Getting Started
2222

23-
1. Create an [mcp-compose.yml](./mcp-compose.yml) file in `$HOME/.config/mcp/mcp-compose.yml` with your MCP server configurations. See example below, or copy the included example file.
23+
1. Create an [mcp-compose.yml](./mcp-compose.yml) file with your MCP server configurations. You can place this file in either:
24+
- Your current working directory (for project-specific configurations)
25+
- `$HOME/.config/mcp/mcp-compose.yml` (for global configurations)
2426

2527
```sh
28+
# For global configuration
2629
mkdir -p ~/.config/mcp
2730
cp ./mcp-compose.yml $HOME/.config/mcp/
2831
```
@@ -33,6 +36,24 @@ cp ./mcp-compose.yml $HOME/.config/mcp/
3336
mcp set -t q-cli # or -t cursor, -t claude-desktop
3437
```
3538

39+
### Configuration File Resolution
40+
41+
MCP CLI automatically looks for configuration files in the following order:
42+
43+
1. **Local directory**: `./mcp-compose.yml` in your current working directory
44+
2. **Global directory**: `$HOME/.config/mcp/mcp-compose.yml` in your home config directory
45+
3. **Custom path**: Use the `-f` flag to specify a custom location
46+
47+
This allows you to have project-specific MCP server configurations that override your global settings when working in specific directories.
48+
49+
```sh
50+
# Uses local mcp-compose.yml if it exists, otherwise falls back to global
51+
mcp ls
52+
53+
# Explicitly use a custom configuration file
54+
mcp ls -f ./custom-mcp-compose.yml
55+
```
56+
3657
### Listing MCP Servers
3758

3859
View available MCP servers defined in your configuration:

cmd/root.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@ func Execute() error {
2626
}
2727

2828
func init() {
29+
defaultComposeFile := getDefaultComposeFile()
30+
rootCmd.PersistentFlags().StringVarP(&composeFile, "file", "f", defaultComposeFile, "Path to the mcp-compose.yml file")
31+
}
32+
33+
// getDefaultComposeFile returns the default compose file path, checking local directory first
34+
func getDefaultComposeFile() string {
35+
// First check for local mcp-compose.yml in current directory
36+
localComposeFile := "mcp-compose.yml"
37+
if _, err := os.Stat(localComposeFile); err == nil {
38+
return localComposeFile
39+
}
40+
41+
// Fall back to the global config directory
2942
homeDir, err := os.UserHomeDir()
3043
if err != nil {
3144
fmt.Fprintf(os.Stderr, "Error getting user home directory: %v\n", err)
3245
os.Exit(1)
3346
}
3447

35-
defaultComposeFile := filepath.Join(homeDir, ".config", "mcp", "mcp-compose.yml")
36-
37-
rootCmd.PersistentFlags().StringVarP(&composeFile, "file", "f", defaultComposeFile, "Path to the mcp-compose.yml file")
48+
return filepath.Join(homeDir, ".config", "mcp", "mcp-compose.yml")
3849
}

cmd/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ func loadEnvVars(composePath string) (map[string]string, error) {
7575
if len(parts) == 2 {
7676
key := strings.TrimSpace(parts[0])
7777
value := strings.TrimSpace(parts[1])
78-
78+
7979
// Remove quotes if present
8080
if (strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"")) ||
8181
(strings.HasPrefix(value, "'") && strings.HasSuffix(value, "'")) {
8282
value = value[1 : len(value)-1]
8383
}
84-
84+
8585
// Only set if not already in environment
8686
if _, exists := envVars[key]; !exists {
8787
envVars[key] = value
@@ -126,7 +126,7 @@ func filterServers(config *ComposeConfig, profile string, all bool) map[string]S
126126
// Check if this is a default server (no profile or has "default" in profile)
127127
isDefault := false
128128
profileStr, hasProfile := service.Labels["mcp.profile"]
129-
129+
130130
if !hasProfile {
131131
// No profile specified, consider it default
132132
isDefault = true

0 commit comments

Comments
 (0)