Starts Nov 23Live Cohort 3 of Vibe Coding & AI Agents (Nov 23, 18:30 MSK): 3 weeks, 9 live hands-on sessionsCohort 3 (Nov 23) →
ReleaseAPI / Product · ActionableKDnuggets→ original

How to Give an AI Agent a Tool Without an MCP Server: Five Lightweight Approaches from KDnuggets

MCP is a common protocol for connecting tools to AI, but for a single function like "price by SKU," a separate MCP server is usually unnecessary. KDnuggets compared five lightweight approaches: a dictionary dispatcher, tools inside an agent framework, an adapter to a REST API, running a command, and a webhook. The model only proposes a call; validation and permissions stay with the application. MCP makes sense when the same tools are needed by several clients.

AI-processed from KDnuggets; edited by Hamidun News
How to Give an AI Agent a Tool Without an MCP Server: Five Lightweight Approaches from KDnuggets
Source: KDnuggets. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceKDnuggets ↗
Editor-in-Chief
Test on qwen3.54b: for a nonexistent SKU, the model did not make up a price
Command that hangsafter 5 seconds the agent got an error instead of freezing
REST adapterhost and path in the config, key from the environment, redirects forbidden

When a developer wants a model to call their function, the hand often reaches for MCP, the Model Context Protocol, a shared protocol through which AI applications discover and call external tools. But if you need one simple operation, such as fetching a product's price from a catalog by SKU, standing up a separate MCP server usually isn't worth it. KDnuggets (author: Nahla Davies) compared five lightweight ways to wire up such a function: a simple dictionary dispatcher in Python, tools inside an agent framework, an adapter to an existing REST API, running a command as a separate process, and a webhook, meaning a plain HTTP request to someone else's workflow.

All examples use the same case: an A5 notebook with SKU BK-17 priced at 1299 cents. The model in the runs is qwen3.5:4b on Ollama 0.

40.13.

The author is upfront about one caveat: MCP does not require a network service. The protocol version dated July 28, 2026 also works over stdio on the same machine. The five options are not competing standards but five places where the same function can live, depending on what you already have.

What stays the same in every option

The scheme is always the same. The model proposes a call: a tool name and arguments. The application checks the proposal against its own contract: the name is allowed, the arguments match the expected shape, and the user is permitted to perform this operation. Then the executor does the work and returns data or an explicit error. All five approaches change only the executor and where it runs, not the business rules or the checks. The OWASP classification identifies three sources of problems: too many functions, too many permissions, and too much autonomy. All three are addressed in the application, not by the connection method.

The five approaches in order

1. Native tool calling and a small dispatcher. If the function lives in the same Python process, the provider's interface and a dictionary are enough. You send the tool schema with the request, get tool_calls from the model, run the call yourself, add the result as a message with the tool role, and ask again. The dictionary must be fixed: a name that isn't in it is never executed. In a test with a nonexistent BK-99, the application returned a structural error, and the model honestly said it could not find a price rather than inventing one. The downside is coupling to Ollama's message format; the loop, turn limit, and error handling remain your responsibility.

2. Typed tools in a framework. In PydanticAI, the schema is built from the function signature and docstring, and the dispatcher is replaced by a decorator. The framework added additionalProperties: false on its own, and Pydantic's strict mode rejected the number 17 instead of a string (by default, Pydantic tries to coerce types). ModelRetry returns an error message to the model so it can retry. You still check permissions yourself. The cost is a dependency (pydantic-ai 2.66.0 in the test) and reliance on the framework's conventions.

3. Adapter to an existing REST API. If the operation already exists in a service, you need a small adapter for one vetted operation, and the OpenAPI description serves as a map: method, path, parameters, security requirements. The address and path are set in configuration, the key is read from the environment and never comes from the model's arguments, response size is capped, the shape is validated, and redirects are forbidden. You are still responsible for storing the key, handling API version changes, and normalizing the response if fields get renamed.

4. A single command via subprocess. Never let the model write command lines. Instead, fix the executable and the script, and pass input and output as JSON. The command is passed as a list, without a shell, so the shell interprets nothing. In the test, the script was told to hang, and the calling code returned an error after 5 seconds rather than stalling the agent. But the child process runs with your permissions, so the protection is validating the SKU against a pattern before launch and choosing the script in advance. Untrusted code requires real isolation, and at that point the approach is no longer lightweight.

5. A webhook to a ready-made workflow. It looks similar to the REST adapter, but on the other side there is not one service operation but someone else's process with its own steps.

In n8n, this is a pair of a Webhook node with header authentication and a response node. The client distinguishes three states: 200 with status completed means the result is ready; 202 means the work was accepted but not finished (a job_id came back to check via restock-check); 401 means rejected, with a reason. The application does not declare a check complete and does not retry a write just because the first call was slow.

The author's caveat: if you don't already have a workflow platform, deploying one just for a single function isn't worth it.

When you do need MCP

The author's table gives the criteria. A dispatcher stops being enough when several providers or clients need the same contracts. A framework isn't justified when the lock-in costs more than the code it saves. The REST adapter gets heavy with broad, frequently changing specifications, and the webhook when deploying the platform costs more than the integration itself. The practical takeaway is simple: start with the option closest to your stack, keep the checks in the application, and move to MCP when the same tools are needed by different clients. Caveat: all examples work with a fictional catalog and local stubs, not production systems.

Story

Key Questions Answered

What stays the same in every option?

The scheme is always the same. The model proposes a call: a tool name and arguments. The application checks the proposal against its own contract: the name is allowed, the arguments match the expected shape, and the user is permitted to perform this operation. Then the executor does the work and returns data or an explicit error. All five approaches change only the executor and where it runs, not the business rules or the checks.

What are the key details on The five approaches in order?

1. Native tool calling and a small dispatcher. If the function lives in the same Python process, the provider's interface and a dictionary are enough. You send the tool schema with the request, get tool_calls from the model, run the call yourself, add the result as a message with the tool role, and ask again. The dictionary must be fixed: a name that isn't in it is never executed.

When you do need MCP?

The author's table gives the criteria. A dispatcher stops being enough when several providers or clients need the same contracts. A framework isn't justified when the lock-in costs more than the code it saves. The REST adapter gets heavy with broad, frequently changing specifications, and the webhook when deploying the platform costs more than the integration itself.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Hands-On AI Engineering · Hamidun Academy

Build & Ship Production AI Agents Without Boilerplate Code

Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.

Start 72h Free Trial →Vibe-Coding Intensive
What do you think?
Loading comments…