Skip to content

fix(xmcp): align prompt and resource loader startup behavior - #538

Merged
0xKoller merged 4 commits into
basementstudio:canaryfrom
FiammaMuscari:feat/prompt-resource-loader-error-handling-alignment
Apr 9, 2026
Merged

fix(xmcp): align prompt and resource loader startup behavior#538
0xKoller merged 4 commits into
basementstudio:canaryfrom
FiammaMuscari:feat/prompt-resource-loader-error-handling-alignment

Conversation

@FiammaMuscari

@FiammaMuscari FiammaMuscari commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR is the follow-up requested during the review of #528.

It extends the same graceful loader startup behavior already implemented for tools to prompts and resources, while keeping the scope intentionally small and limited to the runtime and compiler pieces required for that behavior to work in the real bundled app.

What changed

  • added graceful startup handling for prompt files
  • added graceful startup handling for resource files
  • wired prompt/resource loader reporting into server startup alongside the existing tool-loader flow
  • taught the loaders to treat bundled interop modules with an empty default export as empty files, so they still follow the friendly warning path at runtime
  • regenerated prompt/resource import handling when file contents change in development without rebuilding unrelated client bundles
  • aligned the Next.js server lifecycle with the current loader contract used by server startup

Why

The tool-loader behavior added in #528 handled empty files and missing default exports gracefully. This follow-up applies the same behavior to prompts and resources and closes the remaining gap in the bundled HTTP example, where empty prompt/resource files can arrive at runtime as an interop-shaped module with default: {}.

Scope

This PR intentionally avoids expanding scope.

It does not add docs, tests, demo files, screenshots, or unrelated refactors. It only includes the production changes required to make prompt/resource startup behavior consistent with the existing tool-loader behavior.

Files changed

  • packages/xmcp/src/compiler/index.ts
  • packages/xmcp/src/runtime/adapters/nextjs/handler/server-lifecycle.ts
  • packages/xmcp/src/runtime/utils/prompt-loader.ts
  • packages/xmcp/src/runtime/utils/resource-loader.ts
  • packages/xmcp/src/runtime/utils/server.ts
  • packages/xmcp/src/runtime/utils/tool-loader.ts

Validation

Manual validation was performed with examples/template-config:

  • empty prompt file -> friendly warning, startup continues
  • missing default export -> friendly warning, startup continues
  • syntax error -> original error still surfaces and fails loudly

Follow-up context

Requested in the review of #528:
#528

@greptile-apps

greptile-apps Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@vercel

vercel Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

@FiammaMuscari is attempting to deploy a commit to the xmcp Team on Vercel.

A member of the Team first needs to authorize it.

@0xKoller 0xKoller 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.

LGTM!

Consistency with the previous PR #528, following the instructions and considerations from that review.

The only thing missing is the addition in the docs for this new behavior.

@FiammaMuscari

Copy link
Copy Markdown
Contributor Author

Added the missing docs requested in review, consistent with #528. Pushed in 6dd88cc.

@vercel

vercel Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
xmcp-website Ready Ready Preview, Comment Apr 9, 2026 2:14pm

@0xKoller
0xKoller merged commit 43a59db into basementstudio:canary Apr 9, 2026
5 of 6 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