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];