Skip to content

Add instructions to server info#519

Open
0xKoller wants to merge 2 commits intocanaryfrom
add-support-for-instructions-according-to-mcp-standart-xmcp-408
Open

Add instructions to server info#519
0xKoller wants to merge 2 commits intocanaryfrom
add-support-for-instructions-according-to-mcp-standart-xmcp-408

Conversation

@0xKoller
Copy link
Copy Markdown
Collaborator

No description provided.

@0xKoller 0xKoller requested a review from valebearzotti as a code owner March 16, 2026 19:26
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 16, 2026

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

Project Deployment Actions Updated (UTC)
xmcp-website Ready Ready Preview, Comment Mar 17, 2026 9:27pm
@0xKoller 0xKoller changed the base branch from main to canary March 16, 2026 19:26
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

Rspack Bundle Analysis

Build Assets Total Size (MB) Build Time
Main Compiler 4 6.32 5.18s
Runtime Compiler 6 5.35 6.00s

Main Compiler

Source: stats-main.json

Asset Chunk Size (KB) Size (MB)
cli.js cli 6009.40 5.87
index.js index 368.80 0.36
cloudflare.js cloudflare 81.70 0.08
detached-flush.js detached-flush 15.18 0.01

Total emitted JS: 6.32 MB

Runtime Compiler

Source: stats-runtime.json

Asset Chunk Size (KB) Size (MB)
http.js http 1305.70 1.28
adapter-nestjs.js adapter-nestjs 1281.97 1.25
adapter-nextjs.js adapter-nextjs 1276.39 1.25
adapter-express.js adapter-express 1274.28 1.24
stdio.js stdio 343.31 0.34
headers.js headers 1.33 0.00

Total emitted JS: 5.35 MB

Package Footprint (npm pack + npm install)

Item Size (KB) Size (MB)
Tarball (.tgz) 4622.10 4.51
dist/ 12011.22 11.73
node_modules/ 101024.96 98.66
dist + node_modules 113036.18 110.39
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR adds an optional instructions field to the xmcp server template configuration, which is forwarded to MCP clients in the initialize response so they can include it in the system prompt. It also fixes an existing divergence where the Next.js adapter's initializeMcpServer() was creating McpServer directly (bypassing createServer()), by refactoring it to delegate to createServer() — the same pattern already used by the Express and NestJS adapters.

  • template.ts: adds instructions: z.string().optional() with thorough JSDoc documentation.
  • injection.ts: conditionally injects SERVER_INSTRUCTIONS at build time when instructions are provided, consistent with how other config variables (e.g., SERVER_INFO) are handled.
  • server.ts: reads INJECTED_INSTRUCTIONS using a safe typeof guard (necessary since the variable may not be injected), and passes it to McpServer options in createServer().
  • server-lifecycle.ts (Next.js adapter): initializeMcpServer() is reduced to a single return createServer() call, eliminating the duplicated setup logic and ensuring instructions is correctly applied for Next.js users.
  • Documentation in server-info.mdx is updated with a clear usage example and guidance on what the field should and should not contain.

Confidence Score: 5/5

  • This PR is safe to merge — the change is well-scoped, consistent with existing patterns, and the previously identified Next.js adapter divergence has been correctly resolved.
  • All adapters (Next.js, NestJS, Express) now route through a single createServer() call, the injected-variable pattern is consistent with the rest of the codebase, the typeof guard on SERVER_INSTRUCTIONS correctly handles the case when no instructions are configured, and the documentation is clear and accurate.
  • No files require special attention.

Important Files Changed

Filename Overview
packages/xmcp/src/runtime/utils/server.ts Adds INJECTED_INSTRUCTIONS module-level variable and passes it to McpServer options inside createServer(); logic is sound and consistent with other injected globals.
packages/xmcp/src/runtime/adapters/nextjs/handler/server-lifecycle.ts Refactored initializeMcpServer() to delegate entirely to createServer(), fixing the previously-identified divergence where the Next.js adapter bypassed instructions support.
packages/xmcp/src/compiler/config/injection.ts Conditionally injects SERVER_INSTRUCTIONS when templateConfig.instructions is truthy; consistent with the pattern used for other injected variables.
packages/xmcp/src/compiler/config/schemas/template.ts Adds instructions: z.string().optional() with thorough JSDoc; no issues.
apps/website/content/docs/configuration/server-info.mdx Documentation updated with a clear instructions section, usage example, and guidance on what the field should contain.

Last reviewed commit: b644384

@0xKoller 0xKoller linked an issue Mar 17, 2026 that may be closed by this pull request
@0xKoller
Copy link
Copy Markdown
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant