Skip to content

feat: improve beta server configuration and DX - #406

Open
HugoRCD wants to merge 3 commits into
v1-05-nuxtfrom
v1-06-docs
Open

HugoRCD wants to merge 3 commits into
v1-05-nuxtfrom
v1-06-docs

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Written by an AI agent on behalf of @HugoRCD, who shaped the solution. @HugoRCD has not reviewed it yet.

The beta guides still taught SDK-era APIs, and common typed tool outputs needed return annotations or satisfies. This aligns the guides with the shared runtime, lets discovered endpoints keep runtime settings beside their definitions and read authentication credentials at request time, and makes enum/array output inference work without extra syntax. Nitro 2 also removes unused MCP/JWT dependencies from deployment output.

Stack

Based on #405 (v1-05-nuxt). Review after #402 → #403 → #405; retarget to v1 as predecessors land. This PR includes the runtime auth and DX follow-up to the documentation work. Beta consumer readiness remains required before publishing.

Changes

  • Migrate the beta guides, READMEs, starter guidance and published skill to the shared definitions, endpoint/layer model, resources, prompts, continuations and explicit request events. Redirect retired Code Mode pages to migration guidance.
  • Add complete Nuxt OAuth setup with Clerk/Okta/WorkOS, verified claims/scopes and manual metadata routes. Preserve useful typed-output and native Nitro caching examples.
  • Add optional per-endpoint index.ts with defineMcpServer() for metadata, instructions, protocol settings and runtime authentication. Keep routing and directory discovery in framework config. Index values override module defaults, the first layer containing an index wins, and conflicting authentication refuses requests. Explicit defineMcpAuth() files remain supported.
  • Use discovered public metadata in Nuxt installation links and llms.txt. Creation/removal of an index triggers a development rebuild; definition ownership remains per endpoint.
  • Infer literal, enum and nested array output fields directly from callbacks; keep rejection of invalid results and explicit toolResult() envelopes. Add public-type and emitted-declaration regressions.
  • Inline the toolkit runtime, h3-mcp, internal H3 v2 and jose on Nitro 2 while preserving host H3 v1. Packed fixtures check bearer-only and JWT consumers on Nitro 2/3 and both protocol generations.
  • Include release notes for both published packages. Per-definition cache shortcuts remain removed; application services use Nitro caching.

Server configuration beside definitions

nuxt.config.ts selects endpoints:

export default defineNuxtConfig({
  modules: ['@nuxtjs/mcp-toolkit'],
  runtimeConfig: { mcpAdminToken: '' },
  mcp: { servers: { default: {}, admin: { dir: 'mcp-admin' } } },
})

server/mcp-admin/index.ts configures the admin server:

import { defineMcpServer } from '@nuxtjs/mcp-toolkit/server'
import { useRuntimeConfig } from 'nuxt/server'

export default defineMcpServer({
  name: 'admin',
  instructions: 'Use these tools for team operations.',
  auth: {
    schemes: ['bearer'],
    validate: ({ token }) => {
      const { mcpAdminToken } = useRuntimeConfig()
      return Boolean(mcpAdminToken) && token === mcpAdminToken
    },
  },
})

Set NUXT_MCP_ADMIN_TOKEN at runtime. Add tools, resources and prompts under the same directory; no imports or registration lists are needed. Bare Nitro uses the same index convention with imports from nitro-mcp-toolkit. Module auth/oauth cannot be combined with index auth; invalid exports and ambiguous selected indexes refuse access.

The Nuxt and Nitro playgrounds use this convention. The public metadata virtual reads only the selected index and does not load definitions or plugins, so install links and the optional llms.txt section use the same name, description and documentation URL as the endpoint.

Output inference regression

The same TypeScript compiler input was checked with the previous tool.ts from a582ad1 and the current source, using an in-memory source overlay. No checkout was reverted. test/types.test.ts also checks invalid literal, missing-field, async, nested-array and callable-field results.

Actual compiler input and before/after output
import { defineMcpTool } from '../src/runtime/index.ts'
import { z } from 'zod'
defineMcpTool({
  outputSchema: z.object({ status: z.enum(['ok', 'degraded']), checks: z.array(z.enum(['ok', 'degraded'])) }),
  handler: async () => ({ status: 'ok', checks: ['ok'] }),
})

before:
packages/nitro-mcp-toolkit/test/pr-inference.ts(5,24): error TS2769: No overload matches this call.
  Overload 1 of 2, '(definition: McpToolDefinitionWithoutInput<ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>): McpTool', gave the following error.
    Type 'Promise<{ status: string; checks: string[]; }>' is not assignable to type 'Awaitable<McpToolReturn<ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>>'.
      Type 'Promise<{ status: string; checks: string[]; }>' is not assignable to type 'Promise<McpToolReturn<ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>>'.
        Type '{ status: string; checks: string[]; }' is not assignable to type 'McpToolReturn<ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>'.
          Type '{ status: string; checks: string[]; }' is not assignable to type '{ status: "ok" | "degraded"; checks: ("ok" | "degraded")[]; }'.
            Types of property 'status' are incompatible.
              Type 'string' is not assignable to type '"ok" | "degraded"'.
  Overload 2 of 2, '(definition: McpToolDefinition<Schema, ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>): McpTool', gave the following error.
    Type 'Promise<{ status: string; checks: string[]; }>' is not assignable to type 'Awaitable<McpToolReturn<ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>>'.
      Type 'Promise<{ status: string; checks: string[]; }>' is not assignable to type 'Promise<McpToolReturn<ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>>'.
        Type '{ status: string; checks: string[]; }' is not assignable to type 'McpToolReturn<ZodObject<{ status: ZodEnum<{ ok: "ok"; degraded: "degraded"; }>; checks: ZodArray<ZodEnum<{ ok: "ok"; degraded: "degraded"; }>>; }, $strip>>'.
          Type '{ status: string; checks: string[]; }' is not assignable to type '{ status: "ok" | "degraded"; checks: ("ok" | "degraded")[]; }'.
            Types of property 'status' are incompatible.
              Type 'string' is not assignable to type '"ok" | "degraded"'.

compiler exit code: 1

after:
No TypeScript errors.
compiler exit code: 0

Packed consumer evidence

Actual output from the packed-package run using discovered index authentication, exit 0:

{"framework":2,"oauth":false,"javaScriptFiles":12,"bytes":485919,"gzipBytes":122375,"joseBytes":0}
{"framework":2,"oauth":true,"javaScriptFiles":14,"bytes":525009,"gzipBytes":133564,"joseBytes":31615}
{"framework":3,"oauth":false,"javaScriptFiles":7,"bytes":188799,"gzipBytes":43709,"joseBytes":0}
{"framework":3,"oauth":true,"javaScriptFiles":10,"bytes":226478,"gzipBytes":54596,"joseBytes":31909}
Packed runtime, types, ordinary peer resolution and Nitro 2/3 endpoints passed.

joseBytes measures rendered JWT code. Bearer-only consumers also assert no external jose files; OAuth consumers verify ES256 signatures and reject expired tokens and wrong audiences, serving modern and legacy clients.

The earlier controlled experiment, with the same installed dependencies and fresh build directories, measured JavaScript gzip size of 161,388 → 120,433 bytes after the jose inlining rule. This is a minimal Nitro 2 fixture measurement, not a whole-application or deployment startup claim.

Portable helper types

Compiling the examples exposed H3 v1 alias collisions in continuation helpers and an unnecessary host-context requirement in the test client's fetch type. The public helper aliases now keep the exact engine function references while exposing canonical h3/generic event signatures, including signed-state callbacks and codecs. The test client requires the request-to-response function it actually calls.

New regression tests cover inferred response types, canonical event/header access, state codecs, composed Nuxt handlers, and engine function identity. Patch changesets cover both packages. The same Nuxt type-check command failed before and passes after:

Original type-check failure excerpt

Command: pnpm --filter @nuxtjs/mcp-toolkit typecheck, exit 1. Unedited excerpt:

$ vue-tsc --noEmit
test/types.test.ts(30,20): error TS2722: Cannot invoke an object which is possibly 'undefined'.
test/types.test.ts(30,38): error TS2349: This expression is not callable.
  No constituent of type 'string | string[]' is callable.
test/types.test.ts(35,43): error TS2345: Argument of type 'McpEvent' is not assignable to parameter of type 'H3Event<EventHandlerRequest>'.
  Type 'H3Event<EventHandlerRequest> & { context: H3EventContext & { mcp: RequestContext & { notifier: McpNotifier; }; oauth?: McpOAuthClaims | undefined; }; }' is missing the following properties from type 'H3Event<EventHandlerRequest>': "__is_event__", _handled, _onBeforeResponseCalled, _onAfterResponseCalled, and 5 more.
test/types.test.ts(37,42): error TS2345: Argument of type 'McpEvent' is not assignable to parameter of type 'H3Event<EventHandlerRequest>'.
  Type 'H3Event<EventHandlerRequest> & { context: H3EventContext & { mcp: RequestContext & { notifier: McpNotifier; }; oauth?: McpOAuthClaims | undefined; }; }' is missing the following properties from type 'H3Event<EventHandlerRequest>': "__is_event__", _handled, _onBeforeResponseCalled, _onAfterResponseCalled, and 5 more.
