From 89cac676627b8c1cae31bec8985a0c74ec839561 Mon Sep 17 00:00:00 2001 From: AkhilTrivediX <118957648+AkhilTrivediX@users.noreply.github.com> Date: Wed, 22 Jul 2026 18:57:21 +0530 Subject: [PATCH] fix(cli): align --log-level with MCP LoggingLevel specification --- cli/__tests__/cli.test.ts | 25 +++++++++++++++++++++++++ cli/src/client/connection.ts | 7 +++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cli/__tests__/cli.test.ts b/cli/__tests__/cli.test.ts index b263f618c..85dc3ba58 100644 --- a/cli/__tests__/cli.test.ts +++ b/cli/__tests__/cli.test.ts @@ -410,6 +410,31 @@ describe("CLI Tests", () => { expectCliFailure(result); }); + + it("should reject non-spec log levels trace and warn", async () => { + const { command, args } = getTestMcpServerCommand(); + const resultTrace = await runCli([ + command, + ...args, + "--cli", + "--method", + "logging/setLevel", + "--log-level", + "trace", + ]); + expectCliFailure(resultTrace); + + const resultWarn = await runCli([ + command, + ...args, + "--cli", + "--method", + "logging/setLevel", + "--log-level", + "warn", + ]); + expectCliFailure(resultWarn); + }); }); describe("Combined Options", () => { diff --git a/cli/src/client/connection.ts b/cli/src/client/connection.ts index dcbe8e518..f5560da09 100644 --- a/cli/src/client/connection.ts +++ b/cli/src/client/connection.ts @@ -3,11 +3,14 @@ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import { McpResponse } from "./types.js"; export const validLogLevels = [ - "trace", "debug", "info", - "warn", + "notice", + "warning", "error", + "critical", + "alert", + "emergency", ] as const; export type LogLevel = (typeof validLogLevels)[number];