Repository navigation
feat(mcp): add prompts to the mcp route options - #476
Conversation
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.
|
@erkamyaman is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"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"
}
} |
There was a problem hiding this comment.
🟡 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/listandprompts/gethandlers. - 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.

Adds a
promptsoption to the MCP route options,createMcpServerandcreateMcpFetchHandler, the same way #452 addedresourceTemplates. The hub and the Next host pass it on too.promptscapability and servesprompts/listandprompts/get.name, an optionaltitle,descriptionandarguments, and aget(args)function that can be sync or async.prompts/getanswers invalid params for an unknown name, or when a required argument is missing or empty.getis not called then.getgoes to the MCP client.DF0085when the route mounts.Docs: a "Prompts" section in the MCP adapter page, one line in the hub guide, and the
DF0085error page.Checks
eslinton the changed filestsc --noEmitindevframe,agentic,hubandnext