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

> Source: <https://agentgateway.dev/blog/2026-12-04-agentgateway-mcp-tasks-skills/>
> Published: 2026-12-04 00:00:00+00:00

**Key takeaway:** agentgateway v1.8.1 routes MCP tasks by prefixing task IDs as <target>+<taskId> and enforcing RBAC on mcp.task.target and mcp.task.name, so a multi-server gateway can poll long-running tools without exposing which tasks exist.

The setup is one agentgateway `v1.8.1` binary on my Linux box, in front of two copies of the MCP reference server (`@modelcontextprotocol/server-everything@2.4.0`) 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:

`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`.` 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](https://agentgateway.dev/docs/standalone/latest/documentation/mcp/spec-compatibility/).

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:

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.

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:

`<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`Task` (`rbac.rs` L72-L80`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.` 2026-07-28` clients and stripped for older protocol versions (`upstream/mod.rs` L819-L850`v1.8.0`, `mcpGuardrails` request-phase processors also run on `tasks/*` (
The original support is [#2745 “mcp tasks support”](https://github.com/agentgateway/agentgateway/pull/2745), 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
```

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/server-everything@2.4.0 \
 @modelcontextprotocol/server@2.4.0 @modelcontextprotocol/client@2.4.0 \
 @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.

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`:

``` js
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.

``` php
# 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
```

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
```

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.

``` php
# 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
```

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 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`.

``` php
# 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 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.

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:

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.

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:

`skill://code-review/SKILL.md`.` skill://<target>/<path>` in `directoryRead: true` if any target supports `resources/directory/read`.` mcpAuthorization` as a resource (`-32602`.` ttlMs: 0` and `cacheScope: private` on the responses (
This came in `v1.8.0` with [#4214 “mcp: initial “Skills” extension support”](https://github.com/agentgateway/agentgateway/pull/4214) and [#4490 “mcp skills: support multiplex targets”](https://github.com/agentgateway/agentgateway/pull/4490). 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:

``` php
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 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 &
php
# 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 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.

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`:

`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:

``` php
# 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
```

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.

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](https://github.com/agentgateway/agentgateway/blob/v1.8.1/crates/agentgateway/src/mcp/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:

``` php
# 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
```

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.

`tasks/result` either. The result comes back in `failOpen`, or a tool on every server, as Test 5 shows.` 2.4.0` has `SkillsExtension` on the server and `SkillsClient` on the client, but tasks handlers need an explicit schema. TypeScript issue `2.3.0` has no skills module. That’s part of why I wrote the client by hand.`skills` field passes through the gateway untouched, apart from URL rewriting. The `input_required` task, the Kubernetes path, and JWT-based rules.
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.

`v1.4.1`), `v1.8.1`: `crates/agentgateway/src/mcp/``@modelcontextprotocol/server-everything`
