Skip to content
groundworkv0.2

Agents, tools and MCP

How the agent loop and tool calling work, what MCP adds, and how to decide what an agent may touch and when a human must approve.

11 min read · Last reviewed November 20, 2026

Agents, tools and MCP

Working with coding agents introduced the vocabulary. This page goes one level down: how tool calls actually flow, what standardizes, and the permission decisions that are yours.

You'll be able to#

  • Explain what happens between your prompt and an edited file, step by step
  • Choose between a fixed workflow and a free-running
  • Decide which tools and MCP servers to connect, and what each is allowed to do
  • Set approval points and limits so a mistake stays small

The mental model#

The model never touches your machine. It can only produce text, and some of that text is a structured request such as "call the tool run_tests with these arguments." The (or your own code) decides whether to run it, runs it, and puts the result back into the model's context. Then the model decides what to do next. Everything an agent does is a loop of that exchange.

That makes the tools list the real boundary of what an agent can do. If a tool can delete rows, a confused or manipulated agent can delete rows. Good agent setups are mostly good decisions about that boundary.

Key concepts#

  • : The model decides, based on the request and each tool's description, whether to call a tool. With Claude's , a tool you define runs in your own code and its result goes back to the model. Some tools (such as web search) run on the provider's side. The description you write is what the model uses to pick the tool, so it matters as much as the code.
  • Workflow versus agent: Anthropic's engineering guide distinguishes workflows (the model and tools are orchestrated through predefined code paths) from agents (the model decides its own steps and tool use). Its advice is to use the simplest thing that works and add autonomy only when it measurably helps.
  • Common patterns: Prompt chaining, routing, parallelization, orchestrator-workers and evaluator-optimizer are building blocks that stay inside a workflow shape.
  • MCP (Model Context Protocol): An open standard for connecting AI applications to external systems. It defines roles: the host is the AI application, which runs one client per connection, and each server provides context.
  • What a server can offer: Tools (functions the model can call), resources (data to read) and prompts (reusable templates).
  • Where servers run: Locally as a process on your machine (stdio), or remotely over HTTP. A local server is a program running on your machine, so you are trusting its code.
  • Model-controlled tools: In the MCP spec, tools are designed to be discovered and invoked by the model automatically. The protocol itself does not enforce a user-approval flow, so the application you use has to.
  • Skills and subagents: A packages instructions for a recurring multi-step procedure. A subagent works in its own fresh context and returns a short summary. Both keep the main context small. See Context engineering.
  • : An environment where mistakes can't reach anything you care about (a container, a throwaway database, a branch).

Decisions you make (not the agent)#

Your call, not the agent's

DecisionSensible defaultChoose otherwise when…
Workflow or agentA fixed workflow, or a single agent with few tools, for well-understood tasksThe steps genuinely can't be predicted in advance
Which tools to connectOnly what this task needs; fewer, clearer toolsNever connect a server "just in case"
Whose serversOnes you trust or have read; prefer well-known maintainersYou wrote it yourself
Local or remote serverLocal for personal tooling you controlRemote when a team shares it and it supports proper authentication
ApprovalAsk before anything that writes, deletes, spends or sendsAuto-approve only read-only actions you have reviewed
What it connects toA sandbox, staging or read-only copyProduction access is needed: use a least-privilege account and confirm each write
LimitsA maximum number of steps or retries, and a place to stop and askA short, tightly scoped task
MCP server or a scriptA plain script or CLI the agent can runSeveral tools need sharing across agents and apps

What good output looks like#

  • The agent says which tools it used and why
  • It shows queries and commands before running anything that changes state, or asks first
  • Tool errors are handled and reported instead of ignored
  • It stops and asks at a checkpoint or when the same step keeps failing
  • It stays inside the access you gave it

