Skip to content

Tools, MCP & Gateways

The tools layer defines what an AI app or agent can do outside the model. This includes calling APIs, reading files, querying databases, opening tickets, changing code, sending emails, and invoking internal systems.

This layer is where capability becomes risk. A model that can only answer text is limited. A model that can call tools can create value, but also needs authorization, policy, audit, and rollback boundaries.

What this layer owns

ConcernWhat it controls
Tool schemaWhat arguments the model can produce
Tool discoveryWhich tools are visible to which agent/user
AuthenticationWhich identity is used to call the tool
AuthorizationWhether the requested action is allowed
ApprovalWhether human confirmation is required
Rate limitHow much tool usage is allowed
AuditWhat was called, by whom, with what inputs, and why
IsolationWhether tools can affect local files, prod systems, or sensitive data

Function calling vs MCP vs OpenAPI tools

MechanismMeaning
Function callingModel emits structured tool arguments
OpenAPI toolTool schema comes from an HTTP API contract
MCPStandard protocol for exposing tools/resources/prompts to agents
Tool gatewayOrganization-controlled boundary for policy, auth, rate limit, and audit

Function calling is the model-facing shape. MCP is a protocol for exposing tool and context surfaces to AI apps. OpenAPI is a common way to describe existing HTTP services. A tool gateway is the enterprise control plane you add when many agents and many tools need consistent policy.

Tool gateway pattern

mermaid
flowchart TB
    A[Agent or AI app] --> B[Tool gateway]
    B --> C[MCP servers]
    B --> D[OpenAPI services]
    B --> E[Internal scripts]
    B --> F[Database tools]
    G[Policy engine] -. allow or deny .-> B
    H[Audit log] -. records .-> B
    I[Human approval] -. gates .-> B

A gateway is useful when you need one place to enforce:

  1. Which tools are available to which agent.
  2. Which actions require approval.
  3. Which data classes can be sent to which tool.
  4. Which calls must be logged.
  5. Which credentials and scopes are used.
  6. Which tools are read-only, write-capable, or destructive.

Permission and approval model

Action classExampleControl
Read-only low risksearch docs, read public metadataallow with logging
Read-only sensitiveread customer record, inspect incident logsallow only with scoped identity
Write low riskcreate draft ticket, update local branchallow with trace
Write medium riskupdate issue status, create pull requestapproval or review gate
Destructive/high riskdelete resource, rotate secrets, deploy prodexplicit human approval and break-glass policy

The right default is not "agents cannot use tools." The right default is "tools are scoped by risk."

Tool safety checklist

  • Does every tool have a clear name and narrow description?
  • Are arguments typed and validated?
  • Is the tool read-only by default?
  • Is the credential scoped to the minimum permission?
  • Is the user identity propagated when needed?
  • Are destructive actions blocked or approval-gated?
  • Are tool inputs and outputs logged with sensitive fields redacted?
  • Are prompts prevented from inventing tool permissions?
  • Are retries idempotent?
  • Is there a rollback or compensation path for writes?

Step-by-step adoption guide

  1. Inventory the tools the agent needs: filesystem, shell, Git, issue tracker, CRM, database, cloud APIs.
  2. Classify each tool as read-only, write, destructive, or sensitive.
  3. Start with read-only tools and local development tools.
  4. Wrap tool calls behind a gateway or policy layer before exposing production systems.
  5. Add approval gates for write and destructive actions.
  6. Log tool call intent, arguments, actor, result, and trace ID.
  7. Add eval cases for unsafe tool requests.
  8. Review tool access during every new agent capability rollout.

Failure modes

Failure modeSymptomBetter approach
Broad shell access in productionagent can mutate systems unexpectedlyseparate dev harness tools from prod app tools
Tool descriptions are vaguemodel calls the wrong toolnarrow schemas and examples
No approval for writesaccidental tickets, emails, or deploysrisk-tiered approval
Tool output leaks secretslogs or prompts contain sensitive dataredaction and data classification
MCP treated as governanceprotocol exists but policy is absentadd gateway, RBAC, audit, and approval
No audit logimpossible to investigate incidentstrace every tool call

References

Built as a static bilingual AI engineering stack guide.