AI agent API tools are the declared interfaces through which a language model asks for something outside itself: a weather lookup, a customer record, a database query, a message sent on a user’s behalf. The model does not make the call itself. It emits a structured request, host code or a tool server executes it, and the result returns as a new observation. This article explains that mechanism, compares function calling, direct API calls, standard protocols such as MCP and A2A, and database access, and ends with the guardrails that decide whether an integration is safe.
What a tool is to an AI agent
A tool is a declared capability: a name, a description, and an input schema stating what arguments it accepts. The description matters as much as the types, because it is the model’s main evidence for when to use the tool and how to fill in each field. A precise description produces requests the host can actually execute.
The work happens in a loop. The model reasons over the conversation, decides it needs external information or an external action, and returns a structured tool call instead of plain text. Host code looks up the tool by name, validates the arguments, executes the real operation, and sends the result back. Nothing in this loop gives the model direct access to your network, files, or credentials: external effects are executed by the host, a provider runtime, a remote tool server, or the database, each enforcing its own validation, credentials, and permissions. Each stage leaves a record for debugging.
Function calling: how models request a tool

Function calling, also called tool calling, is the dominant mechanism by which a model requests an external action. The developer describes each function using JSON Schema. In OpenAI’s original formulation, developers could describe functions to the model and have it intelligently choose to output a JSON object containing the arguments to call those functions. Anthropic’s Claude API works the same way in structure: the model returns a tool_use block, the host executes the tool, and the result returns in a tool_result message, repeating while the stop reason is tool_use.
A tool definition is deliberately small. The following JSON is an illustrative tool definition in the shape described in the Anthropic tool-use documentation consulted for this article — a name, a description, and an input schema. Other providers use different wrappers and field names, so adapt it to the API you call:
{
"name": "get_order_status",
"description": "Look up the current status of one order by its order ID. Use only when the user asks about a specific order.",
"input_schema": {
"type": "object",
"properties": {
"order_id": {
"type": "integer",
"description": "The numeric order ID supplied by the user."
}
},
"required": ["order_id"],
"additionalProperties": false
}
}Three controls shape this in practice. The host decides how much choice the model gets: leave the choice to the model, force a specific tool, or forbid tool use for a turn. Independent lookups can run in parallel; calls with ordering dependencies must be serialised. Validation happens in the host: required fields are checked before anything executes. The failure modes — hallucinated arguments, the wrong tool when descriptions overlap, a missing field — become routine, recoverable events when the host validates, rejects malformed calls clearly, and logs every call.
AI agent API tools in practice: REST, SDKs and generated clients
Most integrations bottom out in an ordinary HTTP API. The host builds a request from the model’s arguments, sends it, and returns the response. Authentication is the host’s job: a key or token is attached from the host’s own credential store, never from model output. Retries, timeouts, and rate-limit handling also belong to the host.
Vendor SDKs wrap that HTTP work. Official SDKs handle authentication, request formatting, and error handling, but they hide detail — the request built, the errors retried, the defaults applied — so keep logging at the HTTP level even when an SDK does the calling.
OpenAPI descriptions offer a middle path. OpenAPI is a vendor-neutral standard for describing HTTP APIs in a machine-readable JSON or YAML document: paths and methods, parameters and bodies, responses, authentication, and data shapes using JSON Schema. One file can feed documentation renderers, client generators, validators, and mock servers. The following fragment shows one operation; it is an excerpt, not a complete file:
openapi: 3.1.0
info:
title: Orders API
version: 1.2.0
paths:
/orders/{order_id}:
get:
summary: Get one order by ID
parameters:
- name: order_id
in: path
required: true
schema:
type: integer
responses:
"200":
description: The requested order
content:
application/json:
schema:
type: object
properties:
status:
type: stringChoose a direct call when the integration is simple and the API stable. Add a protocol layer, described next, when several hosts need the same tools, when tools must be discovered rather than hard-coded, or when provider and host are built by different teams.
Standard protocols: MCP, OpenAPI and agent-to-agent communication
The Model Context Protocol (MCP) is an open standard for connecting AI applications to external systems, introduced by Anthropic in November 2024. It standardises how a host discovers and calls tools, reads data, and fetches prompt templates. MCP has three roles: the host is the AI application; the client is a connector inside the host, one per server; the server is the program exposing capabilities — a database, a file system, a SaaS product, or an HTTP API.
Servers offer three primitives: tools the model can invoke, resources the application can read into context, and prompts, reusable interaction templates. Each follows a list-then-use pattern over JSON-RPC 2.0: tools/list returns the tools a server has, and tools/call runs one with given arguments. The following two messages are complete JSON-RPC 2.0 requests as the protocol defines them:
{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}
{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "get_order_status", "arguments": {"order_id": 42}}}MCP standardises two transports: stdio for local servers and Streamable HTTP for remote servers, which requires an authentication layer. The older HTTP and server-sent-events transport is described as deprecated in the sources consulted. The specification has been revised several times, so check the current revision before relying on a version-specific detail.
Authorisation for remote MCP servers follows OAuth 2.1: the server acts as OAuth resource server, the client as OAuth client, and a separate authorisation server issues tokens. A client without a token receives a 401 challenge pointing to protected resource metadata, discovers the authorisation server, and sends the resulting token, issued for that one server, as a bearer token on every request. Local stdio servers instead take credentials from the environment. The protocol does not decide whether a particular tool call should run, who the agent acts for, or what the server’s credentials may reach; those decisions remain with host and server.
Where MCP connects an agent to tools, A2A connects agents to each other. A2A is an open standard, announced by Google in April 2025, letting agents built by different vendors discover one another and delegate work. A remote agent publishes an Agent Card, a JSON document usually served at /.well-known/agent-card.json, listing its name, endpoints, authentication requirements, formats, and skills. A client reads the card and sends a message, receiving a direct reply or a trackable task. Version 1.0, released in March 2026, defines three bindings — JSON-RPC 2.0, gRPC, and HTTP with JSON — with operations including SendMessage, GetTask, and CancelTask. The following fragment is a conceptual illustration of the Agent Card contents described in the research — name, endpoints, authentication, formats, and skills — with one skill shown. It is not specification-validated: check it against the current A2A specification before use:
{
"name": "Shelf Vision Agent",
"description": "Checks shelf stock from store camera images.",
"version": "1.0.0",
"supportedInterfaces": [
{"url": "https://example.com/a2a", "transport": "JSONRPC"}
],
"capabilities": {"streaming": true},
"defaultInputModes": ["text"],
"defaultOutputModes": ["text"],
"skills": [
{
"id": "check-shelf-stock",
"name": "Check shelf stock",
"description": "Report stock levels for one shelf from a camera image.",
"tags": ["retail", "vision"]
}
]
}Use A2A when the work belongs to another agent — a long-running job with its own tools and memory — and direct tool use when your agent can call an API or query a database itself. Delegating to an agent you cannot inspect costs observability, so reserve it for work where that specialisation justifies the cost.
Databases: queries, guardrails and read versus write access

