@mrrlin-dev/mcp 0.4.101 → 0.4.104

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 +463 -67
  2. package/package.json +3 -3
package/dist/bin.cjs CHANGED
@@ -37428,6 +37428,14 @@ var openApiOperationIds = {
37428
37428
  resolveArtifactKindRoute: "resolveArtifactKindRoute",
37429
37429
  resolveDeliveryForArtifactKind: "resolveDeliveryForArtifactKind",
37430
37430
  recordCapabilityUse: "recordCapabilityUse",
37431
+ appendOperatorTranscriptMessage: "appendOperatorTranscriptMessage",
37432
+ listOperatorTranscriptMessages: "listOperatorTranscriptMessages",
37433
+ createIntentProposal: "createIntentProposal",
37434
+ getIntentProposal: "getIntentProposal",
37435
+ recordIntentClarification: "recordIntentClarification",
37436
+ answerIntentClarification: "answerIntentClarification",
37437
+ confirmIntentProposal: "confirmIntentProposal",
37438
+ getIntentConfirmation: "getIntentConfirmation",
37431
37439
  resolveAccount: "resolveAccount",
37432
37440
  linkAccountIdentity: "linkAccountIdentity",
37433
37441
  getMyAccount: "getMyAccount",
@@ -38109,6 +38117,152 @@ var TASK_NOTES_JOURNAL_SECTIONS = [
38109
38117
  ];
38110
38118
  var JOURNAL_HEADING_RE = new RegExp(`^##[ \\t]+(${TASK_NOTES_JOURNAL_SECTIONS.map((s) => s.heading).join("|")})\\b[ \\t]*(?:[\u2014\u2013-][ \\t]*(\\S.*?))?[ \\t]*$`);
38111
38119
 
38120
+ // ../../packages/schemas/dist/intent.js
38121
+ var taskImpactSchema = external_exports.enum(["low", "medium", "high"]);
38122
+ var autonomyLevelSchema = external_exports.enum(["auto", "human_review"]);
38123
+ var autoDeploySchema = external_exports.enum(["off", "dev", "prod"]);
38124
+ var mrrlinOperatorTranscriptMessageSchema = external_exports.object({
38125
+ id: external_exports.string().uuid(),
38126
+ projectSlug: external_exports.string().min(1),
38127
+ content: external_exports.string().min(1),
38128
+ revision: external_exports.number().int().nonnegative().optional(),
38129
+ createdAt: external_exports.string()
38130
+ });
38131
+ var mrrlinOperatorTranscriptAppendSchema = external_exports.object({
38132
+ content: external_exports.string().min(1)
38133
+ });
38134
+ var mrrlinOperatorTranscriptListSchema = external_exports.array(mrrlinOperatorTranscriptMessageSchema);
38135
+ var operatorTranscriptMessageResponseSchema = external_exports.object({
38136
+ data: mrrlinOperatorTranscriptMessageSchema
38137
+ });
38138
+ var operatorTranscriptListResponseSchema = external_exports.object({
38139
+ data: mrrlinOperatorTranscriptListSchema
38140
+ });
38141
+ var mrrlinIntentProposalStateSchema = external_exports.enum([
38142
+ "pending",
38143
+ "confirmed",
38144
+ "rejected",
38145
+ "blocked",
38146
+ "superseded"
38147
+ ]);
38148
+ var mrrlinIntentProposalSchema = external_exports.object({
38149
+ id: external_exports.string().uuid(),
38150
+ projectSlug: external_exports.string().min(1),
38151
+ proposalId: external_exports.string().uuid(),
38152
+ version: external_exports.number().int().min(1),
38153
+ state: mrrlinIntentProposalStateSchema,
38154
+ resolvedIntent: external_exports.record(external_exports.string(), external_exports.unknown()),
38155
+ digest: external_exports.string().min(1),
38156
+ messageIds: external_exports.array(external_exports.string().uuid()).default([]),
38157
+ transcriptRevision: external_exports.string(),
38158
+ transcriptRevisionNumber: external_exports.number().int().nonnegative().optional(),
38159
+ createdAt: external_exports.string(),
38160
+ updatedAt: external_exports.string()
38161
+ });
38162
+ var mrrlinIntentProposalCreateSchema = external_exports.object({
38163
+ proposalId: external_exports.string().uuid(),
38164
+ version: external_exports.number().int().min(1),
38165
+ resolvedIntent: external_exports.record(external_exports.string(), external_exports.unknown()),
38166
+ digest: external_exports.string().min(1),
38167
+ transcriptRevision: external_exports.string().optional(),
38168
+ expectedTranscriptRevisionNumber: external_exports.number().int().nonnegative(),
38169
+ messageIds: external_exports.array(external_exports.string().uuid())
38170
+ }).strict();
38171
+ var intentProposalResponseSchema = external_exports.object({
38172
+ data: mrrlinIntentProposalSchema
38173
+ });
38174
+ var intentProposalMaybeResponseSchema = external_exports.object({
38175
+ data: mrrlinIntentProposalSchema.nullable()
38176
+ });
38177
+ var mrrlinIntentClarificationStateSchema = external_exports.enum(["open", "answered", "rejected"]);
38178
+ var mrrlinIntentClarificationSchema = external_exports.object({
38179
+ id: external_exports.string().uuid(),
38180
+ projectSlug: external_exports.string().min(1),
38181
+ proposalId: external_exports.string().uuid(),
38182
+ proposalVersion: external_exports.number().int().min(1),
38183
+ round: external_exports.number().int().min(1).max(3),
38184
+ ordinal: external_exports.number().int().min(1).max(3),
38185
+ question: external_exports.string().min(1),
38186
+ state: mrrlinIntentClarificationStateSchema,
38187
+ answer: external_exports.string().nullable().optional(),
38188
+ actor: external_exports.string().nullable().optional(),
38189
+ answeredAt: external_exports.string().nullable().optional(),
38190
+ createdAt: external_exports.string()
38191
+ });
38192
+ var mrrlinIntentClarificationRecordSchema = external_exports.object({
38193
+ proposalId: external_exports.string().uuid(),
38194
+ proposalVersion: external_exports.number().int().min(1),
38195
+ round: external_exports.number().int().min(1).max(3),
38196
+ ordinal: external_exports.number().int().min(1).max(3),
38197
+ question: external_exports.string().min(1)
38198
+ }).strict();
38199
+ var mrrlinIntentClarificationAnswerSchema = external_exports.object({
38200
+ answer: external_exports.string().min(1),
38201
+ actor: external_exports.string().min(1).optional()
38202
+ }).strict();
38203
+ var intentClarificationResponseSchema = external_exports.object({
38204
+ data: mrrlinIntentClarificationSchema
38205
+ });
38206
+ var mrrlinIntentConfirmRequestSchema = external_exports.object({
38207
+ proposalId: external_exports.string().uuid(),
38208
+ expectedVersion: external_exports.number().int().min(1),
38209
+ expectedDigest: external_exports.string().min(1),
38210
+ actor: external_exports.string().min(1).optional(),
38211
+ materializeParams: external_exports.object({
38212
+ task: external_exports.object({
38213
+ id: external_exports.string().min(1),
38214
+ title: external_exports.string().min(1).optional(),
38215
+ category: external_exports.string().optional(),
38216
+ subcategory: external_exports.string().optional(),
38217
+ impact: taskImpactSchema.optional(),
38218
+ autonomyLevel: autonomyLevelSchema.optional(),
38219
+ autonomyReason: external_exports.string().optional(),
38220
+ autoDeploy: autoDeploySchema.optional(),
38221
+ domains: external_exports.array(external_exports.string()).optional(),
38222
+ tags: external_exports.array(external_exports.string()).optional(),
38223
+ planId: external_exports.string().optional(),
38224
+ specWikiPageId: external_exports.string().optional(),
38225
+ assignee: external_exports.string().optional(),
38226
+ notes: external_exports.string().optional()
38227
+ }).strict().optional(),
38228
+ plan: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
38229
+ }).strict().optional()
38230
+ }).strict();
38231
+ var mrrlinIntentConfirmResponseSchema = external_exports.discriminatedUnion("ok", [
38232
+ external_exports.object({
38233
+ ok: external_exports.literal(true),
38234
+ confirmation_id: external_exports.string().uuid(),
38235
+ proposal_id: external_exports.string().uuid(),
38236
+ proposal_version: external_exports.number().int(),
38237
+ digest: external_exports.string(),
38238
+ task_id: external_exports.string().nullable().optional()
38239
+ }),
38240
+ external_exports.object({
38241
+ ok: external_exports.literal(false),
38242
+ code: external_exports.string(),
38243
+ message: external_exports.string(),
38244
+ expected_version: external_exports.number().optional(),
38245
+ current_state: external_exports.string().optional()
38246
+ })
38247
+ ]);
38248
+ var intentConfirmResultResponseSchema = external_exports.object({
38249
+ data: mrrlinIntentConfirmResponseSchema
38250
+ });
38251
+ var mrrlinIntentConfirmationSchema = external_exports.object({
38252
+ id: external_exports.string().uuid(),
38253
+ projectSlug: external_exports.string().min(1),
38254
+ proposalId: external_exports.string().uuid(),
38255
+ proposalVersion: external_exports.number().int().min(1),
38256
+ confirmedBy: external_exports.string().min(1),
38257
+ digest: external_exports.string().min(1),
38258
+ transcriptRevision: external_exports.string(),
38259
+ transcriptRevisionNumber: external_exports.number().int().nonnegative().optional(),
38260
+ createdAt: external_exports.string()
38261
+ });
38262
+ var intentConfirmationMaybeResponseSchema = external_exports.object({
38263
+ data: mrrlinIntentConfirmationSchema.nullable()
38264
+ });
38265
+
38112
38266
  // ../../packages/schemas/dist/appsumo.js
38113
38267
  var APPSUMO_CODE_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
38114
38268
  var APPSUMO_ALPHABET_SET = new Set(APPSUMO_CODE_ALPHABET);
@@ -41299,6 +41453,84 @@ function createMrrlinClient(config2) {
41299
41453
  method: "DELETE"
41300
41454
  });
