MCPcopy Create free account
hub / github.com/TanStack/ai / schemaToType

Function schemaToType

packages/ai-mcp/src/cli/emit.ts:31–42  ·  view source on GitHub ↗

* Compile a JSON Schema into a TypeScript type via `json-schema-to-typescript`. * Returns `'unknown'` for absent/non-object schemas. The compiled output is an * `export interface { ... }` declaration which callers inline via * inlineBody.

(
  schema: unknown,
  typeName: string,
)

Source from the content-addressed store, hash-verified

29 * {@link inlineBody}.
30 */
31async function schemaToType(
32 schema: unknown,
33 typeName: string,
34): Promise<string> {
35 if (!schema || typeof schema !== 'object') return 'unknown'
36 const compiled = await compile(schema, typeName, {
37 bannerComment: '',
38 additionalProperties: false,
39 declareExternallyReferenced: true,
40 })
41 return compiled.trim()
42}
43
44export interface EmitInput {
45 [serverName: string]: { prefix?: string; surface: ServerSurface }

Callers 1

emitDescriptorsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected