@settlemint/sdk-mcp 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.js CHANGED
@@ -53834,8 +53834,14 @@ var ToolSchema = z.object({
53834
53834
  description: z.optional(z.string()),
53835
53835
  inputSchema: z.object({
53836
53836
  type: z.literal("object"),
53837
- properties: z.optional(z.object({}).passthrough())
53837
+ properties: z.optional(z.object({}).passthrough()),
53838
+ required: z.optional(z.array(z.string()))
53838
53839
  }).passthrough(),
53840
+ outputSchema: z.optional(z.object({
53841
+ type: z.literal("object"),
53842
+ properties: z.optional(z.object({}).passthrough()),
53843
+ required: z.optional(z.array(z.string()))
53844
+ }).passthrough()),
53839
53845
  annotations: z.optional(ToolAnnotationsSchema)
53840
53846
  }).passthrough();
53841
53847
  var ListToolsRequestSchema = PaginatedRequestSchema.extend({
@@ -53844,10 +53850,26 @@ var ListToolsRequestSchema = PaginatedRequestSchema.extend({
53844
53850
  var ListToolsResultSchema = PaginatedResultSchema.extend({
53845
53851
  tools: z.array(ToolSchema)
53846
53852
  });
53847
- var CallToolResultSchema = ResultSchema.extend({
53848
- content: z.array(z.union([TextContentSchema, ImageContentSchema, AudioContentSchema, EmbeddedResourceSchema])),
53849
- isError: z.boolean().default(false).optional()
53853
+ var ContentListSchema = z.array(z.union([
53854
+ TextContentSchema,
53855
+ ImageContentSchema,
53856
+ AudioContentSchema,
53857
+ EmbeddedResourceSchema
53858
+ ]));
53859
+ var CallToolUnstructuredResultSchema = ResultSchema.extend({
53860
+ content: ContentListSchema,
53861
+ structuredContent: z.never().optional(),
53862
+ isError: z.optional(z.boolean())
53850
53863
  });
53864
+ var CallToolStructuredResultSchema = ResultSchema.extend({
53865
+ structuredContent: z.object({}).passthrough(),
53866
+ content: z.optional(ContentListSchema),
53867
+ isError: z.optional(z.boolean())
53868
+ });
53869
+ var CallToolResultSchema = z.union([
53870
+ CallToolUnstructuredResultSchema,
53871
+ CallToolStructuredResultSchema
53872
+ ]);
53851
53873
  var CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
53852
53874
  toolResult: z.unknown()
53853
53875
  }));
@@ -55766,7 +55788,7 @@ class McpServer {
55766
55788
  });
55767
55789
  this.server.setRequestHandler(ListToolsRequestSchema, () => ({
55768
55790
  tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
55769
- return {
55791
+ const toolDefinition = {
55770
55792
  name,
55771
55793
  description: tool.description,
55772
55794
  inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
@@ -55774,6 +55796,10 @@ class McpServer {
55774
55796
  }) : EMPTY_OBJECT_JSON_SCHEMA,
55775
55797
  annotations: tool.annotations
55776
55798
  };
55799
+ if (tool.outputSchema) {
55800
+ toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, { strictUnions: true });
55801
+ }
55802
+ return toolDefinition;
55777
55803
  })
55778
55804
  }));
55779
55805
  this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