41301
41455
  },
41456
+ // ── Server-Authoritative Intent Methods ─────────────────────────────────
41457
+ async appendOperatorTranscriptMessage(projectSlug, content) {
41458
+ const body = await request(`${projectPath(projectSlug)}/intent/transcript`, {
41459
+ method: "POST",
41460
+ headers: { "content-type": "application/json" },
41461
+ body: JSON.stringify({ content })
41462
+ });
41463
+ return operatorTranscriptMessageResponseSchema.parse(body).data;
41464
+ },
41465
+ async listOperatorTranscriptMessages(projectSlug) {
41466
+ const body = await request(`${projectPath(projectSlug)}/intent/transcript`);
41467
+ return operatorTranscriptListResponseSchema.parse(body).data;
41468
+ },
41469
+ async createIntentProposal(projectSlug, input) {
41470
+ const body = await request(`${projectPath(projectSlug)}/intent/proposals`, {
41471
+ method: "POST",
41472
+ headers: { "content-type": "application/json" },
41473
+ body: JSON.stringify(input)
41474
+ });
41475
+ return intentProposalResponseSchema.parse(body).data;
41476
+ },
41477
+ async getIntentProposal(projectSlug, proposalId, version2) {
41478
+ try {
41479
+ const body = await request(`${projectPath(projectSlug)}/intent/proposals/${encodeURIComponent(proposalId)}/${encodeURIComponent(String(version2))}`);
41480
+ return intentProposalMaybeResponseSchema.parse(body).data;
41481
+ } catch (error51) {
41482
+ if (error51 instanceof MrrlinApiError && error51.status === 404)
41483
+ return null;
41484
+ throw error51;
41485
+ }
41486
+ },
41487
+ async recordIntentClarification(projectSlug, input) {
41488
+ const body = await request(`${projectPath(projectSlug)}/intent/clarifications`, {
41489
+ method: "POST",
41490
+ headers: { "content-type": "application/json" },
41491
+ body: JSON.stringify(input)
41492
+ });
41493
+ return intentClarificationResponseSchema.parse(body).data;
41494
+ },
41495
+ async answerIntentClarification(projectSlug, id, input) {
41496
+ const body = await request(`${projectPath(projectSlug)}/intent/clarifications/${encodeURIComponent(id)}/answer`, {
41497
+ method: "POST",
41498
+ headers: { "content-type": "application/json" },
41499
+ body: JSON.stringify(input)
41500
+ });
41501
+ return intentClarificationResponseSchema.parse(body).data;
41502
+ },
41503
+ async confirmIntentProposal(projectSlug, proposalId, input) {
41504
+ try {
41505
+ const body = await request(`${projectPath(projectSlug)}/intent/proposals/${encodeURIComponent(proposalId)}/confirm`, {
41506
+ method: "POST",
41507
+ headers: { "content-type": "application/json" },
41508
+ body: JSON.stringify(input)
41509
+ });
41510
+ return intentConfirmResultResponseSchema.parse(body).data;
41511
+ } catch (error51) {
41512
+ if (error51 instanceof MrrlinApiError && (error51.status === 409 || error51.status === 422)) {
41513
+ try {
41514
+ const parsed = JSON.parse(error51.responseBody);
41515
+ const maybeResult = mrrlinIntentConfirmResponseSchema.safeParse(parsed);
41516
+ if (maybeResult.success)
41517
+ return maybeResult.data;
41518
+ } catch {
41519
+ }
41520
+ }
41521
+ throw error51;
41522
+ }
41523
+ },
41524
+ async getIntentConfirmation(projectSlug, proposalId, version2) {
41525
+ try {
41526
+ const body = await request(`${projectPath(projectSlug)}/intent/confirmations/${encodeURIComponent(proposalId)}/${encodeURIComponent(String(version2))}`);
41527
+ return intentConfirmationMaybeResponseSchema.parse(body).data;
41528
+ } catch (error51) {
41529
+ if (error51 instanceof MrrlinApiError && error51.status === 404)
41530
+ return null;
41531
+ throw error51;
41532
+ }
41533
+ },
41302
41534
  async resolveAccount() {
41303
41535
  const body = await request("/auth/account/resolve", {
41304
41536
  method: "POST"
@@ -41404,7 +41636,13 @@ async function resolveIndexPath(input) {
41404
41636
  return import_node_path5.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
41405
41637
  }
41406
41638
  const workspaceRoot = await findWorkspaceRoot();
41407
- return import_node_path5.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
41639
+ const packageIndexPath = import_node_path5.default.join(workspaceRoot, "packages", "wiki", "wiki-index.json");
41640
+ try {
41641
+ await import_promises3.default.access(packageIndexPath);
41642
+ return packageIndexPath;
41643
+ } catch {
41644
+ return import_node_path5.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
41645
+ }
41408
41646
  }
41409
41647
  async function walkMarkdownFiles(root, dir = root) {
41410
41648
  const entries = await import_promises3.default.readdir(dir, { withFileTypes: true });
@@ -46746,7 +46984,7 @@ async function deliverToWiki(client, projectSlug, payload) {
46746
46984
  return client.updateWikiPage(projectSlug, payload.pageId, payload.patch);
46747
46985
  }
46748
46986
 
46749
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
46987
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
46750
46988
  function isZ4Schema(s) {
46751
46989
  const schema = s;
46752
46990
  return !!schema._zod;
@@ -46809,7 +47047,7 @@ function getLiteralValue(schema) {
46809
47047
  return void 0;
46810
47048
  }
46811
47049
 
46812
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
47050
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
46813
47051
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
46814
47052
  var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
46815
47053
  var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
@@ -48329,7 +48567,7 @@ var UrlElicitationRequiredError = class extends McpError {
48329
48567
  }
48330
48568
  };
48331
48569
 
48332
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
48570
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
48333
48571
  function isTerminal(status) {
48334
48572
  return status === "completed" || status === "failed" || status === "cancelled";
48335
48573
  }
@@ -48340,7 +48578,7 @@ var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use")
48340
48578
  // ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@4.4.3/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
48341
48579
  var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
48342
48580
 
48343
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
48581
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
48344
48582
  function getMethodLiteral(schema) {
48345
48583
  const shape = getObjectShape(schema);
48346
48584
  const methodSchema = shape?.method;
@@ -48361,7 +48599,7 @@ function parseWithCompat(schema, data) {
48361
48599
  return result.data;
48362
48600
  }
48363
48601
 
48364
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
48602
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
48365
48603
  var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
48366
48604
  var Protocol = class {
48367
48605
  constructor(_options) {
@@ -48402,6 +48640,9 @@ var Protocol = class {
48402
48640
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
48403
48641
  const handleTaskResult = async () => {
48404
48642
  const taskId = request.params.taskId;
48643
+ if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
48644
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
48645
+ }
48405
48646
  if (this._taskMessageQueue) {
48406
48647
  let queuedMessage;
48407
48648
  while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
@@ -48432,12 +48673,12 @@ var Protocol = class {
48432
48673
  throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
48433
48674
  }
48434
48675
  if (!isTerminal(task.status)) {
48435
- await this._waitForTaskUpdate(taskId, extra.signal);
48676
+ await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
48436
48677
  return await handleTaskResult();
48437
48678
  }
48438
48679
  if (isTerminal(task.status)) {
48439
48680
  const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
48440
- this._clearTaskQueue(taskId);
48681
+ this._clearTaskQueue(taskId, extra.sessionId);
48441
48682
  return {
48442
48683
  ...result,
48443
48684
  _meta: {
@@ -48474,7 +48715,7 @@ var Protocol = class {
48474
48715
  throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
48475
48716
  }
48476
48717
  await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
48477
- this._clearTaskQueue(request.params.taskId);
48718
+ this._clearTaskQueue(request.params.taskId, extra.sessionId);
48478
48719
  const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
48479
48720
  if (!cancelledTask) {
48480
48721
  throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
@@ -48602,6 +48843,19 @@ var Protocol = class {
48602
48843
  const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
48603
48844
  const capturedTransport = this._transport;
48604
48845
  const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
48846
+ const sessionId = capturedTransport?.sessionId;
48847
+ const store = this._taskStore;
48848
+ let relatedTaskFound = true;
48849
+ let relatedTaskLookup;
48850
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
48851
+ relatedTaskFound = false;
48852
+ relatedTaskLookup = (async () => {
48853
+ if (!await store.getTask(relatedTaskId, sessionId)) {
48854
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
48855
+ }
48856
+ relatedTaskFound = true;
48857
+ })();
48858
+ }
48605
48859
  if (handler === void 0) {
48606
48860
  const errorResponse = {
48607
48861
  jsonrpc: "2.0",
@@ -48611,7 +48865,10 @@ var Protocol = class {
48611
48865
  message: "Method not found"
48612
48866
  }
48613
48867
  };
48614
- if (relatedTaskId && this._taskMessageQueue) {
48868
+ if (relatedTaskId && relatedTaskLookup) {
48869
+ const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
48870
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error51) => this._onerror(new Error(`Failed to send an error response: ${error51}`)));
48871
+ } else if (relatedTaskId && this._taskMessageQueue) {
48615
48872
  this._enqueueTaskMessage(relatedTaskId, {
48616
48873
  type: "error",
48617
48874
  message: errorResponse,
@@ -48662,7 +48919,10 @@ var Protocol = class {
48662
48919
  closeSSEStream: extra?.closeSSEStream,
48663
48920
  closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
48664
48921
  };
48665
- Promise.resolve().then(() => {
48922
+ (relatedTaskLookup ?? Promise.resolve()).then(() => {
48923
+ if (relatedTaskLookup && abortController.signal.aborted) {
48924
+ throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
48925
+ }
48666
48926
  if (taskCreationParams) {
48667
48927
  this.assertTaskHandlerCapability(request.method);
48668
48928
  }
@@ -48697,7 +48957,7 @@ var Protocol = class {
48697
48957
  ...error51["data"] !== void 0 && { data: error51["data"] }
48698
48958
  }
48699
48959
  };
48700
- if (relatedTaskId && this._taskMessageQueue) {
48960
+ if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
48701
48961
  await this._enqueueTaskMessage(relatedTaskId, {
48702
48962
  type: "error",
48703
48963
  message: errorResponse,
@@ -49177,7 +49437,7 @@ var Protocol = class {
49177
49437
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
49178
49438
  }
49179
49439
  const maxQueueSize = this._options?.maxTaskQueueSize;
49180
- await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
49440
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
49181
49441
  }
49182
49442
  /**
49183
49443
  * Clears the message queue for a task and rejects any pending request resolvers.
@@ -49206,12 +49466,13 @@ var Protocol = class {
49206
49466
  * Uses polling to check for updates at the task's configured poll interval.
49207
49467
  * @param taskId The task ID to wait for
49208
49468
  * @param signal Abort signal to cancel the wait
49469
+ * @param sessionId Session of the request that waits, passed to the task store
49209
49470
  * @returns Promise that resolves when an update occurs or rejects if aborted
49210
49471
  */
49211
- async _waitForTaskUpdate(taskId, signal) {
49472
+ async _waitForTaskUpdate(taskId, signal, sessionId) {
49212
49473
  let interval = this._options?.defaultTaskPollInterval ?? 1e3;
49213
49474
  try {
49214
- const task = await this._taskStore?.getTask(taskId);
49475
+ const task = await this._taskStore?.getTask(taskId, sessionId);
49215
49476
  if (task?.pollInterval) {
49216
49477
  interval = task.pollInterval;
49217
49478
  }
@@ -49315,7 +49576,7 @@ function mergeCapabilities(base, additional) {
49315
49576
  return result;
49316
49577
  }
49317
49578
 
49318
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
49579
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
49319
49580
  var import_ajv = __toESM(require_ajv(), 1);
49320
49581
  var import_ajv_formats = __toESM(require_dist(), 1);
49321
49582
  function createDefaultAjvInstance() {
@@ -49383,7 +49644,7 @@ var AjvJsonSchemaValidator = class {
49383
49644
  }
49384
49645
  };
49385
49646
 
49386
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
49647
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
49387
49648
  var ExperimentalClientTasks = class {
49388
49649
  constructor(_client) {
49389
49650
  this._client = _client;
@@ -49537,7 +49798,7 @@ var ExperimentalClientTasks = class {
49537
49798
  }
49538
49799
  };
49539
49800
 
49540
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
49801
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
49541
49802
  function assertToolsCallTaskCapability(requests, method, entityName) {
49542
49803
  if (!requests) {
49543
49804
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -49572,7 +49833,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
49572
49833
  }
49573
49834
  }
49574
49835
 
49575
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
49836
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
49576
49837
  function applyElicitationDefaults(schema, data) {
49577
49838
  if (!schema || data === null || typeof data !== "object")
49578
49839
  return;
@@ -50083,7 +50344,7 @@ var Client = class extends Protocol {
50083
50344
  }
50084
50345
  };
50085
50346
 
50086
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
50347
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
50087
50348
  var import_content_type = __toESM(require_content_type(), 1);
50088
50349
  function mediaTypeEssence(header) {
50089
50350
  if (!header) {
@@ -50100,7 +50361,7 @@ function mediaTypeEssence(header) {
50100
50361
  }
50101
50362
  }
50102
50363
 
50103
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
50364
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
50104
50365
  function normalizeHeaders(headers) {
50105
50366
  if (!headers)
50106
50367
  return {};
@@ -50126,6 +50387,68 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
50126
50387
  return baseFetch(url2, mergedInit);
50127
50388
  };
50128
50389
  }
50390
+ var MAX_REDIRECTS = 5;
50391
+ var REDIRECT_STATUSES = [301, 302, 303, 307, 308];
50392
+ function isWithinOrigin(from, to) {
50393
+ if (from.protocol === to.protocol && from.hostname === to.hostname && from.port === to.port) {
50394
+ return true;
50395
+ }
50396
+ return from.hostname === to.hostname && from.protocol === "http:" && from.port === "" && to.protocol === "https:" && to.port === "";
50397
+ }
50398
+ function redirectTarget(response, requestUrl) {
50399
+ const location = REDIRECT_STATUSES.includes(response.status) ? response.headers.get("location") : null;
50400
+ try {
50401
+ return location ? new URL(location, requestUrl) : void 0;
50402
+ } catch {
50403
+ return void 0;
50404
+ }
50405
+ }
50406
+ function followWithinOrigin(baseFetch, url2, init, response, followed = 0) {
50407
+ const target = redirectTarget(response, url2);
50408
+ const keepsMethod = response.status === 307 || response.status === 308 || (init?.method ?? "GET").toUpperCase() === "GET";
50409
+ if (!target || followed === MAX_REDIRECTS || !keepsMethod) {
50410
+ return void 0;
50411
+ }
50412
+ const from = new URL(url2);
50413
+ const addsUserinfo = (target.username || target.password) && (target.username !== from.username || target.password !== from.password);
50414
+ if (addsUserinfo || !isWithinOrigin(from, target)) {
50415
+ return void 0;
50416
+ }
50417
+ return Promise.resolve(response.body?.cancel()).then(() => baseFetch(target, { ...init, redirect: "manual" })).then((next) => followWithinOrigin(baseFetch, target, init, next, followed + 1) ?? next);
50418
+ }
50419
+ var followingFetches = /* @__PURE__ */ new WeakSet();
50420
+ function fetchLeavingRedirects(baseFetch) {
50421
+ const following = (url2, init) => (baseFetch ?? fetch)(url2, init);
50422
+ followingFetches.add(following);
50423
+ return following;
50424
+ }
50425
+ function fetchWithinOrigin(baseFetch = fetch) {
50426
+ if (followingFetches.has(baseFetch)) {
50427
+ return baseFetch;
50428
+ }
50429
+ return (url2, init) => {
50430
+ if (init?.redirect === "error" || init?.redirect === "manual") {
50431
+ return baseFetch(url2, init);
50432
+ }
50433
+ return Promise.resolve(baseFetch(url2, { ...init, redirect: "manual" })).then((response) => followWithinOrigin(baseFetch, url2, init, response) ?? response);
50434
+ };
50435
+ }
50436
+ function unfollowedRedirect(response, requestUrl) {
50437
+ if (response.type === "opaqueredirect") {
50438
+ return "Redirect not followed: this runtime does not expose the redirect target";
50439
+ }
50440
+ const from = response.url || requestUrl;
50441
+ const target = redirectTarget(response, from);
50442
+ if (!target) {
50443
+ return void 0;
50444
+ }
50445
+ target.username = target.password = target.search = target.hash = "";
50446
+ if (target.protocol === "http:" && new URL(from).protocol === "https:") {
50447
+ target.protocol = "https:";
50448
+ return `Redirect to plain http not followed; try ${target.href} instead`;
50449
+ }
50450
+ return `Redirect to ${target.href} not followed`;
50451
+ }
50129
50452
 
50130
50453
  // ../../node_modules/.pnpm/pkce-challenge@5.0.1/node_modules/pkce-challenge/dist/index.node.js
50131
50454
  var crypto3;
@@ -50170,7 +50493,7 @@ async function pkceChallenge(length) {
50170
50493
  };
50171
50494
  }
50172
50495
 
50173
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
50496
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
50174
50497
  var SafeUrlSchema = url().superRefine((val, ctx) => {
50175
50498
  if (!URL.canParse(val)) {
50176
50499
  ctx.addIssue({
@@ -50272,7 +50595,12 @@ var OAuthTokensSchema = object({
50272
50595
  token_type: string2(),
50273
50596
  expires_in: coerce_exports.number().optional(),
50274
50597
  scope: string2().optional(),
50275
- refresh_token: string2().optional()
50598
+ refresh_token: string2().optional(),
50599
+ /**
50600
+ * Not part of the wire format: the authorization server this value was obtained from, added by
50601
+ * the client's `auth()` before it is stored and compared when it is read back.
50602
+ */
50603
+ issuer: string2().optional().catch(void 0)
50276
50604
  }).strip();
50277
50605
  var OAuthErrorResponseSchema = object({
50278
50606
  error: string2(),
@@ -50302,7 +50630,12 @@ var OAuthClientInformationSchema = object({
50302
50630
  client_id: string2(),
50303
50631
  client_secret: string2().optional(),
50304
50632
  client_id_issued_at: number2().optional(),
50305
- client_secret_expires_at: number2().optional()
50633
+ client_secret_expires_at: number2().optional(),
50634
+ /**
50635
+ * Not part of the wire format: the authorization server this value was obtained from, added by
50636
+ * the client's `auth()` before it is stored and compared when it is read back.
50637
+ */
50638
+ issuer: string2().optional().catch(void 0)
50306
50639
  }).strip();
50307
50640
  var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
50308
50641
  var OAuthClientRegistrationErrorSchema = object({
@@ -50314,7 +50647,7 @@ var OAuthTokenRevocationRequestSchema = object({
50314
50647
  token_type_hint: string2().optional()
50315
50648
  }).strip();
50316
50649
 
50317
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
50650
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
50318
50651
  function resourceUrlFromServerUrl(url2) {
50319
50652
  const resourceURL = typeof url2 === "string" ? new URL(url2) : new URL(url2.href);
50320
50653
  resourceURL.hash = "";
@@ -50334,7 +50667,7 @@ function checkResourceAllowed({ requestedResource, configuredResource }) {
50334
50667
  return requestedPath.startsWith(configuredPath);
50335
50668
  }
50336
50669
 
50337
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js
50670
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js
50338
50671
  var OAuthError = class extends Error {
50339
50672
  constructor(message, errorUri) {
50340
50673
  super(message);
@@ -50429,7 +50762,7 @@ var OAUTH_ERRORS = {
50429
50762
  [InvalidTargetError.errorCode]: InvalidTargetError
50430
50763
  };
50431
50764
 
50432
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js
50765
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js
50433
50766
  var UnauthorizedError = class extends Error {
50434
50767
  constructor(message) {
50435
50768
  super(message ?? "Unauthorized");
@@ -50500,10 +50833,31 @@ async function parseErrorResponse(input) {
50500
50833
  const errorClass = OAUTH_ERRORS[error51] || ServerError;
50501
50834
  return new errorClass(error_description || "", error_uri);
50502
50835
  } catch (error51) {
50503
- const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}Invalid OAuth error response: ${error51}. Raw body: ${body}`;
50836
+ const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : void 0;
50837
+ const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error51}. Raw body: ${body}`}`;
50504
50838
  return new ServerError(errorMessage);
50505
50839
  }
50506
50840
  }
50841
+ function issuersMatch(a, b) {
50842
+ let [x, y] = [a, b];
50843
+ try {
50844
+ [x, y] = [new URL(a).href, new URL(b).href];
50845
+ } catch {
50846
+ }
50847
+ return x === y || x.endsWith("/") && x.slice(0, -1) === y || y.endsWith("/") && y.slice(0, -1) === x;
50848
+ }
50849
+ function discardIfIssuerMismatch(stored, issuer) {
50850
+ if (!stored)
50851
+ return void 0;
50852
+ if (typeof stored.issuer !== "string")
50853
+ return stored.issuer == null ? stored : { ...stored, issuer: void 0 };
50854
+ return issuersMatch(stored.issuer, issuer) ? stored : void 0;
50855
+ }
50856
+ var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
50857
+ var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
50858
+ function boundElsewhereError(stored, issuer) {
50859
+ return new Error(`OAuth client information is bound to authorization server ${stored.issuer} and is not presented to ${issuer}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`);
50860
+ }
50507
50861
  async function auth(provider, options) {
50508
50862
  try {
50509
50863
  return await authInternal(provider, options);
@@ -50557,9 +50911,24 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
50557
50911
  authorizationServerMetadata: metadata
50558
50912
  });
50559
50913
  }
50560
- const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
50914
+ const issuer = String(authorizationServerUrl);
50915
+ const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
50916
+ const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
50561
50917
  const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
50562
- let clientInformation = await Promise.resolve(provider.clientInformation());
50918
+ const storedClientInformation = await Promise.resolve(provider.clientInformation());
50919
+ let clientInformation = discardIfIssuerMismatch(storedClientInformation, issuer);
50920
+ const canRegisterAgain = provider.saveClientInformation !== void 0 && !!provider.redirectUrl;
50921
+ if (storedClientInformation && !clientInformation && !canRegisterAgain) {
50922
+ throw boundElsewhereError(storedClientInformation, issuer);
50923
+ }
50924
+ const unstampedClientInformation = clientInformation?.issuer == null ? clientInformation : void 0;
50925
+ const bindClientInformation = async () => {
50926
+ try {
50927
+ if (unstampedClientInformation)
50928
+ await provider.saveClientInformation?.({ ...unstampedClientInformation, issuer });
50929
+ } catch {
50930
+ }
50931
+ };
50563
50932
  if (!clientInformation) {
50564
50933
  if (authorizationCode !== void 0) {
50565
50934
  throw new Error("Existing OAuth client information is required when exchanging an authorization code");
@@ -50571,9 +50940,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
50571
50940
  }
50572
50941
  const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
50573
50942
  if (shouldUseUrlBasedClientId) {
50574
- clientInformation = {
50575
- client_id: clientMetadataUrl
50576
- };
50943
+ clientInformation = { client_id: clientMetadataUrl, issuer };
50577
50944
  await provider.saveClientInformation?.(clientInformation);
50578
50945
  } else {
50579
50946
  if (!provider.saveClientInformation) {
@@ -50585,8 +50952,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
50585
50952
  scope: resolvedScope,
50586
50953
  fetchFn
50587
50954
  });
50588
- await provider.saveClientInformation(fullInformation);
50589
- clientInformation = fullInformation;
50955
+ clientInformation = { ...fullInformation, issuer };
50956
+ await provider.saveClientInformation(clientInformation);
50590
50957
  }
50591
50958
  }
50592
50959
  const nonInteractiveFlow = !provider.redirectUrl;
@@ -50597,10 +50964,14 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
50597
50964
  authorizationCode,
50598
50965
  fetchFn
50599
50966
  });
50600
- await provider.saveTokens(tokens3);
50967
+ await bindClientInformation();
50968
+ await provider.saveTokens({ ...tokens3, issuer });
50601
50969
  return "AUTHORIZED";
50602
50970
  }
50603
- const tokens2 = await provider.tokens();
50971
+ const tokens2 = discardIfIssuerMismatch(await provider.tokens(), issuer);
50972
+ if (tokens2?.refresh_token && tokens2.issuer == null) {
50973
+ console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged.");
50974
+ }
50604
50975
  if (tokens2?.refresh_token) {
50605
50976
  try {
50606
50977
  const newTokens = await refreshAuthorization(authorizationServerUrl, {
@@ -50611,7 +50982,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
50611
50982
  addClientAuthentication: provider.addClientAuthentication,
50612
50983
  fetchFn
50613
50984
  });
50614
- await provider.saveTokens(newTokens);
50985
+ await bindClientInformation();
50986
+ await provider.saveTokens({ ...newTokens, issuer });
50615
50987
  return "AUTHORIZED";
50616
50988
  } catch (error51) {
50617
50989
  if (!(error51 instanceof OAuthError) || error51 instanceof ServerError) {
@@ -50710,7 +51082,7 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
50710
51082
  }
50711
51083
  async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
50712
51084
  try {
50713
- return await fetchFn(url2, { headers });
51085
+ return await fetchWithinOrigin(fetchFn)(url2, { headers });
50714
51086
  } catch (error51) {
50715
51087
  if (error51 instanceof TypeError) {
50716
51088
  if (headers) {
@@ -50735,7 +51107,7 @@ async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
50735
51107
  return await fetchWithCorsRetry(url2, headers, fetchFn);
50736
51108
  }
50737
51109
  function shouldAttemptFallback(response, pathname) {
50738
- return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
51110
+ return !response || !response.ok && response.status < 500 && pathname !== "/";
50739
51111
  }
50740
51112
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
50741
51113
  const issuer = new URL(serverUrl);
@@ -50801,7 +51173,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
50801
51173
  }
50802
51174
  if (!response.ok) {
50803
51175
  await response.body?.cancel();
50804
- if (response.status >= 400 && response.status < 500) {
51176
+ if (response.status < 500) {
50805
51177
  continue;
50806
51178
  }
50807
51179
  throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
@@ -50834,6 +51206,9 @@ async function discoverOAuthServerInfo(serverUrl, opts) {
50834
51206
  resourceMetadata
50835
51207
  };
50836
51208
  }
51209
+ function resourceIndicatorToString(resource) {
51210
+ return typeof resource === "string" ? resource : resource.href;
51211
+ }
50837
51212
  async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
50838
51213
  let authorizationUrl;
50839
51214
  if (metadata) {
@@ -50865,7 +51240,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
50865
51240
  authorizationUrl.searchParams.append("prompt", "consent");
50866
51241
  }
50867
51242
  if (resource) {
50868
- authorizationUrl.searchParams.set("resource", resource.href);
51243
+ authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
50869
51244
  }
50870
51245
  return { authorizationUrl, codeVerifier };
50871
51246
  }
@@ -50884,7 +51259,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
50884
51259
  Accept: "application/json"
50885
51260
  });
50886
51261
  if (resource) {
50887
- tokenRequestParams.set("resource", resource.href);
51262
+ tokenRequestParams.set("resource", resourceIndicatorToString(resource));
50888
51263
  }
50889
51264
  if (addClientAuthentication) {
50890
51265
  await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
@@ -50893,7 +51268,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
50893
51268
  const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
50894
51269
  applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
50895
51270
  }
50896
- const response = await (fetchFn ?? fetch)(tokenUrl, {
51271
+ const response = await fetchWithinOrigin(fetchFn ?? fetch)(tokenUrl, {
50897
51272
  method: "POST",
50898
51273
  headers,
50899
51274
  body: tokenRequestParams
@@ -50901,7 +51276,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
50901
51276
  if (!response.ok) {
50902
51277
  throw await parseErrorResponse(response);
50903
51278
  }
50904
- return OAuthTokensSchema.parse(await response.json());
51279
+ return TokenResponseSchema.parse(await response.json());
50905
51280
  }
50906
51281
  async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
50907
51282
  const tokenRequestParams = new URLSearchParams({
@@ -50919,6 +51294,15 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
50919
51294
  return { refresh_token: refreshToken, ...tokens2 };
50920
51295
  }
50921
51296
  async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
51297
+ const readClientInformation = async () => {
51298
+ const storedClientInformation = await provider.clientInformation();
51299
+ const checked = discardIfIssuerMismatch(storedClientInformation, String(authorizationServerUrl));
51300
+ if (storedClientInformation && !checked) {
51301
+ throw boundElsewhereError(storedClientInformation, String(authorizationServerUrl));
51302
+ }
51303
+ return checked;
51304
+ };
51305
+ let clientInformation = await readClientInformation();
50922
51306
  const scope = provider.clientMetadata.scope;
50923
51307
  let tokenRequestParams;
50924
51308
  if (provider.prepareTokenRequest) {
@@ -50934,11 +51318,11 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
50934
51318
  const codeVerifier = await provider.codeVerifier();
50935
51319
  tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
50936
51320
  }
50937
- const clientInformation = await provider.clientInformation();
51321
+ clientInformation ?? (clientInformation = await readClientInformation());
50938
51322
  return executeTokenRequest(authorizationServerUrl, {
50939
51323
  metadata,
50940
51324
  tokenRequestParams,
50941
- clientInformation: clientInformation ?? void 0,
51325
+ clientInformation,
50942
51326
  addClientAuthentication: provider.addClientAuthentication,
50943
51327
  resource,
50944
51328
  fetchFn
@@ -50954,7 +51338,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
50954
51338
  } else {
50955
51339
  registrationUrl = new URL("/register", authorizationServerUrl);
50956
51340
  }
50957
- const response = await (fetchFn ?? fetch)(registrationUrl, {
51341
+ const response = await fetchWithinOrigin(fetchFn ?? fetch)(registrationUrl, {
50958
51342
  method: "POST",
50959
51343
  headers: {
50960
51344
  "Content-Type": "application/json"
@@ -50967,7 +51351,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
50967
51351
  if (!response.ok) {
50968
51352
  throw await parseErrorResponse(response);
50969
51353
  }
50970
- return OAuthClientInformationFullSchema.parse(await response.json());
51354
+ return RegistrationResponseSchema.parse(await response.json());
50971
51355
  }
50972
51356
 
50973
51357
  // ../../node_modules/.pnpm/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/index.js
@@ -51171,7 +51555,7 @@ var EventSourceParserStream = class extends TransformStream {
51171
51555
  }
51172
51556
  };
51173
51557
 
51174
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
51558
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
51175
51559
  var DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
51176
51560
  initialReconnectionDelay: 1e3,
51177
51561
  maxReconnectionDelay: 3e4,
@@ -51194,9 +51578,19 @@ var StreamableHTTPClientTransport = class {
51194
51578
  this._authProvider = opts?.authProvider;
51195
51579
  this._fetch = opts?.fetch;
51196
51580
  this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
51581
+ this._followRedirects = opts?.redirectPolicy === "follow";
51582
+ if (this._followRedirects) {
51583
+ this._fetch = fetchLeavingRedirects(this._fetch);
51584
+ this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
51585
+ }
51197
51586
  this._sessionId = opts?.sessionId;
51198
51587
  this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
51199
51588
  }
51589
+ /** Error text for a redirect `response` that was not followed, or `undefined` for any other response. */
51590
+ _unfollowedRedirect(response, url2) {
51591
+ const text = unfollowedRedirect(response, url2);
51592
+ return text && !this._followRedirects ? `${text} (redirectPolicy: 'same-origin')` : text;
51593
+ }
51200
51594
  async _authThenStart() {
51201
51595
  if (!this._authProvider) {
51202
51596
  throw new UnauthorizedError("No auth provider");
@@ -51246,11 +51640,13 @@ var StreamableHTTPClientTransport = class {
51246
51640
  if (resumptionToken) {
51247
51641
  headers.set("last-event-id", resumptionToken);
51248
51642
  }
51249
- const response = await (this._fetch ?? fetch)(this._url, {
51250
- method: "GET",
51251
- headers,
51252
- signal: this._abortController?.signal
51253
- });
51643
+ const fetchFn = this._fetch ?? fetch;
51644
+ const init = { method: "GET", headers, signal: this._abortController?.signal };
51645
+ let response = await fetchFn(this._url, this._followRedirects ? init : { ...init, redirect: "manual" });
51646
+ const followed = this._followRedirects ? void 0 : followWithinOrigin(fetchFn, this._url, init, response);
51647
+ if (followed) {
51648
+ response = await followed;
51649
+ }
51254
51650
  if (!response.ok) {
51255
51651
  await response.body?.cancel();
51256
51652
  if (response.status === 401 && this._authProvider) {
@@ -51259,7 +51655,7 @@ var StreamableHTTPClientTransport = class {
51259
51655
  if (response.status === 405) {
51260
51656
  return;
51261
51657
  }
51262
- throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
51658
+ throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
51263
51659
  }
51264
51660
  this._handleSseStream(response.body, options, true);
51265
51661
  } catch (error51) {
@@ -51422,7 +51818,7 @@ var StreamableHTTPClientTransport = class {
51422
51818
  body: JSON.stringify(message),
51423
51819
  signal: this._abortController?.signal
51424
51820
  };
51425
- const response = await (this._fetch ?? fetch)(this._url, init);
51821
+ const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
51426
51822
  const sessionId = response.headers.get("mcp-session-id");
51427
51823
  if (sessionId) {
51428
51824
  this._sessionId = sessionId;
@@ -51474,7 +51870,7 @@ var StreamableHTTPClientTransport = class {
51474
51870
  return this.send(message);
51475
51871
  }
51476
51872
  }
51477
- throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
51873
+ throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${this._unfollowedRedirect(response, this._url) ?? text}`);
51478
51874
  }
51479
51875
  this._hasCompletedAuthFlow = false;
51480
51876
  this._lastUpscopingHeader = void 0;
@@ -51536,10 +51932,10 @@ var StreamableHTTPClientTransport = class {
51536
51932
  headers,
51537
51933
  signal: this._abortController?.signal
51538
51934
  };
51539
- const response = await (this._fetch ?? fetch)(this._url, init);
51935
+ const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
51540
51936
  await response.body?.cancel();
51541
51937
  if (!response.ok && response.status !== 405) {
51542
- throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
51938
+ throw new StreamableHTTPError(response.status, `Failed to terminate session: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
51543
51939
  }
51544
51940
  this._sessionId = void 0;
51545
51941
  } catch (error51) {
@@ -51568,12 +51964,12 @@ var StreamableHTTPClientTransport = class {
51568
51964
  }
51569
51965
  };
51570
51966
 
51571
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
51967
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
51572
51968
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
51573
51969
  var import_node_process = __toESM(require("node:process"), 1);
51574
51970
  var import_node_stream = require("node:stream");
51575
51971
 
51576
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
51972
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
51577
51973
  var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
51578
51974
  var ReadBuffer = class {
51579
51975
  constructor(options) {
@@ -51610,7 +52006,7 @@ function serializeMessage(message) {
51610
52006
  return JSON.stringify(message) + "\n";
51611
52007
  }
51612
52008
 
51613
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
52009
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
51614
52010
  var DEFAULT_INHERITED_ENV_VARS = import_node_process.default.platform === "win32" ? [
51615
52011
  "APPDATA",
51616
52012
  "HOMEDRIVE",
@@ -59134,7 +59530,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
59134
59530
  }
59135
59531
 
59136
59532
  // src/_generated/version.ts
59137
- var PKG_VERSION = "0.4.101";
59533
+ var PKG_VERSION = "0.4.104";
59138
59534
 
59139
59535
  // src/director-closure.ts
59140
59536
  var CLOSURE_SNAPSHOT_TIMEOUT_MS = 2e3;
@@ -73639,7 +74035,7 @@ function renderContextPrefix(context) {
73639
74035
  return parts.join("\n\n");
73640
74036
  }
73641
74037
 
73642
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
74038
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
73643
74039
  var ExperimentalServerTasks = class {
73644
74040
  constructor(_server) {
73645
74041
  this._server = _server;
@@ -73852,7 +74248,7 @@ var ExperimentalServerTasks = class {
73852
74248
  }
73853
74249
  };
73854
74250
 
73855
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
74251
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
73856
74252
  var Server = class extends Protocol {
73857
74253
  /**
73858
74254
  * Initializes this server with the given name and version information.
@@ -74223,7 +74619,7 @@ var Server = class extends Protocol {
74223
74619
  }
74224
74620
  };
74225
74621
 
74226
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
74622
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
74227
74623
  var import_node_process2 = __toESM(require("node:process"), 1);
74228
74624
  var StdioServerTransport = class {
74229
74625
  constructor(_stdin = import_node_process2.default.stdin, _stdout = import_node_process2.default.stdout, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.101",
3
+ "version": "0.4.104",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"
@@ -16,11 +16,11 @@
16
16
  "dependencies": {
17
17
  "@clack/prompts": "^0.8.2",
18
18
  "@iarna/toml": "^2.2.5",
19
- "@modelcontextprotocol/sdk": "^1.6.0",
19
+ "@modelcontextprotocol/sdk": "^1.32.0",
20
20
  "@mrrlin-dev/external-agents": "latest",
21
21
  "@playwright/mcp": "0.0.76",
22
22
  "dotenv": "^16.4.5",
23
- "hono": "^4.7.2",
23
+ "hono": "^4.13.11",
24
24
  "playwright-core": "1.61.0-alpha-1781023400000",
25
25
  "proper-lockfile": "^4.1.2",
26
26
  "qrcode": "^1.5.3",