Skip to content

Listen option is ignored unless config option is set explicitly #14

Closed

Description

@stek29

I've changed the listen option, but it only works if -c is passed explicitly.

$ <~/.mcpproxy/mcp_config.json jq -r .listen
127.0.0.1:12080

trying to start mcpproxy:

$ mcpproxy |& grep -e 'Starting HTTP' -e 'config'
2025-07-09 15:03:37	INFO	[email protected]/command.go:1015	Log directory configured	{"path": "/Users/username/Library/Logs/mcpproxy", "os": "darwin", "standard": "macOS File System Programming Guide"}
2025-07-09 15:03:37	INFO	server/server.go:193	Status updated	{"phase": "Loading", "message": "Loading configuration and connecting to servers..."}
2025-07-09 15:03:37	INFO	server/server.go:196	Synchronizing servers from configuration (config as source of truth)
2025-07-09 15:03:37	INFO	server/server.go:196	Server synchronization completed	{"configured_servers": 0, "removed_servers": 0}
2025-07-09 15:03:37	INFO	tray/tray.go:156	Config file watcher initialized{path 15 0 /Users/username/.mcpproxy/mcp_config.json <nil>}
2025-07-09 15:03:37	INFO	server/server.go:483	Starting HTTP server	{"address": ":8080", "endpoints": ["/mcp", "/mcp/", "/v1/tool_code", "/v1/tool-code"]}
^C

notice how it started on default :8080

Now starting it with -c option, which points to default config file path which was loaded before:

$ mcpproxy -c ~/.mcpproxy/mcp_config.json |& grep -e 'Starting HTTP' -e 'config'
2025-07-09 15:04:06	INFO	[email protected]/command.go:1015	Log directory configured	{"path": "/Users/username/Library/Logs/mcpproxy", "os": "darwin", "standard": "macOS File System Programming Guide"}
2025-07-09 15:04:06	INFO	server/server.go:193	Status updated	{"phase": "Loading", "message": "Loading configuration and connecting to servers..."}
2025-07-09 15:04:06	INFO	server/server.go:196	Synchronizing servers from configuration (config as source of truth)
2025-07-09 15:04:06	INFO	server/server.go:196	Server synchronization completed	{"configured_servers": 0, "removed_servers": 0}
2025-07-09 15:04:06	INFO	tray/tray.go:156	Config file watcher initialized{path 15 0 /Users/username/.mcpproxy/mcp_config.json <nil>}
2025-07-09 15:04:06	INFO	server/server.go:483	Starting HTTP server	{"address": "127.0.0.1:12080", "endpoints": ["/mcp", "/mcp/", "/v1/tool_code", "/v1/tool-code"]}

and this time it has started with expected listen address

Activity

  1. Dumbris commented on Jul 15, 2025

    @Dumbris
    Member

    Hi @stek29 ,

    Thank you for filing this issue and providing such detailed reproduction steps! This was indeed a bug in the configuration loading logic, and it has now been fixed.

    What was wrong

    The issue was that mcpproxy without the -c flag was ignoring the listen setting from the config file due to viper's default values overwriting the loaded configuration.

    The fix #20

    The configuration loading logic has been updated to properly respect config file values when no explicit CLI flags are provided.

    🔧 Port Configuration Guide

    You can configure the listen port using any of these methods, in order of priority:

    1. CLI parameter (highest priority)

      mcpproxy -l 127.0.0.1:9000
      # or
      mcpproxy --listen 127.0.0.1:9000
    2. Config file (medium priority)

      {
        "listen": "127.0.0.1:12080",
        "data_dir": "/Users/user/.mcpproxy",
        ...
      }
    3. Default port (lowest priority)

      :8080
      

    Config file locations

    mcpproxy automatically looks for mcp_config.json in:

    • Current directory: ./mcp_config.json
    • User data directory: ~/.mcpproxy/mcp_config.json

    Verification

    Your original test case now works correctly:

    # This now uses 127.0.0.1:12080 from config file
    $ mcpproxy --log-level=debug --tray=false
    2025-07-15 17:45:40     INFO    server/server.go:483    Starting HTTP server    {"address": "127.0.0.1:12080", ...}

    Thanks again for the detailed bug report! 🙏

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions