This repository has been archived on 2026-04-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
claude-code-2026-04-02/docs-site/docs/guides/mcp-and-tool-loop-patterns.md
2026-03-31 16:04:03 +05:00

32 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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)
1. Define tools with **names, descriptions, and JSON Schema** (or equivalent) for arguments.
2. Send user + conversation + tool definitions to the model.
3. If the model returns a **tool call**, validate arguments, **execute** on the host, append a **tool_result** message (or provider-specific equivalent).
4. 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 Codes `services/mcp/` implements configuration, transports, OAuth, and channel-style push—see **[MCP reference](../reference/mcp.md)** for file-level mapping.
For **your** project:
- Start from [MCP documentation](https://modelcontextprotocol.io) 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 products plugin manifest.
## See also
- [Building an agentic CLI overview](building-an-agentic-cli-overview.md)
- [Official: MCP](https://code.claude.com/docs/en/mcp)