{"slug": "mcp-tasks-and-skills-through-agentgateway-long-running-tools-and-shared-know-how", "title": "MCP tasks and skills through agentgateway: long-running tools and shared know-how, with routing and auth", "summary": "Agentgateway v1.8.1 routes MCP tasks and skills across multiple MCP servers behind a single endpoint, supporting the io.modelcontextprotocol/tasks (SEP-2663) and io.modelcontextprotocol/skills (SEP-2640) extensions added in MCP protocol version 2026-07-28. The gateway has supported tasks since v1.4.1 and skills since v1.8.0, and v1.8.1 changed neither; the author tested it with two copies of @modelcontextprotocol/server-everything@2.4.0 and two TypeScript SDK 2.4.0 skills servers. For tasks, the gateway prefixes task IDs as <target>+<taskId>, strips the prefix on return, and enforces RBAC on mcp.methodName, mcp.task.target and mcp.task.name, returning -32602 unknown resource for denied requests so task existence is not revealed.", "body_md": "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.\n\nThat protocol version added two extensions:\n\n`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`.\nagentgateway 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/).\n\nA 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:\n\nTasks 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.\n\nIn 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:\n\n`<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/*` (\nThe 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.\n\nWith two targets, `research` and `batch`, a task call and its polls look like this:\n\n```\nsequenceDiagram\nparticipant C as Agent\nparticipant G as agentgateway\nparticipant R as research\nparticipant B as batch\nC->>G: tools/call batch_simulate-research-query\nG->>B: tools/call simulate-research-query\nB-->>G: resultType task, taskId 6d529c69\nG-->>C: taskId batch+6d529c69\nloop until completed\nC->>G: tasks/get batch+6d529c69\nNote over G: check mcpAuthorization, strip the prefix\nG->>B: tasks/get 6d529c69\nB-->>G: working, then completed with the result\nG-->>C: status and result\nend\nNote over R: never sees the task\n```\n\nYou need Node.js 24 or later and the agentgateway `v1.8.1` binary.\n\n```\nmkdir agw-mcp-skills-tasks && cd agw-mcp-skills-tasks\nnpm init -y\nnpm install @modelcontextprotocol/server-everything@2.4.0 \\\n @modelcontextprotocol/server@2.4.0 @modelcontextprotocol/client@2.4.0 \\\n @modelcontextprotocol/node zod\n\n# Two copies of the reference server over Streamable HTTP (they bind 127.0.0.1)\nPORT=3001 node node_modules/@modelcontextprotocol/server-everything/dist/index.js streamableHttp &\nPORT=3002 node node_modules/@modelcontextprotocol/server-everything/dist/index.js streamableHttp &\n```\n\nThe 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.\n\nI 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`:\n\n``` js\nexport const PROTOCOL = \"2026-07-28\";\n\nexport function meta() {\n return {\n \"io.modelcontextprotocol/protocolVersion\": PROTOCOL,\n \"io.modelcontextprotocol/clientInfo\": { name: \"maniak-demo\", version: \"0.1.0\" },\n \"io.modelcontextprotocol/clientCapabilities\": {\n extensions: {\n \"io.modelcontextprotocol/tasks\": {},\n \"io.modelcontextprotocol/skills\": {},\n },\n },\n };\n}\n\nexport async function rpc(url, method, params = {}) {\n const headers = {\n \"content-type\": \"application/json\",\n accept: \"application/json, text/event-stream\",\n \"mcp-protocol-version\": PROTOCOL,\n \"mcp-method\": method,\n };\n // Mcp-Name carries the tool name, the task ID, or the resource URI\n const name = method === \"tools/call\" ? params.name\n : method.startsWith(\"tasks/\") ? params.taskId\n : params.uri;\n if (name) headers[\"mcp-name\"] = name;\n const body = { jsonrpc: \"2.0\", id: nextId++, method, params: { ...params, _meta: meta() } };\n const res = await fetch(url, { method: \"POST\", headers, body: JSON.stringify(body) });\n // ...parse JSON or the SSE \"data:\" line\n}\n```\n\n`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.\n\n``` php\n# configs/tasks-single.yaml\n# yaml-language-server: $schema=https://agentgateway.dev/schema/config\nmcp:\n port: 4000\n targets:\n - name: everything\n mcp:\n host: http://127.0.0.1:3001/mcp\nagentgateway -f configs/tasks-single.yaml &\nnode client/tasks-demo.mjs http://127.0.0.1:4000/mcp simulate-research-query\n```\n\nThe 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.\n\nCancel works the same way:\n\n```\nnode client/tasks-demo.mjs http://127.0.0.1:4000/mcp simulate-research-query cancel\n```\n\nNow two targets. I named them `research` and `batch`. They’re the same server image on different ports, which is the worst case for collisions.\n\n``` php\n# configs/tasks-multi.yaml\n# yaml-language-server: $schema=https://agentgateway.dev/schema/config\nmcp:\n port: 4000\n targets:\n - name: research\n mcp:\n host: http://127.0.0.1:3001/mcp\n - name: batch\n mcp:\n host: http://127.0.0.1:3002/mcp\nagentgateway -f configs/tasks-multi.yaml &\nnode client/tasks-demo.mjs http://127.0.0.1:4000/mcp batch_simulate-research-query\nnode client/tasks-errors.mjs http://127.0.0.1:4000/mcp\n```\n\nThe 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:\n\n`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`.\n\n``` php\n# configs/tasks-authz.yaml\n# yaml-language-server: $schema=https://agentgateway.dev/schema/config\nmcp:\n port: 4000\n policies:\n mcpAuthorization:\n rules:\n # Rules are allow rules. Anything not matched is denied.\n - 'mcp.tool.name == \"simulate-research-query\"'\n - 'mcp.methodName == \"tasks/get\"'\n targets:\n - name: research\n mcp:\n host: http://127.0.0.1:3001/mcp\n```\n\n`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`.\n\nIf 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.\n\nAgents 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:\n\nSkills 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.\n\nThe 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:\n\n`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 (\nThis 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.\n\nThis 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:\n\n``` php\nflowchart LR\nA[Agent] -- \"skills/list, skills/get, resources/read\" --> G[agentgateway<br/>mcpAuthorization]\nG -- \"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]\nG -- \"skill://security/rotate-prod-credentials/SKILL.md\" --> S[security<br/>skill://rotate-prod-credentials/SKILL.md]\nG -- \"research_echo and other tools\" --> R[research<br/>tools and tasks, no skills]\n```\n\nThe 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:\n\n```\n// server/skills-server.mjs\n// Usage: node skills-server.mjs <skills-folder> <port> <name>\nimport http from \"node:http\";\nimport { McpServer, createMcpHandler } from \"@modelcontextprotocol/server\";\nimport { loadSkills } from \"@modelcontextprotocol/server/ext/skills/node\";\nimport { toNodeHandler } from \"@modelcontextprotocol/node\";\n\nconst [folder, port = \"3101\", name = \"skills\"] = process.argv.slice(2);\nconst catalog = await loadSkills(folder);\n\nconst handler = createMcpHandler(() => {\n const server = new McpServer({ name, version: \"0.1.0\" });\n catalog.attach(server);\n return server;\n});\nconst serve = toNodeHandler(handler);\n\nhttp\n .createServer((req, res) => {\n if (req.url?.startsWith(\"/mcp\")) return serve(req, res);\n res.writeHead(404).end();\n })\n .listen(Number(port), \"127.0.0.1\");\n```\n\nTwo skill folders, one per team:\n\n```\nskills-platform/\ncode-review/SKILL.md\nincident-runbook/SKILL.md\nincident-runbook/references/ESCALATION.md\nskills-security/\nrotate-prod-credentials/SKILL.md\n```\n\nEach `SKILL.md` is ordinary markdown with frontmatter:\n\n```\n---\nname: incident-runbook\ndescription: First 15 minutes of a production incident. Use when an alert fires or someone says prod is down.\n---\n\n# Incident runbook\n\n1. Acknowledge the page and open an incident channel.\n2. Check the gateway dashboards before touching anything.\n3. Follow [the escalation matrix](references/ESCALATION.md) if customer traffic is affected.\n4. Write a timeline as you go. Times in UTC.\nnode server/skills-server.mjs skills-platform 3101 platform &\nnode server/skills-server.mjs skills-security 3102 security &\nphp\n# configs/skills-single.yaml\n# yaml-language-server: $schema=https://agentgateway.dev/schema/config\nmcp:\n port: 4000\n targets:\n - name: platform\n mcp:\n host: http://127.0.0.1:3101/mcp\nagentgateway -f configs/skills-single.yaml &\nnode client/skills-demo.mjs http://127.0.0.1:4000/mcp \\\n skill://incident-runbook/SKILL.md \\\n skill://incident-runbook/references/ESCALATION.md\n```\n\n`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.\n\nNow 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`:\n\n`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.\n\nThe fix is one line, `failureMode: failOpen`, which makes the gateway skip a target that fails during fan-out and log a warning:\n\n``` php\n# configs/skills-multi.yaml\n# yaml-language-server: $schema=https://agentgateway.dev/schema/config\nmcp:\n port: 4000\n # The skills-only servers have no tools. With the default (failClosed) their\n # \"method not found\" on tools/list fails the whole fan-out. failOpen skips them.\n failureMode: failOpen\n targets:\n - name: platform\n mcp:\n host: http://127.0.0.1:3101/mcp\n - name: security\n mcp:\n host: http://127.0.0.1:3102/mcp\n - name: research\n mcp:\n host: http://127.0.0.1:3001/mcp\n```\n\nThe 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.\n\n```\nagentgateway -f configs/skills-multi.yaml &\nnode client/skills-demo.mjs http://127.0.0.1:4000/mcp skill://platform/incident-runbook/SKILL.md\nnode client/skills-dir.mjs http://127.0.0.1:4000/mcp skill://platform/incident-runbook\nnode client/list-tools.mjs http://127.0.0.1:4000/mcp research_echo\n```\n\nThe 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.\n\nOne 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.\n\nThe general-purpose agent shouldn’t see the credential rotation runbook. My first attempt was this rule, and it did nothing:\n\n```\n- deny: 'mcp.resource.name.startsWith(\"skill://security/\")'\n```\n\nThe 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:\n\n``` php\n# configs/skills-authz.yaml\n# yaml-language-server: $schema=https://agentgateway.dev/schema/config\nmcp:\n port: 4000\n failureMode: failOpen\n policies:\n mcpAuthorization:\n rules:\n # mcp.resource.name is the upstream URI (skill://rotate-prod-credentials/...),\n # not the client-facing skill://security/... one. The target is its own field.\n - deny: 'mcp.resource.target == \"security\" && mcp.resource.name.startsWith(\"skill://\")'\n targets:\n - name: platform\n mcp:\n host: http://127.0.0.1:3101/mcp\n - name: security\n mcp:\n host: http://127.0.0.1:3102/mcp\n - name: research\n mcp:\n host: http://127.0.0.1:3001/mcp\n```\n\nThe 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`.\n\nI 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.\n\n`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.\nBoth 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.\n\n`v1.4.1`), `v1.8.1`: `crates/agentgateway/src/mcp/``@modelcontextprotocol/server-everything`", "url": "https://wpnews.pro/news/mcp-tasks-and-skills-through-agentgateway-long-running-tools-and-shared-know-how", "canonical_source": "https://agentgateway.dev/blog/2026-12-04-agentgateway-mcp-tasks-skills/", "published_at": "2026-12-04 00:00:00+00:00", "updated_at": "2026-12-04 17:16:23.235272+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "developer-tools", "ai-tools"], "entities": ["agentgateway", "Model Context Protocol", "@modelcontextprotocol/server-everything", "TypeScript SDK", "SEP-2663", "SEP-2640"], "also_reported_by": [], "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.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/mcp-tasks-and-skills-through-agentgateway-long-running-tools-and-shared-know-how", "markdown": "https://wpnews.pro/news/mcp-tasks-and-skills-through-agentgateway-long-running-tools-and-shared-know-how.md", "text": "https://wpnews.pro/news/mcp-tasks-and-skills-through-agentgateway-long-running-tools-and-shared-know-how.txt", "jsonld": "https://wpnews.pro/news/mcp-tasks-and-skills-through-agentgateway-long-running-tools-and-shared-know-how.jsonld"}}