Commit graph inspector/cli/src
Author SHA1 Message Date
lorenzo.neumann
5b9e69f36a Aligned naming 2025-10-27 12:24:47 +01:00
lorenzo.neumann
caa1a2e1f5 Merge remote-tracking branch 'origin2/main' into meta_properies_in_tools 2025-10-24 15:04:38 +02:00
lorenzo.neumann
809436d65c Added metadata cli tests, renaming 2025-10-24 14:37:22 +02:00
cliffhall
19a7d3752c Depending upon whether it is being invoked from the npm package @modelcontextprotocol/inspector or @modelcontextprotocol/inspector-cli the location of package.json will either be in ../ or ../../
* In cli/src/index.ts
  - load package.json from the parent folder or parent's parent depending on file existence in parent.
  - move the load of package.json into callMethod function, which is the only place it is used, and is closer to where it is referenced.
2025-10-04 14:54:07 -04:00
cliffhall
6e27b5d530 In #544 a change to cli/src/index.ts was introduced that reads package.json from one level up. It works if the project is checked out locally, but not in the npm package, because the package.json of the workspace packages is not included in the inspector package. We can get that from one level up, the inpsector's own package, and so this change does that. 2025-10-04 13:23:33 -04:00
lorenzo.neumann
842aa3c8ca Added general meta data section to add pairs for all requests 2025-10-02 11:23:29 +02:00
Ola Hungerford
32ea112051
Merge branch 'main' into accurate-cli-version 2025-09-22 20:46:14 -07:00
Ola Hungerford
e1d311c6e1
Merge pull request #739 from nsheaps/main
fix: correct stdout buffering issues in spawned processes
2025-09-01 09:22:32 -07:00
Ola Hungerford
80ab4dcc28
Merge branch 'main' into main 2025-09-01 06:52:44 -07:00
olaservo
e27600cbf4 Add CLI header integration tests and update test scripts
- Introduced integration tests for header functionality in a new script `cli-header-tests.js`.
- Updated the `package.json` to include the new test script and modified the existing test command to run all tests.
- Adjusted the main CLI exit behavior to ensure proper termination in CI environments.
- Added `.claude/settings.local.json` to `.gitignore` to prevent local settings from being tracked.
2025-08-28 20:49:11 -07:00
Ola Hungerford
d3fcedc81a
Merge branch 'main' into cmgriffing/fix-cli-truncated-output 2025-08-28 20:40:58 -07:00
Ola Hungerford
897d9f07bc
Merge branch 'main' into feature/add-header-support 2025-08-28 19:44:09 -07:00
Chris Griffing
f4a176eb7b Merge branch 'main' of github.com:modelcontextprotocol/inspector into cmgriffing/fix-cli-truncated-output 2025-08-28 17:55:02 -07:00
Ola Hungerford
e5d0f34981
Merge branch 'main' into feature/add-header-support 2025-08-27 20:33:24 -07:00
Chris Griffing
67f35363d8 Make cli output awaitable to prevent truncating the result 2025-08-26 16:14:44 -07:00
Richard Michael
f942df7e4c Consistent MCP Client() name from package
Make both clients use name from package.json for consistency and protocol clarity

 - web client changes `mcp-inspector` -> `inspector-client` (package.json)
 - cli client remains `inspector-cli` (package.json)
2025-08-22 10:28:50 -07:00
Richard Michael
d7b020fdda Fix hard-coded CLI version, use package.json consistent with client 2025-08-22 10:28:50 -07:00
Ola Hungerford
0b4e395f2b
Merge branch 'main' into parse-tool-arg 2025-08-21 19:12:36 -07:00
Nathan Heaps
9e47d7d3c1 fix: correct stdout buffering issues in spawned processes
Adds stdio inheritance to prevent Node.js from dropping console output after 8192 characters due to premature stdout pipe closure before output finishes flushing. Without this, calls like this would truncate after 8192 characters, leading to broken json output:

```
npx --node-options=--inspect -y @modelcontextprotocol/inspector --cli --config .mcp.json --server notion --method tools/list
```

```
# notion mcp server
    "notion": {
      "//": "doppler needs to expose OPENAPI_MCP_HEADERS (and NOTION_TOKEN within it)",
      "command": "bash",
      "args": [
        "-c",
        "doppler run -p 'mcp' -c \"user_${MCP_USER:-$USER}\" -- npx -y @notionhq/notion-mcp-server"
      ]
    },
```

