json-to-model
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@json-to-modelGenerate a User model from /users/1"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
json-to-model MCP Server
An MCP (Model Context Protocol) server for Claude Code, Codex CLI, or any other MCP-compatible client that works like Postman combined with a code generator: give it an API endpoint, it fetches the response and returns a ready-to-use model/POJO class in your configured language — with login and refresh-token handling built in, so you don't have to keep pasting fresh tokens by hand.
What it does
You configure it once — your target language, optional
baseUrl, and (optionally) your login/refresh token endpoints. Either runsetup_authdirectly, or type/json-to-modelin Claude Code and it will interview you for these values (see Setup process below).From then on, you ask Claude Code to hit an endpoint — e.g. "generate a model from
https://api.example.com/users/1calledUser", or (if you configured abaseUrl) just "generate a model from/users/1".The server calls the API (attaching a valid auth token automatically if one is configured), reads the JSON response, and returns:
a status/shape summary line (e.g.
Status: 200 OK | Response: array with 12 items) — so you can tell "genuinely empty" apart from "auth silently rejected, API returned 200 +[]",the full response body, pretty-printed (truncated past 4000 chars),
the generated source code in your configured language.
Code generation is powered by quicktype-core,
which infers types (including nested objects, arrays, optional/nullable
fields) from the JSON shape.
Related MCP server: MCP Swagger Server
Project structure
json-to-model/
├── package.json Dependencies & npm scripts (build/start/dev)
├── tsconfig.json TypeScript compiler config
├── .gitignore
├── README.md
├── .claude/
│ └── commands/
│ └── json-to-model.md Claude Code slash command — `/json-to-model`
│ walks you through setup or a generate call
└── src/
├── index.ts MCP server entrypoint — registers the tools
│ (setup_auth, generate_model_from_api,
│ list_supported_languages), the `json-to-model`
│ MCP prompt, and wires request building, error
│ handling, and responses
├── types.ts Shared types: AuthConfig, SessionState, ToolTextResult
├── store.ts Reads/writes config.json and session.json under
│ ./.json-to-model/ in the current project root
│ (per-project, not shared globally)
├── auth.ts Token resolution chain: explicit token → cached
│ token → refresh → login → unauthenticated.
│ Handles rotating refresh tokens.
├── language.ts Supported language enum, case-insensitive
│ normalization, and aliases (c# → csharp, ts →
│ typescript, py → python, etc.)
└── codegen.ts Wraps quicktype-core: JSON string → generated
source code for the configured language, with
per-language serializer/framework choicesHow a request flows through the code
generate_model_from_api tool call
│
▼
index.ts: check setup exists (store.ts) ──► no? return setup error
│ yes
▼
auth.ts: resolveToken()
1. explicit `token` param? → use it
2. cached access token still valid? → use it
3. refresh token + endpoint? → refresh, cache, use it
4. login endpoint configured? → login, cache, use it
5. none of the above → proceed unauthenticated
│
▼
index.ts: resolve `url` (or join `path` onto configured baseUrl),
build headers + body (json or form), fetch(url)
│
▼
codegen.ts: quicktype-core turns the JSON response into
source code in the configured language (using that
language's configured serializer — see table below)
│
▼
Status/shape summary + full response body + generated class
returned to Claude / youPrerequisites
Node.js v18 or later (the code uses the built-in
fetchAPI)Claude Code, or OpenAI's Codex CLI — anything that can spawn a stdio MCP server. Instructions below cover Claude Code first, Codex CLI in its own section further down.
Dependencies
Runtime:
Package | Purpose |
MCP server framework — tools, prompts, stdio transport | |
JSON → model code generation engine | |
Schema validation for tool parameters |
Dev-only (not shipped, used to build/run from source):
Package | Purpose |
| Node.js type definitions |
| Runs TypeScript directly for |
| Compiler ( |
Everything else is Node.js built-ins (fs, path, fetch) — no other
third-party libraries.
Setup process
1. Install and build
cd json-to-model
npm install
npm run buildThis compiles src/*.ts → dist/*.js. dist/index.js is what actually runs.
2. Register the server with Claude Code
claude mcp add json-to-model -- node /absolute/path/to/json-to-model/dist/index.jsUse an absolute path — Claude Code spawns this as a subprocess on demand (stdio transport), so there's nothing to host or deploy for local/personal use.
3. Run first-time setup (in a Claude Code conversation)
Easiest: type the slash command.
/json-to-modelThis is defined in .claude/commands/json-to-model.md. If no setup exists
yet, Claude interviews you one question at a time — language (offering to
call list_supported_languages if you're unsure), optional baseUrl, login
endpoint + body + token field, refresh endpoint + fields — then calls
setup_auth with your answers. If setup already exists, it shows a summary
and asks whether to reconfigure or go straight to generating a model.
The same interview flow is also exposed as an MCP prompt named
json-to-model (works from any MCP client, not just the slash command).
Or ask directly / call setup_auth yourself. Fields:
Field | Required? | Notes |
| Yes | java, kotlin, typescript, python, csharp, go, swift, dart, rust. Fixed at setup — not chosen per call. Call |
| No | Host to join with a relative |
| No | POST endpoint that returns an access token. Skip this if you'll always pass a |
| No | JSON body sent to the login endpoint (credentials, API key, etc.) |
| No | Field in the login response holding the token. Default: |
| No | POST endpoint that exchanges a refresh token for a new access token |
| No | Field holding the refresh token. Default: |
| No | Field holding token lifetime in seconds. Default: |
Example:
"Set up json-to-model. Language: Kotlin. Login endpoint:
https://api.example.com/auth/loginwith body{ "apiKey": "..." }."
Config is saved to <project-root>/.json-to-model/config.json — scoped to
whichever project directory Claude Code/Codex was running in when the MCP
server was spawned, not shared globally. Different projects get their own
language, baseUrl, login/refresh endpoints, etc. Session tokens are
cached separately in <project-root>/.json-to-model/session.json (file
permissions 600, never logged, never echoed back in any tool response).
Add .json-to-model/ to that project's .gitignore — session.json holds
live tokens and shouldn't be committed.
4. Use it
GET request (full URL):
"Generate a model from
https://api.example.com/users/1calledUser"
GET request (relative path, requires baseUrl configured):
"Generate a model from
/users/1calledUser"
POST with JSON body:
"POST
https://api.example.com/clientswith body{ "name": "Acme" }as JSON, call the modelClient"
POST with form data:
"POST
https://api.example.com/clientsas form data withname=Acme, call the modelClient"
One-off call with a manual token (bypasses stored login/refresh):
"Generate a model from
https://api.example.com/orders/5using tokeneyJhbGciOi..." — theBearerprefix is optional, it's stripped and re-added automatically either way.
Every successful call returns three things, in order: a status/shape summary line, the full pretty-printed response body, then the generated model code. The generated code also carries the same response JSON baked in as a comment header (plus a "Generated by json-to-model MCP server" line), so the pairing between response and model survives even if the code is saved to its own file or the chat reply gets trimmed/summarized.
Tool reference
setup_auth
Run once (or again to reconfigure). See the setup table above for fields.
generate_model_from_api
Param | Required? | Default | Notes |
| One of | — | Full endpoint URL |
| One of | — | Relative path, joined onto the configured |
| No |
| Any HTTP method |
| No | — | Per-call override; falls back to configured login/refresh flow |
| No |
| Name for the generated class/type |
| No | — | Extra headers to send |
| No | — | Request body/params for POST/PUT/PATCH/DELETE |
| No |
|
|
GET/HEAD requests reject a body with a clear error, since those methods
don't carry one.
list_supported_languages
No params. Returns the current list of valid language values for
setup_auth — use this if you're not sure what's supported.
Supported HTTP methods
method accepts any HTTP verb — it's passed straight through to fetch().
Method | Body allowed? | Notes |
| No | Rejected with an error if |
| No | Rejected with an error if |
| Yes | Use |
| Yes | Full resource replacement — same body handling as POST |
| Yes | Partial update — same body handling as POST |
| Yes (permissive) | Body is allowed but not required — some APIs expect the resource ID in the URL instead, others (e.g. bulk-delete-by-filter) expect a body. Since a body on DELETE is unusual, the response is prefixed with a note ( |
Examples:
"PATCH
https://api.example.com/clients/5with body{ "status": "active" }, call the modelClient"
"DELETE
https://api.example.com/clients/5"
Generated code: serializer per language
codegen.ts picks a serialization approach per language before handing off
to quicktype-core. Most languages only have one sensible option upstream;
Kotlin and C# support multiple frameworks — this project pins the one below
as the default.
Language | Serializer / framework used | Notes |
Kotlin |
| Explicitly pinned via |
Java | Jackson ( | quicktype's only Java renderer. Needs |
C# | quicktype-core's default C# renderer; | |
TypeScript | Plain interfaces, no library | quicktype emits |
Python |
| quicktype emits |
Go |
| Plain structs with |
Swift |
| Structs conform to |
Dart | Hand-written | Works directly in Flutter projects — no |
Rust |
| The de-facto standard for Rust; needs the |
To change Kotlin's or C#'s framework, edit the rendererOptions block in
src/codegen.ts (valid Kotlin values: klaxon, kotlinx, jackson; valid
C# values: newtonsoft, systemtextjson), then npm run build.
Using with Codex CLI
The server itself is plain MCP over stdio, so it works with OpenAI's Codex CLI too — same build, same tools. Two things differ from the Claude Code setup above:
No
/json-to-modelslash command. That file lives under.claude/commands/, which is Claude-Code-specific — Codex doesn't read it. Codex has its own custom-prompt mechanism instead: drop a markdown file under~/.codex/prompts/<name>.mdand it becomes/<name>inside Codex. You can copy the interview instructions out of.claude/commands/json-to-model.mdinto a file there if you want the same guided flow in Codex; it's plain markdown, no Claude-specific syntax.The MCP
promptprimitive may not surface. Codex's MCP client support has historically focused on tools —setup_auth,generate_model_from_api,list_supported_languagesall work normally, but thejson-to-modelprompt registered inindex.tsmight not appear in Codex's UI even though it's a spec-compliant MCP prompt. Check your installed Codex version if you're relying on it; the tools work regardless.
1. Build
Same as Claude Code — see Install and build above.
2. Register the server with Codex
Add an entry to Codex's config (~/.codex/config.toml):
[mcp_servers.json-to-model]
command = "node"
args = ["/absolute/path/to/json-to-model/dist/index.js"]Use an absolute path, same reasoning as the Claude Code setup — Codex spawns this as a subprocess on demand. Restart Codex (or reload MCP servers) to pick up the config change.
3. Use it
Without the slash command or prompt, just ask Codex directly and it calls the tools for you:
"Set up json-to-model. Language: Kotlin. Login endpoint:
https://api.example.com/auth/loginwith body{ "apiKey": "..." }."
"Generate a model from
https://api.example.com/users/1calledUser"
Everything else — baseUrl/path support, the status/shape summary line,
full response body display, per-language serializers — behaves identically
to Claude Code, since it's all server-side logic in index.ts/codegen.ts,
not client-specific.
Design notes
No profiles within a project — one auth config per project directory, by design (kept intentionally simple; a profile system would be needed only if you're juggling multiple unrelated APIs with different auth from the same project). Across projects, config is already isolated since it's stored per-project under
.json-to-model/in each project root, not globally.Language is fixed at setup, not selectable per call — this removes the need for any "which language?" fallback logic in the main tool.
Symbolic endpoint references (e.g. a constant like
ApiEndpoints.GET_CLIENTin your codebase) aren't resolved by this MCP server itself — it only ever sees the literal URL string it's given. In practice this still works conversationally because Claude Code uses its own separate file-reading tools to resolve the constant to a real URL before calling this tool.Rotating refresh tokens are supported — if a refresh response includes a new refresh token, it overwrites the stored one; if not, the old one is kept.
Errors are returned with
isError: trueper the MCP convention, with a distinct message for: no setup found, incomplete config, auth failure, network failure, non-2xx response, and JSON parse/codegen failure. Tokens are never included in error text.Response body is always shown, not just the generated code — this was added after an empty-array response turned out to be ambiguous (genuinely empty data vs. auth silently rejected + API returning
200 []). It's truncated past 4000 characters to avoid flooding the terminal on huge payloads.Response body is also embedded in the generated code as a comment header (
withHeaderComment()incodegen.ts), along with a "Generated by json-to-model MCP server" line — so if only the code gets saved/copied out of the chat, the exact response it was modeled from isn't lost./json-to-modeland the MCP prompt are two separate mechanisms that do the same interview: the slash command (.claude/commands/json-to-model.md) is Claude-Code-specific and needs to ship alongside this server if used from another project directory; the MCP prompt (registered inindex.ts) works from any MCP client that supports prompts.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- -licenseAquality-maintenanceA TypeScript-based MCP server that generates API clients from OpenAPI specifications, allowing automated code generation through natural language.1441
- Flicense-quality-maintenanceAutomatically generates MCP servers from OpenAPI/Swagger specifications, enabling users to interact with any REST API through natural language with flexible endpoint filtering and authentication support.
- AlicenseAqualityCmaintenanceA standalone MCP server for API debugging, login authentication, API configuration management, and indexed API execution.510MIT
- Alicense-qualityDmaintenanceA minimal MCP server that auto-generates tools from your OpenAPI spec, optimized for Vercel.158MIT
Related MCP Connectors
A basic MCP server to operate on the Postman API.
An MCP server that let you interact with Cycloid.io Internal Development Portal and Platform
MCP server for interacting with the Supabase platform
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ramzanelayodath/mcp-json-to-model'
If you have feedback or need assistance with the MCP directory API, please join our Discord server