The exception path built in Part 4 can now wait for a missing document, loop back to the person and hand over when it should. At the illustrative public service counter, the next request is practical: the person wants to know when they can come back, and would like a slot booked. For that, the workflow needs to reach another system. It needs a tool.
This is where a wrong answer can become a wrong action. Until now, the worst outcome of a mistake was a misleading reply that a person could question. A tool that books, changes or sends something acts in the world, under someone's authority, and may be impossible to take back quietly.
Treat every tool as a permission with a contract: give each step the fewest tools it needs, validate what goes in and what comes out, treat every result as untrusted input, and keep write actions out of the first version until they are idempotent and approved.
A tool is a contract
A tool has three parts that matter for governance, and the function body is the least important of them.
- The input contract: what arguments it accepts, in what format, within what limits.
- The output contract: what shape the result takes, so it can be checked before the model sees it.
- The side-effect class: whether it reads, writes, sends or deletes, and whether a repeat call is harmless.
LangChain's tools page (checked on 25 November 2026) builds the input contract from the function. The @tool decorator, imported from langchain.tools, uses the docstring as the description, and the page states that type hints are required because they define the input schema. For tighter inputs, a Pydantic model can be passed as args_schema. Use that to make the contract strict, rather than trusting the model to supply sensible values.
Illustrative; check against the current documentation. Synthetic office codes; no real endpoint.
from pydantic import BaseModel, Field
from langchain.tools import tool
class SlotQuery(BaseModel):
office_code: str = Field(pattern=r"^[A-Z]{3}[0-9]{2}$")
date: str = Field(description="ISO date within the next 30 days")
@tool(args_schema=SlotQuery)
def check_slots(office_code: str, date: str) -> str:
"""Read-only. List open appointment slots at one office on one date."""
return slot_service.lookup(office_code, date) # synthetic client
The description says "read-only" because the model reads it. The code must make it true, because the model is not the control.
The tool boundary card
The decision tool for this part is a boundary card. Fill one in for every tool before it is connected, and keep it with the tool's owner. The example compares the read tool above with the write tool that the counter will eventually want.
| Question | check_slots (version 1) | book_slot (later) |
|---|---|---|
| Side-effect class | Read | Write, affects a person's appointment |
| Which steps may call it | Answer and follow-up nodes only | Booking node only, after confirmation |
| Input limits | Office code pattern, date window | Same, plus slot ID from a prior read |
| Output check | Schema validated before the model sees it | Confirmation reference validated |
| Identity used downstream | Service workload, read scope | The person's delegated authority, write scope |
| Repeat safety | Harmless | Idempotency key required |
| Approval | None | The person confirms; Part 6 designs the pause |
| Timeout and attempts | Short timeout, small attempt budget | Same, and no retry without the same key |
| Owner | Named owner of the appointments service | Same, plus the service process owner |
The source brief's implementation constraints say the same thing in fewer words: keep tools read-only in the first version, use structured schemas for every input and output, and make all side effects idempotent before adding write actions. Add tools only when the system must act walks through the same read-before-write sequence for a different illustrative service.
MCP standardises the connection, not the boundary
The Model Context Protocol lets an application discover and call tools on a server through a standard interface. Its tools specification (revision 2026-07-28, checked on 25 November 2026) is useful precisely because it is clear about what it leaves to implementers.
- Tools are model-controlled, and the specification says there should always be a human in the loop with the ability to deny tool invocations.
- Each tool has an
inputSchema, an optionaloutputSchema, and results that may includestructuredContent. When an output schema exists, clients should validate results against it. - Clients must treat tool annotations as untrusted unless they come from trusted servers. A server that describes a tool as harmless has not proved it.
- Servers must validate inputs, implement access controls, rate limit and sanitise outputs. Clients should confirm sensitive operations, show inputs to the user, validate results before passing them to the model, set timeouts and log tool usage.
- Tool names are unique only within one server. A client that aggregates servers should disambiguate, for example by prefixing names with a server identifier.
On the framework side, LangChain's MCP page (checked on 25 November 2026) describes an MCPAdapter in langchain.mcp whose list_tools() returns tools an agent can use, and points users of MCP before LangChain v1.4.0 to a migration guide. It also notes that a string target must be an http or https URL, and that the adapter rejects other strings because targets often come from configuration or from a model.
Two habits follow. First, a server's tool list is a menu, not an approval. Select the tools each step may use in your own code, by name, and fail closed if an expected tool is missing or a new one appears. Second, put every MCP server through the review that The MCP security review sets out, and design your own servers as products rather than wrappers. LangGraph and MCP solve different problems explains why the graph owns sequence and the protocol owns connection.
Errors, timeouts and loops
Tool calls fail. Design for it before the first call.
The MCP specification separates protocol errors, such as an unknown tool or a malformed request, from tool execution errors, which are returned with isError set and carry feedback the model may use to correct its arguments. LangChain's tools page shows agent middleware, wrap_tool_call, converting tool exceptions into a ToolMessage the model can handle. Both are useful, and both can produce a loop: the model retries, the tool fails, the model retries again.
Bound it in three places. Give every tool call a timeout. Give each tool an attempt budget in the graph state, as Part 4 set up. And route an exhausted budget to a handoff, with the failure recorded, rather than back to the model. A retry policy that lives only in a prompt is not a policy.
Write tools wait for idempotency and approval
When the counter is ready for book_slot, two conditions come first.
Idempotency. A resumed graph can rerun a node, and a network failure can hide whether a call succeeded. Each write carries a key derived from the case and the intended action, and the receiving system refuses a second action with the same key. The third-party manual this series started from, LangChain 101 at aiengineeringfromscratch.com (accessed 25 November 2026), reports crash tests in which a side-effecting tool without an idempotency key was repeated after restarts, and treats the tool rather than the checkpointer as responsible for safe replay. CloudNala has not reproduced those tests; the design principle stands on its own.
Approval. The person confirms the exact slot before it is booked, and the record shows what they were shown. Part 6 builds that pause and the safe resume after it. Approval is a system, not a button covers approval design more widely.
Tool results are untrusted input
Whatever a tool returns enters the model's context. A record field, a document, an error message or a web page can contain text written to redirect the agent. Validate structured results against their schema, strip or quote free text, keep secrets and tokens out of what the model sees, and never let a tool result change which tools are available or what the step is allowed to do. Red-teaming tool-using agents gives the tests.
How NalaTolika applies it
NalaTolika is a CloudNala concept and reference architecture for governed language interpretation. It has no customers, deployments, pilots, data or results. In its reference design, the first version has read tools only, each with a boundary card and a named owner. Tools are selected per step by name, results are schema-checked before the model sees them, every call has a timeout and an attempt budget, and any write action is held back until it has an idempotency key and the person's confirmation.
Next in the series: Human approval and durable checkpoints. All parts are on the series page.
Sources and limits: this article is CloudNala analysis. The MCP tools specification (revision 2026-07-28) and LangChain's tools and MCP pages were checked on 25 November 2026; protocol revisions, adapters and middleware change between releases. The manual at aiengineeringfromscratch.com is a third-party source and its test results are its own. The code is illustrative and synthetic; no CloudNala code lab or repository exists for this series. The boundary card is a CloudNala recommendation. The counter scenario describes no department or organisation. NalaTolika is a concept with no deployments.
How CloudNala can help
CloudNala reviews the tools an agent can reach before they are connected. We write a boundary card for each tool, separate read from write, move tool selection and retry budgets out of prompts into code, check every MCP server against the security review, and set the idempotency and approval conditions a write tool must meet before it goes live.
Work with CloudNala
CloudNala helps organisations move from technology ambition to practical execution across cloud, AI, data, platform engineering and digital services.
Whether you are exploring AI, modernising your cloud environment, building a public-sector digital service, or turning an idea into a working MVP, we can help you shape the roadmap and deliver the next step.
Book an AI Production Readiness Review or write to us at consult@cloudnala.co.za