Skip to content

feat(mcp): add prompts to the mcp route options - #476

Merged
antfu merged 2 commits into
devframes:mainfrom
erkamyaman:feat/mcp-prompts-v2
Nov 1, 2026
Merged

antfu merged 2 commits into
devframes:mainfrom
erkamyaman:feat/mcp-prompts-v2

Conversation

@erkamyaman

Copy link
Copy Markdown
Contributor

Adds a prompts option to the MCP route options, createMcpServer and createMcpFetchHandler, the same way #452 added resourceTemplates. The hub and the Next host pass it on too.

  • A non-empty list declares the prompts capability and serves prompts/list and prompts/get.
  • Each prompt has a name, an optional title, description and arguments, and a get(args) function that can be sync or async.
  • prompts/get answers invalid params for an unknown name, or when a required argument is missing or empty. get is not called then.
  • An error thrown by get goes to the MCP client.
  • A repeated prompt name throws the new DF0085 when the route mounts.

Docs: a "Prompts" section in the MCP adapter page, one line in the hub guide, and the DF0085 error page.

Checks

  • Tests for the server, the HTTP route and the hub aggregate route (8 new tests; 85 pass in the touched files)
  • eslint on the changed files
  • tsc --noEmit in devframe, agentic, hub and next
  • API snapshots regenerated

The route options, `createMcpServer` and `createMcpFetchHandler` take a
`prompts` list. The MCP server declares the `prompts` capability for a
non-empty list and serves `prompts/list` and `prompts/get`. An unknown
name, or a required argument that is missing or empty, gets invalid
params. A repeated name throws DF0085 when the route mounts.
Copilot AI balanced review requested due to automatic review settings November 1, 2026 12:06
@vercel

vercel Bot commented Nov 1, 2026

Copy link
Copy Markdown

@erkamyaman is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/476?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-11-01 12:18 UTC
🔗 head 54e1711
🤖 automated by pulls.review

