Generate MCP Tool Definitions from JSON
npx typemorph-cli mcp-tool schema.json --root SearchProducts outputs a complete MCP tool definition with inputSchema as a JSON Schema object — ready to register in your MCP server.
The problem
Writing MCP tool definitions by hand is repetitive. The inputSchema field must be a valid JSON Schema, and getting the types right for nested objects, arrays, and string formats takes time.
The solution
TypeMorph infers the JSON Schema from your data (or existing schema file) and wraps it in an MCP-compatible tool definition. You get a ready-to-use object you can paste directly into your MCP server's tool registry.
Step-by-step
- 1
Generate from a JSON sample
Point typemorph-cli at any JSON file. The --root flag becomes the tool name (camelCase).
Terminal
echo '{"query": "shoes", "limit": 10, "category": "footwear"}' \ | npx typemorph-cli mcp-tool --root SearchProducts - 2
See the output
The result is a JSON object you can spread into your tools array.
JSON
{ "name": "SearchProducts", "description": "SearchProducts tool", "inputSchema": { "type": "object", "properties": { "query": { "type": "string" }, "limit": { "type": "integer", "minimum": 0 }, "category": { "type": "string" } }, "required": ["query", "limit", "category"] } } - 3
Register in your MCP server
Paste the output into your server's tool definitions.
TypeScript
// server.ts const tools = [ // paste typemorph output here { name: "SearchProducts", description: "Search product catalog", inputSchema: { /* ... */ }, }, ]; - 4
Also works for OpenAI function calling and Vercel AI SDK
Same JSON, different output format.
Terminal
# OpenAI function calling echo '{"query":"shoes",...}' | npx typemorph-cli openai-function --root SearchProducts # Vercel AI SDK tool echo '{"query":"shoes",...}' | npx typemorph-cli vercel-ai-tool --root SearchProducts
Frequently asked
What version of the MCP spec does this target?
The output follows the MCP tool definition format with inputSchema as a JSON Schema Draft 7 object, compatible with the current MCP TypeScript SDK.
Can I use an existing Zod schema as input?
Not directly yet. The recommended workflow is: generate a JSON sample from your Zod schema using typemorph reverse, then pipe that through typemorph mcp-tool.
Does TypeMorph infer string formats in the inputSchema?
Yes. Fields detected as email, uuid, or uri get a format annotation in the JSON Schema output.
Can I generate tool definitions for all my endpoints at once?
Yes — loop over your JSON samples in a shell script and redirect each output to a separate file, then import them all into your MCP server.