diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 8bd3bb8ec..3a5f502bb 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -32,7 +32,7 @@ jobs: run: npm run build - name: Explicitly pre-install test dependencies - run: npx -y @modelcontextprotocol/server-everything --help || true + run: npx -y @modelcontextprotocol/server-everything@2026.1.14 --help || true - name: Run tests run: npm test diff --git a/cli/package.json b/cli/package.json index 6551c80aa..1cb2b662c 100644 --- a/cli/package.json +++ b/cli/package.json @@ -17,10 +17,11 @@ "scripts": { "build": "tsc", "postbuild": "node scripts/make-executable.js", - "test": "node scripts/cli-tests.js && node scripts/cli-tool-tests.js && node scripts/cli-header-tests.js", + "test": "node scripts/cli-tests.js && node scripts/cli-tool-tests.js && node scripts/cli-header-tests.js && node scripts/cli-metadata-tests.js", "test:cli": "node scripts/cli-tests.js", "test:cli-tools": "node scripts/cli-tool-tests.js", - "test:cli-headers": "node scripts/cli-header-tests.js" + "test:cli-headers": "node scripts/cli-header-tests.js", + "test:cli-metadata": "node scripts/cli-metadata-tests.js" }, "devDependencies": {}, "dependencies": { diff --git a/cli/scripts/cli-metadata-tests.js b/cli/scripts/cli-metadata-tests.js index 0bc664d2c..eaddc3577 100755 --- a/cli/scripts/cli-metadata-tests.js +++ b/cli/scripts/cli-metadata-tests.js @@ -56,7 +56,7 @@ const BUILD_DIR = path.resolve(SCRIPTS_DIR, "../build"); // Define the test server command using npx const TEST_CMD = "npx"; -const TEST_ARGS = ["@modelcontextprotocol/server-everything"]; +const TEST_ARGS = ["@modelcontextprotocol/server-everything@2026.1.14"]; // Create output directory for test results const OUTPUT_DIR = path.join(SCRIPTS_DIR, "metadata-test-output"); @@ -335,7 +335,7 @@ async function runTests() { "--method", "resources/read", "--uri", - "test://static/resource/1", + "demo://resource/static/document/architecture.md", "--metadata", "client=test-client", ); @@ -349,7 +349,7 @@ async function runTests() { "--method", "prompts/get", "--prompt-name", - "simple_prompt", + "simple-prompt", "--metadata", "client=test-client", ); @@ -383,7 +383,7 @@ async function runTests() { "--method", "tools/call", "--tool-name", - "add", + "get-sum", "--tool-arg", "a=10", "b=20", @@ -566,7 +566,7 @@ async function runTests() { "--method", "prompts/get", "--prompt-name", - "simple_prompt", + "simple-prompt", "--metadata", "prompt_client=test-prompt-client", ); diff --git a/cli/scripts/cli-tests.js b/cli/scripts/cli-tests.js index 554a5262e..38f57bb24 100755 --- a/cli/scripts/cli-tests.js +++ b/cli/scripts/cli-tests.js @@ -56,8 +56,9 @@ const PROJECT_ROOT = path.join(SCRIPTS_DIR, "../../"); const BUILD_DIR = path.resolve(SCRIPTS_DIR, "../build"); // Define the test server command using npx +const EVERYTHING_SERVER = "@modelcontextprotocol/server-everything@2026.1.14"; const TEST_CMD = "npx"; -const TEST_ARGS = ["@modelcontextprotocol/server-everything"]; +const TEST_ARGS = [EVERYTHING_SERVER]; // Create output directory for test results const OUTPUT_DIR = path.join(SCRIPTS_DIR, "test-output"); @@ -163,7 +164,7 @@ fs.writeFileSync( "test-stdio": { type: "stdio", command: "npx", - args: ["@modelcontextprotocol/server-everything"], + args: [EVERYTHING_SERVER], env: { TEST_ENV: "test-value", }, @@ -184,7 +185,7 @@ fs.writeFileSync( mcpServers: { "test-legacy": { command: "npx", - args: ["@modelcontextprotocol/server-everything"], + args: [EVERYTHING_SERVER], env: { LEGACY_ENV: "legacy-value", }, @@ -543,7 +544,7 @@ async function runTests() { "--method", "resources/read", "--uri", - "test://static/resource/1", + "demo://resource/static/document/architecture.md", ); // Test 17: CLI mode with resource read but missing URI (should fail) @@ -569,7 +570,7 @@ async function runTests() { "--method", "prompts/get", "--prompt-name", - "simple_prompt", + "simple-prompt", ); // Test 19: CLI mode with prompt get and args @@ -581,10 +582,10 @@ async function runTests() { "--method", "prompts/get", "--prompt-name", - "complex_prompt", + "args-prompt", "--prompt-args", - "temperature=0.7", - "style=concise", + "city=New York", + "state=NY", ); // Test 20: CLI mode with prompt get but missing prompt name (should fail) @@ -734,7 +735,7 @@ async function runTests() { mcpServers: { "only-server": { command: "npx", - args: ["@modelcontextprotocol/server-everything"], + args: [EVERYTHING_SERVER], }, }, }, @@ -755,7 +756,7 @@ async function runTests() { mcpServers: { "default-server": { command: "npx", - args: ["@modelcontextprotocol/server-everything"], + args: [EVERYTHING_SERVER], }, "other-server": { command: "node", @@ -777,7 +778,7 @@ async function runTests() { mcpServers: { server1: { command: "npx", - args: ["@modelcontextprotocol/server-everything"], + args: [EVERYTHING_SERVER], }, server2: { command: "node", @@ -827,14 +828,10 @@ async function runTests() { console.log( `${colors.BLUE}Starting server-everything in streamableHttp mode.${colors.NC}`, ); - const httpServer = spawn( - "npx", - ["@modelcontextprotocol/server-everything", "streamableHttp"], - { - detached: true, - stdio: "ignore", - }, - ); + const httpServer = spawn("npx", [EVERYTHING_SERVER, "streamableHttp"], { + detached: true, + stdio: "ignore", + }); runningServers.push(httpServer); await new Promise((resolve) => setTimeout(resolve, 3000)); diff --git a/cli/scripts/cli-tool-tests.js b/cli/scripts/cli-tool-tests.js index b06aea940..30b5a2e2f 100644 --- a/cli/scripts/cli-tool-tests.js +++ b/cli/scripts/cli-tool-tests.js @@ -50,7 +50,7 @@ const BUILD_DIR = path.resolve(SCRIPTS_DIR, "../build"); // Define the test server command using npx const TEST_CMD = "npx"; -const TEST_ARGS = ["@modelcontextprotocol/server-everything"]; +const TEST_ARGS = ["@modelcontextprotocol/server-everything@2026.1.14"]; // Create output directory for test results const OUTPUT_DIR = path.join(SCRIPTS_DIR, "tool-test-output"); @@ -137,7 +137,21 @@ async function runBasicTest(testName, ...args) { clearTimeout(timeout); outputStream.end(); + // Check for JSON errors even if exit code is 0 + let hasJsonError = false; if (code === 0) { + try { + const jsonMatch = output.match(/\{[\s\S]*\}/); + if (jsonMatch) { + const parsed = JSON.parse(jsonMatch[0]); + hasJsonError = parsed.isError === true; + } + } catch (e) { + // Not valid JSON or parse failed, continue with original check + } + } + + if (code === 0 && !hasJsonError) { console.log(`${colors.GREEN}✓ Test passed: ${testName}${colors.NC}`); console.log(`${colors.BLUE}First few lines of output:${colors.NC}`); const firstFewLines = output @@ -225,8 +239,22 @@ async function runErrorTest(testName, ...args) { clearTimeout(timeout); outputStream.end(); - // For error tests, we expect a non-zero exit code - if (code !== 0) { + // For error tests, we expect a non-zero exit code OR JSON with isError: true + let hasJsonError = false; + if (code === 0) { + // Try to parse JSON and check for isError field + try { + const jsonMatch = output.match(/\{[\s\S]*\}/); + if (jsonMatch) { + const parsed = JSON.parse(jsonMatch[0]); + hasJsonError = parsed.isError === true; + } + } catch (e) { + // Not valid JSON or parse failed, continue with original check + } + } + + if (code !== 0 || hasJsonError) { console.log( `${colors.GREEN}✓ Error test passed: ${testName}${colors.NC}`, ); @@ -312,7 +340,7 @@ async function runTests() { "--method", "tools/call", "--tool-name", - "add", + "get-sum", "--tool-arg", "a=42", "b=58", @@ -327,7 +355,7 @@ async function runTests() { "--method", "tools/call", "--tool-name", - "add", + "get-sum", "--tool-arg", "a=19.99", "b=20.01", @@ -342,7 +370,7 @@ async function runTests() { "--method", "tools/call", "--tool-name", - "annotatedMessage", + "get-annotated-message", "--tool-arg", "messageType=success", "includeImage=true", @@ -357,7 +385,7 @@ async function runTests() { "--method", "tools/call", "--tool-name", - "annotatedMessage", + "get-annotated-message", "--tool-arg", "messageType=error", "includeImage=false", @@ -386,7 +414,7 @@ async function runTests() { "--method", "tools/call", "--tool-name", - "add", + "get-sum", "--tool-arg", "a=42.5", "b=57.5", @@ -537,11 +565,10 @@ async function runTests() { "--method", "prompts/get", "--prompt-name", - "complex_prompt", + "args-prompt", "--prompt-args", - "temperature=0.7", - 'style="concise"', - 'options={"format":"json","max_tokens":100}', + "city=New York", + "state=NY", ); // Test 25: Prompt with simple arguments @@ -553,7 +580,7 @@ async function runTests() { "--method", "prompts/get", "--prompt-name", - "simple_prompt", + "simple-prompt", "--prompt-args", "name=test", "count=5", @@ -586,7 +613,7 @@ async function runTests() { "--method", "tools/call", "--tool-name", - "add", + "get-sum", "--tool-arg", "a=10", "b=20",