AgentProtocol.ai
//tutorial · 12 min read

Building your first Agent Protocol-compliant agent in 15 minutes

The Agent Protocol is a REST specification for driving an agent through tasks, steps and artifacts. In this walkthrough you'll expose a minimal agent behind that interface and call it like any HTTP API — no framework lock-in required.

TutorialREST / HTTP

What you'll build

A tiny agent service that speaks the Agent Protocol: clients create a task, trigger steps, and read back artifacts. The internal logic is deliberately trivial so the focus stays on the protocol surface.

Prerequisites
Basic familiarity with HTTP and JSON, and any language that can serve an HTTP endpoint. The examples use pseudocode-style HTTP so you can port them to your stack. Confirm exact routes against the current Agent Protocol spec — details evolve.

Step 1 — Model the core resources

Agent Protocol centres on a small set of resources. A task represents a goal; a step is one unit of the agent's execution; an artifact is an output produced along the way.

resources.txt
text
Task     { task_id, input, artifacts[] }
Step     { step_id, task_id, output, is_last }
Artifact { artifact_id, file_name }

Step 2 — Create a task

Expose an endpoint that accepts an input goal and returns a new task with an identifier.

create-task.http
http
POST /ap/v1/agent/tasks
Content-Type: application/json

{ "input": "List three risks in the attached plan." }

# → 200 OK
{ "task_id": "t_01", "input": "List three risks...", "artifacts": [] }

Step 3 — Execute a step

Each call to the steps endpoint advances the agent. Return the step's output and whether it's the final step. Real agents may plan, call tools (for example over MCP), and iterate here.

execute-step.http
http
POST /ap/v1/agent/tasks/t_01/steps
Content-Type: application/json

{ "input": "" }

# → 200 OK
{ "step_id": "s_01", "task_id": "t_01", "output": "Risk 1: ...", "is_last": true }

Step 4 — Return artifacts

If your agent produces files or structured outputs, expose them as artifacts clients can list and download.

list-artifacts.http
http
GET /ap/v1/agent/tasks/t_01/artifacts

# → 200 OK
{ "artifacts": [ { "artifact_id": "a_01", "file_name": "risks.md" } ] }

Step 5 — Call it from a client

Because the interface is standard, any Agent Protocol client can drive your agent without knowing its internals: create a task, loop over steps until is_last, then fetch artifacts.

Where to go next
Swap the trivial logic for a real agent, add tool access with MCP, or let it delegate to peers with A2A. To decide what your project actually needs, try the protocol selector.
//questions

Frequently asked questions

Is Agent Protocol tied to a specific framework?

No — it's framework-agnostic by design. It defines an HTTP/REST surface (tasks, steps, artifacts), so you can implement it in any language or agent framework and clients won't care how it's built.

Do I need MCP or A2A for this tutorial?

No. This tutorial only covers the client-to-agent API layer. MCP (tools) and A2A (agent-to-agent) are complementary and can be added later if your agent needs them.

Are these exact endpoints guaranteed?

Treat the routes here as illustrative. The Agent Protocol spec evolves, so verify current paths and payloads against its official documentation before shipping.