esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Letโ€™s talk

Iโ€™ll build the agent for it.

Design a Tool Layer for Native, OpenAPI and MCP Tools

How to put native code, OpenAPI endpoints and MCP servers behind one safe tool layer, explained simply for your AI interview.

In short

A tool layer puts native code, OpenAPI endpoints and MCP servers behind one interface. It checks every call, asks a person before risky actions, sets timeouts and logs each call, so the model sees one consistent set of tools.

12 min readAdvancedOccasional ยท estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

A tool layer is the one piece of our agent code that turns every tool into the same shape. Some tools are our own functions, some come from an OpenAPI spec, and some come from MCP servers that other teams run. The layer checks each input, asks a person before any action that sends money or deletes data, sets a timeout, and logs the call. The model sees one tidy list. Everything risky sits in one place we can test.

What is a tool layer, in plain words?

A tool is a function the model may ask us to run, such as looking up a policy or sending an email. The model never runs it. Anthropic puts it this way: "Your code runs the operation and sends back a tool_result."

Picture the booking desk at a mid-size firm. Staff book flights through one screen, even though each airline has its own system, rules and outages. The desk checks who may book business class, asks a manager before a big spend and logs every booking. A tool layer does that job for an AI agent.

Take an insurer's claims assistant. It reads policies from the insurer's own database, gets repair quotes from a partner garage network's web API, and searches documents on a legal team's MCP (Model Context Protocol) server. Three sources, three styles, one model. The layer hides those differences from the model.

Key words

Tool
A function the model can ask us to run, with a name and a list of inputs.
Native tool
A function we write in our own code, running inside our app.
OpenAPI tool
A tool built from an OpenAPI spec, the standard file that describes a web API's endpoints.
MCP server
A separate program, run by someone, that offers tools over the Model Context Protocol, an open standard.
Tool layer
Our one piece of code that puts every tool into one shape and checks each call.

How do native, OpenAPI and MCP tools differ?

  • Native

    Our own code

    We write the function and it runs inside our app. It is the easiest kind to test.

  • OpenAPI

    A contract from the API owner

    We read a standard spec file and turn chosen endpoints into tools. Microsoft's Foundry docs (its platform for AI apps and agents) say: "OpenAPI specifications provide a formal standard for describing HTTP APIs." We expose a few endpoints, not every one.

  • MCP

    A server that offers tools

    Another team runs a server that offers tools over the Model Context Protocol. Our client asks it which tools exist, using a standard request called tools/list. The server can change its list later and announce the change.

The trust level differs too. Our own code is ours to vouch for. An OpenAPI spec is a contract the vendor can change. An MCP server supplies its own tool annotations, which describe tool behaviour, and the MCP spec says that "clients MUST consider tool annotations to be untrusted unless they come from trusted servers".

Two details come up in interviews. Foundry's OpenAPI tool needs an operation name on every function, and the spec itself does not ask for one. Foundry also allows one API key security scheme per spec. A spec with two needs two OpenAPI tools.

One tool layer, three sources

Agent

Asks for a tool

Tool layer

Check every call

Inputs, rights, timeouts

Ask a person

Before any act-level tool

Log the call

Who, what and the result

Native adapter

Calls our own functions

OpenAPI adapter

Calls HTTP endpoints

MCP client

Talks to MCP servers

Policy database

Our own claims data

Garage quote API

A partner's endpoints

Legal MCP server

Another team's server

  1. 1The model asks for a tool by name, with its inputs.
  2. 2A call that passes the checks goes to our own code.
  3. 3The same call, as a web request.
  4. 4The same call, sent to the MCP server.
  5. 5Our code reads our own database.
  6. 6The partner's API answers the quote request.
  7. 7The legal server searches its document index.
The model talks only to the tool layer. The layer checks each call, then hands it to the adapter for its source, and each adapter calls its own backend. The numbers run in the order a call travels.

What must the tool layer do?

  1. 1

    Give every tool one shape

    A name, a plain description, an input schema (the JSON Schema that lists the allowed fields) and a risk level, read or act. The MCP spec defines tools the same way: "inputSchema: JSON Schema defining expected parameters".

  2. 2

    Check every input and keep keys inside

    The MCP spec tells servers they MUST "Validate all tool inputs", and our layer checks too. Keys stay in the layer, so the model never sees them. Foundry gets the same benefit from a managed endpoint, which centralizes "credential management, versioning, and policy enforcement through a managed MCP endpoint".

  3. 3

    Ask a person before anything acts

    Sending money, sending mail or deleting data waits for a yes. The MCP spec says there SHOULD always be a human in the loop with the ability to deny tool invocations.

  4. 4

    Set a timeout on every call

    Set a time limit (a timeout) on every call, so a stuck tool cannot hang the agent. The MCP spec tells clients to "Implement timeouts for tool calls". Retry only reads, because a repeated payment or email does real harm.

  5. 5

    Send errors back as text the model can fix

    The MCP spec says tool execution errors should carry "actionable feedback that language models can use to self-correct and retry with adjusted parameters". A missing field is an example.

  6. 6

    Log every call

    Record the source, the inputs, the result and the time, so an audit can answer who asked for what. The MCP spec asks clients to "Log tool usage for audit purposes".

  • โ€œFor trust & safety and security, there SHOULD always be a human in the loop with the ability to deny tool invocations.โ€

    Model Context Protocol

  • โ€œProvide extremely detailed descriptions. This is by far the most important factor in tool performance.โ€

    Anthropic

