Skip to main content
Automate/Chapter 20 · Tools

Connecting Your Agent to the World

Share

Share this page

Pass it to someone who needs it.

A model with no tools can only think and talk. Tools are how it reaches out and touches the real world: your database, your browser, your repository, your accounts. With them, the agent stops guessing and starts checking.

3.7.1What MCP is

MCP (the Model Context Protocol) is the standard plug for connecting an agent to an outside system. You register a server in a config file and the agent gains a set of real actions, one adapter shape for every integration instead of hand-wiring each:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres",
               "postgresql://localhost/app"]
    }
  }
}

Claude Code reads this from an .mcp.json file; most tools read something like it. The servers are swappable; the plug is the same. See modelcontextprotocol.io.

3.7.2Databases, browsers, GitHub, APIs

Once it is wired, "the agent cannot know that" becomes "the agent just looked." Instead of assuming a number, it runs the query:

SELECT count(*) FROM users
WHERE created_at > now() - interval '7 days';

Instead of describing a bug it drives a real browser and reads the console. Instead of narrating a change it opens the pull request, the change packaged up for review. Each connection turns a guess into a fact.

3.7.3Custom tools

When no ready-made server exists, you write one, in whatever language your tool's SDK uses. A custom tool is a small named function with a typed input, so the model calls it the same way every time:

@tool
def send_alert(message: str, level: Literal["info", "critical"]) -> str:
    """Notify the operator. Use 'critical' only for outages."""
    post_to_channel(message, level)
    return "sent"

You are not teaching the agent everything. You are handing it a few exact levers that do the specific things your system needs.

3.7.4When a tool beats a prompt

The rule of thumb: if you explain the same procedure in prose more than twice, it wants to be a tool. Prompts are for judgment; tools are for actions that must be exact and repeatable.

"Carefully format the currency like this, round like that" is a tool waiting to be written. Move the mechanical into tools, and leave the prompt for thinking.

3.7.5Wire up your first tool

This prompt connects your agent to something real:

Act as a senior engineer connecting my agent to my stack.
Pick the one connection that would help most right now (my
database, my repo, or my browser), set up its MCP server in
my tool's config, and show me one real check it can now run
instead of guessing.

My stack and what I want it to see:

Do this now: paste the prompt and wire up one connection, then ask your agent a question it can only answer by actually looking.

Discussion

Questions, ideas, and feedback on this chapter.

Mahmoud Zalt

Mahmoud Zalt

Software engineer, 16+ yrs · built Sistava.com in 3 months, idea to production, using these methods

ExploreBook a call
Companion RepoContribute
Support me

Support my work

A small tip keeps the free work coming.

© 2026 Mahmoud Zalt. Free to read, not to republish. Copyright & license