@@ -55784,6 +55810,7 @@ class McpServer {
55784
55810
  if (!tool.enabled) {
55785
55811
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
55786
55812
  }
55813
+ let result;
55787
55814
  if (tool.inputSchema) {
55788
55815
  const parseResult = await tool.inputSchema.safeParseAsync(request.params.arguments);
55789
55816
  if (!parseResult.success) {
@@ -55792,9 +55819,9 @@ class McpServer {
55792
55819
  const args = parseResult.data;
55793
55820
  const cb = tool.callback;
55794
55821
  try {
55795
- return await Promise.resolve(cb(args, extra));
55822
+ result = await Promise.resolve(cb(args, extra));
55796
55823
  } catch (error) {
55797
- return {
55824
+ result = {
55798
55825
  content: [
55799
55826
  {
55800
55827
  type: "text",
@@ -55807,9 +55834,9 @@ class McpServer {
55807
55834
  } else {
55808
55835
  const cb = tool.callback;
55809
55836
  try {
55810
- return await Promise.resolve(cb(extra));
55837
+ result = await Promise.resolve(cb(extra));
55811
55838
  } catch (error) {
55812
- return {
55839
+ result = {
55813
55840
  content: [
55814
55841
  {
55815
55842
  type: "text",
@@ -55820,6 +55847,27 @@ class McpServer {
55820
55847
  };
55821
55848
  }
55822
55849
  }
55850
+ if (tool.outputSchema) {
55851
+ if (!result.structuredContent && !result.isError) {
55852
+ throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has outputSchema but returned no structuredContent`);
55853
+ }
55854
+ if (result.structuredContent && !result.content) {
55855
+ result.content = [
55856
+ {
55857
+ type: "text",
55858
+ text: JSON.stringify(result.structuredContent, null, 2)
55859
+ }
55860
+ ];
55861
+ }
55862
+ } else {
55863
+ if (!result.content && !result.isError) {
55864
+ throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has no outputSchema and must return content`);
55865
+ }
55866
+ if (result.structuredContent) {
55867
+ throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has no outputSchema but returned structuredContent`);
55868
+ }
55869
+ }
55870
+ return result;
55823
55871
  });
55824
55872
  this._toolHandlersInitialized = true;
55825
55873
  }
@@ -56053,33 +56101,13 @@ class McpServer {
56053
56101
  return registeredResourceTemplate;
56054
56102
  }
56055
56103
  }
56056
- tool(name, ...rest) {
56057
- if (this._registeredTools[name]) {
56058
- throw new Error(`Tool ${name} is already registered`);
56059
- }
56060
- let description;
56061
- if (typeof rest[0] === "string") {
56062
- description = rest.shift();
56063
- }
56064
- let paramsSchema;
56065
- let annotations;
56066
- if (rest.length > 1) {
56067
- const firstArg = rest[0];
56068
- if (isZodRawShape(firstArg)) {
56069
- paramsSchema = rest.shift();
56070
- if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShape(rest[0])) {
56071
- annotations = rest.shift();
56072
- }
56073
- } else if (typeof firstArg === "object" && firstArg !== null) {
56074
- annotations = rest.shift();
56075
- }
56076
- }
56077
- const cb = rest[0];
56104
+ _createRegisteredTool(name, description, inputSchema, outputSchema, annotations, callback) {
56078
56105
  const registeredTool = {
56079
56106
  description,
56080
- inputSchema: paramsSchema === undefined ? undefined : z.object(paramsSchema),
56107
+ inputSchema: inputSchema === undefined ? undefined : z.object(inputSchema),
56108
+ outputSchema: outputSchema === undefined ? undefined : z.object(outputSchema),
56081
56109
  annotations,
56082
- callback: cb,
56110
+ callback,
56083
56111
  enabled: true,
56084
56112
  disable: () => registeredTool.update({ enabled: false }),
56085
56113
  enable: () => registeredTool.update({ enabled: true }),
@@ -56108,6 +56136,38 @@ class McpServer {
56108
56136
  this.sendToolListChanged();
56109
56137
  return registeredTool;
56110
56138
  }
56139
+ tool(name, ...rest) {
56140
+ if (this._registeredTools[name]) {
56141
+ throw new Error(`Tool ${name} is already registered`);
56142
+ }
56143
+ let description;
56144
+ let inputSchema;
56145
+ let outputSchema;
56146
+ let annotations;
56147
+ if (typeof rest[0] === "string") {
56148
+ description = rest.shift();
56149
+ }
56150
+ if (rest.length > 1) {
56151
+ const firstArg = rest[0];
56152
+ if (isZodRawShape(firstArg)) {
56153
+ inputSchema = rest.shift();
56154
+ if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShape(rest[0])) {
56155
+ annotations = rest.shift();
56156
+ }
56157
+ } else if (typeof firstArg === "object" && firstArg !== null) {
56158
+ annotations = rest.shift();
56159
+ }
56160
+ }
56161
+ const callback = rest[0];
56162
+ return this._createRegisteredTool(name, description, inputSchema, outputSchema, annotations, callback);
56163
+ }
56164
+ registerTool(name, config, cb) {
56165
+ if (this._registeredTools[name]) {
56166
+ throw new Error(`Tool ${name} is already registered`);
56167
+ }
56168
+ const { description, inputSchema, outputSchema, annotations } = config;
56169
+ return this._createRegisteredTool(name, description, inputSchema, outputSchema, annotations, cb);
56170
+ }
56111
56171
  prompt(name, ...rest) {
56112
56172
  if (this._registeredPrompts[name]) {
56113
56173
  throw new Error(`Prompt ${name} is already registered`);
@@ -56300,7 +56360,7 @@ class StdioServerTransport {
56300
56360
  }
56301
56361
 
56302
56362
  // ../utils/dist/environment.mjs
56303
- import { join as join2 } from "node:path";
56363
+ import { join as join2 } from "path";
56304
56364
 
56305
56365
  // ../../node_modules/yoctocolors/base.js
56306
56366
  import tty from "node:tty";
@@ -61874,7 +61934,7 @@ var {
61874
61934
  var package_default = {
61875
61935
  name: "@settlemint/sdk-mcp",
61876
61936
  description: "MCP interface for SettleMint SDK, providing development tools and project management capabilities",
61877
- version: "2.3.0",
61937
+ version: "2.3.1",
61878
61938
  type: "module",
61879
61939
  private: false,
61880
61940
  license: "FSL-1.1-MIT",
@@ -61915,9 +61975,9 @@ var package_default = {
61915
61975
  dependencies: {
61916
61976
  "@graphql-tools/load": "8.1.0",
61917
61977
  "@graphql-tools/url-loader": "8.0.31",
61918
- "@modelcontextprotocol/sdk": "1.11.3",
61919
- "@settlemint/sdk-js": "2.3.0",
61920
- "@settlemint/sdk-utils": "2.3.0",
61978
+ "@modelcontextprotocol/sdk": "1.11.4",
61979
+ "@settlemint/sdk-js": "2.3.1",
61980
+ "@settlemint/sdk-utils": "2.3.1",
61921
61981
  "@commander-js/extra-typings": "11.1.0",
61922
61982
  commander: "11.1.0",
61923
61983
  zod: "3.24.4"
@@ -64207,7 +64267,7 @@ function initGraphQLTada() {
64207
64267
  var t3 = initGraphQLTada();
64208
64268
 
64209
64269
  // ../js/dist/settlemint.mjs
64210
- import { createHash } from "node:crypto";
64270
+ import { createHash } from "crypto";
64211
64271
  var graphql = initGraphQLTada();
64212
64272
  var WorkspaceFragment = graphql(`
64213
64273
  fragment Workspace on Workspace {
@@ -67687,4 +67747,4 @@ await main().catch((error2) => {
67687
67747
  process.exit(1);
67688
67748
  });
67689
67749
 
67690
- //# debugId=433800AB979D17CA64756E2164756E21
67750
+ //# debugId=7977AEEEF7D562C264756E2164756E21