DF0019: Agent Requires JSON-Serializable RPC
Message
RPC function "
{name}" hasagentset butjsonSerializableis nottrue— MCP requires JSON-serializable data.
Cause
The agent field exposes an RPC function as an MCP tool. MCP and the underlying schema-conversion path (@valibot/to-json-schema) only consume JSON-shaped data. Functions whose payloads can include Map, Set, Date, BigInt, circular references, or class instances cannot be safely advertised to agents.
A registered function is rejected when agent is present and jsonSerializable is not explicitly true.
Example
ts
defineRpcFunction({
name: 'my-plugin:summary',
agent: { description: 'Returns a summary' },
// missing `jsonSerializable: true` → registration throws DF0019
handler: () => ({ items: [1, 2, 3] }),
})Fix
Either declare the payload as JSON-safe:
ts
defineRpcFunction({
name: 'my-plugin:summary',
jsonSerializable: true,
agent: { description: 'Returns a summary' },
handler: () => ({ items: [1, 2, 3] }),
})Or remove agent to keep the function as an internal RPC (no agent exposure):
ts
defineRpcFunction({
name: 'my-plugin:summary',
handler: () => new Map([['a', 1]]),
})Source
packages/devframe/src/rpc/collector.ts—RpcFunctionsCollectorBase.register()throwsDF0019when a definition hasagentset but is not declaredjsonSerializable: true.