Tip

Do not turn a 200-endpoint spec into 200 tools. Every extra tool is one more choice the model can get wrong, so expose the few the job needs and describe each one well.

How would the layer handle the claims case?

Here are four tools in that insurer's assistant. get_policy is native and only reads our database. get_repair_quote comes from the garage network's OpenAPI spec, and we expose three of its operations, each with a five-second timeout. search_documents comes from the legal team's MCP server. send_settlement_offer is native and acts, so it always waits for a claims handler.

The demo runs that table with the Python standard library. It is simplified: a real layer also checks permissions, and real calls go over the network.

Python
# A simplified tool layer: one table of tools, whatever their source.
TOOLS = {
    "get_policy": {"source": "native", "risk": "read", "needs": ["policy_id"]},
    "get_repair_quote": {"source": "openapi", "risk": "read", "needs": ["car_id"]},
    "search_documents": {"source": "mcp", "risk": "read", "needs": ["query"]},
    "send_settlement_offer": {"source": "native", "risk": "act", "needs": ["claim_id", "amount"]},
}

def call(name, args, approved=False):
    tool = TOOLS.get(name)
    if tool is None:
        return "ERROR: unknown tool " + name
    missing = [k for k in tool["needs"] if k not in args]
    if missing:
        return "ERROR: missing " + ", ".join(missing)  # plain text, so the model can fix and retry
    if tool["risk"] == "act" and not approved:
        return "WAITING: a claims handler must approve " + name
    return "OK: " + name + " via " + tool["source"]

print(call("get_policy", {"policy_id": "P-1042"}))
print(call("get_repair_quote", {}))
print(call("send_settlement_offer", {"claim_id": "C-881", "amount": 2400}))
print(call("send_settlement_offer", {"claim_id": "C-881", "amount": 2400}, approved=True))
print(call("delete_claim", {}))

Output

OK: get_policy via native
ERROR: missing car_id
WAITING: a claims handler must approve send_settlement_offer
OK: send_settlement_offer via native
ERROR: unknown tool delete_claim

Read the output from the top. The first call passes. The second is missing a field, so the model gets text it can fix. The settlement waits for a person, and goes through once approved. A tool that is not in the table is refused.

How would you handle two MCP servers that both offer a search tool?

Tool names should be unique inside one server. The MCP spec says "Tool name uniqueness is scoped to a single server." It adds that proxies combining several servers MAY encounter naming collisions.

The fix is a stable prefix that the layer adds, such as legal_search and docs_search. Set the prefix in one place, the layer's table, so the model, the logs and the audit all agree on which server answered.

Tip

Keep the prefix stable across releases. If it changes, saved prompts, tests and logs quietly point at the wrong tool.

What does the interviewer want to hear?

A strong answer covers

  • One internal tool shape, with a thin adapter for each source.
  • Native, OpenAPI and MCP differ in who owns the code and who can change it.
  • Every input is checked, and keys stay inside the layer.
  • Anything that acts waits for a person, and reads get timeouts.
  • Errors go back as text the model can fix, and every call is logged.
  • Few tools, well described, with stable names across sources.

Common traps

  • Trap"Expose every endpoint, so the model has more options."

    BetterMore tools means more wrong picks. Expose the few the job needs, and describe each one well.

  • Trap"The MCP server is safe because it uses a standard."

    BetterA standard only says how tools are offered. Use only servers on your approved list, and treat their tool annotations as untrusted input.

  • Trap"Put the API key in the prompt so the model can call the API."

    BetterKeys stay in the layer, so the model never sees them. The layer makes the call on the model's behalf.

Can you spot the risky tool?

Spot the risky tool

Which of these tools should the layer hold until a human approves?

Quick check

Your agent has a native search tool, and a partner's MCP server also offers search. What is the cleanest fix?

Can you answer these from memory?

Flash cards ยท tap a card to flip it

1 / 6

What will they ask next?

  1. Q190How do you trace and debug an agent run?11 min
  2. Q191What is memory poisoning?12 min
  3. Q194How do you design stop conditions?12 min
  4. Q198How do you roll out a new agent version safely?14 min
  5. Q201What is prompt injection?12 min

Learn it in depth

Last updated on 27 November 2026

Wiring tools from three sources into one agent?

Venkat designs and builds AI products and agents, including the UI and the system behind it. Book a short call and say which tools your agent needs and where they live.