Building AI Agents with MCP

Connect real agents to real capabilities without giving the model uncontrolled access to your systems.

Practical mini-lab

Support agent with a dangerous refund tool

A support agent can read orders automatically, but issuing a refund changes money. Treat those tools differently.

READ_TOOLS = ["search_customer", "get_order"]
SENSITIVE_TOOLS = ["refund_order"]

if tool.name in SENSITIVE_TOOLS:
    approval = await request_human_approval(tool.arguments)
    if not approval:
        return "Refund cancelled"

return await mcp.call_tool(tool.name, tool.arguments)
Agent responsibility

Understand the user request and choose the right capability.

Application responsibility

Check identity, permissions, refund limits and audit the action.

Trade-off: approvals add friction, but only to the actions where a mistaken tool call would have a real cost.