MCPcopy Index your code
hub / github.com/simstudioai/sim / toToolInputSchema

Function toToolInputSchema

apps/sim/app/api/mcp/serve/[serverId]/route.ts:207–225  ·  view source on GitHub ↗
(schema: unknown)

Source from the content-addressed store, hash-verified

205}
206
207function toToolInputSchema(schema: unknown): Partial<Tool['inputSchema']> {
208 if (!schema || typeof schema !== 'object' || Array.isArray(schema)) return {}
209
210 const candidate = schema as Record<string, unknown>
211 const properties =
212 candidate.properties &&
213 typeof candidate.properties === 'object' &&
214 !Array.isArray(candidate.properties)
215 ? (candidate.properties as Tool['inputSchema']['properties'])
216 : {}
217 const required = Array.isArray(candidate.required)
218 ? candidate.required.filter((entry): entry is string => typeof entry === 'string')
219 : undefined
220
221 return {
222 properties,
223 ...(required && required.length > 0 && { required }),
224 }
225}
226
227function isJsonObject(value: unknown): value is Record<string, unknown> {
228 return value !== null && typeof value === 'object' && !Array.isArray(value)

Callers 1

handleToolsListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected