Beyond MCP: Five Lightweight Ways to Give AI Agents Tools

The Model Context Protocol has become the default answer to a question most developers ask exactly once: how do I let a model call a function? The answer is usually correct in spirit and oversized in practice. If all you need is lookup_product(sku), standing up a full MCP server is like hiring a switchboard operator to answer one phone.

That is not an argument against MCP. It is an argument for choosing the smallest place your function can live, given what you already run. The five routes below are not competing standards. They are five locations for the same function: a Python dispatcher, an agent framework’s tool decorator, a REST adapter, a subprocess, and a webhook. What separates them is not protocol purity. It is how many integration and deployment responsibilities you take on in your current environment.

A note on depth before we start: the first two routes get a fuller treatment because they are where the runtime details matter most, and the last three are presented as brief sketches of locations. The goal is not equal coverage but a clear map of where a function can live.

The Single-Function Problem

“Lightweight” gets used as a synonym for “simple,” which hides the actual trade. A lightweight tool route is one that adds few new things to operate: no new service to deploy, no new process to monitor, no new schema to keep in sync with a second client. By that measure, a full MCP server for one lookup function is heavy, and a Python function you already own is light.

The five options differ almost entirely in that dimension. They do not differ much in what happens at runtime, which is the point most comparisons miss.

What MCP Actually Requires

A common misconception is that adopting MCP forces you to run a network service. It does not. The protocol runs over stdio on the same machine as the host as well as over Streamable HTTP. If you want a local server process, you can have one; the protocol has also been shedding session overhead, as we covered in MCP Goes Stateless: Building a Python Server with the v2 SDK.

So the honest case against MCP for a single function is narrower than the folklore: it adds a server to maintain, a tool description to keep accurate, and a discovery surface you may not need. That is a real cost. It is not a network cost.

The Shared Execution Pattern Behind Every Option

Strip away the transport and all five routes do the same four things.

  1. The model proposes a call: a tool name and arguments.
  2. The application checks the proposal against a contract it owns. The name must be allowed, the arguments must fit the declared shape, and the operation must be permitted for that user.
  3. An executor performs the work.
  4. The result, or an explicit error, goes back to the model.

The alternatives change who the executor is and where the function runs. They do not change the business rule, and none of them removes the application’s checks. This is where OWASP’s excessive-agency guidance becomes concrete: its three failure modes are too much functionality, too many permissions, and too much autonomy. All three are decided by what your application allows, not by whether the call arrived over stdio, HTTP, or a decorator.

If you are still building the mental model for the propose-check-execute loop, Build Your First AI Agent in Python: Inside the OpenAI Agents SDK walks through it from the ground up.

The Test Setup

To keep this concrete, every output below comes from a small experiment. The catalog is invented: SKU BK-17 is an A5 field notebook priced at USD 12.99, and every record carries fixture: true so test data can never be mistaken for production. The model was qwen3.5:4b running on Ollama 0.40.13. These are illustrative versions chosen for the experiment, not a claim about the current release of either tool. Nothing shown here is paraphrased; these are the strings the code printed.

Option 1: A Python Dispatcher with Provider-Native Tool Calling

Ollama’s native tool calling is a three-step exchange. First you send the tool schema with the chat request, and the assistant replies with tool_calls instead of text. Then you run the call and append a tool message carrying the result. Finally you ask again, and the model answers with the result in hand.

The dispatcher is the entire security model of this route, which is why it must be a fixed dictionary mapping tool names to functions. Never getattr on a module, never anything the model can name into existence. A dictionary you wrote is a closed set; a string lookup is an open one.

The error path is the interesting part. When the model requested a SKU that does not exist, the dispatcher returned a structured error object rather than raising an exception. The model then told the user the SKU was not found instead of inventing a price. That behavior is not guaranteed by the model; it is encouraged by giving the model a clean, machine-readable failure to reason about.

One more note on thickness: the function behind the boundary can be arbitrarily complex. A document-processing tool could extract table data from PDFs inside an SDK-backed function, so the agent receives returned fields rather than managing a parser itself. That would bring its own licensing terms from the vendor; the catalog example here needs only the standard library.

The Portability Trade-off

The dispatcher route has a hard ceiling. Message shapes are Ollama-specific, and other providers lay out tool_calls differently. You own the loop, the turn limit, and the error handling. For one application with a handful of functions, that is a fine bargain. The moment a second client wants the same tools, you are maintaining parallel glue, and the calculus flips toward a shared server.

Option 2: Agent Framework Tools

If your agents already live inside a framework, the dispatcher collapses into a decorator. PydanticAI’s typed function tools build the model-facing schema from the function signature and docstring; @agent.tool_plain is the variant for functions that need no run context.

In the test, the framework generated the schema from one type hint and one docstring line, and added additionalProperties: false without being asked. That single line closes the door on undeclared arguments, and it appeared for free.

Validation behavior deserves attention. Pydantic’s strict mode rejected 17 where a string was declared. By default, Pydantic coerces when it can, so rejecting rather than repairing model arguments is a choice you must state explicitly. When a tool does want to give the model another attempt, ModelRetry sends the bad argument back with an explanation.

Authorization Doesn’t Come Free

Here is the boundary that decorators do not cross. Nothing in @agent.tool_plain knows whether a given user is permitted to run the operation. The framework validates shape; it does not validate entitlement. That check stays with the developer, along with the decision to reject malformed arguments rather than quietly coerce them. A schema is a contract about form, not a policy about people.

Options 3 – 5: REST Adapters, Subprocesses, and Webhooks

The remaining three routes follow the same logic, matched to where the function already lives. Each is a location rather than a protocol, so the details below stay at the level of what changes when you pick it.

REST adapter. A REST adapter wraps an endpoint you already expose. The tool schema mirrors the request body, and the executor is an HTTP client; your existing authentication and rate limits apply.

Subprocess. A subprocess invokes a command-line tool you already ship, with the arguments passed as a validated argument list and the output parsed into structured data. This is the natural fit when the logic is already a CLI and rewriting it as a library would duplicate behavior.

Webhook. A webhook hands the call to a workflow platform you already operate, which owns retries and downstream steps.

None of these is a rival to MCP. Each is a location. The question is which location your function already occupies.

Choosing Your Route

Work backward from what you own. If the function is a Python callable and one application consumes it, use a dispatcher with native tool calling. If your agents are already framework-shaped, use the framework’s typed tools and turn on strict validation. If the function sits behind a REST API, adapt the endpoint. If it is a CLI, spawn it. If it lives in a workflow platform, fire a webhook.

MCP becomes worth considering when the function needs to be discovered and called by more than one host, or when you want a shared description that outlives any single application. The crossover point depends on how many clients you expect and how much you value a standard discovery surface over a dictionary you control, so treat it as a judgment call rather than a fixed number.

What does not change at any point on that spectrum is the security model. Whether the call arrives through stdio, a decorator, an HTTP client, or a subprocess, the application still decides what the model may name, what shape the arguments must take, and who is allowed to ask. The transport moves the function. It never moves the check.

Similar Posts