xmcp 0.8.0 → 1.0.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.
@@ -1,8 +1,4 @@
1
1
  import type { TemplateConfig } from "@/config/schemas";
2
- import { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types";
3
- import { Transport } from "@modelcontextprotocol/sdk/shared/transport";
4
- import { MessageExtraInfo } from "@modelcontextprotocol/sdk/types";
5
- import { IncomingMessage, ServerResponse } from "http";
6
2
  export interface HttpTransportOptions {
7
3
  port?: number;
8
4
  host?: string;
@@ -19,14 +15,3 @@ export interface JsonRpcMessage {
19
15
  result?: any;
20
16
  error?: any;
21
17
  }
22
- export declare abstract class BaseHttpServerTransport implements Transport {
23
- onmessage?: (message: JsonRpcMessage, extra?: MessageExtraInfo) => void;
24
- onerror?: (error: Error) => void;
25
- onclose?: () => void;
26
- abstract start(): Promise<void>;
27
- abstract close(): Promise<void>;
28
- abstract send(message: JsonRpcMessage): Promise<void>;
29
- abstract handleRequest(req: IncomingMessage & {
30
- auth?: AuthInfo;
31
- }, res: ServerResponse, parsedBody?: unknown): Promise<void>;
32
- }
@@ -1,7 +1,7 @@
1
1
  import type { JsonRpcMessage } from "@/runtime/transports/http/base-streamable-http";
2
2
  import type { HttpHeaders } from "@/runtime/contexts/http-request-context";
3
3
  import type { McpClientInfo } from "@/types/client-info";
4
- import type { Implementation } from "@modelcontextprotocol/sdk/types";
4
+ import type { Implementation } from "@modelcontextprotocol/server";
5
5
  export declare const mapImplementationToClientInfo: (implementation: Implementation | undefined) => McpClientInfo | undefined;
6
6
  export declare const extractClientInfoFromMessage: (message: JsonRpcMessage | undefined) => McpClientInfo | undefined;
7
7
  export declare const extractClientInfoFromMessages: (payload: unknown) => McpClientInfo | undefined;
@@ -1,4 +1,3 @@
1
- import type { ElicitRequest, ElicitResult, ToolExtraArguments, ToolRequestOptions } from "@/types/tool";
2
- type ElicitRequestSender = Pick<ToolExtraArguments, "sendRequest">;
3
- export declare function elicitFromTool(extra: ElicitRequestSender, request: ElicitRequest, options?: ToolRequestOptions): Promise<ElicitResult>;
4
- export {};
1
+ import { ServerContext } from "@modelcontextprotocol/server";
2
+ import type { ElicitRequest, ElicitResult, ToolRequestOptions } from "@/types/tool";
3
+ export declare function elicitFromTool(ctx: ServerContext, request: ElicitRequest, options?: ToolRequestOptions): Promise<ElicitResult>;
@@ -1,4 +1,4 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp";
1
+ import { McpServer } from "@modelcontextprotocol/server";
2
2
  import { ZodOptional, ZodType, ZodTypeDef } from "zod/v3";
3
3
  import { PromptFile } from "./server";
4
4
  export type PromptArgsRawShape = {
@@ -1,4 +1,4 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp";
1
+ import { McpServer } from "@modelcontextprotocol/server";
2
2
  import { ResourceFile } from "./server";
3
3
  /** Loads resources and injects them into the server */
4
4
  export declare function addResourcesToServer(server: McpServer, resourcesModules: Map<string, ResourceFile>): McpServer;
@@ -0,0 +1,61 @@
1
+ import type { StandardSchemaWithJSON } from "@modelcontextprotocol/server";
2
+ /**
3
+ * A single field schema from either zod major. zod v3 (>= 3.24) and zod v4
4
+ * both expose `~standard.validate`; zod v4.2+ additionally exposes
5
+ * `~standard.jsonSchema`. xmcp operates on fields structurally so user
6
+ * schemas keep working regardless of which zod instance created them.
7
+ */
8
+ export interface StandardFieldSchema {
9
+ "~standard": {
10
+ version: number;
11
+ vendor: string;
12
+ validate: (value: unknown) => {
13
+ value: unknown;
14
+ issues?: undefined;
15
+ } | {
16
+ issues: ReadonlyArray<{
17
+ message: string;
18
+ path?: ReadonlyArray<unknown>;
19
+ }>;
20
+ } | Promise<{
21
+ value: unknown;
22
+ issues?: undefined;
23
+ } | {
24
+ issues: ReadonlyArray<{
25
+ message: string;
26
+ path?: ReadonlyArray<unknown>;
27
+ }>;
28
+ }>;
29
+ jsonSchema?: {
30
+ input: (options: {
31
+ target: string;
32
+ }) => Record<string, unknown>;
33
+ output: (options: {
34
+ target: string;
35
+ }) => Record<string, unknown>;
36
+ };
37
+ };
38
+ safeParse?: (value: unknown) => {
39
+ success: false;
40
+ } | {
41
+ success: true;
42
+ data: unknown;
43
+ };
44
+ }
45
+ export declare function isStandardFieldSchema(value: unknown): value is StandardFieldSchema;
46
+ export type RawShape = Record<string, StandardFieldSchema>;
47
+ /**
48
+ * Assembles a Standard Schema object from a raw `{ field: zodSchema }` shape,
49
+ * validating and converting per field. This is what lets xmcp keep its
50
+ * `zod ^3 || ^4` peer contract with SDK v2, which registers schemas through
51
+ * the Standard Schema interface instead of zod instances: no `z.object()`
52
+ * composition happens, so fields never cross zod-instance boundaries.
53
+ *
54
+ * The returned schema exposes the raw fields as `shape` so the SDK can find
55
+ * `completable()` fields for `completion/complete`.
56
+ */
57
+ export declare function rawShapeToStandardSchema(shape: RawShape, options?: {
58
+ strict?: boolean;
59
+ }): StandardSchemaWithJSON<Record<string, unknown>, Record<string, unknown>> & {
60
+ shape: RawShape;
61
+ };
@@ -1,5 +1,4 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp";
2
- import { Implementation } from "@modelcontextprotocol/sdk/types";
1
+ import { McpServer, Implementation } from "@modelcontextprotocol/server";
3
2
  import { PromptArgsRawShape } from "./prompts";
4
3
  import { ToolMetadata } from "@/types/tool";
5
4
  import { PromptMetadata } from "@/types/prompt";
@@ -1,4 +1,4 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp";
1
+ import { McpServer } from "@modelcontextprotocol/server";
2
2
  import { ZodRawShape } from "zod/v3";
3
3
  import { ToolFile } from "./server";
4
4
  import { ToolMetadata } from "@/types/tool";
@@ -1,5 +1,4 @@
1
- import { GetPromptResult, ServerRequest, ServerNotification } from "@modelcontextprotocol/sdk/types";
2
- import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol";
1
+ import { GetPromptResult, ServerContext } from "@modelcontextprotocol/server";
3
2
  import { PromptArgsRawShape } from "../prompts";
4
3
  /**
5
4
  * Type for content that users can return from prompt handlers
@@ -10,11 +9,11 @@ export type PromptContent = GetPromptResult["messages"][number]["content"];
10
9
  * The extra parameter is optional for backward compatibility
11
10
  * Users can only return content objects, strings, or numbers - not full message arrays
12
11
  */
13
- export type UserPromptHandler = (args: PromptArgsRawShape, extra?: RequestHandlerExtra<ServerRequest, ServerNotification>) => PromptContent | string | number | Promise<PromptContent | string | number>;
12
+ export type UserPromptHandler = (args: PromptArgsRawShape, extra?: ServerContext) => PromptContent | string | number | Promise<PromptContent | string | number>;
14
13
  /**
15
14
  * Type for the transformed handler that the MCP server expects
16
15
  */
17
- export type McpPromptHandler = (args: PromptArgsRawShape, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult>;
16
+ export type McpPromptHandler = (args: PromptArgsRawShape, extra: ServerContext) => GetPromptResult | Promise<GetPromptResult>;
18
17
  /**
19
18
  * Transforms a user's prompt handler into an MCP-compatible handler.
20
19
  *
@@ -1,14 +1,13 @@
1
- import { ReadResourceResult, ServerRequest, ServerNotification } from "@modelcontextprotocol/sdk/types";
2
- import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol";
1
+ import { ReadResourceResult, ServerContext } from "@modelcontextprotocol/server";
3
2
  import { ZodRawShape } from "zod/v3";
4
3
  /**
5
4
  * Type for the original resource handler that users write
6
5
  */
7
- export type UserResourceHandler = (args: ZodRawShape, extra?: RequestHandlerExtra<ServerRequest, ServerNotification>) => ReadResourceResult | string | Promise<ReadResourceResult | string>;
6
+ export type UserResourceHandler = (args: ZodRawShape, extra?: ServerContext) => ReadResourceResult | string | Promise<ReadResourceResult | string>;
8
7
  /**
9
8
  * Type for the transformed handler that the MCP server expects (direct resources)
10
9
  */
11
- export type McpResourceHandler = (uri: URL, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => ReadResourceResult | Promise<ReadResourceResult>;
10
+ export type McpResourceHandler = (uri: URL, extra: ServerContext) => ReadResourceResult | Promise<ReadResourceResult>;
12
11
  /**
13
12
  * Transforms a user's resource handler into an MCP-compatible handler.
14
13
  *
@@ -1,16 +1,15 @@
1
- import { CallToolResult, ServerRequest, ServerNotification } from "@modelcontextprotocol/sdk/types";
2
- import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol";
1
+ import { CallToolResult, InputRequiredResult, ServerContext } from "@modelcontextprotocol/server";
3
2
  import { ZodRawShape } from "zod/v3";
4
3
  import type { ToolExtraArguments } from "@/types/tool";
5
4
  /**
6
5
  * Type for the original tool handler that users write
7
6
  */
8
- export type UserToolResponse = CallToolResult | string | number | Record<string, unknown>;
7
+ export type UserToolResponse = CallToolResult | InputRequiredResult | string | number | Record<string, unknown>;
9
8
  export type UserToolHandler = (args: ZodRawShape, extra: ToolExtraArguments) => UserToolResponse | Promise<UserToolResponse>;
10
9
  /**
11
10
  * Type for the transformed handler that the MCP server expects
12
11
  */
13
- export type McpToolHandler = (args: ZodRawShape, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult>;
12
+ export type McpToolHandler = (args: ZodRawShape, ctx: ServerContext) => CallToolResult | InputRequiredResult | Promise<CallToolResult | InputRequiredResult>;
14
13
  /**
15
14
  * Transforms a user's tool handler into an MCP-compatible handler.
16
15
  *
@@ -1,5 +1,5 @@
1
1
  import type { RequestHandler, Router } from "express";
2
- import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types";
2
+ import type { AuthInfo } from "@modelcontextprotocol/server";
3
3
  export type RequestHandlerAndRouter = {
4
4
  middleware: RequestHandler;
5
5
  router: Router;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod/v3";
2
2
  import type { ZodType as ZodTypeV4, infer as inferV4 } from "zod";
3
- import type { ElicitResult as McpElicitResult } from "@modelcontextprotocol/sdk/types";
3
+ import type { ElicitResult as McpElicitResult } from "@modelcontextprotocol/server";
4
4
  import { UIMetadata } from "./ui-meta";
5
5
  import type { McpClientInfo } from "./client-info";
6
6
  export interface ToolAnnotations {
@@ -137,6 +137,19 @@ export interface ToolExtraArguments {
137
137
  sendRequest: <U extends CompatibleZodType>(request: any, resultSchema: U, options?: ToolRequestOptions) => Promise<InferCompatibleZodType<U>>;
138
138
  /** Requests user input from the connected client */
139
139
  elicit: (request: ElicitRequest, options?: ToolRequestOptions) => Promise<ElicitResult>;
140
+ /**
141
+ * Multi round-trip input responses carried by a retried request
142
+ * (protocol 2026-07-28). Read with `acceptedContent()` / `inputResponse()`
143
+ * after returning `inputRequired(...)` from a previous round. Values come
144
+ * from the client and are not validated — treat them as untrusted input.
145
+ */
146
+ inputResponses?: Record<string, unknown>;
147
+ /**
148
+ * Reads the multi round-trip request state minted by a previous round
149
+ * (protocol 2026-07-28). Round-trips through the client — verify it with
150
+ * `createRequestStateCodec` when it influences authorization or logic.
151
+ */
152
+ requestState: <T = unknown>() => T | undefined;
140
153
  }
141
154
  export type InferSchema<T extends Record<string, unknown>> = {
142
155
  [K in keyof T]: T[K] extends z.ZodTypeAny ? z.infer<T[K]> : T[K] extends ZodTypeV4<unknown> ? inferV4<T[K]> : never;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xmcp",
3
3
  "description": "The MCP framework",
4
- "version": "0.8.0",
4
+ "version": "1.0.0",
5
5
  "author": {
6
6
  "name": "xmcp",
7
7
  "email": "support@xmcp.dev",
@@ -90,8 +90,10 @@
90
90
  ],
91
91
  "dependencies": {},
92
92
  "devDependencies": {
93
+ "@modelcontextprotocol/client": "^2.0.0",
94
+ "@modelcontextprotocol/node": "^2.0.0",
95
+ "@modelcontextprotocol/server": "^2.0.0",
93
96
  "@nestjs/common": "^11.1.12",
94
- "@modelcontextprotocol/sdk": "^1.26.0",
95
97
  "@rspack/core": "^1.6.7",
96
98
  "@types/async-retry": "^1.4.9",
97
99
  "@types/content-type": "^1.1.9",
@@ -116,9 +118,9 @@
116
118
  "glob": "^11.1.0",
117
119
  "is-docker": "^4.0.0",
118
120
  "is-wsl": "^3.1.0",
121
+ "jose": "^6.1.3",
119
122
  "json5": "^2.2.3",
120
123
  "jsonwebtoken": "^9.0.3",
121
- "jose": "^6.1.3",
122
124
  "memfs": "^4.51.1",
123
125
  "postcss-loader": "^8.2.0",
124
126
  "raw-body": "^3.0.2",
@@ -126,17 +128,22 @@
126
128
  "rxjs": "^7.8.2",
127
129
  "ts-checker-rspack-plugin": "^1.2.1",
128
130
  "tsx": "^4.21.0",
129
- "typescript": "^5.9.3"
131
+ "typescript": "^5.9.3",
132
+ "zod-to-json-schema": "^3.25.0"
130
133
  },
131
134
  "peerDependencies": {
132
- "@modelcontextprotocol/sdk": "^1.26.0",
135
+ "@modelcontextprotocol/client": "^2.0.0",
136
+ "@modelcontextprotocol/server": "^2.0.0",
133
137
  "jose": "^6.1.3",
134
138
  "react": ">=19.0.0",
135
139
  "react-dom": ">=19.0.0",
136
140
  "zod": "^3.25.76 || ^4.0.0"
137
141
  },
138
142
  "peerDependenciesMeta": {
139
- "@modelcontextprotocol/sdk": {
143
+ "@modelcontextprotocol/client": {
144
+ "optional": true
145
+ },
146
+ "@modelcontextprotocol/server": {
140
147
  "optional": true
141
148
  },
142
149
  "jose": {
@@ -155,6 +162,7 @@
155
162
  "analyze": "cross-env GENERATE_STATS=true pnpm build && pnpm tsx scripts/analyze-rspack-stats.ts",
156
163
  "bench": "tsx bench/run.mts",
157
164
  "test:config": "pnpm --dir ../compiler test:config",
158
- "test:adapters": "node --import tsx --test src/runtime/adapters/fastify/__tests__/*.test.ts"
165
+ "test:adapters": "node --import tsx --test src/runtime/adapters/fastify/__tests__/*.test.ts",
166
+ "test:runtime": "node --import tsx --test src/runtime/utils/__tests__/*.test.ts src/runtime/utils/ui/__tests__/*.test.ts"
159
167
  }
160
168
  }