@procedures/mcp 0.0.0-stage → 0.2.0

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 (54) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +21 -0
  3. package/README.md +359 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/context/index.d.ts +5 -0
  6. package/dist/context/index.d.ts.map +1 -0
  7. package/dist/context/index.js +5 -0
  8. package/dist/context/index.js.map +1 -0
  9. package/dist/context/mcp-context.d.ts +57 -0
  10. package/dist/context/mcp-context.d.ts.map +1 -0
  11. package/dist/context/mcp-context.js +40 -0
  12. package/dist/context/mcp-context.js.map +1 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +15 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/mapping/index.d.ts +6 -0
  18. package/dist/mapping/index.d.ts.map +1 -0
  19. package/dist/mapping/index.js +6 -0
  20. package/dist/mapping/index.js.map +1 -0
  21. package/dist/mapping/path-encoder.d.ts +72 -0
  22. package/dist/mapping/path-encoder.d.ts.map +1 -0
  23. package/dist/mapping/path-encoder.js +93 -0
  24. package/dist/mapping/path-encoder.js.map +1 -0
  25. package/dist/mapping/procedure-to-tool.d.ts +47 -0
  26. package/dist/mapping/procedure-to-tool.d.ts.map +1 -0
  27. package/dist/mapping/procedure-to-tool.js +172 -0
  28. package/dist/mapping/procedure-to-tool.js.map +1 -0
  29. package/dist/schema/index.d.ts +5 -0
  30. package/dist/schema/index.d.ts.map +1 -0
  31. package/dist/schema/index.js +5 -0
  32. package/dist/schema/index.js.map +1 -0
  33. package/dist/schema/tool-schema.d.ts +77 -0
  34. package/dist/schema/tool-schema.d.ts.map +1 -0
  35. package/dist/schema/tool-schema.js +103 -0
  36. package/dist/schema/tool-schema.js.map +1 -0
  37. package/dist/schema/zod-to-json-schema.d.ts +58 -0
  38. package/dist/schema/zod-to-json-schema.d.ts.map +1 -0
  39. package/dist/schema/zod-to-json-schema.js +79 -0
  40. package/dist/schema/zod-to-json-schema.js.map +1 -0
  41. package/dist/types.d.ts +111 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +8 -0
  44. package/dist/types.js.map +1 -0
  45. package/package.json +63 -3
  46. package/src/context/index.ts +10 -0
  47. package/src/context/mcp-context.ts +80 -0
  48. package/src/index.ts +57 -0
  49. package/src/mapping/index.ts +20 -0
  50. package/src/mapping/path-encoder.ts +103 -0
  51. package/src/mapping/procedure-to-tool.ts +217 -0
  52. package/src/schema/index.ts +15 -0
  53. package/src/schema/tool-schema.ts +135 -0
  54. package/src/types.ts +120 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Path Encoder
