Skip to content
Help guide the future of agentgateway — Take the survey

MCP tasks and skills through agentgateway: long-running tools and shared know-how, with routing and auth

MCP 2026-07-28 added two extensions: tasks, so a long tool call returns a handle you poll instead of a connection you hold open, and skills, so servers can publish SKILL.md instructions that agents load when they need them. This post shows the problem each one solves and runs both through agentgateway v1.8.1: task polling and cancel, task IDs across two servers, skill URIs across three, and authorization rules that limit both.

Sebastian Maniak 15 min read
Back to blog

The setup is one agentgateway v1.8.1 binary on my Linux box, in front of two copies of the MCP reference server (@modelcontextprotocol/[email protected]) and two small skills servers I wrote with the TypeScript SDK 2.4.0. A test client talks to the gateway with MCP protocol version 2026-07-28. I ran every command in this post today and the screenshots are the real output.

That protocol version added two extensions:

  • Tasks (io.modelcontextprotocol/tasks, SEP-2663). A slow tools/call returns a task handle right away. The client polls it with tasks/get, answers it with tasks/update, or stops it with tasks/cancel.
  • Skills (io.modelcontextprotocol/skills, SEP-2640). A server publishes SKILL.md files, the procedural instructions an agent reads when it needs them, through skills/list, skills/get and resources/read.

agentgateway has supported tasks since v1.4.1 and skills since v1.8.0. v1.8.1 didn’t change either one. I’ll show what problem each solves, what the gateway does with it, and the test. The official reference is the MCP spec compatibility page.

Part 1: MCP tasks

The problem

A tool that runs a research job, a build, a data export or a report can take minutes. Without tasks, the client keeps one HTTP request open for the whole run. That breaks in a few ways:

  • A proxy or load balancer between the agent and the server times the request out, and the work is lost even if the server finishes it.
  • The agent is blocked. It can’t do anything else on that call, and if the user closes the laptop or the pod restarts, the result has nowhere to go.
  • A retry starts the job again, because nothing identifies the run that’s already going.

Tasks turn that into “call now, fetch later”. The server answers tools/call with resultType: "task", a taskId and a suggested pollIntervalMs. The client can disconnect, reconnect and poll with the ID. When the status is completed, the result is in the tasks/get response.

Why it matters once there’s a gateway

In a company the agent rarely talks to the server directly. There’s a gateway that puts many MCP servers behind one endpoint and decides who can call what. Tasks raise three questions for that gateway:

  1. Routing. A tasks/get has no tool name in it, only a task ID. With ten servers behind one URL, which one owns the task?
  2. Collisions. Two servers can hand out the same task ID.
  3. Authorization. If your policy says who can call a tool, what about the follow-up calls? Polling a task and cancelling it aren’t the same permission.

How agentgateway handles it

  • Task ID rewriting. With more than one target, agentgateway prefixes each task ID with the target name, <target>+<taskId>, the same way it prefixes tool names. On the way back it strips the prefix and sends the request to that target only (handler.rs L237-L289, session.rs L776-L822). With one target the ID passes through unchanged.
  • Authorization on every task request. Each tasks/get, tasks/update and tasks/cancel is checked as its own resource type, Task (rbac.rs L72-L80). In CEL you get mcp.methodName, mcp.task.target, and mcp.task.name (the ID without the prefix). A denied request gets -32602 unknown resource, so it doesn’t reveal whether the task exists.
  • Capability handling. The tasks extension is passed to targets for 2026-07-28 clients and stripped for older protocol versions (session.rs L952-L969). With several targets, agentgateway merges their extension capabilities (upstream/mod.rs L819-L850).
  • Guardrails. Since v1.8.0, mcpGuardrails request-phase processors also run on tasks/* (#4493). I didn’t test guardrails for this post.

The original support is #2745 “mcp tasks support”, first released in v1.4.1. There’s no config switch. If both sides speak tasks, it works.

With two targets, research and batch, a task call and its polls look like this:

    sequenceDiagram
    participant C as Agent
    participant G as agentgateway
    participant R as research
    participant B as batch
    C->>G: tools/call batch_simulate-research-query
    G->>B: tools/call simulate-research-query
    B-->>G: resultType task, taskId 6d529c69
    G-->>C: taskId batch+6d529c69
    loop until completed
        C->>G: tasks/get batch+6d529c69
        Note over G: check mcpAuthorization, strip the prefix
        G->>B: tasks/get 6d529c69
        B-->>G: working, then completed with the result
        G-->>C: status and result
    end
    Note over R: never sees the task
  

Set up the lab

You need Node.js 24 or later and the agentgateway v1.8.1 binary.

mkdir agw-mcp-skills-tasks && cd agw-mcp-skills-tasks
npm init -y
npm install @modelcontextprotocol/[email protected] \
  @modelcontextprotocol/[email protected] @modelcontextprotocol/[email protected] \
  @modelcontextprotocol/node zod

# Two copies of the reference server over Streamable HTTP (they bind 127.0.0.1)
PORT=3001 node node_modules/@modelcontextprotocol/server-everything/dist/index.js streamableHttp &
PORT=3002 node node_modules/@modelcontextprotocol/server-everything/dist/index.js streamableHttp &

The everything server’s simulate-research-query tool runs as a task. It moves through four stages, one per second, and works out its state from the clock when you read it. That’s short for a demo, but the client code is the same for a job that takes an hour. The server refuses task tools with -32021 if the client doesn’t declare the tasks extension.

The client

I wanted to see the wire, so the client is plain fetch: one JSON-RPC request per POST, no session. A 2026-07-28 client sends its protocol version and capabilities with every request, in _meta, and mirrors the method and task ID into the Mcp-Method and Mcp-Name headers. This is the core of client/mcp.mjs:

export const PROTOCOL = "2026-07-28";

export function meta() {
  return {
    "io.modelcontextprotocol/protocolVersion": PROTOCOL,
    "io.modelcontextprotocol/clientInfo": { name: "maniak-demo", version: "0.1.0" },
    "io.modelcontextprotocol/clientCapabilities": {
      extensions: {
        "io.modelcontextprotocol/tasks": {},
        "io.modelcontextprotocol/skills": {},
      },
    },
  };
}

export async function rpc(url, method, params = {}) {
  const headers = {
    "content-type": "application/json",
    accept: "application/json, text/event-stream",
    "mcp-protocol-version": PROTOCOL,
    "mcp-method": method,
  };
  // Mcp-Name carries the tool name, the task ID, or the resource URI
  const name = method === "tools/call" ? params.name
    : method.startsWith("tasks/") ? params.taskId
    : params.uri;
  if (name) headers["mcp-name"] = name;
  const body = { jsonrpc: "2.0", id: nextId++, method, params: { ...params, _meta: meta() } };
  const res = await fetch(url, { method: "POST", headers, body: JSON.stringify(body) });
  // ...parse JSON or the SSE "data:" line
}

client/tasks-demo.mjs calls a tool, then polls tasks/get once a second until the task finishes. With cancel as the last argument, it polls once, cancels, and reads the task again.

Test 1: a task through the gateway

# configs/tasks-single.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
mcp:
  port: 4000
  targets:
  - name: everything
    mcp:
      host: http://127.0.0.1:3001/mcp
agentgateway -f configs/tasks-single.yaml &
node client/tasks-demo.mjs http://127.0.0.1:4000/mcp simulate-research-query
A tools/call through agentgateway v1.8.1 returns resultType task; tasks/get polls through four stages to completed and the result arrives in the last response

The call came back in 0.1 seconds with a task ID and status=working. Four polls later the status was completed and the report was in the response. With one target, the gateway passed the server’s UUID through as is.

Cancel works the same way:

node client/tasks-demo.mjs http://127.0.0.1:4000/mcp simulate-research-query cancel
tasks/cancel through agentgateway; the next tasks/get shows status cancelled

Test 2: two servers, one endpoint

Now two targets. I named them research and batch. They’re the same server image on different ports, which is the worst case for collisions.

# configs/tasks-multi.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
mcp:
  port: 4000
  targets:
  - name: research
    mcp:
      host: http://127.0.0.1:3001/mcp
  - name: batch
    mcp:
      host: http://127.0.0.1:3002/mcp
agentgateway -f configs/tasks-multi.yaml &
node client/tasks-demo.mjs http://127.0.0.1:4000/mcp batch_simulate-research-query
node client/tasks-errors.mjs http://127.0.0.1:4000/mcp
With two targets, the task ID comes back as batch+uuid and every tasks/get uses it; bad prefixes and tasks/list return errors

The tool is batch_simulate-research-query and the task ID is batch+6d529c69-.... The client sends that ID back unchanged and the gateway routes each poll to batch. The error cases:

  • nosuch+1234 gets -32602 unknown service nosuch, and 1234 with no prefix gets -32602 invalid task id. The gateway rejects both without asking any server.
  • research+00000000-... reaches the research server, which answers Unknown task: 00000000-.... The error shows the ID without the prefix, so the gateway stripped it before it forwarded the request.
  • tasks/list returns HTTP 404 with -32601. That method isn’t in the 2026-07-28 tasks extension, so there’s nothing to route.

Test 3: allow polling, deny cancel

This is the policy case I care about most. A support bot should be able to start a report and check on it. It shouldn’t be able to cancel someone else’s job. In agentgateway, mcpAuthorization rules in a list are allow rules, and anything they don’t match is denied. The task rule comes straight from the docs and from the gateway’s own test authorization_by_method_name_allows_tasks_get_denies_tasks_cancel.

# configs/tasks-authz.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
mcp:
  port: 4000
  policies:
    mcpAuthorization:
      rules:
      # Rules are allow rules. Anything not matched is denied.
      - 'mcp.tool.name == "simulate-research-query"'
      - 'mcp.methodName == "tasks/get"'
  targets:
  - name: research
    mcp:
      host: http://127.0.0.1:3001/mcp
tools/list shows one tool, echo is denied, tasks/get works, tasks/cancel is denied with unknown resource, and the task keeps running

tools/list shows only the one allowed tool, and echo is denied. The task starts and tasks/get works. tasks/cancel gets -32602 unknown resource, and the next tasks/get still says working, so the cancel never reached the server. The gateway log has the real reason: authorization denied for task: 17241fac-... with reason=Authorization.

If you write tool-only rules, add the task methods. A rule on mcp.tool.name doesn’t match a tasks/get, so a policy that only lists tools lets clients start tasks they can’t poll.

Part 2: MCP skills

The problem

Agents need procedural know-how: how this team reviews a PR, what to do in the first fifteen minutes of an incident, how to rotate a credential without an outage. Today that ends up in one of two places, and both are bad:

  • The system prompt: every instruction for every situation, loaded into every conversation, paid for in tokens whether it’s used or not.
  • Tool descriptions: paragraphs of “before calling this, always…” stuffed into a description that was meant to say what the tool does.

Skills give that know-how its own place. A skill is a folder with a SKILL.md (name and description in the frontmatter, instructions below) and optional reference files. The agent lists skills, reads the short descriptions, and fetches the full text only when the task calls for it.

Why it matters once there’s a gateway

The know-how is spread out. The platform team owns the code review and incident skills, the security team owns credential rotation, and each team runs its own MCP server. An agent shouldn’t have to connect to every one of them, and not every agent should see every skill. That raises the same questions as tasks:

  1. One catalog. Merge the skills from many servers into one skills/list.
  2. Collisions. Two servers can both publish skill://code-review/SKILL.md.
  3. Governance. The security team’s runbook should be invisible to the general-purpose agent, in the list and on direct reads.

How agentgateway handles it

  • URI rewriting. With more than one target, agentgateway rewrites skill URIs to skill://<target>/<path> in skills/list, skills/get and directory listings, and parses them back on the way in (handler.rs L160-L235, L642-L658). With one target the URIs pass through.
  • Merged list. skills/list fans out to every target and merges the results. A target that answers “method not found” (an MCP server without skills) adds an empty list instead of failing the request (handler.rs L1264-L1353).
  • Merged capability. The gateway advertises io.modelcontextprotocol/skills if any target does, with directoryRead: true if any target supports resources/directory/read.
  • Authorization per skill and per file. Each listed skill, each file in its manifest and each directory entry is checked against mcpAuthorization as a resource (handler.rs L1086-L1134, L1533-L1565). Denied skills drop out of the list, and direct skills/get or resources/read calls get -32602.
  • No shared caching. Because the list depends on who’s asking, the gateway forces ttlMs: 0 and cacheScope: private on the responses (handler.rs L2350-L2356).

This came in v1.8.0 with #4214 “mcp: initial “Skills” extension support” and #4490 “mcp skills: support multiplex targets”. Like tasks, there’s no config field, CRD field or UI setting for it.

This is the three-target setup from Test 5 and Test 6. The agent sees the URIs on the left, and each server keeps its own URIs on the right:

    flowchart LR
    A[Agent] -- "skills/list, skills/get, resources/read" --> G[agentgateway<br/>mcpAuthorization]
    G -- "skill://platform/code-review/SKILL.md<br/>skill://platform/incident-runbook/SKILL.md" --> P[platform<br/>skill://code-review/SKILL.md<br/>skill://incident-runbook/SKILL.md]
    G -- "skill://security/rotate-prod-credentials/SKILL.md" --> S[security<br/>skill://rotate-prod-credentials/SKILL.md]
    G -- "research_echo and other tools" --> R[research<br/>tools and tasks, no skills]
  

The skills servers

The TypeScript SDK 2.4.0 has a SkillsExtension that loads a folder of skills and attaches it to a server. This is the whole server:

// server/skills-server.mjs
// Usage: node skills-server.mjs <skills-folder> <port> <name>
import http from "node:http";
import { McpServer, createMcpHandler } from "@modelcontextprotocol/server";
import { loadSkills } from "@modelcontextprotocol/server/ext/skills/node";
import { toNodeHandler } from "@modelcontextprotocol/node";

const [folder, port = "3101", name = "skills"] = process.argv.slice(2);
const catalog = await loadSkills(folder);

const handler = createMcpHandler(() => {
  const server = new McpServer({ name, version: "0.1.0" });
  catalog.attach(server);
  return server;
});
const serve = toNodeHandler(handler);

http
  .createServer((req, res) => {
    if (req.url?.startsWith("/mcp")) return serve(req, res);
    res.writeHead(404).end();
  })
  .listen(Number(port), "127.0.0.1");

Two skill folders, one per team:

skills-platform/
  code-review/SKILL.md
  incident-runbook/SKILL.md
  incident-runbook/references/ESCALATION.md
skills-security/
  rotate-prod-credentials/SKILL.md

Each SKILL.md is ordinary markdown with frontmatter:

---
name: incident-runbook
description: First 15 minutes of a production incident. Use when an alert fires or someone says prod is down.
---

# Incident runbook

1. Acknowledge the page and open an incident channel.
2. Check the gateway dashboards before touching anything.
3. Follow [the escalation matrix](references/ESCALATION.md) if customer traffic is affected.
4. Write a timeline as you go. Times in UTC.
node server/skills-server.mjs skills-platform 3101 platform &
node server/skills-server.mjs skills-security 3102 security &

Test 4: skills through the gateway, one target

# configs/skills-single.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
mcp:
  port: 4000
  targets:
  - name: platform
    mcp:
      host: http://127.0.0.1:3101/mcp
agentgateway -f configs/skills-single.yaml &
node client/skills-demo.mjs http://127.0.0.1:4000/mcp \
  skill://incident-runbook/SKILL.md \
  skill://incident-runbook/references/ESCALATION.md
server/discover advertises the skills extension; skills/list returns two skills with unchanged URIs; skills/get lists two files with digests; resources/read returns the escalation matrix

server/discover advertises the skills extension with directoryRead: true. skills/list returns both skills with their original URIs and ttlMs=0, cacheScope=private. skills/get returns the manifest with a size and SHA-256 digest per file, and resources/read returns the file. An agent would read the two descriptions, decide the incident runbook applies, and only then fetch it.

Test 5: three targets, one catalog

Now both skills servers plus the everything server (which has tools and tasks but no skills) behind one endpoint. My first run of this used the default settings, and it broke tools/list:

With the default failureMode, tools/list through the three-target gateway fails with HTTP 404 Method not found while skills/list still works

skills/list was fine. The gateway skips targets without skills for that method. But tools/list failed for the whole endpoint with -32601 Method not found. My skills servers have no tools, so the SDK answers tools/list with HTTP 404 and -32601. The gateway treats that as a failed target, and with the default failureMode: failClosed one failed target fails the fan-out. In v1.8.1 the “skip unsupported” logic covers skills/list only.

The fix is one line, failureMode: failOpen, which makes the gateway skip a target that fails during fan-out and log a warning:

# configs/skills-multi.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
mcp:
  port: 4000
  # The skills-only servers have no tools. With the default (failClosed) their
  # "method not found" on tools/list fails the whole fan-out. failOpen skips them.
  failureMode: failOpen
  targets:
  - name: platform
    mcp:
      host: http://127.0.0.1:3101/mcp
  - name: security
    mcp:
      host: http://127.0.0.1:3102/mcp
  - name: research
    mcp:
      host: http://127.0.0.1:3001/mcp

The tradeoff: failOpen also hides a target that’s really down, so watch for the upstream 'platform' failed during fanout, skipping warning in the log. The other option is to give each skills server at least one tool.

agentgateway -f configs/skills-multi.yaml &
node client/skills-demo.mjs http://127.0.0.1:4000/mcp skill://platform/incident-runbook/SKILL.md
node client/skills-dir.mjs http://127.0.0.1:4000/mcp skill://platform/incident-runbook
node client/list-tools.mjs http://127.0.0.1:4000/mcp research_echo
Three targets: skills/list merges three skills with skill://platform/ and skill://security/ prefixes; directory read and file URIs are rewritten; tools still work

The merged list has three skills. The URIs are now skill://platform/code-review/SKILL.md, skill://platform/incident-runbook/SKILL.md and skill://security/rotate-prod-credentials/SKILL.md. The file URIs inside each manifest are rewritten too, and so are the entries from resources/directory/read. server/discover advertises all three extensions (events, skills and tasks) because each one comes from at least one target. The research tools still work.

One detail I got wrong at first: a directory URI has no trailing slash. skill://platform/incident-runbook works, and skill://platform/incident-runbook/ gets is not a directory resource from the SDK server.

Test 6: hide the security team’s skills

The general-purpose agent shouldn’t see the credential rotation runbook. My first attempt was this rule, and it did nothing:

- deny: 'mcp.resource.name.startsWith("skill://security/")'

The skill was still listed and readable. The code explains why: in the authorization check, mcp.resource.name is the upstream URI, skill://rotate-prod-credentials/SKILL.md, and the target name is a separate field, mcp.resource.target (session.rs L824-L854). The docs example, mcp.resource.name.startsWith("skill://secret/"), uses the upstream URI too, so it matches a skill named secret. The skill://<target>/ form is what the client sees, not what the policy sees. This rule works:

# configs/skills-authz.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
mcp:
  port: 4000
  failureMode: failOpen
  policies:
    mcpAuthorization:
      rules:
      # mcp.resource.name is the upstream URI (skill://rotate-prod-credentials/...),
      # not the client-facing skill://security/... one. The target is its own field.
      - deny: 'mcp.resource.target == "security" && mcp.resource.name.startsWith("skill://")'
  targets:
  - name: platform
    mcp:
      host: http://127.0.0.1:3101/mcp
  - name: security
    mcp:
      host: http://127.0.0.1:3102/mcp
  - name: research
    mcp:
      host: http://127.0.0.1:3001/mcp
With the deny rule, skills/list shows only the two platform skills; skills/get and resources/read on the security skill return -32602 unknown resource; tools still work; the gateway log shows authorization denied

The list drops to the two platform skills. skills/get and resources/read on skill://security/rotate-prod-credentials/SKILL.md both get -32602 unknown resource. A made-up skill on the security target gets the same answer, so a client can’t tell which security skills exist. (A made-up skill on platform gets the SDK’s own No skill is served at ... message.) Tools on research still work. The gateway log shows mcp.target=security mcp.resource.uri=skill://rotate-prod-credentials/SKILL.md and reason=Authorization.

I used a deny rule because I only wanted to remove one thing, and it left tool calls alone. The schema warns that a deny expression that fails to evaluate doesn’t deny anything. For production I’d write an allow list tied to JWT claims instead, like the tasks example above.

What’s not supported, and SDK gaps

  • No tasks/list. It isn’t part of the 2026-07-28 tasks extension, and the gateway returns HTTP 404 with -32601. There’s no tasks/result either. The result comes back in tasks/get.
  • No switches. Neither feature has a config, CRD or UI field. Tasks and skills pass through when both client and server support them. Older protocol versions don’t get the tasks extension.
  • Mixed targets need failOpen, or a tool on every server, as Test 5 shows.
  • SDK support is uneven. The TypeScript SDK 2.4.0 has SkillsExtension on the server and SkillsClient on the client, but tasks handlers need an explicit schema. TypeScript issue #2189 and Python issue #2806 (“Implement SEP-2663: Tasks Extension”) are still open. The Python SDK 2.3.0 has no skills module. That’s part of why I wrote the client by hand.
  • Skills in other places. The A2A AgentCard skills field passes through the gateway untouched, apart from URL rewriting. The SKILL.md packages on agentgateway.dev are for coding assistants and aren’t part of the proxy.
  • What I didn’t test: guardrails on tasks/*, tasks/update with an input_required task, the Kubernetes path, and JWT-based rules.

Summary

Both extensions work through agentgateway v1.8.1 with no gateway config of their own. The settings you do need to think about are policy and failure mode. Write task rules on mcp.methodName, because tool rules don’t cover tasks/get or tasks/cancel. Write skill rules on mcp.resource.target plus the upstream URI, not on the skill://<target>/ URI the client sees. And if you put skills-only servers next to tool servers, set failureMode: failOpen or tools/list breaks for everyone.

References

Share: