Skip to content

Conversation

@leblancfg
Copy link
Contributor

@leblancfg leblancfg commented Jul 9, 2025

Motivation and Context

At the moment, the CLI tool expects that remote MCP servers, either using SSE or streamable HTTP transport, have certain endpoints or fragments -- /sse and /mcp, respectively. These specific routes are not part of the MCP spec, nor should it be expected.

I also added a check to make sure a URL is provided if STDIO isn't picked, erroring out if not.

Fixes: #594
See: #578. Recreating it here with a pared-down version that addresses the review comments. I needed this locally now and am sharing it. Please merge whichever.

How Has This Been Tested?

I have a local MCP server on a root endpoint (/) served by a little Express server (not /mcp). Currently, I can't use the inspector CLI as a little integration test in development. Only now can I do:

$ ./build/cli.js --cli --transport http http://localhost:37242 --method tools/list

Breaking Changes

Yes. It used to implicitly append /sse and /mcp routes to remote transport URLs that didn't have them, now it doesn't.

People might have workflows set up that depend on these paths not being explicitly configured.

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

At the moment, the CLI tool expects that remote MCP servers, either
using SSE or streamable HTTP transport, have certain endpoints or
fragments -- `/sse` and `/mcp`, respectively. This is not part of the
MCP spec, nor should it be expected.

I also added a check to make sure a URL is provided if STDIO isn't
picked, erroring out if not.
@pztrick
Copy link

pztrick commented Jul 13, 2025

@cliffhall you had previously reviewed my p/r #578. i think this p/r is cleaner and it also addresses your request to remove the warn-level log statements. this p/r LGTM.

i checked out this p/r locally and confirmed it was working for my own HTTP Streamable endpoint.

Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

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

This looks good to me - although its technically breaking it actually matches the Readme from what I can tell, and this change should help unblock more usage.

I did have one question about testing: were you able to run the updated cli-tests.js? I also wasn't totally clear on this comment from your PR description:

Currently, I can't use the inspector CLI as a little integration test in development.

Could you clarify what you mean?

@leblancfg
Copy link
Contributor Author

CLI tests passing
$ npm run test

> @modelcontextprotocol/[email protected] test
> node scripts/cli-tests.js

=== MCP Inspector CLI Test Script ===
This script tests the MCP Inspector CLI's ability to handle various command line options:
- Basic CLI mode
- Environment variables (-e)
- Config file (--config)
- Server selection (--server)
- Method selection (--method)
- Tool-related options (--tool-name, --tool-arg)
- Resource-related options (--uri)
- Prompt-related options (--prompt-name, --prompt-args)
- Logging options (--log-level)
- Transport types (--transport http/sse/stdio)
- Transport inference from URL suffixes (/mcp, /sse)


Using existing sample config file: /Users/leblancfg/src/github.com/leblancfg/inspector//sample-config.json
{
  "mcpServers": {
    "everything": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-everything"],
      "env": {
        "HELLO": "Hello MCP!"
      }
    },
    "myserver": {
      "command": "node",
      "args": ["build/index.js", "arg1", "arg2"],
      "env": {
        "KEY": "value",
        "KEY2": "value2"
      }
    }
  }
}


=== Running Basic CLI Mode Tests ===

Testing: basic_cli_mode
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method tools/list
✓ Test passed: basic_cli_mode
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing error case: nonexistent_method
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method nonexistent/method
✓ Error test passed: nonexistent_method
Error output (expected):
  Unsupported method: nonexistent/method. Supported methods include: tools/list, tools/call, resources/list, resources/read, resources/templates/list, prompts/list, prompts/get, logging/setLevel
  Unsupported method: nonexistent/method. Supported methods include: tools/list, tools/call, resources/list, resources/read, resources/templates/list, prompts/list, prompts/get, logging/setLevel

  Failed with exit code: 1


Testing error case: missing_method
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli
✓ Error test passed: missing_method
Error output (expected):
  Method is required. Use --method to specify the method to invoke.
  Method is required. Use --method to specify the method to invoke.

  Failed with exit code: 1


=== Running Environment Variable Tests ===

Testing: env_variables
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything -e KEY1=value1 -e KEY2=value2 --cli --method tools/list
✓ Test passed: env_variables
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing error case: invalid_env_format
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything -e INVALID_FORMAT --cli --method tools/list
✓ Error test passed: invalid_env_format
Error output (expected):
  Invalid parameter format: INVALID_FORMAT. Use key=value format.