{
  "headSha": "54e17111c7fbda512a28eab51f040be5dc1172c3",
  "result": {
    "overallSummary": "Adds a `prompts` option to the MCP route options, `createMcpServer` and `createMcpFetchHandler`, mirroring how `resourceTemplates` was added earlier. The server now declares the `prompts` capability and serves `prompts/list`/`prompts/get`, validates required arguments, propagates errors from `get` to the client, and rejects a repeated prompt name with the new `DF0085` diagnostic. The hub and Next host forward the option, with docs, tests and regenerated API snapshots updated accordingly.",
    "groups": [
      {
        "key": "core-prompts",
        "label": "Prompts core implementation",
        "summary": "Adds the `prompts` option throughout the MCP route/server/fetch-handler types and wires it into the server build, declaring the `prompts` capability and serving `prompts/list`/`prompts/get`. Includes the new `DF0085` diagnostic for a repeated prompt name, raised by the new `compilePrompts()` helper.",
        "category": "api",
        "filePaths": [
          "packages/devframe/src/types/mcp.ts",
          "packages/devframe/src/types/devframe.ts",
          "packages/devframe/src/node/diagnostics.ts",
          "packages/devframe/src/adapters/_shared.ts",
          "packages/devframe/src/adapters/initiate.ts",
          "packages/devframe/src/adapters/mcp.ts",
          "packages/agentic/src/mcp/build-server.ts",
          "packages/agentic/src/mcp/fetch.ts"
        ],
        "fileNotes": [
          {
            "path": "packages/agentic/src/mcp/build-server.ts",
            "text": "`compilePrompts()` indexes prompts by name and throws DF0085 on duplicates; `registerPromptHandlers()` validates required arguments using `Object.hasOwn` (own keys only) before calling `get`, and lets errors thrown by `get` propagate to the client.",
            "critical": true
          }
        ]
      },
      {
        "key": "host-integrations",
        "label": "Hub and Next host wiring",
        "summary": "Passes the new `prompts` option through from the hub's aggregate MCP route and the Next host config to the underlying MCP fetch handler.",
        "category": "api",
        "filePaths": [
          "packages/hub/src/node/initiate.ts",
          "packages/next/src/host.ts"
        ]
      },
      {
        "key": "tests",
        "label": "Tests for prompts",
        "summary": "New tests covering prompt listing/building, argument validation (including Object.prototype-named arguments), error propagation, the DF0085 duplicate check, and the hub's aggregate route serving prompts.",
        "category": "tests",
        "filePaths": [
          "packages/agentic/src/mcp/__tests__/mcp-http.test.ts",
          "packages/agentic/src/mcp/__tests__/mcp-server.test.ts",
          "packages/hub/src/node/__tests__/initiate.test.ts"
        ]
      },
      {
        "key": "docs",
        "label": "Documentation updates",
        "summary": "Documents the `prompts` option on the MCP adapter page, mentions it in the hub guide, and adds the DF0085 error reference page.",
        "category": "docs",
        "filePaths": [
          "docs/content/1.guide/18.hub-initiate.md",
          "docs/content/2.adapters/7.mcp.md",
          "docs/content/6.errors/DF0085.md",
          "docs/content/6.errors/index.md"
        ]
      },
      {
        "key": "snapshots",
        "label": "Generated API snapshots",
        "summary": "Regenerated public API type snapshots reflecting the new prompt types and the DF0085 diagnostic.",
        "category": "other",
        "filePaths": [
          "tests/__snapshots__/tsnapi/@devframes/next/hub.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/devframe/index.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/devframe/internal.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/devframe/types.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/devframe/adapters/mcp.snapshot.d.ts"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-11-01T12:18:45.639Z",
    "model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
    "locale": "en"
  }
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Required arguments with prototype-inherited names can bypass validation when omitted, allowing get to run without the required string instead of returning InvalidParams.

1 open issue
What changed in this PR

Adds configurable MCP prompt templates to devframe’s MCP servers and routes, with forwarding through the hub and Next.js host.

Changes:

  • Adds prompt types, capability declaration, and prompts/list and prompts/get handlers.
  • Validates required arguments and rejects duplicate prompt names with DF0085.
  • Adds server, HTTP, and hub tests, documentation, and updated API snapshots.
File Description
tests/​__snapshots__/​tsnapi/​devframe/​types.snapshot.d.ts Records prompt type exports.
tests/​__snapshots__/​tsnapi/​devframe/​internal.snapshot.d.ts Records the DF0085 diagnostic.
tests/​__snapshots__/​tsnapi/​devframe/​index.snapshot.d.ts Records prompt interfaces and options.
tests/​__snapshots__/​tsnapi/​devframe/​adapters/​mcp.snapshot.d.ts Records MCP adapter type exports.
tests/​__snapshots__/​tsnapi/​@devframes/​next/​hub.snapshot.d.ts Records the Next.js prompts option.
packages/​next/​src/​host.ts Forwards prompts to the MCP handler.
packages/​hub/​src/​node/​initiate.ts Forwards prompts to the aggregate route.
packages/​hub/​src/​node/​__tests__/​initiate.test.ts Tests prompts on the aggregate route.
packages/​devframe/​src/​types/​mcp.ts Defines prompt types and server options.
packages/​devframe/​src/​types/​devframe.ts Adds prompts to route options.
packages/​devframe/​src/​node/​diagnostics.ts Defines DF0085 for duplicate names.
packages/​devframe/​src/​adapters/​mcp.ts Exports prompt types.
packages/​devframe/​src/​adapters/​initiate.ts Passes prompts when mounting the route.
packages/​devframe/​src/​adapters/​_shared.ts Preserves prompts during option resolution.
packages/​agentic/​src/​mcp/​fetch.ts Compiles prompts when creating the HTTP handler.
packages/​agentic/​src/​mcp/​build-server.ts Implements prompt registration, validation, and handlers.
packages/​agentic/​src/​mcp/​__tests__/​mcp-server.test.ts Tests prompt capabilities, results, and errors.
packages/​agentic/​src/​mcp/​__tests__/​mcp-http.test.ts Tests prompts over HTTP.
docs/​content/​6.errors/​index.md Lists DF0085.
docs/​content/​6.errors/​DF0085.md Explains duplicate prompt names and fixes.
docs/​content/​2.adapters/​7.mcp.md Documents prompt configuration and behavior.
docs/​content/​1.guide/​18.hub-initiate.md Documents aggregate-route prompt support.

Review effort: Balanced

`prompts/get` read each required argument with `given[name]`, so a
required argument named like an `Object.prototype` key, such as
`constructor`, counted as sent when the client left it out. It now
checks own keys only.
Copilot AI balanced review requested due to automatic review settings November 1, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the MCP prompt-template change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@antfu
antfu merged commit bf41031 into devframes:main Nov 1, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants