Skip to content

Commit bbbf22d

Browse files
claudehyperpolymath
authored andcommitted
feat(mcp): declare logging capability + implement logging/setLevel
- Advertise MCP logging capability in initialize response alongside tools - Add runtime setLevel() to logger.js for client-requested verbosity changes - Accept and validate logging/setLevel requests in main.js dispatch - Fix stale mcp-bridge/lib/version.js (was 0.4.0; bump to 0.4.2) - Bump package.json / mcp-bridge/package.json / jsr.json to 0.4.2 https://claude.ai/code/session_01AQeaZPrDneQqFYxwxVTJqm
1 parent 6f8dcc6 commit bbbf22d

6 files changed

Lines changed: 38 additions & 8 deletions

File tree

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hyperpolymath/boj-server",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Bundle of Joy — cartridge-based MCP server with 100 domain cartridges, formally verified (Idris2) coord core",
55
"license": "MPL-2.0",
66
"exports": "./mcp-bridge/main.js",

mcp-bridge/lib/logger.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,22 @@
77
// MCP JSON-RPC messages). Log level controlled via BOJ_LOG_LEVEL env.
88

99
const LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 };
10-
const currentLevel = LOG_LEVELS[process.env.BOJ_LOG_LEVEL || "info"] ?? LOG_LEVELS.info;
10+
let currentLevel = LOG_LEVELS[process.env.BOJ_LOG_LEVEL || "info"] ?? LOG_LEVELS.info;
11+
12+
/**
13+
* Update the minimum log level at runtime. Used by the MCP
14+
* `logging/setLevel` handler to honour client-requested verbosity.
15+
* Unknown levels are ignored (no-op).
16+
* @param {"debug"|"info"|"warn"|"error"|"silent"} level
17+
* @returns {boolean} true if the level was recognised and applied
18+
*/
19+
function setLevel(level) {
20+
if (level in LOG_LEVELS) {
21+
currentLevel = LOG_LEVELS[level];
22+
return true;
23+
}
24+
return false;
25+
}
1126

1227
/**
1328
* Emit a structured log entry to stderr.
@@ -38,4 +53,4 @@ function warn(msg, fields) { log("warn", msg, fields); }
3853
/** @param {string} msg @param {Record<string, unknown>} [fields] */
3954
function error(msg, fields) { log("error", msg, fields); }
4055

41-
export { debug, error, info, log, warn };
56+
export { debug, error, info, log, setLevel, warn };

mcp-bridge/lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
// Single source of truth for server version and name.
55

66
export const SERVER_NAME = "boj-server";
7-
export const SERVER_VERSION = "0.4.0";
7+
export const SERVER_VERSION = "0.4.2";

mcp-bridge/main.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
tryParseEnvelope,
3636
validateEnvelope,
3737
} from "./lib/nickel-validator.js";
38-
import { info, warn, error as logError } from "./lib/logger.js";
38+
import { info, warn, error as logError, setLevel as setLogLevel } from "./lib/logger.js";
3939

4040
const BOJ_BASE = process.env.BOJ_URL || "http://localhost:7700";
4141
const SERVER_NAME = "boj-server";
@@ -338,7 +338,10 @@ async function handleMessage(line) {
338338
info("MCP initialize", { client: params?.clientInfo?.name });
339339
sendResult(id, {
340340
protocolVersion: "2024-11-05",
341-
capabilities: { tools: { listChanged: false } },
341+
capabilities: {
342+
tools: { listChanged: false },
343+
logging: {},
344+
},
342345
serverInfo: { name: SERVER_NAME, version: SERVER_VERSION },
343346
});
344347
break;
@@ -347,6 +350,18 @@ async function handleMessage(line) {
347350
case "notifications/initialized":
348351
break;
349352

353+
case "logging/setLevel": {
354+
const level = params?.level;
355+
const applied = setLogLevel(level);
356+
if (!applied) {
357+
sendError(id, -32602, `Unknown log level: ${level}. Expected debug|info|warn|error|silent.`);
358+
} else {
359+
info("MCP logging/setLevel", { level });
360+
sendResult(id, {});
361+
}
362+
break;
363+
}
364+
350365
case "tools/list": {
351366
const tools = buildToolList();
352367
sendResult(id, { tools });

mcp-bridge/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hyperpolymath/boj-server",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Bundle of Joy (BoJ) MCP Server — cartridge-based DevOps + multi-agent coordination toolkit with 100 domain cartridges (database, container, git, k8s, observability, secrets, IaC, multi-instance AI coord, and more). Formally verified (Idris2) core; MPL-2.0.",
55
"license": "MPL-2.0",
66
"author": "Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hyperpolymath/boj-server",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Bundle of Joy (BoJ) MCP Server — cartridge-based DevOps + multi-agent coordination toolkit with 100 domain cartridges (database, container, git, k8s, observability, secrets, IaC, multi-instance AI coord, and more). Formally verified (Idris2) core; MPL-2.0.",
55
"license": "MPL-2.0",
66
"author": "Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>",

0 commit comments

Comments
 (0)