Testing: env_variable_with_equals
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything -e API_KEY=abc123=xyz789== --cli --method tools/list
✓ Test passed: env_variable_with_equals
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing: env_variable_with_base64
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything -e JWT_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0= --cli --method tools/list
✓ Test passed: env_variable_with_base64
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

=== Running Config File Tests ===

Testing: config_file
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --config /Users/leblancfg/src/github.com/leblancfg/inspector/sample-config.json --server everything --cli --method tools/list
✓ Test passed: config_file
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing error case: config_without_server
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --config /Users/leblancfg/src/github.com/leblancfg/inspector/sample-config.json --cli --method tools/list
✓ Error test passed: config_without_server
Error output (expected):
  Both --config and --server must be provided together. If you specify one, you must specify the other.


Testing error case: server_without_config
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --server everything --cli --method tools/list
✓ Error test passed: server_without_config
Error output (expected):
  Both --config and --server must be provided together. If you specify one, you must specify the other.


Testing error case: nonexistent_config
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --config ./nonexistent-config.json --server everything --cli --method tools/list
✓ Error test passed: nonexistent_config
Error output (expected):
  Config file not found: /Users/leblancfg/src/github.com/leblancfg/inspector/cli/nonexistent-config.json


Testing error case: invalid_config
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --config /var/folders/15/g6qxcjjj4hq091wfwtrlzf1w0000gn/T/mcp-inspector-tests/invalid-config.json --server everything --cli --method tools/list
✓ Error test passed: invalid_config
Error output (expected):
  Invalid JSON in config file: Expected property name or '}' in JSON at position 36 (line 3 column 17)


Testing error case: nonexistent_server
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --config /Users/leblancfg/src/github.com/leblancfg/inspector/sample-config.json --server nonexistent --cli --method tools/list
✓ Error test passed: nonexistent_server
Error output (expected):
  Server 'nonexistent' not found in config file. Available servers: everything, myserver


=== Running Tool-Related Tests ===

