Skip to content

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

✅  24 passed

Details

24 tests across 3 suites
 29.3 seconds
 6831970
ℹ️  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 6 times, most recently 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
Collaborator

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. 😂 )

@felixweinberger felixweinberger force-pushed the fweinberger/better-config-support branch from 50b96a0 to 9d8c2ec Compare August 5, 2025 11:12
@felixweinberger felixweinberger changed the base branch from main to fweinberger/fix-npx-no-args August 5, 2025 11:12
Base automatically changed from fweinberger/fix-npx-no-args to main August 5, 2025 12:14
felixweinberger and others added 8 commits August 5, 2025 14:08
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]>
- 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
Move transport configuration parsing to cli.js as suggested in PR review. The CLI entry point (cli.js) should handle config file parsing and pass parameters to start.js.
- Remove web client launch tests from CLI test suite
- Add CLI-mode tests for SSE and streamable-http configs
- Keep only tests that use --cli flag as intended
- Test that transport and serverUrl parameters are correctly passed via URL
- Verify SSE and streamable-http transport types are handled
- Test default STDIO behavior
- Auto-select server when --config is used without --server
- Use 'default-server' if it exists in config
- Use single server if only one is defined
- Show helpful error if multiple servers exist without default
- Add tests for all default-server scenarios
- Add examples for stdio, sse, and streamable-http transport types
- Document automatic server selection behavior
- Show how to use default-server in config files
@felixweinberger felixweinberger force-pushed the fweinberger/better-config-support branch from d175c34 to 1e399b7 Compare August 5, 2025 13:09
- Pass URL as command for SSE/HTTP configs instead of empty string
- Update runCli to pass transport type flag when needed
- Update tests to expect connection errors for non-existent SSE/HTTP servers
@felixweinberger felixweinberger force-pushed the fweinberger/better-config-support branch from c288e03 to 195f790 Compare August 5, 2025 13:22
@felixweinberger
Copy link
Contributor Author

Hey @felixweinberger, thanks for this!

@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.

Thanks for the reviews - I've updated the PR to:

  • Moved arg parsing implementation to cli.ts
  • Reorganized CLI tests to not have web UI based tests in cli-tests.js
  • Added a new set of playwright based e2e tests that check config is respected in the web UI
  • Added default-server support (if default-server exists or if there's only one server with any name in the config file)
  • Updated docs

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.

@felixweinberger Tests are looking good now.

I still had a problem launching without specifying the server.

mcp.json

{
  "mcpServers" : {
	"default-server": {
	  "command": "node",
	  "args": [
		"/Users/cliffhall/Projects/mcp-c64/dist/server/index.js"
	  ]
	}
  }
}

node cli/build/cli.js --config mcp.json
Screenshot 2025-08-05 at 1 03 26 PM

Inspector fields
Screenshot 2025-08-05 at 1 00 18 PM

node cli/build/cli.js --config mcp.json --server default-server

Screenshot 2025-08-05 at 1 06 08 PM

Inspector fields
Screenshot 2025-08-05 at 1 00 18 PM

- Add --transport and --server-url support to client/bin/start.js
- Pass transport configuration through server to client via /config endpoint
- Update client App.tsx to use defaultTransport and defaultServerUrl from server
- Ensure SSE and HTTP transport configs work properly from CLI
@felixweinberger
Copy link
Contributor Author

felixweinberger commented Aug 6, 2025

@cliffhall thanks for taking a detailed look, good catch!

I used your mcp.json example to add another commit on top of this to properly pass through the args now managed by cli.js back to start.js:

Before After
CleanShot 2025-08-06 at 16 52 27@2x CleanShot 2025-08-06 at 16 52 59@2x

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, the config file is working great on my machine now, and I'm going to do a proper review of the code momentarily, but would you mind adding mcp.json to the .gitignore and .prettierignore in this PR?

I am just realizing that I will have one present for testing, and I expect @olaservo and other maintainers and contributors will as well. We don't want anyone to accidentally commit their file. And running prettier-check (automatically part of running tests) fails locally because of my mcp.json, which is what triggered this suggestion.

Also, from the playwright tests, I tried this command line:

npx . --transport sse --server-url http://localhost:3000/sse
Screenshot 2025-08-06 at 12 25 10 PM

Inspector
Screenshot 2025-08-06 at 12 25 47 PM

- Add --transport option to command line parser
- Support --transport stdio/sse/http flags
- Convert 'http' to 'streamable-http' internally
- Fix transport type conversion for CLI mode
Add --server-url option to CLI parser so the flag is properly recognized
and passed through to the server process via the /config endpoint.
@felixweinberger
Copy link
Contributor Author

felixweinberger commented Aug 7, 2025

Hey @felixweinberger, the config file is working great on my machine now, and I'm going to do a proper review of the code momentarily, but would you mind adding mcp.json to the .gitignore and .prettierignore in this PR?

I am just realizing that I will have one present for testing, and I expect @olaservo and other maintainers and contributors will as well. We don't want anyone to accidentally commit their file. And running prettier-check (automatically part of running tests) fails locally because of my mcp.json, which is what triggered this suggestion.

Also, from the playwright tests, I tried this command line:

npx . --transport sse --server-url http://localhost:3000/sse Screenshot 2025-08-06 at 12 25 10 PM

Inspector Screenshot 2025-08-06 at 12 25 47 PM

🤦 forgot to actually parse --server-url in the cli.ts - amended. Also added mcp.json to .gitignore and .prettierignore as requested.

Tested with multiple different combinations:

  1. npx . -> just opens last
CleanShot 2025-08-07 at 12 12 06
  1. npx . --config mcp.json -> works as expected for stdio, sse, http
CleanShot 2025-08-07 at 12 12 36 CleanShot 2025-08-07 at 12 13 50
  1. npx . --transport sse --server-url http://localhost:3000/sse -> works
CleanShot 2025-08-07 at 12 14 25
  1. npx . --transport http --server-url http://localhost:4321/mcp -> works
CleanShot 2025-08-07 at 12 15 45
  1. npx . --transport stdio python main.py -> works
CleanShot 2025-08-07 at 12 16 33

Copy link
Contributor

@ochafik ochafik left a comment

Choose a reason for hiding this comment

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

Thanks Felix!

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.

@felixweinberger thanks for handling those things. It's all looking good to me so far. I see @ochafik has a few requests, but I'm onboard to approve as soon as that's settled. Also, I think you're inheriting the manual args parsing stuff from the original cli.ts author, and if you want to punt that to another PR, it would fully make sense; it could be a bigger can of worms than you bargained for in this PR.

Only auto-select when there's exactly one server in the config file.
Removes special handling for "default-server" naming convention.

Addresses review feedback from @ochafik on PR #661
Test 30 now expects an error when multiple servers exist, even with
"default-server" present, aligning with the simplified logic that only
auto-selects when there's exactly one server.
@felixweinberger felixweinberger requested a review from ochafik August 7, 2025 20:21
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.

LGTM! 👍

Copy link
Contributor

@ochafik ochafik left a comment

Choose a reason for hiding this comment

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

Thanks!

@felixweinberger felixweinberger merged commit 7b3e2c1 into main Aug 8, 2025
12 checks passed
@felixweinberger felixweinberger deleted the fweinberger/better-config-support branch August 8, 2025 08:51
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.

4 participants