You can see this in their [openapi spec](https://github.com/makenotion/notion-mcp-server/blob/main/scripts/notion-openapi.json), which powers their MCP server.
2025-08-20 21:06:06 -04:00
Ola Hungerford
44b4417951
Merge branch 'main' into reverse-env-order-for-cli-stdio 2025-08-18 06:57:16 -07:00
Phil Freo
77d4963b8a
Add support for --header flags in MCP Inspector CLI
- Add --header option to both wrapper CLI (cli.ts) and main CLI (index.ts)
- Support multiple headers with "HeaderName: Value" format validation
- Pass headers to HTTP and SSE transports via requestInit.headers
- Add parseHeaderPair function for proper header parsing
- Fix output truncation issue by removing forced process.exit(0)
- Update types to include headers in Args and TransportOptions

Usage: --header "Authorization: Bearer token" --header "X-Custom: value"
2025-08-14 12:10:18 -04:00
Ola Hungerford
30a7d5e484
Merge branch 'main' into parse-tool-arg 2025-08-11 08:01:53 -07:00
Felix Weinberger
1263ffdf58
Simplify server auto-selection logic
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
2025-08-07 20:45:23 +01:00
Felix Weinberger
14b01815ad
prettier 2025-08-07 12:01:17 +01:00
Felix Weinberger
cf7c138958
Fix --server-url flag not being parsed by CLI
Add --server-url option to CLI parser so the flag is properly recognized
and passed through to the server process via the /config endpoint.
2025-08-07 11:58:08 +01:00
Felix Weinberger
98b7e63bb0 Add --transport flag support to CLI
- 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
2025-08-06 19:50:23 +01:00
Felix Weinberger
195f79076e
Fix CLI test failures for SSE/HTTP transport configs
- 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
2025-08-05 14:22:16 +01:00
Felix Weinberger
1e399b7055
prettier 2025-08-05 14:08:57 +01:00
Felix Weinberger
0e2906c4c4
Implement default-server support
- 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
2025-08-05 14:08:57 +01:00
Felix Weinberger
acf6c1e118
feat: Auto-detect transport type from config files
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 <noreply@anthropic.com>
2025-08-05 14:08:57 +01:00
olaservo
6e665b5d24 Merge branch 'main' into parse-tool-arg 2025-08-01 20:38:45 -07:00
olaservo
6ce4a0b563 Fix formatting 2025-07-27 07:19:48 -07:00
Ola Hungerford
1ed920297f
Merge branch 'main' into oleina/logging 2025-07-26 09:43:20 -07:00
olaservo
99b962d445 Parse tool args from CLI as JsonValue instead of just strings 2025-07-26 09:15:27 -07:00
Felix Weinberger
c7b90a1af9
Fix command-line argument passing to pre-fill UI
When running the inspector with command-line arguments (e.g.,
`npx @modelcontextprotocol/inspector node build/index.js arg1 arg2`),
the command and arguments were not being properly passed through to
the UI for pre-filling.

Changes:
- cli.ts now passes command and args to start.js
- start.js uses --command for the command and --args for arguments
- Server parses the new --command parameter
- /config endpoint returns correct values for UI pre-filling

This ensures the UI correctly displays the command and arguments
passed on the command line instead of showing old localStorage values.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 13:06:36 +01:00
Cliff Hall
efc8f32ad2
Merge branch 'main' into ci-test-cli 2025-07-15 16:04:47 -04:00
François Leblanc
b84e5271f4 Explicitly exit process for CI 2025-07-14 23:35:52 -04:00
François Leblanc
ff2d932904 Add await to runCli call 2025-07-14 23:27:58 -04:00
Ola Hungerford
824d5e1ec2
Merge branch 'main' into cli-remote-no-required-endpoint 2025-07-14 18:51:14 -07:00
oleina
f4d9bf6d5e initalize logging for cli mode 2025-07-11 17:34:14 -07:00
cliffhall
0eebd01ebe Remove environment-related startup vars. Those will be captured by start.js 2025-07-10 15:17:54 -04:00
cliffhall
6a66ca5b23 fix startup of webclient through cli 2025-07-10 13:51:15 -04:00
François Leblanc
7c2b761748 [cli] Don't force specific endpoints for remote servers
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.
2025-07-09 11:51:41 -04:00
Ryan Clark
daa863ddfc
feat: add transport option to cli 2025-06-01 13:27:16 -05:00
olaservo
f514857a34 Apply process env after defaults 2025-05-19 05:31:24 -07:00
cliffhall
6a99feaf33 Refactor project components
* Remove bin folder, leaving cli, server, and client
* This fixes #315
* In .gitignore,
  - add .idea
  - remove bin/build
* Remove bin and bin/cli.js
* Remove bin/scripts/copy-cli.js
* Refactor/move bin/scripts to cli/scripts
* Refactor/move bin/src/index.ts to cli/src/cli.ts
* Refactor/renamed client/bin/cli.js to client/bin/client.js
* In .github/workflows/main.yml,
  - add run of cli tests
* In cli/pacakge.json
  - change main and bin/mcp-inspector-cli properties to build/cli.js
* In client/package.json,
  - change bin/mcp-inspector-client properties to build/start.js
* In pacakge.json
  - change bin/mcp-inspector property to ./cli/build/cli.js
  - removed bin and cli/bin from files list
  - removed @modelcontextprotocol/inspector-bin dependency
  - rearranged and corrected scripts
2025-04-15 17:59:26 -04:00
Nicolas Barraud
dae389034a Change --tool-args to --tool-arg for consistency 2025-03-11 12:40:39 -04:00
Nicolas Barraud
f4e6f4d4ea Removed package-info.ts 2025-03-10 20:40:06 -04:00
Nicolas Barraud
4c4c8a0884 Add CLI and config file support 2025-03-10 20:19:23 -04:00