Skip to content

feat!: replace re-exported h3-mcp types with toolkit-owned names - #420

Open
HugoRCD wants to merge 1 commit into
v1-07-auth-dxfrom
v1-08-toolkit-types
Open

HugoRCD wants to merge 1 commit into
v1-07-auth-dxfrom
v1-08-toolkit-types

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Written by an AI agent on behalf of @HugoRCD. @HugoRCD has reviewed it.

The beta's public API re-exported h3-mcp's own types (AuthOptions, Era, ExtensionPlugin, OriginOptions, PluginOptions, …) and McpHandlerOptions extended h3-mcp's whole HandlerOptions, so every engine option and callback was public API of both nitro-mcp-toolkit and @nuxtjs/mcp-toolkit (which re-exports it). Swapping or upgrading the engine after 1.0 would then be a breaking change for users. This PR exports engine concepts only under toolkit-owned Mcp-prefixed names and lists the handler options the toolkit actually maps. MCP spec types such as CallToolResult and Icon keep their names, and runtime behaviour does not change.

To try it, install the PR build and typecheck code that uses the new names:

npm i https://pkg.pr.new/nitro-mcp-toolkit@420
import { createMcpHandler, defineMcpAuth } from 'nitro-mcp-toolkit'
import type { McpAuthOptions, McpEra, McpExtensionPlugin, McpRequestContext } from 'nitro-mcp-toolkit'

const era: McpEra = 'dual'
export const auth: McpAuthOptions = defineMcpAuth({ tokens: [process.env.MCP_TOKEN!] })
export default createMcpHandler({ era, auth })
Before After
AuthOptions, AuthCredentials, AuthScheme McpAuthOptions, McpAuthCredentials, McpAuthScheme
CacheHints McpCacheHints
Era McpEra
ExtensionPlugin McpExtensionPlugin
OriginOptions McpOriginOptions
PluginOptions McpHandlerSetup
event.context.mcp typed as h3-mcp's RequestContext McpRequestContext (new), plus McpSessionOptions, McpLimitsOptions

Before and after

The same consumer file, typechecked with the package's tsc --noEmit against #415 (v1-07-auth-dx) and against this branch:

import type { AuthOptions, Era, ExtensionPlugin } from 'nitro-mcp-toolkit'
import type { McpAuthOptions, McpEra, McpExtensionPlugin } from 'nitro-mcp-toolkit'
import { createMcpHandler } from 'nitro-mcp-toolkit'

export const handler = createMcpHandler({ era: 'dual', onStream: () => {} })
export type Names = [AuthOptions, Era, ExtensionPlugin, McpAuthOptions, McpEra, McpExtensionPlugin]

Before:

test/proof/consumer.ts(2,15): error TS2724: '"nitro-mcp-toolkit"' has no exported member named 'McpAuthOptions'. Did you mean 'McpOAuthOptions'?
test/proof/consumer.ts(2,31): error TS2305: Module '"nitro-mcp-toolkit"' has no exported member 'McpEra'.
test/proof/consumer.ts(2,39): error TS2724: '"nitro-mcp-toolkit"' has no exported member named 'McpExtensionPlugin'. Did you mean 'ExtensionPlugin'?
exit 2

After:

test/proof/consumer.ts(1,15): error TS2724: '"nitro-mcp-toolkit"' has no exported member named 'AuthOptions'. Did you mean 'McpAuthOptions'?
test/proof/consumer.ts(1,28): error TS2305: Module '"nitro-mcp-toolkit"' has no exported member 'Era'.
test/proof/consumer.ts(1,33): error TS2724: '"nitro-mcp-toolkit"' has no exported member named 'ExtensionPlugin'. Did you mean 'McpExtensionPlugin'?
test/proof/consumer.ts(5,56): error TS2353: Object literal may only specify known properties, and 'onStream' does not exist in type 'McpHandlerOptions'.
exit 2

Dropping the pass-through removes the h3-mcp options nothing in the repo used: onListen, onStream, onCancelled, onProgress, onLogLevelSet, onSubscribe, onUnsubscribe, cache, extensions, subscriptions and echoServerInfo. handler.notify still pushes list-changed and resource-updated events; the README used to point to onListen and no longer does. A type test now pins the option set, so adding one is a deliberate change. The changeset is major for both packages, like the other beta changesets.

Two leaks remain and are documented in AGENTS.md. h3-mcp declares H3EventContext.mcp globally, so editors still show the engine's full context on McpEvent.context.mcp (a probe sees RequestContext & Pick<…>); that goes only with the engine. McpExtensionPlugin is h3-mcp's plugin contract under a toolkit name, so plugins stay engine-specific by nature.

Beyond CI: the Nuxt module's tests need pnpm build:module first (two fixtures load its dist); after that they passed locally. I also built nitro-mcp-toolkit and checked that dist/runtime/index.d.mts exports none of the removed names. Nobody has tried the renames in a real app yet.

ELI5

The toolkit is built on top of another library, and it was handing that library's own type names straight to users. Now it gives them its own names, so if the library underneath changes one day, users' code doesn't have to.

@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nuxt-mcp-toolkit-docs Ready Ready Preview Nov 25, 2026 1:46pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/nitro-mcp-toolkit@420
npm i https://pkg.pr.new/@nuxtjs/mcp-toolkit@420

commit: fdbe7bb

The public API now exports engine types only under Mcp-prefixed names
(McpAuthOptions, McpEra, McpExtensionPlugin, McpRequestContext, ...), and
McpHandlerOptions lists its options instead of extending h3-mcp's
HandlerOptions. MCP spec types keep their names.

Amp-Thread-ID: https://ampcode.com/threads/T-01a21265-50f0-764e-97c3-f8296e9c8df5
Co-authored-by: Amp <amp@ampcode.com>

This branch was successfully deployed

1 active deployment
Preview — fdbe7bbe Deployed Nov 25, 2026 by vercel[bot]
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.

1 participant