← All courses

EDGE FDE

Intermediate

On-Device MCP for Foundation Models

Plug new tools into your Apple AI app without rewriting the chat loop.

Raw JSON-RPC MCP server and client mapped into Foundation Models Tool types.

Speak MCP in Swift. Keep LanguageModelSession as the chat loop. iOS 27 and macOS 27 only.

Lessons

  1. Why MCP sits next to your chat tools
  2. Read the raw JSON-RPC messages
  3. Build a small on-device MCP server
  4. Map MCP tools into Foundation Models
  5. Plug in a tool without rewriting chat

Key concepts

Takeaways

Agent briefs

FAQ

What is MCP on device?

MCP lists and calls tools over JSON-RPC 2.0 at runtime. You speak MCP in Swift and keep LanguageModelSession as the chat loop. iOS 27 and macOS 27 only.

Does Apple ship an MCP adapter?

No. There is no built-in Apple MCP adapter. On iOS 27 use an in-process Swift actor or XPC.

How do MCP tools relate to Foundation Models?

Foundation Models Tool types are compile-time. Your bridge joins MCP tools to those types.

Do I rewrite the chat loop for each new tool?

No. Keep session.respond(to:) as the only chat entry point and plug new tools through the bridge.

What does the course build?

A raw JSON-RPC MCP server and client, then a map of those tools into Foundation Models Tool types.

Related courses

Run tools in a safe box · Stop prompt attacks and leaks · Make several agents agree first · Core AI vs Core ML vs MLX