Connecting tools
Stand up an MCP tool server, secure it, register it in the project, reference it from the manifest, and design tools the agent calls correctly.
Context — Assumes the Tools concept page. This guide covers the practical side: building a server, wiring it in, authentication, and — most importantly — designing tools a language model uses well.
YAML examples follow manifest schema 9.10.0. Manifest and content shapes are schema-versioned and differ across runtime versions — see Versioning & compatibility.
1. Build an MCP server
The agent consumes tools over the Model Context Protocol with the streamable-http transport. Any MCP-compliant server works; in Python, fastmcp is the shortest path:
pip install fastmcp"""CRM tool server example."""
from fastmcp import FastMCP
mcp = FastMCP("crm")
@mcp.tool
def get_account_status(party_id: str) -> dict:
"""Fetch the current account status for a customer.
Args:
party_id: The customer's PARTYID exactly as provided by
authentication — do not transform it.
Returns:
{"status": "ACTIVE" | "SUSPENDED" | "CLOSED",
"since": "YYYY-MM-DD",
"reason": str | None}
"""
record = lookup_account(party_id)
return {
"status": record.status,
"since": record.status_since.isoformat(),
"reason": record.status_reason,
}
if __name__ == "__main__":
mcp.run(transport="streamable-http", host="0.0.0.0", port=8001)Requirements on your side:
Transport:
streamable-httponly.Reachability: the agent connects to the address you register in step 2. A self-hosted server runs inside the project. A remote server's URL must be reachable from the platform: a public URL, or an address your platform networking allows. The agent connects out to your server; it never needs to reach in.
Statelessness between calls is your design choice; the agent passes whatever parameters the tool declares, nothing more.
2. Register it and reference it from the manifest
Register the server as an MCP in your project, then reference it by name from agent_config.mcps. When the platform deploys the agent, it resolves each reference into the server's address and credential.
To register a server you host elsewhere, give its URL, endpoint path included:
The credential defaults to bearer auth. To send it in another header, add --auth-header X-Token --auth-header-prefix "Token ". You can also add a remote server in the platform UI under Connectors as a Custom MCP.
To have the platform run the server from your container image, register it as self-hosted:
Add --path /api/mcp when the server mounts MCP on a non-default path, and --endpoint to expose it publicly. A provider from the platform catalog needs only its catalog id and credential: iai mcps create github --catalog-id github --credential "$GITHUB_TOKEN".
Check that the connection works by listing the tools it exposes:
Then reference the MCP from the manifest:
iai agents create and iai agents update write this entry for you with --mcp crm. To call the tools under a prefix other than the MCP's name, use the object form, or pass --mcp crm-prod --mcp-id crm:
ref
string
yes
—
Name of the MCP connection registered in the project.
id
string
no
ref
Namespace prefix applied to this MCP's tools at runtime.
endpoint
private | public
no
private
Which endpoint of the MCP the agent connects to. private is reachable only within the project. public needs a self-hosted MCP with its public endpoint enabled.
A bare string entry is the ref, with id defaulting to it.
idbecomes the namespace: this server'sget_account_statusis referenced everywhere ascrm:get_account_status. Pointing a dev agent atcrm-devand a prod agent atcrm-produnder the sameidlets one set of routines call either. Within one manifest, everyidmust be unique.The credential lives on the registered MCP, not in the manifest or the secret bundle. The platform injects it at deploy, and the agent sends it on every MCP request, as
Authorization: Bearerunless you registered a custom header. Your server must check it on every request; the platform doesn't.Deploy the agent through the platform. A manifest that reaches the agent with an unresolved reference fails boot with
Unresolved MCP references in agent_config.mcps: <names>.The agent connects at boot and fails startup if the server is unreachable; at runtime, transient failures reconnect automatically.
3. Designing tools the agent calls well
The model sees three things: the tool's name, its description, and its parameter schema (names, types, defaults, per-parameter docs). It decides when and how to call based on those alone. Treat them as a prompt:
Name by intent, verb-first. search_cars, create_booking, cancel_booking — not cars_api_v2 or do_action.
Document the contract, not the implementation. Say what goes in, what comes out, and the gotchas:
Return errors as data, not exceptions. A structured {"error": "driver_age below minimum of 21"} lands in the conversation history where the model can read it, explain it, and recover. An exception gives it nothing to work with.
Keep results lean and labelled. The entire result enters the model's context. Return the fields the agent needs, with self-explanatory names and enum-like values ("ACTIVE", not 2). Page or summarise large sets — "the cheapest 5 of 23 matches" is a better tool result than 23 rows.
Make state-changing tools idempotent where possible. The model may retry after ambiguous failures; accepting an idempotency parameter or deduplicating server-side prevents double bookings.
One capability per tool. A manage_booking(action=...) multiplexer forces the model to learn your switch statement. Separate cancel_booking, update_booking_dates, get_booking tools each carry their own focused documentation.
4. The other half: tool use in content
The server defines what can be called; routines and policies define when and how:
A routine tool node pairs
tools: crm:get_account_statuswith atool_instructionexplaining parameter derivation in this flow's context.A policy lists
tools:it may invoke from its action.If a tool changes what the engine should believe (authentication, status changes), register it in
context.reevaluation_toolsor the policy'sreevaluate_after— see Reevaluation tools.
Tool descriptions answer "how do I call this correctly?"; instructions answer "why now, with which values from this conversation?". Don't duplicate one into the other.
5. Verify the wiring
Boot the agent; startup fails fast with the server name if an MCP server is unreachable.
Send a message that should trigger the tool; watch the event stream for the
toolevent carryingtool_id,arguments, andresult(isinstance(ev, ToolEvent)in the SDK).Check the trace: each tool call appears with its arguments and result — see Observability.
Test the failure path: stop your MCP server mid-conversation and confirm the agent degrades the way you want (the failed call is visible to the model, which explains per its instructions).
Checklist
Last updated
Was this helpful?