Testing: tool_call
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method tools/call --tool-name echo --tool-arg message=Hello
✓ Test passed: tool_call
First few lines of output:
  {
    "content": [
      {
        "type": "text",
        "text": "Echo: Hello"

Testing error case: missing_tool_name
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method tools/call --tool-arg message=Hello
✓ Error test passed: missing_tool_name
Error output (expected):
  Tool name is required for tools/call method. Use --tool-name to specify the tool name.
  Tool name is required for tools/call method. Use --tool-name to specify the tool name.

  Failed with exit code: 1


Testing error case: invalid_tool_args
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method tools/call --tool-name echo --tool-arg invalid_format
✓ Error test passed: invalid_tool_args
Error output (expected):
  Invalid parameter format: invalid_format. Use key=value format.
  Invalid parameter format: invalid_format. Use key=value format.

  Failed with exit code: 1


Testing: multiple_tool_args
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method tools/call --tool-name add --tool-arg a=1 b=2
✓ Test passed: multiple_tool_args
First few lines of output:
  {
    "content": [
      {
        "type": "text",
        "text": "The sum of 1 and 2 is 3."

=== Running Resource-Related Tests ===

Testing: resource_read
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method resources/read --uri test://static/resource/1
✓ Test passed: resource_read
First few lines of output:
  {
    "contents": [
      {
        "uri": "test://static/resource/1",
        "mimeType": "text/plain",

Testing error case: missing_uri
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method resources/read
✓ Error test passed: missing_uri
Error output (expected):
  URI is required for resources/read method. Use --uri to specify the resource URI.
  URI is required for resources/read method. Use --uri to specify the resource URI.

  Failed with exit code: 1


=== Running Prompt-Related Tests ===

Testing: prompt_get
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method prompts/get --prompt-name simple_prompt
✓ Test passed: prompt_get
First few lines of output:
  {
    "messages": [
      {
        "role": "user",
        "content": {

Testing: prompt_get_with_args
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method prompts/get --prompt-name complex_prompt --prompt-args temperature=0.7 style=concise
✓ Test passed: prompt_get_with_args
First few lines of output:
  {
    "messages": [
      {
        "role": "user",
        "content": {

Testing error case: missing_prompt_name
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method prompts/get
✓ Error test passed: missing_prompt_name
Error output (expected):
  Prompt name is required for prompts/get method. Use --prompt-name to specify the prompt name.
  Prompt name is required for prompts/get method. Use --prompt-name to specify the prompt name.

  Failed with exit code: 1


=== Running Logging Tests ===

Testing: log_level
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method logging/setLevel --log-level debug
✓ Test passed: log_level
First few lines of output:
  {}


Testing error case: invalid_log_level
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js npx @modelcontextprotocol/server-everything --cli --method logging/setLevel --log-level invalid
✓ Error test passed: invalid_log_level
Error output (expected):
  Invalid log level: invalid. Valid levels are: trace, debug, info, warn, error
  Invalid log level: invalid. Valid levels are: trace, debug, info, warn, error

  Failed with exit code: 1


=== Running Combined Option Tests ===
Testing combined options with environment variables and config file.

Testing: combined_options
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --config /Users/leblancfg/src/github.com/leblancfg/inspector/sample-config.json --server everything -e CLI_ENV_VAR=cli_value --cli --method tools/list
✓ Test passed: combined_options
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing: all_options
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --config /Users/leblancfg/src/github.com/leblancfg/inspector/sample-config.json --server everything -e CLI_ENV_VAR=cli_value --cli --method tools/call --tool-name echo --tool-arg message=Hello --log-level debug
✓ Test passed: all_options
First few lines of output:
  {
    "content": [
      {
        "type": "text",
        "text": "Echo: Hello"

=== Running HTTP Transport Tests ===
Starting server-everything in streamableHttp mode.

Testing: http_transport_inferred
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js http://127.0.0.1:3001/mcp --cli --method tools/list
✓ Test passed: http_transport_inferred
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing: http_transport_with_explicit_flag
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js http://127.0.0.1:3001/mcp --transport http --cli --method tools/list
✓ Test passed: http_transport_with_explicit_flag
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing: http_transport_with_explicit_flag_and_suffix
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js http://127.0.0.1:3001/mcp --transport http --cli --method tools/list
✓ Test passed: http_transport_with_explicit_flag_and_suffix
First few lines of output:
  {
    "tools": [
      {
        "name": "echo",
        "description": "Echoes back the input",

Testing error case: sse_transport_given_to_http_server
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js http://127.0.0.1:3001 --transport sse --cli --method tools/list
✓ Error test passed: sse_transport_given_to_http_server
Error output (expected):
  Failed to connect to MCP server: SSE error: Non-200 status code (404)
  Failed to connect to MCP server: SSE error: Non-200 status code (404)

  Failed with exit code: 1


Testing error case: http_transport_without_url
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --transport http --cli --method tools/list
✓ Error test passed: http_transport_without_url
Error output (expected):
  error: missing required argument 'target'
  error: missing required argument 'target'

  Failed with exit code: 1


Testing error case: sse_transport_without_url
Command: node /Users/leblancfg/src/github.com/leblancfg/inspector/cli/build/cli.js --transport sse --cli --method tools/list
✓ Error test passed: sse_transport_without_url
Error output (expected):
  error: missing required argument 'target'
  error: missing required argument 'target'

  Failed with exit code: 1

HTTP server killed, waiting for port to be released...

=== Test Summary ===
Passed: 32
Failed: 0
Skipped: 0
Total: 32
Detailed logs saved to: /Users/leblancfg/src/github.com/leblancfg/inspector/cli/scripts/test-output

All tests completed!

@leblancfg
Copy link
Contributor Author

leblancfg commented Jul 14, 2025

Currently, I can't use the inspector CLI as a little integration test in development.

Could you clarify what you mean?

I'd like to use the inspector's CLI in my MCP server's CI pipeline for lightweight testing. However, my server doesn't use the /mcp endpoint. So I can't it for that purpose.

@leblancfg leblancfg mentioned this pull request Jul 14, 2025
7 tasks
Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

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

Thanks for confirming the tests, looks good to me. 👍

@olaservo olaservo merged commit 6d4a664 into modelcontextprotocol:main Jul 15, 2025
4 checks passed
@olaservo olaservo added the cli Issues and PRs specific to cli mode label Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Issues and PRs specific to cli mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cli] Can't use URLs that don't end in /mcp or /sse

3 participants