Skip to content
Get Started

Tools & MCP

Tools & Agent Overview

Understanding the agent, MCP tools, and the /mcp endpoint in the Mirobody C++ engine

Three things do the work in a chat turn, and this page is the map between them.

Mirobody runs one simple agent — “Baseline”, in res/agents/baseline.cpp. No agent loop, no planner, no middleware: it picks an LLM client by provider name, builds a fixed inline system prompt, and streams the provider’s events straight back, letting the model call the built-in tools as needed.

Personal-health questions almost always resolve to the same shape: read the user’s records → optionally read uploaded files → optionally recall long-term memory → answer, sometimes with a chart. The built-in tools map directly onto that, and the model orchestrates them itself within a single streamed turn.

Tools are C++ files in res/mcp_tools/. Each declares a Tool — name, description, an auth flag, a small Param table, and a handler — and self-registers at compile time. CMakeLists.txt globs every .cpp in that directory with CONFIGURE_DEPENDS, so dropping a file in and rebuilding is all it takes: no manual registration, no router wiring, no hand-written JSON schema.

Nine tools ship — file, health, memory, chart and identity — documented one by one in Built-in Tools. To write your own, follow Adding Custom Tools.

How they run: the OpenAI and Gemini clients receive the tools as function-call descriptors, and the engine executes each call locally, in-process, as the authenticated user.

The same tools are served over an MCP endpoint (src/mcp/), speaking JSON-RPC 2.0 on two paths:

PathAuthenticates by
/mcpa bearer JWT
/mcp/{secret}a personal-MCP secret in the URL, for clients that can’t send a header

tools/list and tools/call are the methods you’ll use; discovery is unauthenticated, while auth-flagged tools resolve a caller first. MCP Integration has the Claude / Cursor setup and the tunnelling note for local development.

Terminal window
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Tools like family_health don’t hit ad-hoc tables — they read through the embedded FHIR R4 store (src/fhir/) and return FHIR Observation resources, with units already normalized to UCUM on the way in. The relational backend behind it is chosen at build time; see Architecture for the whole picture.