@mrrlin-dev/mcp 0.4.152 → 0.4.154

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 +633 -40
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -40362,8 +40362,16 @@ var mrrlinInboxItemActionPayloadSchema = external_exports.object({
40362
40362
  codeExecution: external_exports.boolean().optional(),
40363
40363
  // Optional scheduler recovery action carried by an info item.
40364
40364
  retryToolName: external_exports.string().min(1).optional(),
40365
- retryDedupKey: external_exports.string().min(1).optional()
40366
- });
40365
+ retryDedupKey: external_exports.string().min(1).optional(),
40366
+ capability: external_exports.string().optional(),
40367
+ capabilityPayload: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
40368
+ permitId: external_exports.string().optional(),
40369
+ scopeId: external_exports.string().optional(),
40370
+ serverId: external_exports.string().optional(),
40371
+ specRevision: external_exports.string().optional(),
40372
+ specWikiPageId: external_exports.string().optional(),
40373
+ toolName: external_exports.string().optional()
40374
+ }).passthrough();
40367
40375
  var mrrlinInboxQuestionOptionSchema = external_exports.object({
40368
40376
  answer: external_exports.string().trim().min(1),
40369
40377
  description: external_exports.string().trim().min(1),
@@ -40418,6 +40426,7 @@ var mrrlinInboxItemSchema = external_exports.object({
40418
40426
  id: mrrlinInboxItemIdSchema,
40419
40427
  kind: mrrlinInboxItemKindSchema,
40420
40428
  origin: external_exports.string().nullable().optional(),
40429
+ payloadDigest: external_exports.string().nullable().optional(),
40421
40430
  planId: mrrlinPlanIdSchema.nullable().default(null),
40422
40431
  projectSlug: mrrlinProjectSlugSchema,
40423
40432
  questionOptions: mrrlinInboxQuestionOptionsSchema.nullable().default(null),
@@ -40443,6 +40452,7 @@ var mrrlinInboxItemCreateSchema = external_exports.object({
40443
40452
  id: mrrlinInboxItemIdSchema,
40444
40453
  kind: mrrlinInboxItemKindSchema,
40445
40454
  origin: external_exports.string().min(1).optional(),
40455
+ payloadDigest: external_exports.string().min(1).nullable().optional(),
40446
40456
  planId: mrrlinPlanIdSchema.nullable().optional(),
40447
40457
  questionOptions: mrrlinInboxQuestionOptionsSchema.nullable().optional(),
40448
40458
  taskId: mrrlinTaskIdSchema.nullable().optional()
@@ -40458,6 +40468,7 @@ var mrrlinInboxItemCreateSchema = external_exports.object({
40458
40468
  var mrrlinInboxItemDecideSchema = external_exports.object({
40459
40469
  answer: external_exports.string().min(1).optional(),
40460
40470
  decidedBy: external_exports.string().min(1),
40471
+ expectedPayloadDigest: external_exports.string().min(1).optional(),
40461
40472
  reason: external_exports.string().min(1).optional(),
40462
40473
  verdict: external_exports.enum(["approved", "rejected", "acknowledged"])
40463
40474
  }).superRefine((value, context) => {
@@ -40481,6 +40492,7 @@ var mrrlinInboxItemSummarySchema = external_exports.object({
40481
40492
  id: mrrlinInboxItemIdSchema,
40482
40493
  kind: mrrlinInboxItemKindSchema,
40483
40494
  origin: external_exports.string().nullable().optional(),
40495
+ payloadDigest: external_exports.string().nullable().optional(),
40484
40496
  planId: mrrlinPlanIdSchema.nullable().default(null),
40485
40497
  projectSlug: mrrlinProjectSlugSchema,
40486
40498
  readAt: external_exports.string().datetime().nullable(),
@@ -40539,7 +40551,10 @@ var inboxItemsMarkReadResponseSchema = external_exports.object({
40539
40551
  readAt: external_exports.string().datetime()
40540
40552
  })
40541
40553
  });
40542
- var inboxItemResponseSchema = external_exports.object({ data: mrrlinInboxItemSchema });
40554
+ var inboxItemResponseSchema = external_exports.object({
40555
+ data: mrrlinInboxItemSchema,
40556
+ replayed: external_exports.boolean().optional()
40557
+ });
40543
40558
  var inboxItemListResponseSchema = external_exports.object({ data: external_exports.array(mrrlinInboxItemSchema) });
40544
40559
  var inboxItemSummaryListResponseSchema = external_exports.object({ data: external_exports.array(mrrlinInboxItemSummarySchema) });
40545
40560
  var capabilityServerIdSchema = external_exports.string().trim().min(1).max(200);
@@ -55061,7 +55076,7 @@ var RepoHostRouteUnavailableError = class extends Error {
55061
55076
  };
55062
55077
  var NoGrantForServerError = class extends RepoHostRouteUnavailableError {
55063
55078
  };
55064
- async function proceedToDestination(client, route, resolvedToolName, input) {
55079
+ async function proceedToDestination(client, route, resolvedToolName, input, approvalItemId, boundPermitId) {
55065
55080
  const taskless = !input.taskId;
55066
55081
  if (taskless && !MRRLIN_API_CAPABILITIES.has(route.capability)) {
55067
55082
  await recordUse(client, route, resolvedToolName, input, "refused");
@@ -55083,7 +55098,16 @@ async function proceedToDestination(client, route, resolvedToolName, input) {
55083
55098
  if (input.taskId && client.issueCapabilityPermit && client.redeemCapabilityPermit) {
55084
55099
  try {
55085
55100
  const payloadDigest = import_node_crypto5.default.createHash("sha256").update(JSON.stringify(input.payload ?? null)).digest("hex");
55086
- const permit = await client.issueCapabilityPermit(input.taskProjectSlug, {
55101
+ const targetInvocationId = approvalItemId ? `inv_${approvalItemId}` : void 0;
55102
+ let effectivePermitId = boundPermitId;
55103
+ if (!effectivePermitId && targetInvocationId && client.getCapabilityInvocation) {
55104
+ try {
55105
+ const existingInv = await client.getCapabilityInvocation(input.taskProjectSlug, targetInvocationId);
55106
+ if (existingInv) effectivePermitId = existingInv.permitId;
55107
+ } catch {
55108
+ }
55109
+ }
55110
+ const permitId = effectivePermitId ?? (await client.issueCapabilityPermit(input.taskProjectSlug, {
55087
55111
  projectSlug: input.taskProjectSlug,
55088
55112
  taskId: input.taskId,
55089
55113
  serverId: route.serverId,
@@ -55091,12 +55115,13 @@ async function proceedToDestination(client, route, resolvedToolName, input) {
55091
55115
  toolName: resolvedToolName,
55092
55116
  operationClass: resolveOperationClass(route, "reversible"),
55093
55117
  payloadDigest
55094
- });
55095
- const idempotencyKey = `deliver:${input.taskProjectSlug}:${permit.id}`;
55118
+ })).id;
55119
+ const idempotencyKey = approvalItemId ? `deliver:approval:${approvalItemId}` : `deliver:${input.taskProjectSlug}:${permitId}`;
55096
55120
  const redemption = await client.redeemCapabilityPermit(input.taskProjectSlug, {
55097
- permitId: permit.id,
55121
+ permitId,
55098
55122
  idempotencyKey,
55099
- payloadDigest
55123
+ payloadDigest,
55124
+ invocationId: targetInvocationId
55100
55125
  });
55101
55126
  invocationId = redemption.id;
55102
55127
  if (redemption.replayed) {
@@ -55226,8 +55251,10 @@ async function handleApproval(client, route, resolvedToolName, input) {
55226
55251
  if (scopeId === null) {
55227
55252
  return refuse(client, route, resolvedToolName, input);
55228
55253
  }
55229
- const groupId = `capability:approval:${scopeId}:${route.serverId}:${resolvedToolName}`;
55230
- const id = `II-capability-approval-${scopeId}-${route.serverId}-${resolvedToolName}`;
55254
+ const payloadDigest = import_node_crypto5.default.createHash("sha256").update(JSON.stringify(input.payload ?? null)).digest("hex");
55255
+ const digestPrefix = payloadDigest.slice(0, 16);
55256
+ const groupId = `capability:approval:${scopeId}:${route.serverId}:${resolvedToolName}:${digestPrefix}`;
55257
+ const id = `II-capability-approval-${scopeId}-${route.serverId}-${resolvedToolName}-${digestPrefix}`;
55231
55258
  let items;
55232
55259
  try {
55233
55260
  items = await client.listInboxItems(input.taskProjectSlug, { groupId });
@@ -55239,26 +55266,56 @@ async function handleApproval(client, route, resolvedToolName, input) {
55239
55266
  try {
55240
55267
  await client.createInboxItem(input.taskProjectSlug, {
55241
55268
  id,
55242
- kind: "question",
55269
+ kind: "proposal",
55243
55270
  origin: "capability",
55244
55271
  groupId,
55245
- body: `Approve ${resolvedToolName} on ${route.serverId}?`,
55246
- taskId: input.taskId
55272
+ body: `Approve ${resolvedToolName} on ${route.serverId}?
55273
+
55274
+ Payload:
55275
+ \`\`\`json
55276
+ ${JSON.stringify(input.payload ?? {}, null, 2)}
55277
+ \`\`\``,
55278
+ taskId: input.taskId,
55279
+ payloadDigest,
55280
+ actionPayload: {
55281
+ actor: "agent",
55282
+ provider: "mcp",
55283
+ runId: input.runId ?? (input.taskId ? `ER-${input.taskId}` : "ER-CAP-APPROVAL"),
55284
+ codeExecution: false,
55285
+ capabilityPayload: input.payload ?? {},
55286
+ serverId: route.serverId,
55287
+ toolName: resolvedToolName,
55288
+ scopeId,
55289
+ capability: route.capability
55290
+ }
55247
55291
  });
55248
55292
  } catch {
55249
55293
  }
55250
55294
  return refuse(client, route, resolvedToolName, input);
55251
55295
  }
55252
- if (existing.status !== "approved") {
55296
+ if (!existing.payloadDigest || existing.payloadDigest !== payloadDigest) {
55297
+ return refuse(client, route, resolvedToolName, input);
55298
+ }
55299
+ const isApproved = existing.status === "approved";
55300
+ if (!isApproved) {
55253
55301
  return refuse(client, route, resolvedToolName, input);
55254
55302
  }
55255
55303
  if (existing.decidedAt === null) {
55256
55304
  return refuse(client, route, resolvedToolName, input);
55257
55305
  }
55258
- if (await alreadyConsumed(client, route, resolvedToolName, input, existing.decidedAt)) {
55306
+ const invocationId = `inv_${existing.id}`;
55307
+ let existingInv = null;
55308
+ if (client.getCapabilityInvocation) {
55309
+ try {
55310
+ existingInv = await client.getCapabilityInvocation(input.taskProjectSlug, invocationId);
55311
+ } catch {
55312
+ }
55313
+ }
55314
+ if (!existingInv && await alreadyConsumed(client, route, resolvedToolName, input, existing.decidedAt)) {
55259
55315
  return refuse(client, route, resolvedToolName, input);
55260
55316
  }
55261
- return proceedToDestination(client, route, resolvedToolName, input);
55317
+ const boundPermitId = existingInv?.permitId ?? existing.actionPayload?.permitId;
55318
+ return proceedToDestination(client, route, resolvedToolName, input, existing.id, boundPermitId);
55262
55319
  }
55263
55320
  async function handleWindow(client, route, resolvedToolName, input) {
55264
55321
  if (input.taskId === null) {
@@ -60483,6 +60540,27 @@ var COMPACT_OPT_IN = {
60483
60540
  [mcpToolNames.listTaskEvents]: "task-events"
60484
60541
  };
60485
60542
 
60543
+ // src/tool-error-envelope.ts
60544
+ function buildToolError(error51) {
60545
+ const payload = {
60546
+ error: {
60547
+ code: error51.code,
60548
+ message: error51.message,
60549
+ ...error51.violations !== void 0 ? { violations: error51.violations } : {}
60550
+ }
60551
+ };
60552
+ return {
60553
+ isError: true,
60554
+ content: [
60555
+ {
60556
+ type: "text",
60557
+ text: JSON.stringify(payload, null, 2)
60558
+ }
60559
+ ],
60560
+ structuredContent: payload
60561
+ };
60562
+ }
60563
+
60486
60564
  // src/tools.ts
60487
60565
  registerAsyncTool(consensusDescriptor);
60488
60566
  registerAsyncTool(deliverableConsensusDescriptor);
@@ -60880,14 +60958,7 @@ function structuredOk(value) {
60880
60958
  structuredContent: { data: value }
60881
60959
  };
60882
60960
  }
60883
- function structuredErr(error51) {
60884
- const payload = error51.violations ? { code: error51.code, message: error51.message, violations: error51.violations } : { code: error51.code, message: error51.message };
60885
- return {
60886
- content: [{ text: JSON.stringify({ error: payload }, null, 2), type: "text" }],
60887
- isError: true,
60888
- structuredContent: { error: error51 }
60889
- };
60890
- }
60961
+ var structuredErr = buildToolError;
60891
60962
  function classifyClientError(fallbackCode, fallbackMessage, raw) {
60892
60963
  if (raw instanceof MrrlinApiError) {
60893
60964
  return {
@@ -63962,7 +64033,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
63962
64033
  }
63963
64034
 
63964
64035
  // src/_generated/version.ts
63965
- var PKG_VERSION = "0.4.152";
64036
+ var PKG_VERSION = "0.4.154";
63966
64037
 
63967
64038
  // src/bridge-allowed-origins.ts
63968
64039
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -81319,6 +81390,526 @@ var StdioServerTransport = class {
81319
81390
  }
81320
81391
  };
81321
81392
 
81393
+ // src/tool-registry.ts
81394
+ var toolRegistry = {
81395
+ // Read operations (22 tools): RO=true, D=false, ID=true, OW=false
81396
+ [mcpToolNames.getProject]: {
81397
+ name: mcpToolNames.getProject,
81398
+ operationClass: "read",
81399
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81400
+ rationale: "Reads project configuration and state.",
81401
+ compensation: null
81402
+ },
81403
+ [mcpToolNames.getProjectSnapshot]: {
81404
+ name: mcpToolNames.getProjectSnapshot,
81405
+ operationClass: "read",
81406
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81407
+ rationale: "Reads the complete project snapshot.",
81408
+ compensation: null
81409
+ },
81410
+ [mcpToolNames.listProjects]: {
81411
+ name: mcpToolNames.listProjects,
81412
+ operationClass: "read",
81413
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81414
+ rationale: "Lists all accessible projects.",
81415
+ compensation: null
81416
+ },
81417
+ [mcpToolNames.getTask]: {
81418
+ name: mcpToolNames.getTask,
81419
+ operationClass: "read",
81420
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81421
+ rationale: "Reads a task record by ID.",
81422
+ compensation: null
81423
+ },
81424
+ [mcpToolNames.listTasks]: {
81425
+ name: mcpToolNames.listTasks,
81426
+ operationClass: "read",
81427
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81428
+ rationale: "Lists tasks matching query filters.",
81429
+ compensation: null
81430
+ },
81431
+ [mcpToolNames.listPlans]: {
81432
+ name: mcpToolNames.listPlans,
81433
+ operationClass: "read",
81434
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81435
+ rationale: "Lists project plans.",
81436
+ compensation: null
81437
+ },
81438
+ [mcpToolNames.listTaskDependencies]: {
81439
+ name: mcpToolNames.listTaskDependencies,
81440
+ operationClass: "read",
81441
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81442
+ rationale: "Reads task dependency relationships.",
81443
+ compensation: null
81444
+ },
81445
+ [mcpToolNames.listTaskEvents]: {
81446
+ name: mcpToolNames.listTaskEvents,
81447
+ operationClass: "read",
81448
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81449
+ rationale: "Reads task audit and lifecycle events.",
81450
+ compensation: null
81451
+ },
81452
+ [mcpToolNames.listTaxonomy]: {
81453
+ name: mcpToolNames.listTaxonomy,
81454
+ operationClass: "read",
81455
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81456
+ rationale: "Reads project taxonomy categories and tags.",
81457
+ compensation: null
81458
+ },
81459
+ [mcpToolNames.listProjectMembers]: {
81460
+ name: mcpToolNames.listProjectMembers,
81461
+ operationClass: "read",
81462
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81463
+ rationale: "Lists members and roles in the project.",
81464
+ compensation: null
81465
+ },
81466
+ [mcpToolNames.getWikiPage]: {
81467
+ name: mcpToolNames.getWikiPage,
81468
+ operationClass: "read",
81469
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81470
+ rationale: "Reads a wiki documentation page.",
81471
+ compensation: null
81472
+ },
81473
+ [mcpToolNames.listWikiPages]: {
81474
+ name: mcpToolNames.listWikiPages,
81475
+ operationClass: "read",
81476
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81477
+ rationale: "Lists wiki pages in the project.",
81478
+ compensation: null
81479
+ },
81480
+ [mcpToolNames.searchWikiPages]: {
81481
+ name: mcpToolNames.searchWikiPages,
81482
+ operationClass: "read",
81483
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81484
+ rationale: "Performs full-text search across wiki pages.",
81485
+ compensation: null
81486
+ },
81487
+ [mcpToolNames.searchKnowledge]: {
81488
+ name: mcpToolNames.searchKnowledge,
81489
+ operationClass: "read",
81490
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81491
+ rationale: "Searches external and indexed project knowledge.",
81492
+ compensation: null
81493
+ },
81494
+ [mcpToolNames.getExecutionRun]: {
81495
+ name: mcpToolNames.getExecutionRun,
81496
+ operationClass: "read",
81497
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81498
+ rationale: "Reads execution run details and status.",
81499
+ compensation: null
81500
+ },
81501
+ [mcpToolNames.listExecutionRuns]: {
81502
+ name: mcpToolNames.listExecutionRuns,
81503
+ operationClass: "read",
81504
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81505
+ rationale: "Lists execution runs for tasks.",
81506
+ compensation: null
81507
+ },
81508
+ [mcpToolNames.listExecutionArtifacts]: {
81509
+ name: mcpToolNames.listExecutionArtifacts,
81510
+ operationClass: "read",
81511
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81512
+ rationale: "Lists artifacts attached to execution runs.",
81513
+ compensation: null
81514
+ },
81515
+ [mcpToolNames.getProjectSchedulerPolicy]: {
81516
+ name: mcpToolNames.getProjectSchedulerPolicy,
81517
+ operationClass: "read",
81518
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81519
+ rationale: "Reads scheduler concurrency and execution policy.",
81520
+ compensation: null
81521
+ },
81522
+ [mcpToolNames.getSchedulerPendingTasks]: {
81523
+ name: mcpToolNames.getSchedulerPendingTasks,
81524
+ operationClass: "read",
81525
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81526
+ rationale: "Reads runnable tasks pending execution.",
81527
+ compensation: null
81528
+ },
81529
+ [mcpToolNames.listInboxItems]: {
81530
+ name: mcpToolNames.listInboxItems,
81531
+ operationClass: "read",
81532
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81533
+ rationale: "Lists operator inbox items and approval proposals.",
81534
+ compensation: null
81535
+ },
81536
+ [mcpToolNames.listArtifactFiles]: {
81537
+ name: mcpToolNames.listArtifactFiles,
81538
+ operationClass: "read",
81539
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81540
+ rationale: "Lists artifact files and metadata.",
81541
+ compensation: null
81542
+ },
81543
+ [mcpToolNames.retrieveContext]: {
81544
+ name: mcpToolNames.retrieveContext,
81545
+ operationClass: "read",
81546
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
81547
+ rationale: "Rehydrates a compact mrrlin:// context handle into a full record.",
81548
+ compensation: null
81549
+ },
81550
+ // Reversible mutations (8 tools)
81551
+ [mcpToolNames.createPlan]: {
81552
+ name: mcpToolNames.createPlan,
81553
+ operationClass: "reversible_mutation",
81554
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81555
+ rationale: "Creates a new plan within the project.",
81556
+ compensation: "archive_plan"
81557
+ },
81558
+ [mcpToolNames.updatePlan]: {
81559
+ name: mcpToolNames.updatePlan,
81560
+ operationClass: "reversible_mutation",
81561
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81562
+ rationale: "Modifies plan title, status, or description.",
81563
+ compensation: "update_plan"
81564
+ },
81565
+ [mcpToolNames.archivePlan]: {
81566
+ name: mcpToolNames.archivePlan,
81567
+ operationClass: "reversible_mutation",
81568
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81569
+ rationale: "Soft-deletes or archives an existing plan.",
81570
+ compensation: "update_plan"
81571
+ },
81572
+ [mcpToolNames.createTaxonomyEntry]: {
81573
+ name: mcpToolNames.createTaxonomyEntry,
81574
+ operationClass: "reversible_mutation",
81575
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81576
+ rationale: "Adds a category or tag to project taxonomy.",
81577
+ compensation: "delete_taxonomy_entry"
81578
+ },
81579
+ [mcpToolNames.renameTaxonomyEntry]: {
81580
+ name: mcpToolNames.renameTaxonomyEntry,
81581
+ operationClass: "reversible_mutation",
81582
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81583
+ rationale: "Renames an existing taxonomy tag or category.",
81584
+ compensation: "rename_taxonomy_entry"
81585
+ },
81586
+ [mcpToolNames.deleteTaxonomyEntry]: {
81587
+ name: mcpToolNames.deleteTaxonomyEntry,
81588
+ operationClass: "reversible_mutation",
81589
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81590
+ rationale: "Removes a category or tag from project taxonomy.",
81591
+ compensation: "create_taxonomy_entry"
81592
+ },
81593
+ [mcpToolNames.createTaskDependency]: {
81594
+ name: mcpToolNames.createTaskDependency,
81595
+ operationClass: "reversible_mutation",
81596
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81597
+ rationale: "Creates a dependency relationship between tasks.",
81598
+ compensation: "delete_task_dependency"
81599
+ },
81600
+ [mcpToolNames.registerLocalCheckout]: {
81601
+ name: mcpToolNames.registerLocalCheckout,
81602
+ operationClass: "reversible_mutation",
81603
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81604
+ rationale: "Registers or updates a local working tree checkout for the project.",
81605
+ compensation: null
81606
+ },
81607
+ // Irreversible mutations (36 tools)
81608
+ [mcpToolNames.createTask]: {
81609
+ name: mcpToolNames.createTask,
81610
+ operationClass: "irreversible_mutation",
81611
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81612
+ rationale: "Creates a new task in the project.",
81613
+ compensation: "archive_task"
81614
+ },
81615
+ [mcpToolNames.proposeTask]: {
81616
+ name: mcpToolNames.proposeTask,
81617
+ operationClass: "irreversible_mutation",
81618
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81619
+ rationale: "Creates an uncommitted proposal or inbox proposal for a task.",
81620
+ compensation: null
81621
+ },
81622
+ [mcpToolNames.updateTask]: {
81623
+ name: mcpToolNames.updateTask,
81624
+ operationClass: "irreversible_mutation",
81625
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81626
+ rationale: "Updates mutable task fields, status, or priority.",
81627
+ compensation: null
81628
+ },
81629
+ [mcpToolNames.archiveTask]: {
81630
+ name: mcpToolNames.archiveTask,
81631
+ operationClass: "irreversible_mutation",
81632
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81633
+ rationale: "Archives a task and cascades dependent state.",
81634
+ compensation: "unarchive_task"
81635
+ },
81636
+ [mcpToolNames.unarchiveTask]: {
81637
+ name: mcpToolNames.unarchiveTask,
81638
+ operationClass: "irreversible_mutation",
81639
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81640
+ rationale: "Restores an archived task without undoing cascaded execution state.",
81641
+ compensation: "archive_task"
81642
+ },
81643
+ [mcpToolNames.takeOverTask]: {
81644
+ name: mcpToolNames.takeOverTask,
81645
+ operationClass: "irreversible_mutation",
81646
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81647
+ rationale: "Reassigns task execution or claims exclusive worker ownership.",
81648
+ compensation: null
81649
+ },
81650
+ [mcpToolNames.closeTaskAsWontDo]: {
81651
+ name: mcpToolNames.closeTaskAsWontDo,
81652
+ operationClass: "irreversible_mutation",
81653
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81654
+ rationale: "Creates an operator approval question proposing to close task as wont-do.",
81655
+ compensation: null
81656
+ },
81657
+ [mcpToolNames.resetDirectorThread]: {
81658
+ name: mcpToolNames.resetDirectorThread,
81659
+ operationClass: "irreversible_mutation",
81660
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81661
+ rationale: "Resets the active director conversation thread and session state.",
81662
+ compensation: null
81663
+ },
81664
+ [mcpToolNames.deleteTaskDependency]: {
81665
+ name: mcpToolNames.deleteTaskDependency,
81666
+ operationClass: "irreversible_mutation",
81667
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81668
+ rationale: "Removes an existing dependency edge between tasks.",
81669
+ compensation: "create_task_dependency"
81670
+ },
81671
+ [mcpToolNames.appendTaskEvent]: {
81672
+ name: mcpToolNames.appendTaskEvent,
81673
+ operationClass: "irreversible_mutation",
81674
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81675
+ rationale: "Appends an immutable audit event to the task event stream.",
81676
+ compensation: null
81677
+ },
81678
+ [mcpToolNames.addProjectMember]: {
81679
+ name: mcpToolNames.addProjectMember,
81680
+ operationClass: "irreversible_mutation",
81681
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81682
+ rationale: "Grants project access and assigns a member role.",
81683
+ compensation: "remove_project_member"
81684
+ },
81685
+ [mcpToolNames.removeProjectMember]: {
81686
+ name: mcpToolNames.removeProjectMember,
81687
+ operationClass: "irreversible_mutation",
81688
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81689
+ rationale: "Revokes project access for an existing member.",
81690
+ compensation: "add_project_member"
81691
+ },
81692
+ [mcpToolNames.createWikiPage]: {
81693
+ name: mcpToolNames.createWikiPage,
81694
+ operationClass: "irreversible_mutation",
81695
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81696
+ rationale: "Creates a new wiki documentation or specification page.",
81697
+ compensation: null
81698
+ },
81699
+ [mcpToolNames.updateWikiPage]: {
81700
+ name: mcpToolNames.updateWikiPage,
81701
+ operationClass: "irreversible_mutation",
81702
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81703
+ rationale: "Overwrites or edits existing wiki page content and revision.",
81704
+ compensation: null
81705
+ },
81706
+ [mcpToolNames.markSpecReady]: {
81707
+ name: mcpToolNames.markSpecReady,
81708
+ operationClass: "irreversible_mutation",
81709
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81710
+ rationale: "Transitions a task specification to ready status, enabling downstream execution.",
81711
+ compensation: null
81712
+ },
81713
+ [mcpToolNames.runSpecConsensus]: {
81714
+ name: mcpToolNames.runSpecConsensus,
81715
+ operationClass: "irreversible_mutation",
81716
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81717
+ rationale: "Dispatches specification consensus review across arbiter agents.",
81718
+ compensation: null
81719
+ },
81720
+ [mcpToolNames.runCodeReviewerGate]: {
81721
+ name: mcpToolNames.runCodeReviewerGate,
81722
+ operationClass: "irreversible_mutation",
81723
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81724
+ rationale: "Dispatches code review gate inspection for an execution run or PR.",
81725
+ compensation: null
81726
+ },
81727
+ [mcpToolNames.runDecisionConsensus]: {
81728
+ name: mcpToolNames.runDecisionConsensus,
81729
+ operationClass: "irreversible_mutation",
81730
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
81731
+ rationale: "Executes multi-model consensus round consuming external model tokens.",
81732
+ compensation: null
81733
+ },
81734
+ [mcpToolNames.createExecutionRun]: {
81735
+ name: mcpToolNames.createExecutionRun,
81736
+ operationClass: "irreversible_mutation",
81737
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81738
+ rationale: "Spawns a new execution run with allocated runtime environment.",
81739
+ compensation: null
81740
+ },
81741
+ [mcpToolNames.updateExecutionRun]: {
81742
+ name: mcpToolNames.updateExecutionRun,
81743
+ operationClass: "irreversible_mutation",
81744
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81745
+ rationale: "Updates execution run status, heartbeat, or completion metrics.",
81746
+ compensation: null
81747
+ },
81748
+ [mcpToolNames.appendExecutionArtifact]: {
81749
+ name: mcpToolNames.appendExecutionArtifact,
81750
+ operationClass: "irreversible_mutation",
81751
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81752
+ rationale: "Appends behaviorally significant artifact or log to execution run.",
81753
+ compensation: null
81754
+ },
81755
+ [mcpToolNames.recordProducedUrl]: {
81756
+ name: mcpToolNames.recordProducedUrl,
81757
+ operationClass: "irreversible_mutation",
81758
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81759
+ rationale: "Records a verified deployment or preview URL for a run.",
81760
+ compensation: null
81761
+ },
81762
+ [mcpToolNames.updateTaskState]: {
81763
+ name: mcpToolNames.updateTaskState,
81764
+ operationClass: "irreversible_mutation",
81765
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
81766
+ rationale: "Applies director internal state updates to the task.",
81767
+ compensation: null
81768
+ },
81769
+ [mcpToolNames.reclaimExecutionRunLease]: {
81770
+ name: mcpToolNames.reclaimExecutionRunLease,
81771
+ operationClass: "irreversible_mutation",
81772
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81773
+ rationale: "Reclaims an expired execution lease from an inactive runner.",
81774
+ compensation: null
81775
+ },
81776
+ [mcpToolNames.restartExecutionRun]: {
81777
+ name: mcpToolNames.restartExecutionRun,
81778
+ operationClass: "irreversible_mutation",
81779
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81780
+ rationale: "Restarts an interrupted or failed execution run.",
81781
+ compensation: null
81782
+ },
81783
+ [mcpToolNames.stopExecutionRun]: {
81784
+ name: mcpToolNames.stopExecutionRun,
81785
+ operationClass: "irreversible_mutation",
81786
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81787
+ rationale: "Signals immediate cancellation and termination of an active run.",
81788
+ compensation: null
81789
+ },
81790
+ [mcpToolNames.resolveHandoff]: {
81791
+ name: mcpToolNames.resolveHandoff,
81792
+ operationClass: "irreversible_mutation",
81793
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81794
+ rationale: "Resolves or responds to an inter-agent handoff proposal.",
81795
+ compensation: null
81796
+ },
81797
+ [mcpToolNames.upsertProjectSchedulerPolicy]: {
81798
+ name: mcpToolNames.upsertProjectSchedulerPolicy,
81799
+ operationClass: "irreversible_mutation",
81800
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81801
+ rationale: "Updates project task concurrency and execution scheduling limits.",
81802
+ compensation: null
81803
+ },
81804
+ [mcpToolNames.wakeDirector]: {
81805
+ name: mcpToolNames.wakeDirector,
81806
+ operationClass: "irreversible_mutation",
81807
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81808
+ rationale: "Dispatches a wake notification to the project director service.",
81809
+ compensation: null
81810
+ },
81811
+ [mcpToolNames.createInboxItem]: {
81812
+ name: mcpToolNames.createInboxItem,
81813
+ operationClass: "irreversible_mutation",
81814
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
81815
+ rationale: "Creates a new operator inbox notification, question, or approval proposal.",
81816
+ compensation: null
81817
+ },
81818
+ [mcpToolNames.decideInboxItem]: {
81819
+ name: mcpToolNames.decideInboxItem,
81820
+ operationClass: "irreversible_mutation",
81821
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81822
+ rationale: "Records an operator decision on an inbox item, triggering gated side effects.",
81823
+ compensation: null
81824
+ },
81825
+ [mcpToolNames.uploadArtifact]: {
81826
+ name: mcpToolNames.uploadArtifact,
81827
+ operationClass: "irreversible_mutation",
81828
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81829
+ rationale: "Uploads an artifact payload to storage.",
81830
+ compensation: null
81831
+ },
81832
+ [mcpToolNames.deliverFile]: {
81833
+ name: mcpToolNames.deliverFile,
81834
+ operationClass: "irreversible_mutation",
81835
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81836
+ rationale: "Delivers an artifact file via configured capability transport.",
81837
+ compensation: null
81838
+ },
81839
+ [mcpToolNames.initLocalRepo]: {
81840
+ name: mcpToolNames.initLocalRepo,
81841
+ operationClass: "irreversible_mutation",
81842
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81843
+ rationale: "Initializes a local git repository checkout with operator consent.",
81844
+ compensation: null
81845
+ },
81846
+ [mcpToolNames.setProjectCodeHost]: {
81847
+ name: mcpToolNames.setProjectCodeHost,
81848
+ operationClass: "irreversible_mutation",
81849
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81850
+ rationale: "Configures the external repository hosting provider and credentials.",
81851
+ compensation: null
81852
+ },
81853
+ [mcpToolNames.applyLocalRun]: {
81854
+ name: mcpToolNames.applyLocalRun,
81855
+ operationClass: "irreversible_mutation",
81856
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
81857
+ rationale: "Lands completed run changes onto the default branch checkout.",
81858
+ compensation: null
81859
+ }
81860
+ };
81861
+ function assertToolContractCoverage(publicNames, registry3, schemaMap, toolMap) {
81862
+ const publicNamesSet = /* @__PURE__ */ new Set();
81863
+ const duplicates = [];
81864
+ for (const name of publicNames) {
81865
+ if (publicNamesSet.has(name)) {
81866
+ duplicates.push(name);
81867
+ }
81868
+ publicNamesSet.add(name);
81869
+ }
81870
+ if (duplicates.length > 0) {
81871
+ throw new Error(`Duplicate public tool wire names detected: ${duplicates.sort().join(", ")}`);
81872
+ }
81873
+ const registryKeys = Object.keys(registry3);
81874
+ const schemaKeys = Object.keys(schemaMap);
81875
+ const toolKeys = Object.keys(toolMap);
81876
+ const registrySet = new Set(registryKeys);
81877
+ const schemaSet = new Set(schemaKeys);
81878
+ const toolSet = new Set(toolKeys);
81879
+ const allNames = Array.from(/* @__PURE__ */ new Set([...publicNames, ...registryKeys, ...schemaKeys, ...toolKeys])).sort();
81880
+ const missingFromPublic = allNames.filter((n) => !publicNamesSet.has(n));
81881
+ const missingFromRegistry = allNames.filter((n) => !registrySet.has(n));
81882
+ const missingFromSchemas = allNames.filter((n) => !schemaSet.has(n));
81883
+ const missingFromTools = allNames.filter((n) => !toolSet.has(n));
81884
+ if (missingFromRegistry.length > 0 || missingFromSchemas.length > 0 || missingFromTools.length > 0 || missingFromPublic.length > 0) {
81885
+ const details = [
81886
+ missingFromPublic.length ? `missing from public names: [${missingFromPublic.join(", ")}]` : null,
81887
+ missingFromRegistry.length ? `missing from registry: [${missingFromRegistry.join(", ")}]` : null,
81888
+ missingFromSchemas.length ? `missing from schemas: [${missingFromSchemas.join(", ")}]` : null,
81889
+ missingFromTools.length ? `missing from tool map: [${missingFromTools.join(", ")}]` : null
81890
+ ].filter(Boolean).join("; ");
81891
+ throw new Error(`Tool contract inventory mismatch: ${details}`);
81892
+ }
81893
+ const mismatchedToolNames = [];
81894
+ for (const [key, tool] of Object.entries(toolMap)) {
81895
+ if (tool.name !== key) {
81896
+ mismatchedToolNames.push(`key '${key}' !== tool.name '${tool.name}'`);
81897
+ }
81898
+ }
81899
+ if (mismatchedToolNames.length > 0) {
81900
+ throw new Error(`Instantiated tool name mismatch: ${mismatchedToolNames.sort().join(", ")}`);
81901
+ }
81902
+ const mismatchedSchemas = [];
81903
+ for (const [key, tool] of Object.entries(toolMap)) {
81904
+ if (tool.inputSchema !== schemaMap[key]) {
81905
+ mismatchedSchemas.push(key);
81906
+ }
81907
+ }
81908
+ if (mismatchedSchemas.length > 0) {
81909
+ throw new Error(`Instantiated tool inputSchema mismatch: ${mismatchedSchemas.sort().join(", ")}`);
81910
+ }
81911
+ }
81912
+
81322
81913
  // src/server.ts
81323
81914
  function redactUrlForLog(value) {
81324
81915
  try {
@@ -81420,12 +82011,19 @@ function zodInputToJsonSchema(schema) {
81420
82011
  function createMrrlinMcpServer(options = {}) {
81421
82012
  const resolved = resolveServerOptions(options);
81422
82013
  const tools = createMrrlinTools(resolved);
82014
+ assertToolContractCoverage(
82015
+ Object.values(mcpToolNames),
82016
+ toolRegistry,
82017
+ mcpToolInputSchemas,
82018
+ tools
82019
+ );
81423
82020
  const server = new Server(
81424
82021
  { name: options.name ?? "@mrrlin-dev/mcp", version: options.version ?? "0.1.0" },
81425
82022
  { capabilities: { tools: {} } }
81426
82023
  );
81427
82024
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
81428
82025
  tools: Object.values(tools).map((tool) => ({
82026
+ annotations: toolRegistry[tool.name].annotations,
81429
82027
  description: tool.description,
81430
82028
  inputSchema: zodInputToJsonSchema(tool.inputSchema),
81431
82029
  name: tool.name
@@ -81434,24 +82032,19 @@ function createMrrlinMcpServer(options = {}) {
81434
82032
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
81435
82033
  const name = request.params.name;
81436
82034
  const tool = tools[name];
81437
- if (!tool) {
81438
- return {
81439
- content: [{ text: JSON.stringify({ error: { code: "UNKNOWN_TOOL", message: `Unknown MCP tool: ${name}` } }), type: "text" }],
81440
- isError: true
81441
- };
82035
+ if (!Object.prototype.hasOwnProperty.call(tools, name) || !tool) {
82036
+ return buildToolError({
82037
+ code: "UNKNOWN_TOOL",
82038
+ message: `Unknown MCP tool: ${name}`
82039
+ });
81442
82040
  }
81443
82041
  const schema = mcpToolInputSchemas[name];
81444
82042
  const parsed = schema.safeParse(request.params.arguments ?? {});
81445
82043
  if (!parsed.success) {
81446
- return {
81447
- content: [
81448
- {
81449
- text: JSON.stringify({ error: { code: "VALIDATION_FAILED", message: parsed.error.message } }),
81450
- type: "text"
81451
- }
81452
- ],
81453
- isError: true
81454
- };
82044
+ return buildToolError({
82045
+ code: "VALIDATION_FAILED",
82046
+ message: parsed.error.message
82047
+ });
81455
82048
  }
81456
82049
  return tool.invoke(parsed.data);
81457
82050
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.152",
3
+ "version": "0.4.154",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"