Red flags#

  • Everything auto-approved → one bad step (or one malicious instruction in a document the agent reads) runs unattended. The MCP spec says there should always be a human in the loop with the ability to deny tool invocations.
  • A pile of connected servers → overlapping tools make it harder for the model to pick the right one and fill the context with tool definitions. Fewer, clearer tools work better.
  • Read/write database access to production → use a read-only role or a staging copy.
  • An unfamiliar server → read what it does before connecting it. The spec says clients must treat a tool's annotations as untrusted unless they come from a trusted server.
  • Loops with no limit → the agent retries the same failing step forever. Set a maximum and a stop-and-ask rule.
  • Tool errors that vanish → ask what failed. Errors should reach the model so it can correct course, and reach you.
  • No record of what ran → keep logs of tool use so you can audit after the fact.

Worked example#

Task: Speed up slow queries in a Postgres-backed app by letting the agent inspect the database through an MCP server.

You connect a Postgres MCP server using the same connection string the app uses in production, and ask: "Find and fix the slow queries." The agent lists tables, runs EXPLAIN on a few queries, and proposes indexes. Then it decides a table is bloated and runs a cleanup statement directly against the live database.

What a good result contains: a list of candidate queries with their query plans, proposed indexes written as a you can review, and measured before and after timings on a copy of the data.

The wrong turn: the connection had write permission and the server was pointed at production, so a statement the agent considered reasonable executed immediately. Nothing in the setup required a person to say yes.

How review catches it: look at the connection first. Which database, which role, what permissions? Then check the tool log for statements that changed data. The fix is in the setup, not the prompt: a read-only role, a staging copy, approvals on every write, and any schema change delivered as a migration file instead of an ad hoc statement.

Sample prompts#

Weak vs strong#

Strong prompt
Goal: find the three slowest queries in this app and propose fixes.
Access: use only the read-only database connection to the staging copy. Do not connect to production.
Constraints: never run INSERT, UPDATE, DELETE or any schema change. For each candidate query, show me the SQL and its EXPLAIN ANALYZE output before drawing conclusions. If you want to change the schema, write a Drizzle migration file for me to review instead of running it.
Stop and ask me if: a statement would modify data, you need access you don't have, or the same step fails three times.
Verify: for each fix, show timings before and after on the staging copy.

Why it works: Access, limits, checkpoints and proof are explicit, and anything risky becomes a file for review.

What changed

  • Which database is named, and production is ruled out
  • Writes are forbidden, and schema changes become a migration file
  • Evidence first: EXPLAIN output before conclusions
  • Stop-and-ask rules are explicit
  • Verification is timings before and after

Take an inventory of tools#

Prompt
List every tool and MCP server available to you in this session. For each, say what it can read, what it can change, and whether it can reach the network. Then say which of them you actually need for this task and which you would disconnect.

Why it works: It makes the real boundary visible so you can shrink it.

Design a permission setup#

Prompt
We want an agent to help with <task>. Propose the minimum permissions it needs: which tools, which accounts and roles, which actions need my approval, and which environment it should run in. Prefer read-only and a sandbox. List what could go wrong with each permission you ask for.

Why it works: It starts from least privilege and forces a risk list you can review.

Write a clear tool description#

Prompt
Write the description and input schema for a tool called <tool name> that <what it does>. Include an example call, the edge cases it handles, and explicit boundaries (what it must not be used for). Make misuse hard: for example, require absolute file paths and validate inputs. Then list three ways a model might call it incorrectly.

Why it works: Anthropic's agent guidance stresses investing in the agent-tool interface the way you would in a user interface, with examples, edge cases and clear boundaries.

Set a stopping rule#

Prompt
Work in small steps. After each step, run the tests and tell me the result. Stop and ask me if: the same test fails three times, you need to delete or overwrite files, you want to change anything outside <folder>, or you've used 10 steps without finishing.

Why it works: Stopping conditions and human checkpoints keep a loop from running away.

Check your understanding#

Check your understanding

1/3Who actually runs a tool call?
2/3What does the MCP specification say about humans and tool calls?
3/3Which setup limits the damage when an agent connected to a database makes a mistake?

Checklist#

  • Connected only the tools this task needs
  • Every server is one I trust or have read
  • Database and API access is read-only or points at a sandbox
  • Writes, deletes, sends and spends need my approval
  • There is a step limit and a stop-and-ask rule
  • I can see a log of what ran

Go deeper#