1.8 KiB
MCP and tool-loop patterns (abstract)
!!! note "Conceptual only"
This page describes common agent architectures. It references src/ modules only as illustrations of where similar ideas appear in Claude Code—not as code to copy.
Tool loop (functions / tools)
- Define tools with names, descriptions, and JSON Schema (or equivalent) for arguments.
- Send user + conversation + tool definitions to the model.
- If the model returns a tool call, validate arguments, execute on the host, append a tool_result message (or provider-specific equivalent).
- Repeat until the model finishes without further tool calls or a cap is hit.
In this reconstruction, much of that orchestration lives in query.ts and adjacent helpers, while tool implementations live under tools/* and services/tools/.
MCP (Model Context Protocol)
MCP standardizes how tools and resources are exposed by servers the host spawns and talks to over stdio or other transports. Claude Code’s services/mcp/ implements configuration, transports, OAuth, and channel-style push—see MCP reference for file-level mapping.
For your project:
- Start from MCP documentation and official SDKs.
- Implement one small MCP server (e.g. filesystem or git) before designing a full IDE-quality integration.
Parallel: skills and plugins
Claude Code layers skills (project-scoped instructions + commands) and plugins on top of the core loop. Greenfield designs might use: simple slash-commands, SKILL.md conventions, or dynamic imports—without reproducing this product’s plugin manifest.