Skip to content

feat: Auto-detect transport type from config files #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

felixweinberger
Copy link
Contributor

@felixweinberger felixweinberger commented Jul 30, 2025

Motivation and Context

When launching the inspector with --config, automatically set the transport
dropdown and server URL based on the config file contents. This eliminates
the need to manually switch between stdio/sse/streamable-http in the UI.

  • Use discriminated union for ServerConfig to properly type different transports
  • Detect transport type and URL from config, pass via query params
  • Maintain backwards compatibility for configs without explicit type field
  • Add comprehensive tests for the new functionality

Improves UX by making the config file the single source of truth for
server settings.

How Has This Been Tested?

Tested manually with different configs:

E.g. with a stdio based config:

// mcp_dev_config.json
{
    "mcpServers": {
        "default-server": {
            "command": "uv",
            "args": [
                "run",
                "--with",
                "mcp[cli]",
                "mcp",
                "run",
                "/Users/fweinberger/path/to/my/code/stdio-test/main.py"
            ]
        }
    }
}
CleanShot 2025-07-30 at 16 42 22@2x

E.g. with a streamable-http based config:

// mcp_dev_config.json
{
    "mcpServers": {
        "default-server": {
            "type": "streamable-http",
            "url": "http://localhost:8000/mcp",
            "note": "For Streamable HTTP connections, add this URL directly in your MCP Client"
        }
    }
}
CleanShot 2025-07-30 at 16 42 46@2x

Breaking Changes

No.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Copy link

github-actions bot commented Jul 30, 2025

🎭 Playwright E2E Test Results

✅  15 passed

Details

15 tests across 2 suites
 22.3 seconds
 50b96a0
ℹ️  Test Environment: Ubuntu Latest, Node.js v22.17.1
Browsers: Chromium, Firefox

📊 View Detailed HTML Report (download artifacts)

@felixweinberger felixweinberger force-pushed the fweinberger/better-config-support branch 4 times, most recently from d0985b1 to 08857e2 Compare July 30, 2025 18:11
When launching the inspector with --config, automatically set the transport
dropdown and server URL based on the config file contents. This eliminates
the need to manually switch between stdio/sse/streamable-http in the UI.

- Use discriminated union for ServerConfig to properly type different transports
- Detect transport type and URL from config, pass via query params
- Maintain backwards compatibility for configs without explicit 'type' field
- Add comprehensive tests for the new functionality

Improves UX by making the config file the single source of truth for
server settings.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@felixweinberger felixweinberger force-pushed the fweinberger/better-config-support branch from 08857e2 to a0aebdd Compare July 30, 2025 18:18
- Add tests for config files with different transport types (stdio, sse, streamable-http)
- Add test for backward compatibility with configs missing type field
- Verify transport and serverUrl options are correctly parsed from config files
- All 36 tests pass
@felixweinberger felixweinberger force-pushed the fweinberger/better-config-support branch from f2dfe50 to 50b96a0 Compare July 30, 2025 18:55
@felixweinberger felixweinberger marked this pull request as ready for review July 30, 2025 19:11
Copy link
Member

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @felixweinberger, thanks for this!

  1. There is a stalled PR that is working toward this. I'm mentioning it here so it can be closed if this one is merged. It is trying to modify client/bin/start.js though.

  2. I'm testing this locally, and I realized start.js is not going to be the right place but cli.js is, since it's the entrypoint for the inspector package via npx. And placing this hook in cli.js, the common launching script, this should work with the CLI inspector as well, though I'm not certain that's the case. I saw you added tests in cli-tests and that gave me the impression it would be the case, but...

  3. CLI tests are failing. Turns out the CLI tests are launching the web client. Those tests are meant to test the CLI client. they should just run and be done, without having to interact with the browser. Tests of launching the web client would be more appropriate in client/e2e where the Playwright tests happen and can run in CI.

Screenshot 2025-08-01 at 2 59 06 PM
  1. I notice in your example mcp_dev_config.json you provide a default-server, so I tried that and found that you cannot launch with --config and fail to specify a server name. It feels like this should be possible if there is a default-server configured. Maybe the if not present on the command line, the script can grep the file for 'default-server' and if present in the file, use it as the server arg.
Screenshot 2025-08-01 at 3 10 18 PM Screenshot 2025-08-01 at 3 09 09 PM
  1. Verified that I could launch if I added a --server argument
Screenshot 2025-08-01 at 3 20 30 PM Screenshot 2025-08-01 at 3 19 18 PM

@richardkmichael
Copy link
Contributor

richardkmichael commented Aug 2, 2025

@cliffhall @felixweinberger

In #643 there is a setup for Playwright testing of the command line arguments using tag @cli and different web command: .. for startup.

I created that setup to write tests to catch the CLI options bug #649 . PR #664 fixes that bug.

Note the Playwright CLI tests PR is currently on top of the bug fix so that I could verify the tests caught the bug, but passed after the fix.

I think all of this should be ready for review, if it's helpful here.

I thought a full end-to-end test of entry-point CLI arguments to UI would be helpful as a catch-all since the Inspector is several components. (I had experience with Playwright from #582 to test more of the UI.). Tighter tests around just the CLI would be helpful too.

(I also noticed the other new "CLI tests" are not same CLI. 😂 )

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.

3 participants