Agent-First Architecture: MCP Is the Future of APIs

5 min read mcp ai agent api-design rustapi architecture llm

In 2025 everyone was saying "AI will call APIs." In 2026 it actually happened, just not the way anyone expected.

AI agents started calling APIs. But REST APIs weren't designed for them. Swagger docs were for humans. JSON Schema was meant to be read by human eyes. Error codes were built around "developer experience."

Then Anthropic announced MCP. And everything changed.

REST's blind spot

REST was born in 2000 with Roy Fielding's doctoral dissertation. It has been the backbone of the web for 25 years. For human developers it's great: predictable URLs, HTTP verbs, stateless communication.

But to an AI agent, REST looks like this:

Agent: "Get the user's latest order."
API: 401 Unauthorized
Agent: "So I need a token? Where do I get one?"
API: [silence]
Agent: "Let me try GET /orders?filter=latest..."
API: 400 Bad Request, "use 'sort' not 'filter'"
Agent: "..."

AI agents don't get REST's implicit contracts. They need things explicit. A contract where everything is written down, discoverable and machine-readable.

That is exactly what MCP is.

What is MCP?

Model Context Protocol (MCP) is a standard protocol, announced by Anthropic in November 2024, that lets AI agents discover tools and data sources. It runs on top of JSON-RPC 2.0.

Put simply: you tell your AI agent "here are the tools you can use." The agent discovers the tools' names, parameters and descriptions over JSON-RPC. Then it calls whichever one it needs.

// The agent asks:
{"method": "tools/list"}

// The server answers:
{"tools": [{
  "name": "get_weather",
  "description": "Gets the weather for the given city",
  "inputSchema": {
    "type": "object",
    "properties": {
      "city": {"type": "string", "description": "City name"}
    }
  }
}]}

// The agent calls:
{"method": "tools/call", "params": {"name": "get_weather", "arguments": {"city": "İstanbul"}}}

That simple. But that simplicity marks a paradigm shift in API design.

5 principles of agent-first API design

These are the principles I picked up while building RustAPI, while making it the first web framework with native MCP support:

1. Every endpoint should describe itself

For a human developer, GET /api/v2/orders?sort=desc&limit=10 might be enough. For an AI agent, it isn't.

In an agent-first API, every endpoint needs a description, every parameter needs an explanation, and every response needs a schema. Swagger/OpenAPI already did this, but MCP makes it discoverable at runtime, by the agent itself.

2. The input/output contract must be explicit

AI agents don't understand implicit knowledge like "in this case it returns this HTTP status." You have to spell out every possibility:

## What does this endpoint return?

- 200: Success (WeatherResponse JSON)
- 404: City not found (ErrorResponse JSON)  
- 429: Rate limit exceeded, please wait 60 seconds
- 500: Server error, retry

When you write this into the MCP tool description, the agent can handle the error cases. Where were you putting this information in REST? Maybe in Swagger, maybe in the docs, maybe nowhere.

3. Tools should be composable

An AI agent rarely calls a single endpoint. Usually it chains several:

  1. Find the user (search_users)
  2. Get their orders (get_orders)
  3. Pick the latest one (- the agent does this itself)
  4. Track the shipment (track_shipment)

In an agent-first API, tools should be designed so one tool's output can be another's input. The user_id that search_users returns should have the same name and the same format as the user_id that get_orders expects.

I call this tool compatibility.

4. The permission model should be granular

You can tell a human developer "you can do anything with this API key." You can't say that to an AI agent.

In an agent-first API, the permission model should look like this:

  • Agent X can do read:orders but not write:orders
  • Agent Y can do read:orders + read:users but not delete:*
  • Agent Z (admin agent) can do everything, but asks a human for approval on operations where amount > 10000TL

In RustAPI I do this with MCP Permission Scoping (v0.1.508). You can assign a scope to each MCP tool and define a scope set for each agent.

5. Output should be agent-readable

This one is critical. The response you write for a human:

{"message": "Your order was created successfully, thank you!"}

The response you write for an AI agent:

{
  "order_id": "ord_2026_0706_001",
  "status": "confirmed",
  "estimated_delivery": "2026-07-08T14:00:00+03:00",
  "total_amount": {"value": 149.90, "currency": "TRY"},
  "tracking_url": "https://kargo.example.com/track/TRK123456"
}

A human reads "thank you" and feels good. An AI agent looks at order_id and moves on to the next step. Two different worlds.

MCP vs REST vs gRPC vs GraphQL

Which one, and when?

ProtocolWhere it shinesGood fit for AI agents?
RESTAPIs for human developersNo, implicit contracts
GraphQLFlexible data querying (for humans)Partly, there's a schema but no tool semantics
gRPCCommunication between microservicesPartly, protobuf is explicit but there's no discovery
MCPExposing tools to AI agentsYes, it was designed for this

The stack of the future: REST/GraphQL for humans, gRPC for services, MCP for AI agents. All three on the same backend, as different "views" of the same endpoints.

That's exactly what I'm doing in RustAPI. You write one endpoint and it's automatically exposed as both a REST (HTTP) and an MCP (JSON-RPC) endpoint. Same code, two protocols.

What will we see in 2026-2027?

My predictions:

  1. Every SaaS will have an MCP endpoint. Just like every SaaS had a REST API in 2015.
  2. Agent-first, human-second. New APIs will be designed for AI agents first, human developers second.
  3. MCP gateways will become common. Gateways that gather all of a company's APIs behind a single MCP endpoint.
  4. Agent-to-agent protocols. Not just agent-to-API: agent-to-agent communication protocols will get standardized too.
  5. Permission models will be the biggest problem. Who controls what an AI agent can access, and how?

That last one is especially critical. It's something the security community hasn't talked about nearly enough yet. But it's going to blow up soon.

What should you do now?

If you're building an API, start today:

  1. Add an MCP endpoint to your existing API. Start with 3-5 tools.
  2. Write an explicit description and input/output schema for every endpoint. Not just types, actual descriptive text.
  3. Test it with an AI agent. Hook your MCP server up to Claude Desktop and say "get the user's latest order." What happens? Where does it get stuck?
  4. Think through the permission model. Decide what agents can access and what they can change.

The future is agent-first. The people getting ready now will be a step ahead in 2027.


This post is based on what I learned from RustAPI's MCP architecture. In the next post I'll explain how Hyperembed and its embedding inference engine work.

← Blog