---
outline: deep
---

# DF0019: Agent Requires JSON-Serializable RPC

## Message

> RPC function "`{name}`" has `agent` set but `jsonSerializable` is not `true` — MCP requires JSON-serializable data.

## Cause

The `agent` field exposes an RPC function as an MCP tool. MCP only consumes 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`](https://github.com/devframes/devframe/blob/main/packages/devframe/src/rpc/collector.ts) — `RpcFunctionsCollectorBase.register()` throws `DF0019` when a definition has `agent` set but is not declared `jsonSerializable: true`.
