@lonca/baron-mcp-server 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createMcpServer,
4
4
  loadPorts
5
- } from "./chunk-IJ6VTOQW.js";
5
+ } from "./chunk-Y2C7LNNF.js";
6
6
 
7
7
  // src/bin.ts
8
8
  import { cwd, env, exit, stderr } from "process";
@@ -1079,15 +1079,82 @@ function dispatchTool(ports, name, args) {
1079
1079
  // src/server.ts
1080
1080
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
1081
1081
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
1082
- var SERVER_INFO = { name: "baron", version: "0.0.0" };
1083
- function createMcpServer(ports) {
1082
+
1083
+ // src/update-check.ts
1084
+ var UPDATE_CHECK_DISABLE_ENV = "BARON_NO_UPDATE_CHECK";
1085
+ var REGISTRY_BASE = "https://registry.npmjs.org";
1086
+ var ABBREVIATED_ACCEPT = "application/vnd.npm.install-v1+json";
1087
+ var CHECK_TIMEOUT_MS = 4e3;
1088
+ function compareSemver(a, b) {
1089
+ const parse = (v) => {
1090
+ const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
1091
+ return m === null ? void 0 : [Number(m[1]), Number(m[2]), Number(m[3])];
1092
+ };
1093
+ const pa = parse(a);
1094
+ const pb = parse(b);
1095
+ if (pa === void 0 || pb === void 0) return 0;
1096
+ for (let i = 0; i < 3; i += 1) {
1097
+ const da = pa[i] ?? 0;
1098
+ const db = pb[i] ?? 0;
1099
+ if (da !== db) return da < db ? -1 : 1;
1100
+ }
1101
+ return 0;
1102
+ }
1103
+ function formatUpdateNotice(name, current, latest) {
1104
+ return `\u26A0\uFE0F ${name} v${current} outdated \u2192 v${latest} available. Restart the baron MCP server to update (an @latest npx launcher fetches it automatically); pinned installs: reinstall ${name}@latest.`;
1105
+ }
1106
+ async function defaultFetchJson(url, accept) {
1107
+ const response = await fetch(url, {
1108
+ headers: { accept },
1109
+ signal: AbortSignal.timeout(CHECK_TIMEOUT_MS)
1110
+ });
1111
+ if (!response.ok) throw new Error(`registry responded ${response.status}`);
1112
+ return response.json();
1113
+ }
1114
+ function startUpdateCheck(options) {
1115
+ let notice;
1116
+ const disabled = (options.env ?? process.env)[UPDATE_CHECK_DISABLE_ENV];
1117
+ if (disabled === void 0 || disabled.length === 0) {
1118
+ const fetchJson = options.fetchJson ?? defaultFetchJson;
1119
+ void fetchJson(`${REGISTRY_BASE}/${encodeURIComponent(options.name)}`, ABBREVIATED_ACCEPT).then((data) => {
1120
+ const latest = data["dist-tags"]?.latest;
1121
+ if (latest !== void 0 && compareSemver(options.currentVersion, latest) < 0) {
1122
+ notice = formatUpdateNotice(options.name, options.currentVersion, latest);
1123
+ }
1124
+ }).catch(() => {
1125
+ });
1126
+ }
1127
+ return { notice: () => notice };
1128
+ }
1129
+
1130
+ // src/version.ts
1131
+ import { readFileSync as readFileSync2 } from "fs";
1132
+ function readOwnPackage() {
1133
+ try {
1134
+ const raw = readFileSync2(new URL("../package.json", import.meta.url), "utf8");
1135
+ const pkg = JSON.parse(raw);
1136
+ return { name: pkg.name ?? "baron-mcp-server", version: pkg.version ?? "0.0.0" };
1137
+ } catch {
1138
+ return { name: "baron-mcp-server", version: "0.0.0" };
1139
+ }
1140
+ }
1141
+ var OWN_PACKAGE = readOwnPackage();
1142
+
1143
+ // src/server.ts
1144
+ var SERVER_INFO = { name: "baron", version: OWN_PACKAGE.version };
1145
+ function withUpdateNotice(result, notice) {
1146
+ if (notice === void 0 || result.isError === true) return result;
1147
+ return { ...result, content: [...result.content, { type: "text", text: notice }] };
1148
+ }
1149
+ function createMcpServer(ports, options = {}) {
1084
1150
  const server = new Server(SERVER_INFO, { capabilities: { tools: {} } });
1151
+ const updateNotice = options.updateNotice ?? startUpdateCheck({ name: OWN_PACKAGE.name, currentVersion: OWN_PACKAGE.version }).notice;
1085
1152
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
1086
1153
  tools: activeToolDefinitions(ports)
1087
1154
  }));
1088
1155
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
1089
1156
  const result = await dispatchTool(ports, request.params.name, request.params.arguments);
1090
- return result;
1157
+ return withUpdateNotice(result, updateNotice());
1091
1158
  });
1092
1159
  return server;
1093
1160
  }
@@ -1121,5 +1188,6 @@ export {
1121
1188
  activeToolDefinitions,
1122
1189
  dispatchTool,
1123
1190
  SERVER_INFO,
1191
+ withUpdateNotice,
1124
1192
  createMcpServer
1125
1193
  };