test/types.test.ts(39,57): error TS2345: Argument of type 'McpEvent' is not assignable to parameter of type 'H3Event<EventHandlerRequest>'.

Final execution of the same command exits 0.

Evidence

The documented code was copied into a temporary production Nuxt consumer with a local JWKS issuer and real MCP clients. Captured output, exit 0:

Copied OAuth, resource, prompt and elicitation examples: Nuxt build exit 0
OAuth: metadata and 401 challenge passed; wrong audience, issuer and expired tokens rejected
modern: verified identity, scopes, typed output, resource assets/templates, prompt defaults/completion and interaction fallback passed
legacy: verified identity, scopes, typed output, resource assets/templates, prompt defaults/completion and interaction fallback passed
Modern interaction: initial input_required, accepted retry and declined response passed; concurrent identities remain separate
Manual Nuxt OAuth route: metadata/CORS, resource audience separation and verified invocation passed

Built documentation checks, exit 0:

[Icon] failed to load icon `vscode-icons:file-type-txt`
45 rendered documentation pages and 44 raw Markdown pages returned 200 with expected content
Retired Code Mode HTML and raw Markdown URLs return the expected 301 redirects
Published skill discovery and the new OAuth reference returned 200

Per-folder configuration verification

The final nuxt.com production build consumes locally packed toolkit packages. Actual discovery output, exit 0:

[nitro] ℹ [mcp] /mcp serves 12 tools, 3 resources, 3 prompts from server/mcp, layers/nuxi/server/mcp, with index.ts
[nitro] ℹ [mcp] /mcp/admin serves 10 tools, 5 prompts from server/mcp-admin, layers/nuxi/server/mcp-admin, with index.ts

Real modern and legacy clients confirm exact per-directory catalogs, rejected cross-server calls, preserved admin instructions and runtime token checks. Missing, wrong and unconfigured admin tokens are refused. Installation links use the public server name from its index. The website’s 447 unit tests and 46 Nuxt integration tests pass; its published-preview build and type checking pass. Focused catalogs/auth/prompt checks pass against that artifact too. Its broader documentation-content smoke currently hits an external GitHub 403 fetching nuxt/nuxt#4.x; the earlier local-candidate content smoke passed. See nuxt/nuxt.com#2567 for both results.

Current validation and limitations

  • Package suites: 318 Nitro + 73 Nuxt = 391 passing tests. Both package type checks, builds, Nitro formatting/lint, Nitro-playground formatting/lint and Nuxt/docs/playground ESLint pass. CI caught one Nitro-playground formatting difference in the first push; the amended commit corrects it. Existing lint warnings remain.
  • The enum-output example above and the simplified README/guide examples compile. Public Nuxt exports and packed Nitro declarations are covered.
  • The unmodified packed-consumer command failed loading the optional native Rollup 4.68.0 dependency under the configured package-age policy. A temporary verifier pinned the installed Rollup 4.63.3 and matching native dependency; that run passed runtime, declarations, peer resolution and the Nitro 2/3 matrix. No pin or verifier workaround is committed. The standard published-surface CI job passed after the first push.
  • The first Windows run exposed path-separator assumptions in the new compiler fixture and bundling check. Normalize fixture/module paths and the Nitro 2 inlining matcher; local focused tests and type checking pass. The current Windows CI job passes, as do lint/typecheck, package/example builds and the published-surface audit. The Linux test job was still running at this update.
  • Playground type checking still reports errors in unchanged code: a signup field lacks type, resource path values may be undefined, and a created todo may be undefined. The auth example prepared without errors.
  • The earlier docs pass compiled 151 extracted examples and built/served 45 documentation pages. The updated snippets were checked separately; the full extraction and docs production build were not repeated for this follow-up.
  • Live provider login/registration/refresh, model eval execution and deployed-host compatibility remain beta validation work. Local JWT verification uses a local issuer and sanitized fixtures. These checks do not establish complete specification or client compatibility.

ELI5

Each MCP server keeps its description, instructions and access checks beside its tools. The guides match the beta APIs, ordinary tool results need less TypeScript boilerplate, and servers avoid shipping unused JWT code.

@vercel

vercel Bot commented Oct 28, 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:45pm 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 Oct 28, 2026 •

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

commit: a7d0894

@HugoRCD HugoRCD changed the title docs: complete the 1.0 beta guides feat: improve beta auth, tool inference and guides Nov 10, 2026
@HugoRCD
HugoRCD added this pull request to stack #404 November 10, 2026 09:21
@HugoRCD HugoRCD changed the title feat: improve beta auth, tool inference and guides feat: improve beta server configuration and DX Nov 10, 2026

This branch was successfully deployed

1 active deployment
Preview — a7d08941 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