xmcp 0.6.13 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xmcp",
3
3
  "description": "The MCP framework",
4
- "version": "0.6.13",
4
+ "version": "0.7.0",
5
5
  "author": {
6
6
  "name": "xmcp",
7
7
  "email": "support@xmcp.dev",
@@ -80,13 +80,6 @@
80
80
  "dist",
81
81
  "src"
82
82
  ],
83
- "scripts": {
84
- "dev": "cross-env NODE_ENV=development tsx --watch --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
85
- "build": "cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
86
- "analyze": "cross-env GENERATE_STATS=true pnpm build && pnpm tsx scripts/analyze-rspack-stats.ts",
87
- "test:config": "node --import tsx --test src/compiler/config/__tests__/*.test.ts",
88
- "test:adapters": "node --import tsx --test src/runtime/adapters/fastify/__tests__/*.test.ts"
89
- },
90
83
  "dependencies": {
91
84
  "@modelcontextprotocol/sdk": "^1.26.0",
92
85
  "@rspack/core": "^1.6.7",
@@ -140,5 +133,12 @@
140
133
  "react-dom": {
141
134
  "optional": true
142
135
  }
136
+ },
137
+ "scripts": {
138
+ "dev": "cross-env NODE_ENV=development tsx --watch --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
139
+ "build": "cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
140
+ "analyze": "cross-env GENERATE_STATS=true pnpm build && pnpm tsx scripts/analyze-rspack-stats.ts",
141
+ "test:config": "node --import tsx --test src/compiler/config/__tests__/*.test.ts",
142
+ "test:adapters": "node --import tsx --test src/runtime/adapters/fastify/__tests__/*.test.ts"
143
143
  }
144
- }
144
+ }
@@ -80,3 +80,42 @@ export {
80
80
  type AuthConfig,
81
81
  type OAuthProtectedResourceMetadata,
82
82
  } from "./auth";
83
+
84
+ /**
85
+ * MCP Server Card handler for Next.js route files (SEP-1649).
86
+ * Serves server identity and transport metadata at `/.well-known/mcp/server-card.json`,
87
+ * enabling agent discovery clients to auto-configure connections.
88
+ *
89
+ * @example
90
+ * // app/.well-known/mcp/server-card.json/route.ts
91
+ * import { serverCardHandler } from "@xmcp/adapter";
92
+ * export { serverCardHandler as GET };
93
+ */
94
+ export function serverCardHandler(request: Request): Response {
95
+ const url = new URL(request.url);
96
+ const reversedName = url.hostname.split(".").reverse().join(".");
97
+ const card: Record<string, unknown> = {
98
+ $schema:
99
+ "https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json",
100
+ name: `${reversedName}/mcp`,
101
+ version: SERVER_INFO.version,
102
+ description: TEMPLATE_CONFIG.description,
103
+ title: TEMPLATE_CONFIG.name,
104
+ remotes: [
105
+ {
106
+ type: "streamable-http",
107
+ url: `${url.origin}${HTTP_CONFIG.endpoint}`,
108
+ },
109
+ ],
110
+ };
111
+ if (TEMPLATE_CONFIG.icons?.length) {
112
+ card.icons = TEMPLATE_CONFIG.icons;
113
+ }
114
+ return Response.json(card, {
115
+ headers: {
116
+ "Content-Type": "application/mcp-server-card+json",
117
+ "Cache-Control": "public, max-age=3600, must-revalidate",
118
+ "Access-Control-Allow-Origin": "*",
119
+ },
120
+ });
121
+ }
@@ -187,6 +187,7 @@ export class StatelessStreamableHTTPTransport {
187
187
  );
188
188
  });
189
189
 
190
+ this.setupMcpServerCardRoute();
190
191
  this.setupOpenAIAppsChallengeRoute();
191
192
 
192
193
  // isolate requests context
@@ -198,6 +199,47 @@ export class StatelessStreamableHTTPTransport {
198
199
  });
199
200
  }
200
201
 
202
+ /**
203
+ * Serves an MCP Server Card at /.well-known/mcp/server-card.json.
204
+ * Enables agent discovery clients to auto-configure connections to this server.
205
+ */
206
+ private setupMcpServerCardRoute(): void {
207
+ this.app.get(
208
+ "/.well-known/mcp/server-card.json",
209
+ (req: Request, res: Response) => {
210
+ const host = req.get("host") ?? "localhost";
211
+ const hostname = host.replace(/:\d+$/, "");
212
+ const reversedName = hostname.split(".").reverse().join(".");
213
+ const proto =
214
+ (req.headers["x-forwarded-proto"] as string | undefined)
215
+ ?.split(",")[0]
216
+ ?.trim() ?? req.protocol;
217
+ const card: Record<string, unknown> = {
218
+ $schema:
219
+ "https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json",
220
+ name: `${reversedName}/mcp`,
221
+ version: SERVER_INFO.version,
222
+ description: this.options.template?.description,
223
+ title: this.options.template?.name,
224
+ remotes: [
225
+ {
226
+ type: "streamable-http",
227
+ url: `${proto}://${host}${this.endpoint}`,
228
+ },
229
+ ],
230
+ };
231
+ if (this.options.template?.icons?.length) {
232
+ card.icons = this.options.template.icons;
233
+ }
234
+ res
235
+ .setHeader("Content-Type", "application/mcp-server-card+json")
236
+ .setHeader("Cache-Control", "public, max-age=3600, must-revalidate")
237
+ .setHeader("Access-Control-Allow-Origin", "*")
238
+ .json(card);
239
+ }
240
+ );
241
+ }
242
+
201
243
  /**
202
244
  * Exposes the OpenAI Apps verification challenge file when configured.
203
245
  * The presence of OPENAI_APPS_VERIFICATION_TOKEN acts as the feature flag