Skip to content

How MCP Works

MCP (Model Context Protocol) servers expose tools, prompts, and resources that allow Claude to execute functions, access data, and apply templates to extend capabilities beyond text generation.

How Claude Sees Available Tools

When Claude starts, each MCP server advertises its capabilities:

json
{
  "tools": [
    {
      "name": "git_commit",
      "description": "Create a git commit with conventional message",
      "inputSchema": {
        "type": "object", 
        "properties": {
          "message": {"type": "string"},
          "files": {"type": "array"}
        }
      }
    }
  ],
  "resources": [
    {
      "uri": "memory://user-preferences", 
      "name": "User Preferences",
      "description": "Stored user configuration and preferences"
    }
  ]
}

Claude builds an internal catalog of all available capabilities across servers.

Tool Selection and Execution

Claude uses next-token prediction to decide when tools are needed:

  1. Claude generates tokens and determines a tool would best answer your request
  2. Claude emits a structured tool call
  3. MCP client intercepts this output and executes the tool
  4. Result is fed back to Claude as conversation context
  5. Claude continues responding with the result

Key insight: Claude doesn't execute tools—it only predicts structured output that the MCP runtime interprets and runs.

Parameter Resolution

Claude generates tool parameters through token prediction using available context from conversation history, previous tool results, and user input.

Example:

User: "Commit these changes"
Claude generates parameters from context:
- files: [from recent git status result]
- message: [predicted from diff analysis]
- author: [from git config in session context]

Why This Matters: Inference and Ambiguity

Because Claude infers tool parameters from context, you can chain MCP calls naturally without manual configuration. Say "fix the database schema and commit," and Claude reads your table definitions, predicts the schema changes, generates the SQL, executes it, queries the result, and commits — all from intent alone.

But there's a cost: ambiguous context produces unpredictable parameter choices. If you ask "delete the record" without specifying which one, Claude may guess wrong. When stakes are high — destructive operations, financial transfers, or data modification — be explicit. Name the exact files, tables, or records. Ambiguity is a feature when learning; it's a liability when committing.

Tool Execution Flow

Reference

Built with VitePress and powered by Claude Code