---
title: "Read the raw JSON-RPC messages"
lesson_id: "02"
---

# Read the raw JSON-RPC messages

- **Lesson ID:** 02
- **Goal:** Show JSON-RPC 2.0 initialize, tools/list, and tools/call as raw JSON.
- **Human lesson:** [02-raw-json-rpc.html](02-raw-json-rpc.html)

## Prerequisites

Lesson 01, or a clear split between Tool and MCP.

## Inputs, outputs, and artifacts

- **Inputs:** The three MCP methods and JSON-RPC 2.0 fields.
- **Outputs:** A reader who can read a request and a result without a library.
- **Artifacts:** Three JSON samples and progressive .flow diagrams.

## Agent build steps

1. Name jsonrpc, id, method, and params.
2. Show initialize, tools/list, and tools/call as JSON.
3. Mention notifications/initialized has no id.
4. Say iOS should stay in-process or XPC, not stdio.
5. Link [Run tools in a safe box](../on-device-sandboxed-tools/), [Stop prompt attacks and leaks](../on-device-guardrails/), and [Core AI vs Core ML vs MLX](../core-ai-vs-core-ml-vs-mlx/).

## Constraints

iOS 27 or later, or macOS 27 or later, and Xcode 27. Plain spoken English. No metaphor, quizzes, Mermaid, or em dashes. Do not invent a first-party Foundation Models MCP adapter. Show raw JSON-RPC 2.0. Confirm Tool and DynamicGenerationSchema names in the installed SDK docs.

## Key concepts

- MCP uses JSON-RPC 2.0 with `jsonrpc`, `id`, `method`, and optional `params`.
- The three methods are `initialize`, `tools/list`, and `tools/call`.
- After initialize, the client sends `notifications/initialized` with no id.
- On iOS pass JSON through an in-process actor or XPC.

## Takeaways

- Implement the raw methods before hiding them in a client library.
- Keep request ids unique for the life of the connection.
- Do not start with HTTP unless you need a second device.

## Acceptance checks

- The three methods appear as raw JSON.
- JSON-RPC 2.0 fields are named.
- Sibling links, progressive .flow diagrams, and the Agent brief link are present.
- [ ] Proceed to [lesson brief](03-on-device-mcp-server.llms.md).
