@frontmcp/sdk 1.10.12 → 1.10.13

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.
@@ -59,7 +59,9 @@ var stateSchema = z.object({
59
59
  promptContext: z.any(),
60
60
  // z.any() used because prompt output type varies by prompt implementation
61
61
  rawOutput: z.any().optional(),
62
- output: outputSchema
62
+ output: outputSchema,
63
+ // Why the flow failed, set by the flow runner before the finalize stage
64
+ flowError: z.instanceof(Error).optional()
63
65
  });
64
66
  var plan = {
65
67
  pre: [
@@ -288,7 +290,11 @@ var GetPromptFlow = class extends FlowBase {
288
290
  }
289
291
  async finalize() {
290
292
  this.logger.verbose("finalize:start");
291
- const { prompt, rawOutput, input } = this.state;
293
+ const { prompt, rawOutput, input, flowError } = this.state;
294
+ if (flowError) {
295
+ this.logger.verbose("finalize: skipping, an earlier stage failed");
296
+ return;
297
+ }
292
298
  if (!prompt) {
293
299
  this.logger.error("finalize: prompt not found in state");
294
300
  throw new PromptExecutionError("unknown", new Error("Prompt not found in state"));
@@ -64,7 +64,9 @@ var stateSchema = z.object({
64
64
  // Flag indicating this is a UI resource (ui:// scheme)
65
65
  isUIResource: z.boolean().default(false),
66
66
  // Pre-resolved UI resource result (if isUIResource is true)
67
- uiResourceResult: outputSchema.optional()
67
+ uiResourceResult: outputSchema.optional(),
68
+ // Why the flow failed, set by the flow runner before the finalize stage
69
+ flowError: z.instanceof(Error).optional()
68
70
  });
69
71
  var plan = {
70
72
  pre: ["parseInput", "ensureRemoteCapabilities", "findResource", "checkEntryAuthorities", "createResourceContext"],
@@ -312,6 +314,10 @@ var ReadResourceFlow = class extends FlowBase {
312
314
  }
313
315
  async finalize() {
314
316
  this.logger.verbose("finalize:start");
317
+ if (this.state.flowError) {
318
+ this.logger.verbose("finalize: skipping, an earlier stage failed");
319
+ return;
320
+ }
315
321
  if (this.state.isUIResource) {
316
322
  const { uiResourceResult, input: input2 } = this.state;
317
323
  if (!uiResourceResult) {
@@ -1,5 +1,6 @@
1
1
  // libs/sdk/src/transport/mcp-20260728/dispatcher.ts
2
2
  import { isAnonymousSubject } from "@frontmcp/auth";
3
+ import { z } from "@frontmcp/lazy-zod";
3
4
  import {
4
5
  MCP_20260728_ERROR_CODES,
5
6
  MCP_20260728_REMOVED_METHODS,
@@ -92,6 +93,17 @@ function methodOfSchema(schema) {
92
93
  const values = method?._def?.values;
93
94
  return Array.isArray(values) && typeof values[0] === "string" ? values[0] : void 0;
94
95
  }
96
+ var MRTR_PARAMS_SCHEMA = z.object({
97
+ params: z.object({ inputResponses: z.record(z.string(), z.record(z.string(), z.unknown())).optional() }).optional()
98
+ });
99
+ function describeInvalidParams(schema, body) {
100
+ const issues = [schema.safeParse(body), MRTR_PARAMS_SCHEMA.safeParse(body)].flatMap(
101
+ (parsed) => parsed.success ? [] : parsed.error.issues
102
+ );
103
+ if (issues.length === 0) return void 0;
104
+ const problems = issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`);
105
+ return `Invalid params: ${problems.join("; ")}`;
106
+ }
95
107
  function toJsonRpcError(error) {
96
108
  if (error instanceof MissingClientCapabilityError) {
97
109
  return {
@@ -190,6 +202,10 @@ async function dispatch20260728(options) {
190
202
  if (!handler) {
191
203
  return { kind: "error", status: 404, error: { code: -32601, message: `Method not found: ${method}` } };
192
204
  }
205
+ const invalidParams = describeInvalidParams(handler.requestSchema, body);
206
+ if (invalidParams) {
207
+ return { kind: "error", status: 200, error: { code: -32602, message: invalidParams } };
208
+ }
193
209
  const binding = {
194
210
  principal: resolvePrincipal(authInfo),
195
211
  binding: computeRequestBinding(method, params)
@@ -45,6 +45,7 @@ function initializeRequestHandler({
45
45
  request.params.capabilities?.elicitation ? { elicitation: request.params.capabilities.elicitation } : void 0
46
46
  );
47
47
  if (sessionId) {
48
+ const hasRegisteredServer = scope.notifications.getRegisteredServer(sessionId) !== void 0;
48
49
  if (request.params.capabilities) {
49
50
  const clientCapabilities = {
50
51
  roots: request.params.capabilities.roots,
@@ -56,7 +57,7 @@ function initializeRequestHandler({
56
57
  // Include elicitation capability for interactive user input support
57
58
  elicitation: request.params.capabilities.elicitation
58
59
  };
59
- scope.notifications.setClientCapabilities(sessionId, clientCapabilities);
60
+ if (hasRegisteredServer) scope.notifications.setClientCapabilities(sessionId, clientCapabilities);
60
61
  await scope.transportService?.updateStoredSessionCapabilities(
61
62
  sessionId,
62
63
  clientCapabilities
@@ -65,10 +66,12 @@ function initializeRequestHandler({
65
66
  }
66
67
  if (request.params.clientInfo) {
67
68
  const { name: clientName, version: clientVersion } = request.params.clientInfo;
68
- scope.notifications.setClientInfo(sessionId, {
69
- name: clientName,
70
- version: clientVersion
71
- });
69
+ if (hasRegisteredServer) {
70
+ scope.notifications.setClientInfo(sessionId, {
71
+ name: clientName,
72
+ version: clientVersion
73
+ });
74
+ }
72
75
  const finalPlatform = resolvePlatformType(
73
76
  request.params.clientInfo,
74
77
  request.params.capabilities,