From 7c2b7617487a35d4fa76d420a7d81629a7ad1104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Wed, 9 Jul 2025 11:37:53 -0400 Subject: [PATCH 01/16] [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. --- cli/scripts/cli-tests.js | 20 ++++++++++++++++++++ cli/src/transport.ts | 28 ++++++++-------------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/cli/scripts/cli-tests.js b/cli/scripts/cli-tests.js index 51bda553..0585b6ea 100755 --- a/cli/scripts/cli-tests.js +++ b/cli/scripts/cli-tests.js @@ -710,6 +710,26 @@ async function runTests() { "tools/list", ); + // Test 29: HTTP transport without URL (should fail) + await runErrorTest( + "http_transport_without_url", + "--transport", + "http", + "--cli", + "--method", + "tools/list", + ); + + // Test 30: SSE transport without URL (should fail) + await runErrorTest( + "sse_transport_without_url", + "--transport", + "sse", + "--cli", + "--method", + "tools/list", + ); + // Kill HTTP server try { process.kill(-httpServer.pid); diff --git a/cli/src/transport.ts b/cli/src/transport.ts index e0d67b4e..b6276356 100644 --- a/cli/src/transport.ts +++ b/cli/src/transport.ts @@ -14,24 +14,6 @@ export type TransportOptions = { url?: string; }; -function createSSETransport(options: TransportOptions): Transport { - const baseUrl = new URL(options.url ?? ""); - const sseUrl = baseUrl.pathname.endsWith("/sse") - ? baseUrl - : new URL("/sse", baseUrl); - - return new SSEClientTransport(sseUrl); -} - -function createHTTPTransport(options: TransportOptions): Transport { - const baseUrl = new URL(options.url ?? ""); - const mcpUrl = baseUrl.pathname.endsWith("/mcp") - ? baseUrl - : new URL("/mcp", baseUrl); - - return new StreamableHTTPClientTransport(mcpUrl); -} - function createStdioTransport(options: TransportOptions): Transport { let args: string[] = []; @@ -75,12 +57,18 @@ export function createTransport(options: TransportOptions): Transport { return createStdioTransport(options); } + // If not STDIO, then it must be either SSE or HTTP. + if (!options.url) { + throw new Error("URL must be provided for SSE or HTTP transport types."); + } + const url = new URL(options.url); + if (transportType === "sse") { - return createSSETransport(options); + return new SSEClientTransport(url); } if (transportType === "http") { - return createHTTPTransport(options); + return new StreamableHTTPClientTransport(url); } throw new Error(`Unsupported transport type: ${transportType}`); From 7d888fcfa3b7fa257d3066bf5f94f8ab24b577fd Mon Sep 17 00:00:00 2001 From: Laziz Turakulov <4857092+LazaUK@users.noreply.github.com> Date: Thu, 10 Jul 2025 00:05:21 +0100 Subject: [PATCH 02/16] Missing mandatory parameter in the Inspector's CLI command Attempts to execute this command will fail: npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8000 --transport http. The error indicates that --method is a mandatory parameter: "Method is required. Use --method to specify the method to invoke. Failed with exit code: 1". That's why the right command may look like this: npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8000 --transport http --method tools/list. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6368ed04..b02a4a84 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,7 @@ npx @modelcontextprotocol/inspector --cli node build/index.js --method prompts/l npx @modelcontextprotocol/inspector --cli https://my-mcp-server.example.com # Connect to a remote MCP server (with Streamable HTTP transport) -npx @modelcontextprotocol/inspector --cli https://my-mcp-server.example.com --transport http +npx @modelcontextprotocol/inspector --cli https://my-mcp-server.example.com --transport http --method tools/list # Call a tool on a remote server npx @modelcontextprotocol/inspector --cli https://my-mcp-server.example.com --method tools/call --tool-name remotetool --tool-arg param=value From 714192486b11c200835870781d8da5527c99d0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 13:45:50 -0400 Subject: [PATCH 03/16] Fix a failing test --- cli/scripts/cli-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/scripts/cli-tests.js b/cli/scripts/cli-tests.js index 0585b6ea..0c5a6f2d 100755 --- a/cli/scripts/cli-tests.js +++ b/cli/scripts/cli-tests.js @@ -680,7 +680,7 @@ async function runTests() { // Test 26: HTTP transport with explicit --transport http flag await runBasicTest( "http_transport_with_explicit_flag", - "http://127.0.0.1:3001", + "http://127.0.0.1:3001/mcp", "--transport", "http", "--cli", From b3cb84473004f48922e95487299c3010a7f519ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 14:24:05 -0400 Subject: [PATCH 04/16] Run the CLI tests in CI Right now, the inspector has a CLI feature as well as a series of tests. However, they're not currently run in CI. For the moment, they are only triggered on file changes in the CLI folder, as AFAICT it is currently a separate code base. --- .github/workflows/cli_tests.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/cli_tests.yml diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml new file mode 100644 index 00000000..d61e5a4a --- /dev/null +++ b/.github/workflows/cli_tests.yml @@ -0,0 +1,26 @@ +name: CLI Tests + +on: + push: + paths: + - 'cli/**' + +jobs: + test: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./cli + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm test From 1842063ce701e0156cdbbf637d1bd58d89ecdb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 14:29:04 -0400 Subject: [PATCH 05/16] Remove unused import This commit is mostly so that we can see whether the CI triggers a check of the CLI tests when files are touched within the CLI folder. --- cli/scripts/cli-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/scripts/cli-tests.js b/cli/scripts/cli-tests.js index 51bda553..50cf03c9 100755 --- a/cli/scripts/cli-tests.js +++ b/cli/scripts/cli-tests.js @@ -12,7 +12,7 @@ const colors = { import fs from "fs"; import path from "path"; -import { execSync, spawn } from "child_process"; +import { spawn } from "child_process"; import os from "os"; import { fileURLToPath } from "url"; From f49f97f585fa082e6ed2323b3b5f7c5665fdda01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 22:06:20 -0400 Subject: [PATCH 06/16] Run prettier --- .github/workflows/cli_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index d61e5a4a..4e7be19c 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -3,7 +3,7 @@ name: CLI Tests on: push: paths: - - 'cli/**' + - "cli/**" jobs: test: @@ -17,7 +17,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: '14' + node-version: "14" - name: Install dependencies run: npm install From ea6177b552063c371ef81e9f322117d06657bb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 22:11:37 -0400 Subject: [PATCH 07/16] Run in both pull requests and push events --- .github/workflows/cli_tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 4e7be19c..c70823be 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -4,6 +4,9 @@ on: push: paths: - "cli/**" + pull_request: + paths: + - "cli/**" jobs: test: From ace91a81ad71b599238f66d04fc9cb0cfddf278c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 22:25:47 -0400 Subject: [PATCH 08/16] Use Node version defined in cli/package.json --- .github/workflows/cli_tests.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index c70823be..eb18a2c6 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -15,15 +15,19 @@ jobs: run: working-directory: ./cli steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: "14" + node-version-file: package.json + cache: npm - - name: Install dependencies - run: npm install + # Working around https://github.com/npm/cli/issues/4828 + - run: npm install --no-package-lock + + - name: Build CLI + run: npm run build - name: Run tests run: npm test From 718e61d492b071e1be656465aca3ed22162e3c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 22:36:00 -0400 Subject: [PATCH 09/16] Use simpler install method? --- .github/workflows/cli_tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index eb18a2c6..51b64c1c 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -23,8 +23,7 @@ jobs: node-version-file: package.json cache: npm - # Working around https://github.com/npm/cli/issues/4828 - - run: npm install --no-package-lock + - run: npm install - name: Build CLI run: npm run build From 9adcc0dd7739ff95146423e7e44aa4e543abd26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 23:10:56 -0400 Subject: [PATCH 10/16] Add logging for pwd --- .github/workflows/cli_tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 51b64c1c..678941fc 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -23,7 +23,11 @@ jobs: node-version-file: package.json cache: npm - - run: npm install + - name: Current directory + run: pwd + + - name: Install dependencies + run: npm install - name: Build CLI run: npm run build From f10b76b0ae9c65319d03c4d8ef216c60d0d3907d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 23:17:06 -0400 Subject: [PATCH 11/16] Run commands from root dir instead --- .github/workflows/cli_tests.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 678941fc..a393c79a 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -11,26 +11,20 @@ on: jobs: test: runs-on: ubuntu-latest - defaults: - run: - working-directory: ./cli steps: - uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version-file: package.json + node-version-file: cli/package.json cache: npm - - name: Current directory - run: pwd - - name: Install dependencies - run: npm install + run: npm install --workspace=cli - name: Build CLI - run: npm run build + run: npm run build --workspace=cli - name: Run tests - run: npm test + run: npm run test --workspace=cli From c1ab2a52d28de558170d56036b2f60bc9be61a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 23:19:05 -0400 Subject: [PATCH 12/16] Stay in cli/ but ignore scripts? --- .github/workflows/cli_tests.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index a393c79a..4a975b38 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -11,6 +11,9 @@ on: jobs: test: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./cli steps: - uses: actions/checkout@v4 @@ -21,10 +24,10 @@ jobs: cache: npm - name: Install dependencies - run: npm install --workspace=cli + run: npm install --ignore-scripts - name: Build CLI - run: npm run build --workspace=cli + run: npm run build - name: Run tests - run: npm run test --workspace=cli + run: npm test From b6a4aa40cbe02a522eb5af7a18fd1c22cfb47dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 23:21:15 -0400 Subject: [PATCH 13/16] Install more, but stay put --- .github/workflows/cli_tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 4a975b38..46431b46 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -24,7 +24,9 @@ jobs: cache: npm - name: Install dependencies - run: npm install --ignore-scripts + run: | + cd .. + npm ci --ignore-scripts - name: Build CLI run: npm run build From 616ef0d04c62591d47a75b81339ab08a1be8da20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 23:22:47 -0400 Subject: [PATCH 14/16] Use the node version in root package.json --- .github/workflows/cli_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 46431b46..3ea0f0e7 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version-file: cli/package.json + node-version-file: package.json cache: npm - name: Install dependencies From ff2d932904b8dd2ef5d5f8cd18b25440db5fe472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 23:27:58 -0400 Subject: [PATCH 15/16] Add await to runCli call --- .github/workflows/cli_tests.yml | 3 +++ cli/src/cli.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 3ea0f0e7..6f199518 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -31,5 +31,8 @@ jobs: - name: Build CLI run: npm run build + - name: Explicitly pre-install test dependencies + run: npx -y @modelcontextprotocol/server-everything --help || true + - name: Run tests run: npm test diff --git a/cli/src/cli.ts b/cli/src/cli.ts index de0153b0..f29743ab 100644 --- a/cli/src/cli.ts +++ b/cli/src/cli.ts @@ -233,7 +233,7 @@ async function main(): Promise { const args = parseArgs(); if (args.cli) { - runCli(args); + await runCli(args); } else { await runWebClient(args); } From b84e5271f49a623de377f9b0b116d7e8ec9114cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Jul 2025 23:35:52 -0400 Subject: [PATCH 16/16] Explicitly exit process for CI --- .github/workflows/cli_tests.yml | 3 +++ cli/src/index.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 6f199518..8bd3bb8e 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -36,3 +36,6 @@ jobs: - name: Run tests run: npm test + env: + NPM_CONFIG_YES: true + CI: true diff --git a/cli/src/index.ts b/cli/src/index.ts index 5d5dcf8b..2b0c4f53 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -287,6 +287,8 @@ async function main(): Promise { try { const args = parseArgs(); await callMethod(args); + // Explicitly exit to ensure process terminates in CI + process.exit(0); } catch (error) { handleError(error); }