createMcpApp: the input schema drops state/on/watch, and the tool description buries the catalog
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- json, typescript
- Domain
- backend-api-design
Research direction
Start with registerJsonRenderTool and the createMcpApp tool registration in @json-render/mcp, where catalog.zodSchema() is passed as the input schema. Run the repro script in the issue to confirm that state, on and watch are stripped and that unknown props pass. Done means those fields survive the call, unknown props and failed catalog.validate results are reported with isError: true, and the tool description is shorter than the full catalog.prompt() output. The issue proposes a larger schema redesign, so check with maintainers before starting.
Written by the indexing model from the issue text.
Description
createMcpApp from @json-render/mcp 0.21.0 (same code on main) has two problems that together make most generated UIs arrive empty or inert in an MCP Apps host.
1. state, on and watch are stripped before the tool runs
registerJsonRenderTool passes catalog.zodSchema() as the tool's input schema. That schema describes root and elements (type, props, children, visible, repeat) and nothing else. The MCP SDK parses tool arguments with it, so a spec's top-level state and each element's on and watch are removed before the handler sees them. The catalog prompt tells the model to always send state for data-backed UI, so tables and lists render empty and buttons do nothing.
Props are not checked either: an unknown prop passes, and when catalog.validate fails, the handler returns the spec anyway with no error, so the model never learns what it got wrong.
Repro (@json-render/[email protected], @json-render/[email protected], @json-render/[email protected]):
import { createMcpApp } from '@json-render/mcp';
import { defineCatalog } from '@json-render/core';
import { schema } from '@json-render/react/schema';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
import { z } from 'zod';
const catalog = defineCatalog(schema, {
components: {
Text: { props: z.object({ text: z.string() }), description: 'Text' },
Button: { props: z.object({ label: z.string() }), description: 'Button' },
},
actions: {},
});
const server = await createMcpApp({ name: 'repro', version: '0.0.0', catalog, html: '<p>view</p>' });
const client = new Client({ name: 'c', version: '0' });
const [a, b] = InMemoryTransport.createLinkedPair();
await Promise.all([server.connect(b), client.connect(a)]);
const result = await client.callTool({
name: 'render-ui',
arguments: {
spec: {
root: 'main',
state: { name: 'Ada' },
elements: {
main: { type: 'Text', props: { text: { $state: '/name' } }, children: ['go'] },
go: {
type: 'Button',
props: { label: 'Go', bogus: 1 },
on: { press: { action: 'setState', params: { statePath: '/name', value: 'Bob' } } },
watch: { '/name': { action: 'setState', params: { statePath: '/x', value: 1 } } },
children: [],
},
},
},
},
});
console.log(result.content[0].text, result.isError ?? false);
Output:
{"root":"main","elements":{"main":{"type":"Text","props":{"text":{"$state":"/name"}},"children":["go"]},"go":{"type":"Button","props":{"label":"Go","bogus":1},"children":[]}}} false
state, on and watch are gone, and bogus went through.
2. The tool description buries the catalog
The default description is catalog.prompt(), written as a system prompt for a model that streams JSON Patch. For the two-component catalog above it is 15 521 characters, and the component list starts at character 5 372. In our testing, claude.ai showed the model a tool description cut off after roughly 2 000 characters, so the model saw patch-streaming instructions and no component, prop or action, and guessed ("variant": "primary" on a Button the catalog did not define). tool.description can be overridden, but the default is what most people ship.
What fixed both for us
In ngx-json-render/mcp/server (Apache-2.0, same tool name and ui:// resource as createMcpApp):
- An input schema built from the catalog:
state,on,watch,visibleandrepeatdeclared; each component's props typed from its catalog schema, with dynamic values ({ "$state": … }) allowed and unknown props rejected; each action binding checked against the built-in and catalog actions. Shared parts are JSON Schema definitions, so a 33-component catalog comes to about 44 000 characters. - A short description (about 1 600 characters) that covers what a schema cannot say (state, bindings, repeat, events) and leaves the vocabulary to the input schema.
- A spec that fails
validateSpecgoes back asisError: truewith the problems listed, so the model can fix it.
Happy to open a PR along these lines if you would take one, or to adapt it to a different direction you prefer.
- Dominant language
- TypeScript
- Stars
- 20k
- Forks
- 1.1k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 25
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel-labs/json-render
-
React Quick Start examples fail at runtime: Renderer must be wrapped in JSONUIProviderPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
vercel-labs/json-render#443 ·
Maintainers usually reply within 2 days
-
shadcn Grid/Stack are not responsive (fixed grid-cols-N, no min-w-0)Possibly taken @sushanshakya77 claimed this 67 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vercel-labs/json-render#355 ·
Maintainers usually reply within 2 days
-
Array path helpers accept malformed RFC 6902 indexesPossibly taken @simonyang08 claimed this 106 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vercel-labs/json-render#326 ·
Maintainers usually reply within 2 days
-
Support zod 4.4+ — _zod.version.minor type check prevents upgradeMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vercel-labs/json-render#297 · 2 reactions ·
Maintainers usually reply within 2 days
-
feat: Generic `Spec` type supportPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
vercel-labs/json-render#275 · 1 reaction ·
Maintainers usually reply within 2 days
All issues in vercel-labs/json-render
Similar issues
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainers usually reply within 1 day
-
area: middleware enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
agent/quality testing
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
juspay/agent-distro#203 ·
Maintainers usually reply within 1 day