3
+ *
4
+ * Converts procedure paths to/from MCP tool names.
5
+ * MCP tool names should be valid identifiers (alphanumeric with dots/underscores).
6
+ */
7
+ /**
8
+ * Encode a procedure path to an MCP tool name.
9
+ *
10
+ * Strategy: Join path segments with dots.
11
+ * Most procedure paths are already MCP-compatible (lowercase, alphanumeric).
12
+ *
13
+ * @param path - Procedure path array
14
+ * @returns MCP tool name string
15
+ *
16
+ * @example
17
+ * encodePath(["fs", "read"]) // "fs.read"
18
+ * encodePath(["mongo", "collections", "list"]) // "mongo.collections.list"
19
+ */
20
+ export function encodePath(path) {
21
+ return path.join(".");
22
+ }
23
+ /**
24
+ * Decode an MCP tool name back to procedure path.
25
+ *
26
+ * @param toolName - MCP tool name string
27
+ * @returns Procedure path array
28
+ *
29
+ * @example
30
+ * decodePath("fs.read") // ["fs", "read"]
31
+ * decodePath("mongo.collections.list") // ["mongo", "collections", "list"]
32
+ */
33
+ export function decodePath(toolName) {
34
+ return toolName.split(".");
35
+ }
36
+ /**
37
+ * Validate that a path segment is MCP-compatible.
38
+ *
39
+ * Valid segments:
40
+ * - Start with letter or underscore
41
+ * - Contain only letters, numbers, underscores, hyphens
42
+ *
43
+ * @param segment - Path segment to validate
44
+ * @returns True if segment is valid for MCP tool names
45
+ */
46
+ export function isValidPathSegment(segment) {
47
+ return /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(segment);
48
+ }
49
+ /**
50
+ * Validate that an entire path is MCP-compatible.
51
+ *
52
+ * @param path - Procedure path to validate
53
+ * @returns True if all segments are valid
54
+ */
55
+ export function isValidPath(path) {
56
+ return path.length > 0 && path.every(isValidPathSegment);
57
+ }
58
+ /**
59
+ * Sanitize a path segment for MCP compatibility.
60
+ *
61
+ * Replaces invalid characters with underscores.
62
+ *
63
+ * @param segment - Path segment to sanitize
64
+ * @returns Sanitized segment
65
+ *
66
+ * @example
67
+ * sanitizePathSegment("my-func") // "my-func" (valid)
68
+ * sanitizePathSegment("123abc") // "_123abc" (prefix if starts with number)
69
+ * sanitizePathSegment("my.func") // "my_func" (replace dots)
70
+ */
71
+ export function sanitizePathSegment(segment) {
72
+ // Replace invalid chars with underscores
73
+ let sanitized = segment.replace(/[^a-zA-Z0-9_-]/g, "_");
74
+ // Prefix if starts with number
75
+ if (/^[0-9]/.test(sanitized)) {
76
+ sanitized = "_" + sanitized;
77
+ }
78
+ // Ensure not empty
79
+ if (!sanitized) {
80
+ sanitized = "_";
81
+ }
82
+ return sanitized;
83
+ }
84
+ /**
85
+ * Sanitize an entire path for MCP compatibility.
86
+ *
87
+ * @param path - Procedure path to sanitize
88
+ * @returns Sanitized path
89
+ */
90
+ export function sanitizePath(path) {
91
+ return path.map(sanitizePathSegment);
92
+ }
93
+ //# sourceMappingURL=path-encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-encoder.js","sourceRoot":"","sources":["../../src/mapping/path-encoder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAC,IAAmB;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACnD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAmB;IAC7C,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,yCAAyC;IACzC,IAAI,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IAExD,+BAA+B;IAC/B,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,SAAS,GAAG,GAAG,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,mBAAmB;IACnB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Procedure to MCP Tool Mapper
3
+ *
4
+ * Converts procedures from PROCEDURE_REGISTRY to MCP tool definitions.
5
+ */
6
+ import { type AnyProcedure, type ProcedurePath } from "@procedures/client";
7
+ import type { McpTool, McpToolDefinition, McpToolFilter } from "../types.js";
8
+ /**
9
+ * Convert a single procedure to an MCP tool definition.
10
+ *
11
+ * @param procedure - Procedure to convert
12
+ * @returns MCP tool with procedure metadata
13
+ */
14
+ export declare function procedureToMcpTool(procedure: AnyProcedure): McpTool;
15
+ /**
16
+ * Convert an MCP tool to the minimal definition format (for ListToolsRequest).
17
+ *
18
+ * @param tool - Full MCP tool with metadata
19
+ * @returns Minimal tool definition for MCP protocol
20
+ */
21
+ export declare function toToolDefinition(tool: McpTool): McpToolDefinition;
22
+ /**
23
+ * Convert multiple procedures to MCP tools.
24
+ *
25
+ * Filters out procedures without handlers and applies optional filters.
26
+ *
27
+ * @param procedures - Procedures to convert
28
+ * @param filter - Optional filter options
29
+ * @returns Array of MCP tools
30
+ */
31
+ export declare function proceduresToMcpTools(procedures: AnyProcedure[], filter?: McpToolFilter): McpTool[];
32
+ /**
33
+ * Create a lookup map from tool name to MCP tool.
34
+ *
35
+ * @param tools - Array of MCP tools
36
+ * @returns Map for O(1) lookup by tool name
37
+ */
38
+ export declare function createToolMap(tools: McpTool[]): Map<string, McpTool>;
39
+ /**
40
+ * Find a tool by procedure path.
41
+ *
42
+ * @param tools - Array or map of MCP tools
43
+ * @param path - Procedure path to find
44
+ * @returns Tool if found, undefined otherwise
45
+ */
46
+ export declare function findToolByPath(tools: McpTool[] | Map<string, McpTool>, path: ProcedurePath): McpTool | undefined;
47
+ //# sourceMappingURL=procedure-to-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure-to-tool.d.ts","sourceRoot":"","sources":["../../src/mapping/procedure-to-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAa,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA+B7E;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAsCnE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,CAiBjE;AA2CD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,YAAY,EAAE,EAC1B,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,EAAE,CAKX;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBpE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,IAAI,EAAE,aAAa,GAClB,OAAO,GAAG,SAAS,CAUrB"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Procedure to MCP Tool Mapper
3
+ *
4
+ * Converts procedures from PROCEDURE_REGISTRY to MCP tool definitions.
5
+ */
6
+ import { toolHints } from "@procedures/client";
7
+ import { cachedToolInputSchema, cachedToolOutputSchema } from "../schema/tool-schema.js";
8
+ import { encodePath, sanitizePath } from "./path-encoder.js";
9
+ /**
10
+ * Extract metadata from a procedure.
11
+ */
12
+ function extractMetadata(procedure) {
13
+ const meta = procedure.metadata;
14
+ return {
15
+ description: meta?.["description"],
16
+ tags: meta?.["tags"],
17
+ internal: meta?.["internal"],
18
+ };
19
+ }
20
+ /**
21
+ * Convert a single procedure to an MCP tool definition.
22
+ *
23
+ * @param procedure - Procedure to convert
24
+ * @returns MCP tool with procedure metadata
25
+ */
26
+ export function procedureToMcpTool(procedure) {
27
+ // Sanitize each path segment (replacing chars outside [A-Za-z0-9_-], e.g. a
28
+ // literal "." inside a single segment) before dot-joining. This keeps the
29
+ // dot-joined shape valid segments already have (["shell","run"] -> "shell.run",
30
+ // which the Claude client aliases to "shell_run"), while ensuring two distinct
31
+ // paths that would otherwise encode to the same string no longer collide.
32
+ const toolName = encodePath(sanitizePath(procedure.path));
33
+ const cacheKey = procedure.path.join(".");
34
+ const meta = extractMetadata(procedure);
35
+ const tool = {
36
+ name: toolName,
37
+ description: meta.description ?? `Call ${cacheKey}`,
38
+ inputSchema: cachedToolInputSchema(procedure.input, cacheKey),
39
+ procedurePath: procedure.path,
40
+ };
41
+ // MCP structured output: only an output whose JSON Schema is an object
42
+ const outputSchema = cachedToolOutputSchema(procedure.output);
43
+ if (outputSchema !== undefined) {
44
+ tool.outputSchema = outputSchema;
45
+ }
46
+ // The hints of the tool, from the declared effects (CAPABILITIES-2026-10)
47
+ const hints = toolHints(procedure);
48
+ if (Object.keys(hints).length > 0) {
49
+ tool.annotations = { ...hints };
50
+ }
51
+ // Only add optional properties if they have values
52
+ if (procedure.streaming !== undefined) {
53
+ tool.streaming = procedure.streaming;
54
+ }
55
+ if (meta.tags !== undefined) {
56
+ tool.tags = meta.tags;
57
+ }
58
+ return tool;
59
+ }
60
+ /**
61
+ * Convert an MCP tool to the minimal definition format (for ListToolsRequest).
62
+ *
63
+ * @param tool - Full MCP tool with metadata
64
+ * @returns Minimal tool definition for MCP protocol
65
+ */
66
+ export function toToolDefinition(tool) {
67
+ const def = {
68
+ name: tool.name,
69
+ inputSchema: tool.inputSchema,
70
+ };
71
+ if (tool.description !== undefined) {
72
+ def.description = tool.description;
73
+ }
74
+ if (tool.outputSchema !== undefined) {
75
+ def.outputSchema = tool.outputSchema;
76
+ }
77
+ if (tool.annotations !== undefined) {
78
+ def.annotations = tool.annotations;
79
+ }
80
+ return def;
81
+ }
82
+ /**
83
+ * Check if a procedure matches the given filter.
84
+ */
85
+ function matchesFilter(procedure, filter) {
86
+ if (!filter)
87
+ return true;
88
+ const meta = extractMetadata(procedure);
89
+ // Check internal filter
90
+ if (filter.excludeInternal !== false && meta.internal) {
91
+ return false;
92
+ }
93
+ // Check the include function
94
+ if (filter.include && !filter.include(procedure.path)) {
95
+ return false;
96
+ }
97
+ // Check path prefix
98
+ if (filter.pathPrefix) {
99
+ const matches = filter.pathPrefix.every((segment, i) => procedure.path[i] === segment);
100
+ if (!matches)
101
+ return false;
102
+ }
103
+ // Check tag inclusion
104
+ if (filter.includeTags?.length) {
105
+ const hasTags = meta.tags?.some((t) => filter.includeTags.includes(t));
106
+ if (!hasTags)
107
+ return false;
108
+ }
109
+ // Check tag exclusion
110
+ if (filter.excludeTags?.length) {
111
+ const hasExcludedTag = meta.tags?.some((t) => filter.excludeTags.includes(t));
112
+ if (hasExcludedTag)
113
+ return false;
114
+ }
115
+ return true;
116
+ }
117
+ /**
118
+ * Convert multiple procedures to MCP tools.
119
+ *
120
+ * Filters out procedures without handlers and applies optional filters.
121
+ *
122
+ * @param procedures - Procedures to convert
123
+ * @param filter - Optional filter options
124
+ * @returns Array of MCP tools
125
+ */
126
+ export function proceduresToMcpTools(procedures, filter) {
127
+ return procedures
128
+ .filter((p) => p.handler !== undefined)
129
+ .filter((p) => matchesFilter(p, filter))
130
+ .map(procedureToMcpTool);
131
+ }
132
+ /**
133
+ * Create a lookup map from tool name to MCP tool.
134
+ *
135
+ * @param tools - Array of MCP tools
136
+ * @returns Map for O(1) lookup by tool name
137
+ */
138
+ export function createToolMap(tools) {
139
+ const map = new Map();
140
+ for (const tool of tools) {
141
+ const existing = map.get(tool.name);
142
+ if (existing !== undefined) {
143
+ // Two distinct procedure paths encoded to the same MCP tool name. The
144
+ // Map preserves last-wins semantics (for backward compatibility), but
145
+ // this silently shadowed a tool before — warn on stderr so the collision
146
+ // is visible. stderr is used because stdout is reserved for the MCP
147
+ // stdio protocol stream.
148
+ console.error(`[mcp] Tool-name collision: "${tool.name}" is produced by both ` +
149
+ `[${existing.procedurePath.join(", ")}] and ` +
150
+ `[${tool.procedurePath.join(", ")}]; keeping the latter (last-wins).`);
151
+ }
152
+ map.set(tool.name, tool);
153
+ }
154
+ return map;
155
+ }
156
+ /**
157
+ * Find a tool by procedure path.
158
+ *
159
+ * @param tools - Array or map of MCP tools
160
+ * @param path - Procedure path to find
161
+ * @returns Tool if found, undefined otherwise
162
+ */
163
+ export function findToolByPath(tools, path) {
164
+ // Must match the sanitization applied in procedureToMcpTool so lookups by
165
+ // path resolve to the same tool name that was stored.
166
+ const toolName = encodePath(sanitizePath(path));
167
+ if (tools instanceof Map) {
168
+ return tools.get(toolName);
169
+ }
170
+ return tools.find((t) => t.name === toolName);
171
+ }
172
+ //# sourceMappingURL=procedure-to-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure-to-tool.js","sourceRoot":"","sources":["../../src/mapping/procedure-to-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAyC,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiB7D;;GAEG;AACH,SAAS,eAAe,CAAC,SAAuB;IAC9C,MAAM,IAAI,GAAG,SAAS,CAAC,QAA+C,CAAC;IACvE,OAAO;QACL,WAAW,EAAE,IAAI,EAAE,CAAC,aAAa,CAAuB;QACxD,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,CAAyB;QAC5C,QAAQ,EAAE,IAAI,EAAE,CAAC,UAAU,CAAwB;KACpD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAuB;IACxD,4EAA4E;IAC5E,0EAA0E;IAC1E,gFAAgF;IAChF,+EAA+E;IAC/E,0EAA0E;IAC1E,MAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAExC,MAAM,IAAI,GAAY;QACpB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,QAAQ,QAAQ,EAAE;QACnD,WAAW,EAAE,qBAAqB,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC;QAC7D,aAAa,EAAE,S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sD;IACtD,MAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhD,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Schema utilities exports.
3
+ */
4
+ export { toolInputSchema, cachedToolInputSchema, toolOutputSchema, cachedToolOutputSchema, zodToJsonSchema, cachedZodToJsonSchema, clearSchemaCache, getSchemaCacheSize, type ZodToJsonSchemaOptions, } from "./tool-schema.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,sBAAsB,GAC5B,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Schema utilities exports.
3
+ */
4
+ export { toolInputSchema, cachedToolInputSchema, toolOutputSchema, cachedToolOutputSchema, zodToJsonSchema, cachedZodToJsonSchema, clearSchemaCache, getSchemaCacheSize, } from "./tool-schema.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The input JSON Schema of an MCP tool.
3
+ *
4
+ * The JSON Schema comes from `jsonSchemaOf()` of the core, which reads any Standard Schema
5
+ * (zod 4 and other libraries). Before, this file converted schemas with the zod 3 library
6
+ * `zod-to-json-schema`, and a schema without zod 3 fields got an empty object schema.
7
+ */
8
+ import { type ProcedureSchema } from "@procedures/client";
9
+ import type { JsonSchema } from "../types.js";
10
+ /**
11
+ * A schema of a procedure.
12
+ * @deprecated Use `ProcedureSchema` of `@procedures/client`.
13
+ */
14
+ export interface SchemaLike {
15
+ parse?(data: unknown): unknown;
16
+ safeParse?(data: unknown): {
17
+ success: boolean;
18
+ data?: unknown;
19
+ error?: unknown;
20
+ };
21
+ }
22
+ /**
23
+ * Options for the conversion.
24
+ * @deprecated The options are not used. The core gives draft-07 JSON Schema without definitions.
25
+ */
26
+ export interface ZodToJsonSchemaOptions {
27
+ /** Name for the schema (not used) */
28
+ name?: string;
29
+ /** Pre-existing definitions (not used) */
30
+ definitions?: Record<string, unknown>;
31
+ }
32
+ /**
33
+ * The input JSON Schema of a tool for a procedure schema.
34
+ *
35
+ * MCP passes the arguments of a tool as an object, so an input that is not an object (a
36
+ * pass-through schema, a schema with no JSON Schema, a number) gives an object schema that
37
+ * accepts any field.
38
+ */
39
+ export declare function toolInputSchema(schema: ProcedureSchema | unknown): JsonSchema;
40
+ /**
41
+ * The input JSON Schema of a tool.
42
+ * @deprecated Use `toolInputSchema` (the schema need not be zod), or `jsonSchemaOf` of
43
+ * `@procedures/client` for the JSON Schema of any input or output.
44
+ */
45
+ export declare function zodToJsonSchema(schema: SchemaLike | unknown, _options?: ZodToJsonSchemaOptions): JsonSchema;
46
+ /**
47
+ * The input JSON Schema of a tool, cached by the schema object.
48
+ *
49
+ * @param schema - The input schema of the procedure
50
+ * @param _cacheKey - Not used any more (kept for compatibility): the schema object is the key
51
+ */
52
+ export declare function cachedToolInputSchema(schema: ProcedureSchema | unknown, _cacheKey?: string): JsonSchema;
53
+ /**
54
+ * The output JSON Schema of a tool (MCP structured output), or `undefined`.
55
+ *
56
+ * MCP needs an object at the root of an output schema, and a client can check each structured
57
+ * result against it. So only an output whose JSON Schema is an object gives one: a pass-through
58
+ * schema, a union (a stream of items) or a number gives none, and the tool gives text only.
59
+ */
60
+ export declare function toolOutputSchema(schema: ProcedureSchema | unknown): JsonSchema | undefined;
61
+ /** The output JSON Schema of a tool, cached by the schema object. */
62
+ export declare function cachedToolOutputSchema(schema: ProcedureSchema | unknown): JsonSchema | undefined;
63
+ /**
64
+ * The input JSON Schema of a tool, cached.
65
+ * @deprecated Use `cachedToolInputSchema`.
66
+ */
67
+ export declare function cachedZodToJsonSchema(schema: SchemaLike | unknown, cacheKey?: string): JsonSchema;
68
+ /**
69
+ * Clear the schema cache.
70
+ * Useful when procedures are re-registered with different schemas.
71
+ */
72
+ export declare function clearSchemaCache(): void;
73
+ /**
74
+ * Get the current schema cache size.
75
+ */
76
+ export declare function getSchemaCacheSize(): number;
77
+ //# sourceMappingURL=tool-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-schema.d.ts","sourceRoot":"","sources":["../../src/schema/tool-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC/B,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAClF;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAKD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,GAAG,UAAU,CAM7E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,sBAAsB,GAAG,UAAU,CAE3G;AAOD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAWvG;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAG1F;AAMD,qEAAqE;AACrE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAWhG;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAEjG;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The input JSON Schema of an MCP tool.
3
+ *
4
+ * The JSON Schema comes from `jsonSchemaOf()` of the core, which reads any Standard Schema
5
+ * (zod 4 and other libraries). Before, this file converted schemas with the zod 3 library
6
+ * `zod-to-json-schema`, and a schema without zod 3 fields got an empty object schema.
7
+ */
8
+ import { jsonSchemaOf } from "@procedures/client";
9
+ /** The input schema of a tool that takes any arguments. */
10
+ const ANY_OBJECT = { type: "object", additionalProperties: true };
11
+ /**
12
+ * The input JSON Schema of a tool for a procedure schema.
13
+ *
14
+ * MCP passes the arguments of a tool as an object, so an input that is not an object (a
15
+ * pass-through schema, a schema with no JSON Schema, a number) gives an object schema that
16
+ * accepts any field.
17
+ */
18
+ export function toolInputSchema(schema) {
19
+ const json = jsonSchemaOf(schema, { io: "input" });
20
+ if (json && json["type"] === "object") {
21
+ return json;
22
+ }
23
+ return { ...ANY_OBJECT };
24
+ }
25
+ /**
26
+ * The input JSON Schema of a tool.
27
+ * @deprecated Use `toolInputSchema` (the schema need not be zod), or `jsonSchemaOf` of
28
+ * `@procedures/client` for the JSON Schema of any input or output.
29
+ */
30
+ export function zodToJsonSchema(schema, _options) {
31
+ return toolInputSchema(schema);
32
+ }
33
+ // Schema cache for performance, keyed by the schema object: a procedure that is registered
34
+ // again with a different schema gets the new JSON Schema (BUGS-2026-07 L30: the cache was keyed
35
+ // by the procedure path and returned the old schema)
36
+ const schemaCache = new Map();
37
+ /**
38
+ * The input JSON Schema of a tool, cached by the schema object.
39
+ *
40
+ * @param schema - The input schema of the procedure
41
+ * @param _cacheKey - Not used any more (kept for compatibility): the schema object is the key
42
+ */
43
+ export function cachedToolInputSchema(schema, _cacheKey) {
44
+ if (!schema || typeof schema !== "object") {
45
+ return toolInputSchema(schema);
46
+ }
47
+ const cached = schemaCache.get(schema);
48
+ if (cached) {
49
+ return cached;
50
+ }
51
+ const jsonSchema = toolInputSchema(schema);
52
+ schemaCache.set(schema, jsonSchema);
53
+ return jsonSchema;
54
+ }
55
+ /**
56
+ * The output JSON Schema of a tool (MCP structured output), or `undefined`.
57
+ *
58
+ * MCP needs an object at the root of an output schema, and a client can check each structured
59
+ * result against it. So only an output whose JSON Schema is an object gives one: a pass-through
60
+ * schema, a union (a stream of items) or a number gives none, and the tool gives text only.
61
+ */
62
+ export function toolOutputSchema(schema) {
63
+ const json = jsonSchemaOf(schema, { io: "output" });
64
+ return json && json["type"] === "object" ? json : undefined;
65
+ }
66
+ // The output schemas, cached by the schema object like the input schemas. `null` keeps "no
67
+ // output schema", so the check runs once for each schema.
68
+ const outputSchemaCache = new Map();
69
+ /** The output JSON Schema of a tool, cached by the schema object. */
70
+ export function cachedToolOutputSchema(schema) {
71
+ if (!schema || typeof schema !== "object") {
72
+ return toolOutputSchema(schema);
73
+ }
74
+ const cached = outputSchemaCache.get(schema);
75
+ if (cached !== undefined) {
76
+ return cached ?? undefined;
77
+ }
78
+ const jsonSchema = toolOutputSchema(schema);
79
+ outputSchemaCache.set(schema, jsonSchema ?? null);
80
+ return jsonSchema;
81
+ }
82
+ /**
83
+ * The input JSON Schema of a tool, cached.
84
+ * @deprecated Use `cachedToolInputSchema`.
85
+ */
86
+ export function cachedZodToJsonSchema(schema, cacheKey) {
87
+ return cachedToolInputSchema(schema, cacheKey);
88
+ }
89
+ /**
90
+ * Clear the schema cache.
91
+ * Useful when procedures are re-registered with different schemas.
92
+ */
93
+ export function clearSchemaCache() {
94
+ schemaCache.clear();
95
+ outputSchemaCache.clear();
96
+ }
97
+ /**
98
+ * Get the current schema cache size.
99
+ */
100
+ export function getSchemaCacheSize() {
101
+ return schemaCache.size;
102
+ }
103
+ //# sourceMappingURL=tool-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-schema.js","sourceRoot":"","sources":["../../src/schema/tool-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAuBxE,2DAA2D;AAC3D,MAAM,UAAU,GAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAAiC;IAC/D,MAAM,IAAI,GAAG,YAAY,CAAC,MAAyB,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACtE,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,IAAkB,CAAC;IAC5B,CAAC;IAC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BAAgB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,MAAM,IAAI,SAAS,CAAC;IAC7B,CAAC;IACD,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC5C,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC;IAClD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA4B,EAAE,QAAiB;IACnF,OAAO,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,WAAW,CAAC,KAAK,EAAE,CAAC;IACpB,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,WAAW,CAAC,IAAI,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Zod to JSON Schema Converter
3
+ *
4
+ * Converts Zod schemas to JSON Schema format for MCP tool inputSchema.
5
+ * Uses zod-to-json-schema with caching for performance.
6
+ */
7
+ import type { JsonSchema } from "../types.js";
8
+ /**
9
+ * Schema interface compatible with Zod.
10
+ * Allows the system to work without direct Zod dependency.
11
+ */
12
+ export interface SchemaLike {
13
+ parse?(data: unknown): unknown;
14
+ safeParse?(data: unknown): {
15
+ success: boolean;
16
+ data?: unknown;
17
+ error?: unknown;
18
+ };
19
+ _def?: unknown;
20
+ }
21
+ /**
22
+ * Options for Zod to JSON Schema conversion.
23
+ */
24
+ export interface ZodToJsonSchemaOptions {
25
+ /** Name for the schema (used in definitions) */
26
+ name?: string;
27
+ /** Pre-existing definitions to include */
28
+ definitions?: Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Convert a schema to JSON Schema.
32
+ *
33
+ * Uses zod-to-json-schema library for actual Zod schemas,
34
+ * with safe fallbacks for non-Zod implementations.
35
+ *
36
+ * @param schema - Schema to convert (Zod or ZodLike)
37
+ * @param options - Conversion options
38
+ * @returns JSON Schema representation
39
+ */
40
+ export declare function zodToJsonSchema(schema: SchemaLike | unknown, options?: ZodToJsonSchemaOptions): JsonSchema;
41
+ /**
42
+ * Convert a schema to JSON Schema with caching.
43
+ *
44
+ * @param schema - Schema to convert (Zod or ZodLike)
45
+ * @param _cacheKey - Not used any more (kept for compatibility): the schema object is the key
46
+ * @returns Cached or freshly converted JSON Schema
47
+ */
48
+ export declare function cachedZodToJsonSchema(schema: SchemaLike | unknown, _cacheKey?: string): JsonSchema;
49
+ /**
50
+ * Clear the schema cache.
51
+ * Useful when procedures are re-registered with different schemas.
52
+ */
53
+ export declare function clearSchemaCache(): void;
54
+ /**
55
+ * Get the current schema cache size.
56
+ */
57
+ export declare function getSchemaCacheSize(): number;
58
+ //# sourceMappingURL=zod-to-json-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-to-json-schema.d.ts","sourceRoot":"","sources":["../../src/schema/zod-to-json-schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC/B,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACjF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,UAAU,GAAG,OAAO,EAC5B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,UAAU,CA0BZ;AAOD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,UAAU,GAAG,OAAO,EAC5B,SAAS,CAAC,EAAE,MAAM,GACjB,UAAU,CAaZ;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}