@mrrlin-dev/mcp 0.4.153 → 0.4.155

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.
Files changed (2) hide show
  1. package/dist/bin.cjs +618 -50
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -38775,6 +38775,18 @@ var githubRepositorySelectionSchema = external_exports.enum(["all", "selected"])
38775
38775
  var mrrlinTaskIdSchema = external_exports.string().regex(/^GT-\d+$/);
38776
38776
  var mrrlinPlanIdSchema = external_exports.string().regex(/^PL-\d+$/);
38777
38777
  var mrrlinWikiPageIdSchema = external_exports.string().regex(/^WK-\d+$/);
38778
+ function nextMrrlinWikiPageId(existingIds) {
38779
+ let max = 0n;
38780
+ for (const id of existingIds) {
38781
+ const match = /^WK-(\d+)$/.exec(id);
38782
+ if (!match?.[1])
38783
+ continue;
38784
+ const n = BigInt(match[1]);
38785
+ if (n > max)
38786
+ max = n;
38787
+ }
38788
+ return `WK-${max + 1n}`;
38789
+ }
38778
38790
  var mrrlinWikiPagePathSchema = external_exports.string().regex(/^\/[a-z0-9-]+\/[a-z0-9-]+$/);
38779
38791
  var PROJECT_CONSTITUTION_PAGE = {
38780
38792
  folder: "Memory",
@@ -40962,10 +40974,8 @@ function createMrrlinClient(config2) {
40962
40974
  if (retryAfterMs !== null && retryAfterMs > 1e4) {
40963
40975
  return response;
40964
40976
  }
40965
- try {
40966
- await response.body?.cancel();
40967
- } catch {
40968
- }
40977
+ void response.body?.cancel().catch(() => {
40978
+ });
40969
40979
  const backoffMs = retryAfterMs ?? Math.floor(Math.random() * Math.min(2e3, 250 * Math.pow(2, attempt)));
40970
40980
  await abortableDelay(backoffMs, init?.signal);
40971
40981
  continue;
@@ -44164,7 +44174,7 @@ function renderContextBundle(input) {
44164
44174
  const { keptRuns, keptArtifacts, keptAutonomy, anyHistoricalDropped, droppedHandles } = applyHistoricalBudgetIfNeeded(input);
44165
44175
  sections.push(renderRunHistory(keptRuns, input.openRunId, input.compact, anyHistoricalDropped));
44166
44176
  sections.push(renderOpenRun(input.openRunId));
44167
- sections.push(renderArtifacts(keptArtifacts, input.omittedArtifactCount ?? 0, input.compact, anyHistoricalDropped, droppedHandles));
44177
+ sections.push(renderArtifacts(keptArtifacts, input.omittedArtifactCount ?? 0, input.compact, anyHistoricalDropped, droppedHandles, keptArtifacts.length < input.artifacts.length));
44168
44178
  sections.push(renderAutonomyEvents(keptAutonomy, input.compact, anyHistoricalDropped));
44169
44179
  return sections.join("\n\n");
44170
44180
  }
@@ -44249,9 +44259,10 @@ function renderOpenRun(openRunId) {
44249
44259
  return `## Open run (normative)
44250
44260
  ${openRunId ?? "(none)"}`;
44251
44261
  }
44252
- function renderArtifacts(artifacts, omittedCount, compact, anyHistoricalDropped, droppedHandles) {
44253
- if (artifacts.length === 0 && omittedCount === 0)
44262
+ function renderArtifacts(artifacts, omittedCount, compact, anyHistoricalDropped, droppedHandles, anyArtifactDropped) {
44263
+ if (artifacts.length === 0 && omittedCount === 0 && !(compact && anyArtifactDropped && droppedHandles.length > 0)) {
44254
44264
  return "## Artifacts (historical)\n(none)";
44265
+ }
44255
44266
  const lines2 = ["## Artifacts (historical)"];
44256
44267
  if (omittedCount > 0) {
44257
44268
  lines2.push(`(+${omittedCount} older artifact${omittedCount === 1 ? "" : "s"} omitted)`);
@@ -46851,7 +46862,23 @@ async function startProviderProxy(allowedHosts, options) {
46851
46862
  clientSocket.end("HTTP/1.1 403 Forbidden\r\n\r\n");
46852
46863
  return;
46853
46864
  }
46865
+ let upstreamSocket = null;
46866
+ let validatedAuthority = false;
46867
+ clientSocket.once("end", () => {
46868
+ if (!validatedAuthority) {
46869
+ upstreamSocket?.destroy();
46870
+ clientSocket.destroy();
46871
+ }
46872
+ });
46873
+ clientSocket.once("close", () => {
46874
+ upstreamSocket?.destroy();
46875
+ });
46876
+ clientSocket.on("error", () => {
46877
+ upstreamSocket?.destroy();
46878
+ });
46854
46879
  import_node_dns.default.promises.lookup(targetHost, { all: true }).then((addresses) => {
46880
+ if (clientSocket.destroyed)
46881
+ return;
46855
46882
  if (!addresses || addresses.length === 0) {
46856
46883
  clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
46857
46884
  return;
@@ -46864,13 +46891,12 @@ async function startProviderProxy(allowedHosts, options) {
46864
46891
  }
46865
46892
  const firstAddress = addresses[0];
46866
46893
  if (!firstAddress) {
46867
- clientSocket.end("HTTP/1.1 502 Bad Gateway\\r\\n\\r\\n");
46894
+ clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
46868
46895
  return;
46869
46896
  }
46870
46897
  const validatedIp = options?.allowPrivateUpstream ? "127.0.0.1" : firstAddress.address;
46871
46898
  const serverSocket = import_node_net.default.connect({ host: validatedIp, port: targetPort }, () => {
46872
46899
  clientSocket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
46873
- let validatedAuthority = false;
46874
46900
  let clientBuffer = head && head.length > 0 ? Buffer.from(head) : Buffer.alloc(0);
46875
46901
  const validateAndPipe = (chunk) => {
46876
46902
  if (chunk) {
@@ -46931,14 +46957,13 @@ async function startProviderProxy(allowedHosts, options) {
46931
46957
  validateAndPipe();
46932
46958
  }
46933
46959
  });
46960
+ upstreamSocket = serverSocket;
46934
46961
  serverSocket.on("error", () => {
46935
46962
  clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
46936
46963
  });
46937
- clientSocket.on("error", () => {
46938
- serverSocket.destroy();
46939
- });
46940
46964
  }).catch(() => {
46941
- clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
46965
+ if (!clientSocket.destroyed)
46966
+ clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
46942
46967
  });
46943
46968
  });
46944
46969
  let assignedPort;
@@ -56893,14 +56918,7 @@ function findDuplicateLabelEnvPairs(entries) {
56893
56918
  return pairs;
56894
56919
  }
56895
56920
  function nextWikiPageId(pages) {
56896
- let max = 0;
56897
- for (const page of pages) {
56898
- const match = /^WK-(\d+)$/.exec(page.id);
56899
- if (!match) continue;
56900
- const n = Number.parseInt(match[1] ?? "0", 10);
56901
- if (Number.isInteger(n) && n > max) max = n;
56902
- }
56903
- return `WK-${max + 1}`;
56921
+ return nextMrrlinWikiPageId(pages.map((page) => page.id));
56904
56922
  }
56905
56923
  function buildDraftSpecPrompt(task, constitution, deployTarget = null) {
56906
56924
  const budget = resolveSpecBudget(task.impact);
@@ -60540,6 +60558,27 @@ var COMPACT_OPT_IN = {
60540
60558
  [mcpToolNames.listTaskEvents]: "task-events"
60541
60559
  };
60542
60560
 
60561
+ // src/tool-error-envelope.ts
60562
+ function buildToolError(error51) {
60563
+ const payload = {
60564
+ error: {
60565
+ code: error51.code,
60566
+ message: error51.message,
60567
+ ...error51.violations !== void 0 ? { violations: error51.violations } : {}
60568
+ }
60569
+ };
60570
+ return {
60571
+ isError: true,
60572
+ content: [
60573
+ {
60574
+ type: "text",
60575
+ text: JSON.stringify(payload, null, 2)
60576
+ }
60577
+ ],
60578
+ structuredContent: payload
60579
+ };
60580
+ }
60581
+
60543
60582
  // src/tools.ts
60544
60583
  registerAsyncTool(consensusDescriptor);
60545
60584
  registerAsyncTool(deliverableConsensusDescriptor);
@@ -60937,14 +60976,7 @@ function structuredOk(value) {
60937
60976
  structuredContent: { data: value }
60938
60977
  };
60939
60978
  }
60940
- function structuredErr(error51) {
60941
- const payload = error51.violations ? { code: error51.code, message: error51.message, violations: error51.violations } : { code: error51.code, message: error51.message };
60942
- return {
60943
- content: [{ text: JSON.stringify({ error: payload }, null, 2), type: "text" }],
60944
- isError: true,
60945
- structuredContent: { error: error51 }
60946
- };
60947
- }
60979
+ var structuredErr = buildToolError;
60948
60980
  function classifyClientError(fallbackCode, fallbackMessage, raw) {
60949
60981
  if (raw instanceof MrrlinApiError) {
60950
60982
  return {
@@ -64019,7 +64051,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
64019
64051
  }
64020
64052
 
64021
64053
  // src/_generated/version.ts
64022
- var PKG_VERSION = "0.4.153";
64054
+ var PKG_VERSION = "0.4.155";
64023
64055
 
64024
64056
  // src/bridge-allowed-origins.ts
64025
64057
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -75675,17 +75707,31 @@ function reauthorizeRedirect(params) {
75675
75707
 
75676
75708
  // src/verification-broker.ts
75677
75709
  var TEST_CONNECT_OVERRIDE_SYMBOL = Symbol.for("mrrlin.test.connectOverride");
75710
+ var MAX_UNIX_SOCKET_PATH_BYTES = 103;
75711
+ function createBrokerSocketPath(runId, nonce, baseDirs = process.platform === "win32" ? [import_node_os19.default.tmpdir()] : [import_node_os19.default.tmpdir(), "/tmp"]) {
75712
+ const fileName = `b-${runId.replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 24)}-${nonce.slice(0, 16)}.sock`;
75713
+ for (const base of baseDirs) {
75714
+ let dir;
75715
+ try {
75716
+ dir = import_node_fs26.default.mkdtempSync(import_node_path39.default.join(base, "mrrlin-b-"));
75717
+ } catch {
75718
+ continue;
75719
+ }
75720
+ const socketPath = import_node_path39.default.join(dir, fileName);
75721
+ if (process.platform === "win32" || Buffer.byteLength(socketPath) <= MAX_UNIX_SOCKET_PATH_BYTES) {
75722
+ import_node_fs26.default.chmodSync(dir, 448);
75723
+ return { dir, socketPath };
75724
+ }
75725
+ import_node_fs26.default.rmSync(dir, { recursive: true, force: true });
75726
+ }
75727
+ throw new Error(`BROKER_SOCKET_ERROR: no temp directory gives a socket path within ${MAX_UNIX_SOCKET_PATH_BYTES} bytes`);
75728
+ }
75678
75729
  async function createVerificationBrokerSession(options) {
75679
75730
  const nonce = import_node_crypto22.default.randomBytes(16).toString("hex");
75680
75731
  let createdDir = null;
75681
75732
  let socketPath = options.socketPath;
75682
75733
  if (!socketPath) {
75683
- createdDir = import_node_fs26.default.mkdtempSync(import_node_path39.default.join(import_node_os19.default.tmpdir(), "mrrlin-broker-"));
75684
- import_node_fs26.default.chmodSync(createdDir, 448);
75685
- socketPath = import_node_path39.default.join(
75686
- createdDir,
75687
- `broker-${options.runId.replace(/[^a-zA-Z0-9_-]/g, "")}-${nonce}.sock`
75688
- );
75734
+ ({ dir: createdDir, socketPath } = createBrokerSocketPath(options.runId, nonce));
75689
75735
  }
75690
75736
  try {
75691
75737
  if (import_node_fs26.default.existsSync(socketPath)) {
@@ -81376,6 +81422,526 @@ var StdioServerTransport = class {
81376
81422
  }
81377
81423
  };
81378
81424
 
81425
+ // src/tool-registry.ts
81426
+ var toolRegistry = {
81427
+ // Read operations (22 tools): RO=true, D=false, ID=true, OW=false
81428
+ [mcpToolNames.getProject]: {
81429
+ name: mcpToolNames.getProject,
81430
+ operationClass: "read",
81431
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81432
+ rationale: "Reads project configuration and state.",
81433
+ compensation: null
81434
+ },
81435
+ [mcpToolNames.getProjectSnapshot]: {
81436
+ name: mcpToolNames.getProjectSnapshot,
81437
+ operationClass: "read",
81438
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81439
+ rationale: "Reads the complete project snapshot.",
81440
+ compensation: null
81441
+ },
81442
+ [mcpToolNames.listProjects]: {
81443
+ name: mcpToolNames.listProjects,
81444
+ operationClass: "read",
81445
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81446
+ rationale: "Lists all accessible projects.",
81447
+ compensation: null
81448
+ },
81449
+ [mcpToolNames.getTask]: {
81450
+ name: mcpToolNames.getTask,
81451
+ operationClass: "read",
81452
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81453
+ rationale: "Reads a task record by ID.",
81454
+ compensation: null
81455
+ },
81456
+ [mcpToolNames.listTasks]: {
81457
+ name: mcpToolNames.listTasks,
81458
+ operationClass: "read",
81459
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81460
+ rationale: "Lists tasks matching query filters.",
81461
+ compensation: null
81462
+ },
81463
+ [mcpToolNames.listPlans]: {
81464
+ name: mcpToolNames.listPlans,
81465
+ operationClass: "read",
81466
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81467
+ rationale: "Lists project plans.",
81468
+ compensation: null
81469
+ },
81470
+ [mcpToolNames.listTaskDependencies]: {
81471
+ name: mcpToolNames.listTaskDependencies,
81472
+ operationClass: "read",
81473
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81474
+ rationale: "Reads task dependency relationships.",
81475
+ compensation: null
81476
+ },
81477
+ [mcpToolNames.listTaskEvents]: {
81478
+ name: mcpToolNames.listTaskEvents,
81479
+ operationClass: "read",
81480
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81481
+ rationale: "Reads task audit and lifecycle events.",
81482
+ compensation: null
81483
+ },
81484
+ [mcpToolNames.listTaxonomy]: {
81485
+ name: mcpToolNames.listTaxonomy,
81486
+ operationClass: "read",
81487
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81488
+ rationale: "Reads project taxonomy categories and tags.",
81489
+ compensation: null
81490
+ },
81491
+ [mcpToolNames.listProjectMembers]: {
81492
+ name: mcpToolNames.listProjectMembers,
81493
+ operationClass: "read",
81494
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81495
+ rationale: "Lists members and roles in the project.",
81496
+ compensation: null
81497
+ },
81498
+ [mcpToolNames.getWikiPage]: {
81499
+ name: mcpToolNames.getWikiPage,
81500
+ operationClass: "read",
81501
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81502
+ rationale: "Reads a wiki documentation page.",
81503
+ compensation: null
81504
+ },
81505
+ [mcpToolNames.listWikiPages]: {
81506
+ name: mcpToolNames.listWikiPages,
81507
+ operationClass: "read",
81508
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81509
+ rationale: "Lists wiki pages in the project.",
81510
+ compensation: null
81511
+ },
81512
+ [mcpToolNames.searchWikiPages]: {
81513
+ name: mcpToolNames.searchWikiPages,
81514
+ operationClass: "read",
81515
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81516
+ rationale: "Performs full-text search across wiki pages.",
81517
+ compensation: null
81518
+ },
81519
+ [mcpToolNames.searchKnowledge]: {
81520
+ name: mcpToolNames.searchKnowledge,
81521
+ operationClass: "read",
81522
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81523
+ rationale: "Searches external and indexed project knowledge.",
81524
+ compensation: null
81525
+ },
81526
+ [mcpToolNames.getExecutionRun]: {
81527
+ name: mcpToolNames.getExecutionRun,
81528
+ operationClass: "read",
81529
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81530
+ rationale: "Reads execution run details and status.",
81531
+ compensation: null
81532
+ },
81533
+ [mcpToolNames.listExecutionRuns]: {
81534
+ name: mcpToolNames.listExecutionRuns,
81535
+ operationClass: "read",
81536
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81537
+ rationale: "Lists execution runs for tasks.",
81538
+ compensation: null
81539
+ },
81540
+ [mcpToolNames.listExecutionArtifacts]: {
81541
+ name: mcpToolNames.listExecutionArtifacts,
81542
+ operationClass: "read",
81543
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81544
+ rationale: "Lists artifacts attached to execution runs.",
81545
+ compensation: null
81546
+ },
81547
+ [mcpToolNames.getProjectSchedulerPolicy]: {
81548
+ name: mcpToolNames.getProjectSchedulerPolicy,
81549
+ operationClass: "read",
81550
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81551
+ rationale: "Reads scheduler concurrency and execution policy.",
81552
+ compensation: null
81553
+ },
81554
+ [mcpToolNames.getSchedulerPendingTasks]: {
81555
+ name: mcpToolNames.getSchedulerPendingTasks,
81556
+ operationClass: "read",
81557
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81558
+ rationale: "Reads runnable tasks pending execution.",
81559
+ compensation: null
81560
+ },
81561
+ [mcpToolNames.listInboxItems]: {
81562
+ name: mcpToolNames.listInboxItems,
81563
+ operationClass: "read",
81564
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81565
+ rationale: "Lists operator inbox items and approval proposals.",
81566
+ compensation: null
81567
+ },
81568
+ [mcpToolNames.listArtifactFiles]: {
81569
+ name: mcpToolNames.listArtifactFiles,
81570
+ operationClass: "read",
81571
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81572
+ rationale: "Lists artifact files and metadata.",
81573
+ compensation: null
81574
+ },
81575
+ [mcpToolNames.retrieveContext]: {
81576
+ name: mcpToolNames.retrieveContext,
81577
+ operationClass: "read",
81578
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81579
+ rationale: "Rehydrates a compact mrrlin:// context handle into a full record.",
81580
+ compensation: null
81581
+ },
81582
+ // Reversible mutations (8 tools)
81583
+ [mcpToolNames.createPlan]: {
81584
+ name: mcpToolNames.createPlan,
81585
+ operationClass: "reversible_mutation",
81586
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81587
+ rationale: "Creates a new plan within the project.",
81588
+ compensation: "archive_plan"
81589
+ },
81590
+ [mcpToolNames.updatePlan]: {
81591
+ name: mcpToolNames.updatePlan,
81592
+ operationClass: "reversible_mutation",
81593
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81594
+ rationale: "Modifies plan title, status, or description.",
81595
+ compensation: "update_plan"
81596
+ },
81597
+ [mcpToolNames.archivePlan]: {
81598
+ name: mcpToolNames.archivePlan,
81599
+ operationClass: "reversible_mutation",
81600
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81601
+ rationale: "Soft-deletes or archives an existing plan.",
81602
+ compensation: "update_plan"
81603
+ },
81604
+ [mcpToolNames.createTaxonomyEntry]: {
81605
+ name: mcpToolNames.createTaxonomyEntry,
81606
+ operationClass: "reversible_mutation",
81607
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81608
+ rationale: "Adds a category or tag to project taxonomy.",
81609
+ compensation: "delete_taxonomy_entry"
81610
+ },
81611
+ [mcpToolNames.renameTaxonomyEntry]: {
81612
+ name: mcpToolNames.renameTaxonomyEntry,
81613
+ operationClass: "reversible_mutation",
81614
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81615
+ rationale: "Renames an existing taxonomy tag or category.",
81616
+ compensation: "rename_taxonomy_entry"
81617
+ },
81618
+ [mcpToolNames.deleteTaxonomyEntry]: {
81619
+ name: mcpToolNames.deleteTaxonomyEntry,
81620
+ operationClass: "reversible_mutation",
81621
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81622
+ rationale: "Removes a category or tag from project taxonomy.",
81623
+ compensation: "create_taxonomy_entry"
81624
+ },
81625
+ [mcpToolNames.createTaskDependency]: {
81626
+ name: mcpToolNames.createTaskDependency,
81627
+ operationClass: "reversible_mutation",
81628
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81629
+ rationale: "Creates a dependency relationship between tasks.",
81630
+ compensation: "delete_task_dependency"
81631
+ },
81632
+ [mcpToolNames.registerLocalCheckout]: {
81633
+ name: mcpToolNames.registerLocalCheckout,
81634
+ operationClass: "reversible_mutation",
81635
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81636
+ rationale: "Registers or updates a local working tree checkout for the project.",
81637
+ compensation: null
81638
+ },
81639
+ // Irreversible mutations (36 tools)
81640
+ [mcpToolNames.createTask]: {
81641
+ name: mcpToolNames.createTask,
81642
+ operationClass: "irreversible_mutation",
81643
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81644
+ rationale: "Creates a new task in the project.",
81645
+ compensation: "archive_task"
81646
+ },
81647
+ [mcpToolNames.proposeTask]: {
81648
+ name: mcpToolNames.proposeTask,
81649
+ operationClass: "irreversible_mutation",
81650
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81651
+ rationale: "Creates an uncommitted proposal or inbox proposal for a task.",
81652
+ compensation: null
81653
+ },
81654
+ [mcpToolNames.updateTask]: {
81655
+ name: mcpToolNames.updateTask,
81656
+ operationClass: "irreversible_mutation",
81657
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81658
+ rationale: "Updates mutable task fields, status, or priority.",
81659
+ compensation: null
81660
+ },
81661
+ [mcpToolNames.archiveTask]: {
81662
+ name: mcpToolNames.archiveTask,
81663
+ operationClass: "irreversible_mutation",
81664
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81665
+ rationale: "Archives a task and cascades dependent state.",
81666
+ compensation: "unarchive_task"
81667
+ },
81668
+ [mcpToolNames.unarchiveTask]: {
81669
+ name: mcpToolNames.unarchiveTask,
81670
+ operationClass: "irreversible_mutation",
81671
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81672
+ rationale: "Restores an archived task without undoing cascaded execution state.",
81673
+ compensation: "archive_task"
81674
+ },
81675
+ [mcpToolNames.takeOverTask]: {
81676
+ name: mcpToolNames.takeOverTask,
81677
+ operationClass: "irreversible_mutation",
81678
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81679
+ rationale: "Reassigns task execution or claims exclusive worker ownership.",
81680
+ compensation: null
81681
+ },
81682
+ [mcpToolNames.closeTaskAsWontDo]: {
81683
+ name: mcpToolNames.closeTaskAsWontDo,
81684
+ operationClass: "irreversible_mutation",
81685
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81686
+ rationale: "Creates an operator approval question proposing to close task as wont-do.",
81687
+ compensation: null
81688
+ },
81689
+ [mcpToolNames.resetDirectorThread]: {
81690
+ name: mcpToolNames.resetDirectorThread,
81691
+ operationClass: "irreversible_mutation",
81692
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81693
+ rationale: "Resets the active director conversation thread and session state.",
81694
+ compensation: null
81695
+ },
81696
+ [mcpToolNames.deleteTaskDependency]: {
81697
+ name: mcpToolNames.deleteTaskDependency,
81698
+ operationClass: "irreversible_mutation",
81699
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81700
+ rationale: "Removes an existing dependency edge between tasks.",
81701
+ compensation: "create_task_dependency"
81702
+ },
81703
+ [mcpToolNames.appendTaskEvent]: {
81704
+ name: mcpToolNames.appendTaskEvent,
81705
+ operationClass: "irreversible_mutation",
81706
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81707
+ rationale: "Appends an immutable audit event to the task event stream.",
81708
+ compensation: null
81709
+ },
81710
+ [mcpToolNames.addProjectMember]: {
81711
+ name: mcpToolNames.addProjectMember,
81712
+ operationClass: "irreversible_mutation",
81713
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81714
+ rationale: "Grants project access and assigns a member role.",
81715
+ compensation: "remove_project_member"
81716
+ },
81717
+ [mcpToolNames.removeProjectMember]: {
81718
+ name: mcpToolNames.removeProjectMember,
81719
+ operationClass: "irreversible_mutation",
81720
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81721
+ rationale: "Revokes project access for an existing member.",
81722
+ compensation: "add_project_member"
81723
+ },
81724
+ [mcpToolNames.createWikiPage]: {
81725
+ name: mcpToolNames.createWikiPage,
81726
+ operationClass: "irreversible_mutation",
81727
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81728
+ rationale: "Creates a new wiki documentation or specification page.",
81729
+ compensation: null
81730
+ },
81731
+ [mcpToolNames.updateWikiPage]: {
81732
+ name: mcpToolNames.updateWikiPage,
81733
+ operationClass: "irreversible_mutation",
81734
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81735
+ rationale: "Overwrites or edits existing wiki page content and revision.",
81736
+ compensation: null
81737
+ },
81738
+ [mcpToolNames.markSpecReady]: {
81739
+ name: mcpToolNames.markSpecReady,
81740
+ operationClass: "irreversible_mutation",
81741
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81742
+ rationale: "Transitions a task specification to ready status, enabling downstream execution.",
81743
+ compensation: null
81744
+ },
81745
+ [mcpToolNames.runSpecConsensus]: {
81746
+ name: mcpToolNames.runSpecConsensus,
81747
+ operationClass: "irreversible_mutation",
81748
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81749
+ rationale: "Dispatches specification consensus review across arbiter agents.",
81750
+ compensation: null
81751
+ },
81752
+ [mcpToolNames.runCodeReviewerGate]: {
81753
+ name: mcpToolNames.runCodeReviewerGate,
81754
+ operationClass: "irreversible_mutation",
81755
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81756
+ rationale: "Dispatches code review gate inspection for an execution run or PR.",
81757
+ compensation: null
81758
+ },
81759
+ [mcpToolNames.runDecisionConsensus]: {
81760
+ name: mcpToolNames.runDecisionConsensus,
81761
+ operationClass: "irreversible_mutation",
81762
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
81763
+ rationale: "Executes multi-model consensus round consuming external model tokens.",
81764
+ compensation: null
81765
+ },
81766
+ [mcpToolNames.createExecutionRun]: {
81767
+ name: mcpToolNames.createExecutionRun,
81768
+ operationClass: "irreversible_mutation",
81769
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81770
+ rationale: "Spawns a new execution run with allocated runtime environment.",
81771
+ compensation: null
81772
+ },
81773
+ [mcpToolNames.updateExecutionRun]: {
81774
+ name: mcpToolNames.updateExecutionRun,
81775
+ operationClass: "irreversible_mutation",
81776
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81777
+ rationale: "Updates execution run status, heartbeat, or completion metrics.",
81778
+ compensation: null
81779
+ },
81780
+ [mcpToolNames.appendExecutionArtifact]: {
81781
+ name: mcpToolNames.appendExecutionArtifact,
81782
+ operationClass: "irreversible_mutation",
81783
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81784
+ rationale: "Appends behaviorally significant artifact or log to execution run.",
81785
+ compensation: null
81786
+ },
81787
+ [mcpToolNames.recordProducedUrl]: {
81788
+ name: mcpToolNames.recordProducedUrl,
81789
+ operationClass: "irreversible_mutation",
81790
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81791
+ rationale: "Records a verified deployment or preview URL for a run.",
81792
+ compensation: null
81793
+ },
81794
+ [mcpToolNames.updateTaskState]: {
81795
+ name: mcpToolNames.updateTaskState,
81796
+ operationClass: "irreversible_mutation",
81797
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81798
+ rationale: "Applies director internal state updates to the task.",
81799
+ compensation: null
81800
+ },
81801
+ [mcpToolNames.reclaimExecutionRunLease]: {
81802
+ name: mcpToolNames.reclaimExecutionRunLease,
81803
+ operationClass: "irreversible_mutation",
81804
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81805
+ rationale: "Reclaims an expired execution lease from an inactive runner.",
81806
+ compensation: null
81807
+ },
81808
+ [mcpToolNames.restartExecutionRun]: {
81809
+ name: mcpToolNames.restartExecutionRun,
81810
+ operationClass: "irreversible_mutation",
81811
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81812
+ rationale: "Restarts an interrupted or failed execution run.",
81813
+ compensation: null
81814
+ },
81815
+ [mcpToolNames.stopExecutionRun]: {
81816
+ name: mcpToolNames.stopExecutionRun,
81817
+ operationClass: "irreversible_mutation",
81818
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81819
+ rationale: "Signals immediate cancellation and termination of an active run.",
81820
+ compensation: null
81821
+ },
81822
+ [mcpToolNames.resolveHandoff]: {
81823
+ name: mcpToolNames.resolveHandoff,
81824
+ operationClass: "irreversible_mutation",
81825
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81826
+ rationale: "Resolves or responds to an inter-agent handoff proposal.",
81827
+ compensation: null
81828
+ },
81829
+ [mcpToolNames.upsertProjectSchedulerPolicy]: {
81830
+ name: mcpToolNames.upsertProjectSchedulerPolicy,
81831
+ operationClass: "irreversible_mutation",
81832
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81833
+ rationale: "Updates project task concurrency and execution scheduling limits.",
81834
+ compensation: null
81835
+ },
81836
+ [mcpToolNames.wakeDirector]: {
81837
+ name: mcpToolNames.wakeDirector,
81838
+ operationClass: "irreversible_mutation",
81839
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81840
+ rationale: "Dispatches a wake notification to the project director service.",
81841
+ compensation: null
81842
+ },
81843
+ [mcpToolNames.createInboxItem]: {
81844
+ name: mcpToolNames.createInboxItem,
81845
+ operationClass: "irreversible_mutation",
81846
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81847
+ rationale: "Creates a new operator inbox notification, question, or approval proposal.",
81848
+ compensation: null
81849
+ },
81850
+ [mcpToolNames.decideInboxItem]: {
81851
+ name: mcpToolNames.decideInboxItem,
81852
+ operationClass: "irreversible_mutation",
81853
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81854
+ rationale: "Records an operator decision on an inbox item, triggering gated side effects.",
81855
+ compensation: null
81856
+ },
81857
+ [mcpToolNames.uploadArtifact]: {
81858
+ name: mcpToolNames.uploadArtifact,
81859
+ operationClass: "irreversible_mutation",
81860
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81861
+ rationale: "Uploads an artifact payload to storage.",
81862
+ compensation: null
81863
+ },
81864
+ [mcpToolNames.deliverFile]: {
81865
+ name: mcpToolNames.deliverFile,
81866
+ operationClass: "irreversible_mutation",
81867
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81868
+ rationale: "Delivers an artifact file via configured capability transport.",
81869
+ compensation: null
81870
+ },
81871
+ [mcpToolNames.initLocalRepo]: {
81872
+ name: mcpToolNames.initLocalRepo,
81873
+ operationClass: "irreversible_mutation",
81874
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81875
+ rationale: "Initializes a local git repository checkout with operator consent.",
81876
+ compensation: null
81877
+ },
81878
+ [mcpToolNames.setProjectCodeHost]: {
81879
+ name: mcpToolNames.setProjectCodeHost,
81880
+ operationClass: "irreversible_mutation",
81881
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81882
+ rationale: "Configures the external repository hosting provider and credentials.",
81883
+ compensation: null
81884
+ },
81885
+ [mcpToolNames.applyLocalRun]: {
81886
+ name: mcpToolNames.applyLocalRun,
81887
+ operationClass: "irreversible_mutation",
81888
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81889
+ rationale: "Lands completed run changes onto the default branch checkout.",
81890
+ compensation: null
81891
+ }
81892
+ };
81893
+ function assertToolContractCoverage(publicNames, registry3, schemaMap, toolMap) {
81894
+ const publicNamesSet = /* @__PURE__ */ new Set();
81895
+ const duplicates = [];
81896
+ for (const name of publicNames) {
81897
+ if (publicNamesSet.has(name)) {
81898
+ duplicates.push(name);
81899
+ }
81900
+ publicNamesSet.add(name);
81901
+ }
81902
+ if (duplicates.length > 0) {
81903
+ throw new Error(`Duplicate public tool wire names detected: ${duplicates.sort().join(", ")}`);
81904
+ }
81905
+ const registryKeys = Object.keys(registry3);
81906
+ const schemaKeys = Object.keys(schemaMap);
81907
+ const toolKeys = Object.keys(toolMap);
81908
+ const registrySet = new Set(registryKeys);
81909
+ const schemaSet = new Set(schemaKeys);
81910
+ const toolSet = new Set(toolKeys);
81911
+ const allNames = Array.from(/* @__PURE__ */ new Set([...publicNames, ...registryKeys, ...schemaKeys, ...toolKeys])).sort();
81912
+ const missingFromPublic = allNames.filter((n) => !publicNamesSet.has(n));
81913
+ const missingFromRegistry = allNames.filter((n) => !registrySet.has(n));
81914
+ const missingFromSchemas = allNames.filter((n) => !schemaSet.has(n));
81915
+ const missingFromTools = allNames.filter((n) => !toolSet.has(n));
81916
+ if (missingFromRegistry.length > 0 || missingFromSchemas.length > 0 || missingFromTools.length > 0 || missingFromPublic.length > 0) {
81917
+ const details = [
81918
+ missingFromPublic.length ? `missing from public names: [${missingFromPublic.join(", ")}]` : null,
81919
+ missingFromRegistry.length ? `missing from registry: [${missingFromRegistry.join(", ")}]` : null,
81920
+ missingFromSchemas.length ? `missing from schemas: [${missingFromSchemas.join(", ")}]` : null,
81921
+ missingFromTools.length ? `missing from tool map: [${missingFromTools.join(", ")}]` : null
81922
+ ].filter(Boolean).join("; ");
81923
+ throw new Error(`Tool contract inventory mismatch: ${details}`);
81924
+ }
81925
+ const mismatchedToolNames = [];
81926
+ for (const [key, tool] of Object.entries(toolMap)) {
81927
+ if (tool.name !== key) {
81928
+ mismatchedToolNames.push(`key '${key}' !== tool.name '${tool.name}'`);
81929
+ }
81930
+ }
81931
+ if (mismatchedToolNames.length > 0) {
81932
+ throw new Error(`Instantiated tool name mismatch: ${mismatchedToolNames.sort().join(", ")}`);
81933
+ }
81934
+ const mismatchedSchemas = [];
81935
+ for (const [key, tool] of Object.entries(toolMap)) {
81936
+ if (tool.inputSchema !== schemaMap[key]) {
81937
+ mismatchedSchemas.push(key);
81938
+ }
81939
+ }
81940
+ if (mismatchedSchemas.length > 0) {
81941
+ throw new Error(`Instantiated tool inputSchema mismatch: ${mismatchedSchemas.sort().join(", ")}`);
81942
+ }
81943
+ }
81944
+
81379
81945
  // src/server.ts
81380
81946
  function redactUrlForLog(value) {
81381
81947
  try {
@@ -81477,12 +82043,19 @@ function zodInputToJsonSchema(schema) {
81477
82043
  function createMrrlinMcpServer(options = {}) {
81478
82044
  const resolved = resolveServerOptions(options);
81479
82045
  const tools = createMrrlinTools(resolved);
82046
+ assertToolContractCoverage(
82047
+ Object.values(mcpToolNames),
82048
+ toolRegistry,
82049
+ mcpToolInputSchemas,
82050
+ tools
82051
+ );
81480
82052
  const server = new Server(
81481
82053
  { name: options.name ?? "@mrrlin-dev/mcp", version: options.version ?? "0.1.0" },
81482
82054
  { capabilities: { tools: {} } }
81483
82055
  );
81484
82056
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
81485
82057
  tools: Object.values(tools).map((tool) => ({
82058
+ annotations: toolRegistry[tool.name].annotations,
81486
82059
  description: tool.description,
81487
82060
  inputSchema: zodInputToJsonSchema(tool.inputSchema),
81488
82061
  name: tool.name
@@ -81491,24 +82064,19 @@ function createMrrlinMcpServer(options = {}) {
81491
82064
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
81492
82065
  const name = request.params.name;
81493
82066
  const tool = tools[name];
81494
- if (!tool) {
81495
- return {
81496
- content: [{ text: JSON.stringify({ error: { code: "UNKNOWN_TOOL", message: `Unknown MCP tool: ${name}` } }), type: "text" }],
81497
- isError: true
81498
- };
82067
+ if (!Object.prototype.hasOwnProperty.call(tools, name) || !tool) {
82068
+ return buildToolError({
82069
+ code: "UNKNOWN_TOOL",
82070
+ message: `Unknown MCP tool: ${name}`
82071
+ });
81499
82072
  }
81500
82073
  const schema = mcpToolInputSchemas[name];
81501
82074
  const parsed = schema.safeParse(request.params.arguments ?? {});
81502
82075
  if (!parsed.success) {
81503
- return {
81504
- content: [
81505
- {
81506
- text: JSON.stringify({ error: { code: "VALIDATION_FAILED", message: parsed.error.message } }),
81507
- type: "text"
81508
- }
81509
- ],
81510
- isError: true
81511
- };
82076
+ return buildToolError({
82077
+ code: "VALIDATION_FAILED",
82078
+ message: parsed.error.message
82079
+ });
81512
82080
  }
81513
82081
  return tool.invoke(parsed.data);
81514
82082
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.153",
3
+ "version": "0.4.155",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"