MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / jsonSchemaToToolSchemaShape

Function jsonSchemaToToolSchemaShape

src/cli/cli-tool-catalog.ts:28–52  ·  view source on GitHub ↗
(inputSchema: unknown)

Source from the content-addressed store, hash-verified

26};
27
28function jsonSchemaToToolSchemaShape(inputSchema: unknown): ToolSchemaShape {
29 if (!inputSchema || typeof inputSchema !== 'object') {
30 return {};
31 }
32
33 const schema = inputSchema as JsonSchemaObject;
34 const properties = schema.properties;
35 if (!properties || typeof properties !== 'object' || Array.isArray(properties)) {
36 return {};
37 }
38
39 const requiredFields = new Set(
40 Array.isArray(schema.required)
41 ? schema.required.filter((name): name is string => typeof name === 'string')
42 : [],
43 );
44
45 const shape: ToolSchemaShape = {};
46 for (const [name, propertySchema] of Object.entries(properties)) {
47 const zodSchema = jsonSchemaToZod(propertySchema);
48 shape[name] = requiredFields.has(name) ? zodSchema : zodSchema.optional();
49 }
50
51 return shape;
52}
53
54async function invokeRemoteToolOneShot(
55 remoteToolName: string,

Callers 1

createCliXcodeProxyToolFunction · 0.85

Calls 1

jsonSchemaToZodFunction · 0.90

Tested by

no test coverage detected