package/dist/index.d.ts CHANGED
@@ -119,8 +119,21 @@ declare function dispatchTool(ports: McpPorts, name: string, args: Record<string
119
119
 
120
120
  declare const SERVER_INFO: {
121
121
  readonly name: "baron";
122
- readonly version: "0.0.0";
122
+ readonly version: string;
123
123
  };
124
+ interface McpServerOptions {
125
+ /**
126
+ * Supplies the one-line "outdated" notice (or undefined). Defaults to a live npm-registry check;
127
+ * injectable for tests and disabled entirely via BARON_NO_UPDATE_CHECK.
128
+ */
129
+ readonly updateNotice?: () => string | undefined;
130
+ }
131
+ /**
132
+ * Append the update notice as an ADDITIONAL content block. The first block stays untouched: it is
133
+ * parseable JSON that agents (and our tests) read with JSON.parse — prepending prose there would
134
+ * break every consumer. Error results are left alone so the notice never muddies failure handling.
135
+ */
136
+ declare function withUpdateNotice(result: ToolResult, notice: string | undefined): ToolResult;
124
137
  /**
125
138
  * Wire the bound ports' primitives onto a low-level MCP {@link Server}. It advertises only the tools
126
139
  * for ports present in {@link McpPorts} and routes each call to the right port by name prefix. The
@@ -128,7 +141,7 @@ declare const SERVER_INFO: {
128
141
  * / result shapes are structurally the SDK's, cast at this single boundary to bridge readonly /
129
142
  * zod-inferred nominal differences while keeping `tools.ts` SDK-free.
130
143
  */
131
- declare function createMcpServer(ports: McpPorts): Server;
144
+ declare function createMcpServer(ports: McpPorts, options?: McpServerOptions): Server;
132
145
 
133
146
  /**
134
147
  * Load the committed policy and build the ports it serves: the issues/scm ports it binds (either or
@@ -138,4 +151,4 @@ declare function createMcpServer(ports: McpPorts): Server;
138
151
  */
139
152
  declare function loadPorts(root: string, env: Env): McpPorts;
140
153
 
141
- export { CI_TOOL_DEFINITIONS, CI_TOOL_NAMES, DEPLOY_TOOL_DEFINITIONS, DEPLOY_TOOL_NAMES, LOOP_TOOL_DEFINITIONS, LOOP_TOOL_NAMES, MCP_TOOL_NAMES, type McpPorts, NATIVE_TOOL_DEFINITIONS, NATIVE_TOOL_NAMES, NOTIFY_TOOL_DEFINITIONS, NOTIFY_TOOL_NAMES, type NativeAccess, RECIPE_TOOL_DEFINITIONS, RECIPE_TOOL_NAMES, SCM_TOOL_DEFINITIONS, SCM_TOOL_NAMES, SERVER_INFO, TOOL_DEFINITIONS, type ToolDefinition, type ToolResult, activeToolDefinitions, callCiTool, callDeployTool, callLoopTool, callNativeTool, callNotifyTool, callRecipeTool, callScmTool, callTool, createMcpServer, dispatchTool, loadPorts };
154
+ export { CI_TOOL_DEFINITIONS, CI_TOOL_NAMES, DEPLOY_TOOL_DEFINITIONS, DEPLOY_TOOL_NAMES, LOOP_TOOL_DEFINITIONS, LOOP_TOOL_NAMES, MCP_TOOL_NAMES, type McpPorts, type McpServerOptions, NATIVE_TOOL_DEFINITIONS, NATIVE_TOOL_NAMES, NOTIFY_TOOL_DEFINITIONS, NOTIFY_TOOL_NAMES, type NativeAccess, RECIPE_TOOL_DEFINITIONS, RECIPE_TOOL_NAMES, SCM_TOOL_DEFINITIONS, SCM_TOOL_NAMES, SERVER_INFO, TOOL_DEFINITIONS, type ToolDefinition, type ToolResult, activeToolDefinitions, callCiTool, callDeployTool, callLoopTool, callNativeTool, callNotifyTool, callRecipeTool, callScmTool, callTool, createMcpServer, dispatchTool, loadPorts, withUpdateNotice };
package/dist/index.js CHANGED
@@ -27,8 +27,9 @@ import {
27
27
  callTool,
28
28
  createMcpServer,
29
29
  dispatchTool,
30
- loadPorts
31
- } from "./chunk-IJ6VTOQW.js";
30
+ loadPorts,
31
+ withUpdateNotice
32
+ } from "./chunk-Y2C7LNNF.js";
32
33
  export {
33
34
  CI_TOOL_DEFINITIONS,
34
35
  CI_TOOL_NAMES,
@@ -58,5 +59,6 @@ export {
58
59
  callTool,
59
60
  createMcpServer,
60
61
  dispatchTool,
61
- loadPorts
62
+ loadPorts,
63
+ withUpdateNotice
62
64
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lonca/baron-mcp-server",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -19,15 +19,15 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@modelcontextprotocol/sdk": "^1.29.0",
22
- "@lonca/baron-core": "0.3.0",
23
- "@lonca/baron-providers": "0.3.0",
24
- "@lonca/baron-recipes": "0.3.0",
25
- "@lonca/baron-knowledge-loop": "0.3.0"
22
+ "@lonca/baron-core": "0.4.0",
23
+ "@lonca/baron-providers": "0.4.0",
24
+ "@lonca/baron-recipes": "0.4.0",
25
+ "@lonca/baron-knowledge-loop": "0.4.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.0.0",
29
- "@lonca/baron-conformance": "0.3.0",
30
- "@lonca/baron-adapter-github": "0.3.0"
29
+ "@lonca/baron-adapter-github": "0.4.0",
30
+ "@lonca/baron-conformance": "0.4.0"
31
31
  },
32
32
  "description": "Baron MCP server: drive issues, scm, ci, deploy, and notify across providers from any MCP client.",
33
33
  "keywords": [