@lonca/baron-mcp-server 0.3.0 → 0.5.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 +1 -1
- package/dist/{chunk-IJ6VTOQW.js → chunk-7KF4L47I.js} +91 -5
- package/dist/index.d.ts +16 -3
- package/dist/index.js +5 -3
- package/package.json +7 -7
package/dist/bin.js
CHANGED
|
@@ -47,10 +47,12 @@ function loadPorts(root, env) {
|
|
|
47
47
|
import {
|
|
48
48
|
BaronError as BaronError2,
|
|
49
49
|
ISSUE_LINK_TYPES,
|
|
50
|
+
PR_STATE_FILTERS,
|
|
50
51
|
RUN_STATUSES,
|
|
51
52
|
WORKFLOW_ROLES,
|
|
52
53
|
WORK_ITEM_TYPE_ROLES,
|
|
53
54
|
isIssueLinkType,
|
|
55
|
+
isPrStateFilter,
|
|
54
56
|
isRunStatus,
|
|
55
57
|
isWorkItemTypeRole,
|
|
56
58
|
isWorkflowRole
|
|
@@ -108,6 +110,7 @@ var TYPE_ROLE_ENUM = [...WORK_ITEM_TYPE_ROLES];
|
|
|
108
110
|
var LINK_TYPE_ENUM = [...ISSUE_LINK_TYPES];
|
|
109
111
|
var FOLLOWUP_STATUS_ENUM = [...FOLLOWUP_STATUSES];
|
|
110
112
|
var RUN_STATUS_ENUM = [...RUN_STATUSES];
|
|
113
|
+
var PR_STATE_FILTER_ENUM = [...PR_STATE_FILTERS];
|
|
111
114
|
var DEFAULT_QUERY_LIMIT = 50;
|
|
112
115
|
var TOOL_DEFINITIONS = [
|
|
113
116
|
{
|
|
@@ -303,7 +306,7 @@ var SCM_TOOL_DEFINITIONS = [
|
|
|
303
306
|
},
|
|
304
307
|
{
|
|
305
308
|
name: SCM_TOOL_NAMES.prForBranch,
|
|
306
|
-
description: "Find the
|
|
309
|
+
description: "Find the most recent pull request for a branch matching `state` (null when none), with its normalized `state`. `open` (default) = the finish-flow idempotency probe (don't duplicate an open PR); `merged` = the drift probe (did this branch land while its item stayed in progress?).",
|
|
307
310
|
inputSchema: {
|
|
308
311
|
type: "object",
|
|
309
312
|
additionalProperties: false,
|
|
@@ -313,6 +316,11 @@ var SCM_TOOL_DEFINITIONS = [
|
|
|
313
316
|
type: "string",
|
|
314
317
|
minLength: 1,
|
|
315
318
|
description: "Branch name (no refs/heads/)."
|
|
319
|
+
},
|
|
320
|
+
state: {
|
|
321
|
+
type: "string",
|
|
322
|
+
enum: PR_STATE_FILTER_ENUM,
|
|
323
|
+
description: "Lifecycle to search: 'open' (default), 'merged', 'closed', or 'all'."
|
|
316
324
|
}
|
|
317
325
|
}
|
|
318
326
|
}
|
|
@@ -749,7 +757,17 @@ function callScmTool(port, name, args) {
|
|
|
749
757
|
return run(() => port.prStatus(requireString(args, "pullRequestId")));
|
|
750
758
|
case SCM_TOOL_NAMES.prForBranch:
|
|
751
759
|
return run(async () => {
|
|
752
|
-
const
|
|
760
|
+
const stateRaw = optionalString(args, "state");
|
|
761
|
+
if (stateRaw !== void 0 && !isPrStateFilter(stateRaw)) {
|
|
762
|
+
throw new BaronError2(
|
|
763
|
+
`Invalid state '${stateRaw}'. Expected one of: ${PR_STATE_FILTERS.join(", ")}.`,
|
|
764
|
+
INVALID_ARGS
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
const pr = await port.prForBranch(
|
|
768
|
+
requireString(args, "sourceBranch"),
|
|
769
|
+
stateRaw
|
|
770
|
+
);
|
|
753
771
|
return pr ?? null;
|
|
754
772
|
});
|
|
755
773
|
case SCM_TOOL_NAMES.prThread:
|
|
@@ -1079,15 +1097,82 @@ function dispatchTool(ports, name, args) {
|
|
|
1079
1097
|
// src/server.ts
|
|
1080
1098
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
1081
1099
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
1082
|
-
|
|
1083
|
-
|
|
1100
|
+
|
|
1101
|
+
// src/update-check.ts
|
|
1102
|
+
var UPDATE_CHECK_DISABLE_ENV = "BARON_NO_UPDATE_CHECK";
|
|
1103
|
+
var REGISTRY_BASE = "https://registry.npmjs.org";
|
|
1104
|
+
var ABBREVIATED_ACCEPT = "application/vnd.npm.install-v1+json";
|
|
1105
|
+
var CHECK_TIMEOUT_MS = 4e3;
|
|
1106
|
+
function compareSemver(a, b) {
|
|
1107
|
+
const parse = (v) => {
|
|
1108
|
+
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
|
|
1109
|
+
return m === null ? void 0 : [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
1110
|
+
};
|
|
1111
|
+
const pa = parse(a);
|
|
1112
|
+
const pb = parse(b);
|
|
1113
|
+
if (pa === void 0 || pb === void 0) return 0;
|
|
1114
|
+
for (let i = 0; i < 3; i += 1) {
|
|
1115
|
+
const da = pa[i] ?? 0;
|
|
1116
|
+
const db = pb[i] ?? 0;
|
|
1117
|
+
if (da !== db) return da < db ? -1 : 1;
|
|
1118
|
+
}
|
|
1119
|
+
return 0;
|
|
1120
|
+
}
|
|
1121
|
+
function formatUpdateNotice(name, current, latest) {
|
|
1122
|
+
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.`;
|
|
1123
|
+
}
|
|
1124
|
+
async function defaultFetchJson(url, accept) {
|
|
1125
|
+
const response = await fetch(url, {
|
|
1126
|
+
headers: { accept },
|
|
1127
|
+
signal: AbortSignal.timeout(CHECK_TIMEOUT_MS)
|
|
1128
|
+
});
|
|
1129
|
+
if (!response.ok) throw new Error(`registry responded ${response.status}`);
|
|
1130
|
+
return response.json();
|
|
1131
|
+
}
|
|
1132
|
+
function startUpdateCheck(options) {
|
|
1133
|
+
let notice;
|
|
1134
|
+
const disabled = (options.env ?? process.env)[UPDATE_CHECK_DISABLE_ENV];
|
|
1135
|
+
if (disabled === void 0 || disabled.length === 0) {
|
|
1136
|
+
const fetchJson = options.fetchJson ?? defaultFetchJson;
|
|
1137
|
+
void fetchJson(`${REGISTRY_BASE}/${encodeURIComponent(options.name)}`, ABBREVIATED_ACCEPT).then((data) => {
|
|
1138
|
+
const latest = data["dist-tags"]?.latest;
|
|
1139
|
+
if (latest !== void 0 && compareSemver(options.currentVersion, latest) < 0) {
|
|
1140
|
+
notice = formatUpdateNotice(options.name, options.currentVersion, latest);
|
|
1141
|
+
}
|
|
1142
|
+
}).catch(() => {
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
return { notice: () => notice };
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/version.ts
|
|
1149
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
1150
|
+
function readOwnPackage() {
|
|
1151
|
+
try {
|
|
1152
|
+
const raw = readFileSync2(new URL("../package.json", import.meta.url), "utf8");
|
|
1153
|
+
const pkg = JSON.parse(raw);
|
|
1154
|
+
return { name: pkg.name ?? "baron-mcp-server", version: pkg.version ?? "0.0.0" };
|
|
1155
|
+
} catch {
|
|
1156
|
+
return { name: "baron-mcp-server", version: "0.0.0" };
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
var OWN_PACKAGE = readOwnPackage();
|
|
1160
|
+
|
|
1161
|
+
// src/server.ts
|
|
1162
|
+
var SERVER_INFO = { name: "baron", version: OWN_PACKAGE.version };
|
|
1163
|
+
function withUpdateNotice(result, notice) {
|
|
1164
|
+
if (notice === void 0 || result.isError === true) return result;
|
|
1165
|
+
return { ...result, content: [...result.content, { type: "text", text: notice }] };
|
|
1166
|
+
}
|
|
1167
|
+
function createMcpServer(ports, options = {}) {
|
|
1084
1168
|
const server = new Server(SERVER_INFO, { capabilities: { tools: {} } });
|
|
1169
|
+
const updateNotice = options.updateNotice ?? startUpdateCheck({ name: OWN_PACKAGE.name, currentVersion: OWN_PACKAGE.version }).notice;
|
|
1085
1170
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
1086
1171
|
tools: activeToolDefinitions(ports)
|
|
1087
1172
|
}));
|
|
1088
1173
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
1089
1174
|
const result = await dispatchTool(ports, request.params.name, request.params.arguments);
|
|
1090
|
-
return result;
|
|
1175
|
+
return withUpdateNotice(result, updateNotice());
|
|
1091
1176
|
});
|
|
1092
1177
|
return server;
|
|
1093
1178
|
}
|
|
@@ -1121,5 +1206,6 @@ export {
|
|
|
1121
1206
|
activeToolDefinitions,
|
|
1122
1207
|
dispatchTool,
|
|
1123
1208
|
SERVER_INFO,
|
|
1209
|
+
withUpdateNotice,
|
|
1124
1210
|
createMcpServer
|
|
1125
1211
|
};
|
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:
|
|
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
|
-
|
|
30
|
+
loadPorts,
|
|
31
|
+
withUpdateNotice
|
|
32
|
+
} from "./chunk-7KF4L47I.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
|
+
"version": "0.5.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.
|
|
23
|
-
"@lonca/baron-
|
|
24
|
-
"@lonca/baron-
|
|
25
|
-
"@lonca/baron-knowledge-loop": "0.
|
|
22
|
+
"@lonca/baron-core": "0.5.0",
|
|
23
|
+
"@lonca/baron-recipes": "0.5.0",
|
|
24
|
+
"@lonca/baron-providers": "0.5.0",
|
|
25
|
+
"@lonca/baron-knowledge-loop": "0.5.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^22.0.0",
|
|
29
|
-
"@lonca/baron-conformance": "0.
|
|
30
|
-
"@lonca/baron-adapter-github": "0.
|
|
29
|
+
"@lonca/baron-conformance": "0.5.0",
|
|
30
|
+
"@lonca/baron-adapter-github": "0.5.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": [
|