External capabilities join the same routing as native tools

What You’ll Learn

  • What MCP (Model Context Protocol) is and why it matters
  • How external tools integrate through the same dispatch map
  • How plugins extend the agent without modifying core code

The Problem

Your agent has 10 tools — bash, read, write, edit, task, etc. But what about database queries? Browser automation? Image generation? You can’t add every possible tool to the core codebase.

The Solution

MCP servers expose external capabilities through a standard protocol. Plugins register dynamically. Both join the same TOOL_HANDLERS dispatch map:

                    +------------------+
                    | TOOL_HANDLERS    |
                    | {                |
                    |   bash: native   |
                    |   read: native   |
+----------+        |   db_query: mcp  |        +----------+
| MCP      | -----> |   browser: mcp   | <----- | Plugin   |
| Server A |        |   img_gen: plugin|        | Loader   |
+----------+        | }                |        +----------+
                    +------------------+

How It Works

  1. MCP servers run as separate processes, exposing tools via JSON-RPC over stdio or HTTP.

  2. A PluginLoader discovers and registers external tool handlers:

class PluginLoader:
    def load_mcp_server(self, command: str):
        process = subprocess.Popen(command.split(), stdin=PIPE,
                                    stdout=PIPE)
        tools = discover_tools(process)
        for tool in tools:
            TOOL_HANDLERS[tool.name] = lambda **kw, p=process: \
                call_mcp_tool(p, tool.name, kw)
  1. External tools go through the same permission pipeline, same hook system, same result format.

What Changed From s18

ComponentBefore (s18)After (s19)
ToolsFixed setExtensible via MCP/plugin
CapabilitiesLocal filesystem + bashAny external service
RoutingNative tools onlySame dispatch map
PermissionsNative onlyExternal tools get same

Try It

cd learn-claude-code
python agents/s19_mcp_plugin.py
  1. Start an MCP server for SQLite and query a database
  2. Load a plugin for image generation and create an icon
  3. List all available tools — both native and external

Key Takeaway

External capabilities join the same routing, permission, and result-append path as native tools. MCP and plugins don’t bypass the harness — they extend it through the same interfaces.