Agents reach databases through several patterns, and the pattern decides the risk. The simplest is a narrow tool: get_order_status runs a fixed query with one parameter, and the model never sees SQL. Next come query builders and ORMs, which construct queries from structured arguments. Then generated SQL, where the model writes the query from a schema description. Finally, vector-store retrieval returns relevant passages over unstructured data rather than querying tables. Compare each pattern by the operations and data it exposes: generated SQL needs query validation and database controls, while vector retrieval, which returns passages from stored content, carries its own access and untrusted-content risks.
Generated SQL most needs discipline: a model can write a statement that changes data, read tables it should not see, or run an expensive query, and no prompt can prevent that. Safety must sit outside the model: a dedicated read-only role so the database refuses writes; a parser accepting only a single SELECT over an allow-list of tables or views; a statement timeout and row cap; and a record of question, SQL, user, and outcome for every request. The evidence-backed requirements for such a role are: a dedicated login that can only read; access limited to approved views or tables; and a statement timeout and a row cap.
View restriction works only when the role’s access is limited to the approved views, with direct access to underlying tables withheld.
Read-only views add a layer when they are the role’s only access path: a view exposes only needed columns, and direct access to the underlying tables is withheld, so a column the role cannot see is one the model cannot leak. Writes need different guardrails: transactions, an idempotency key so a retry does not apply twice, and, for anything destructive or irreversible, human approval or a reviewed dry run. Writes can change persistent state and require additional safeguards, with approval for destructive or irreversible operations — and reads still need confidentiality controls, since a read can expose data that should not leave the system.
Choosing and combining tools and protocols
Choosing well starts from the task. A single lookup against a stable API needs a direct call with a clear schema and timeout. A tool several hosts must share is a candidate for an MCP server, so it is discovered and versioned in one place. A job another specialist agent does well is a candidate for A2A delegation. A question over your own tables is usually a narrow read tool or a guarded generated-SQL path.
The mechanisms combine freely. An MCP server often wraps a REST API; function calling can sit on a database view while the database enforces read-only access; an SDK can handle the model API while a protocol layer handles discovery. At each join, ask: which layer validates, authenticates, and logs? If no layer owns one of those jobs, the integration has a gap.
Before adding a tool, check: a precise description and validatable schema; a credential scoped to least privilege; timeouts, retries, and result-size limits; logging of every call; and fail-closed behaviour when the external system is down or returns something unexpected. A tool failing that checklist needs its guardrails built first.
Limits, security and common mistakes
The sharpest security failure is indirect prompt injection: the payload arrives in content the agent was asked to read — a page, document, email, or API response containing text that reads like an instruction. The model reads tool results in the same context as its instructions and can mistake that text for a direction. The defence is architectural: treat every tool result as untrusted data, and never let model or tool output become a credential, query, or destination without host-side checks.
Three mitigations do most of the work. Grant tools per task phase: an agent summarising a page needs a read tool only, and exfiltration-capable actions should require human approval after untrusted content has been read. Constrain destinations with allow-lists from configuration, not generated text. And separate reading from acting where stakes justify it: a read-only step extracts structured facts, and a second step acts on those, never on raw retrieved text.
The remaining mistakes are operational. Over-granting tools turns every model error into a blast radius. Unbounded results flood the context. Missing idempotency duplicates a retried write. Absent audit trails make the first incident unexplainable. All are decided in the enforcement layers around the model — host code, tool servers, and database permissions — which is why those layers, not the model alone, are where agent integrations are won or lost.











