@effect-uai/mcp 0.12.1
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/LICENSE +21 -0
- package/dist/Client.d.mts +55 -0
- package/dist/Client.d.mts.map +1 -0
- package/dist/Client.mjs +85 -0
- package/dist/Client.mjs.map +1 -0
- package/dist/McpError-DWg9BlW5.d.mts +83 -0
- package/dist/McpError-DWg9BlW5.d.mts.map +1 -0
- package/dist/McpError.d.mts +2 -0
- package/dist/McpError.mjs +61 -0
- package/dist/McpError.mjs.map +1 -0
- package/dist/Toolkit.d.mts +20 -0
- package/dist/Toolkit.d.mts.map +1 -0
- package/dist/Toolkit.mjs +70 -0
- package/dist/Toolkit.mjs.map +1 -0
- package/dist/auth-ZDvsxpCo.d.mts +126 -0
- package/dist/auth-ZDvsxpCo.d.mts.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +4 -0
- package/dist/internal/auth.d.mts +2 -0
- package/dist/internal/auth.mjs +25 -0
- package/dist/internal/auth.mjs.map +1 -0
- package/dist/internal/httpTransport.d.mts +17 -0
- package/dist/internal/httpTransport.d.mts.map +1 -0
- package/dist/internal/httpTransport.mjs +88 -0
- package/dist/internal/httpTransport.mjs.map +1 -0
- package/dist/internal/protocol.d.mts +2 -0
- package/dist/internal/protocol.mjs +23 -0
- package/dist/internal/protocol.mjs.map +1 -0
- package/dist/internal/protocols/2025-06-18.d.mts +11 -0
- package/dist/internal/protocols/2025-06-18.d.mts.map +1 -0
- package/dist/internal/protocols/2025-06-18.mjs +70 -0
- package/dist/internal/protocols/2025-06-18.mjs.map +1 -0
- package/dist/internal/protocols/2025-11-25.d.mts +2 -0
- package/dist/internal/protocols/2025-11-25.mjs +2 -0
- package/dist/internal/protocols/2026-07-28.d.mts +16 -0
- package/dist/internal/protocols/2026-07-28.d.mts.map +1 -0
- package/dist/internal/protocols/2026-07-28.mjs +83 -0
- package/dist/internal/protocols/2026-07-28.mjs.map +1 -0
- package/dist/internal/rpc.d.mts +2 -0
- package/dist/internal/rpc.mjs +78 -0
- package/dist/internal/rpc.mjs.map +1 -0
- package/dist/internal/schema.d.mts +2 -0
- package/dist/internal/schema.mjs +168 -0
- package/dist/internal/schema.mjs.map +1 -0
- package/dist/internal/stdioTransport.d.mts +15 -0
- package/dist/internal/stdioTransport.d.mts.map +1 -0
- package/dist/internal/stdioTransport.mjs +46 -0
- package/dist/internal/stdioTransport.mjs.map +1 -0
- package/dist/protocol-kjC3iAMb.d.mts +35 -0
- package/dist/protocol-kjC3iAMb.d.mts.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/rpc-Bq95Lio9.d.mts +34 -0
- package/dist/rpc-Bq95Lio9.d.mts.map +1 -0
- package/dist/schema-D2oUNuo5.d.mts +245 -0
- package/dist/schema-D2oUNuo5.d.mts.map +1 -0
- package/package.json +70 -0
- package/src/Client.ts +180 -0
- package/src/McpError.ts +93 -0
- package/src/Toolkit.ts +109 -0
- package/src/index.ts +3 -0
- package/src/internal/auth.ts +48 -0
- package/src/internal/httpTransport.ts +171 -0
- package/src/internal/protocol.ts +67 -0
- package/src/internal/protocols/2025-06-18.ts +110 -0
- package/src/internal/protocols/2025-11-25.ts +8 -0
- package/src/internal/protocols/2026-07-28.test.ts +131 -0
- package/src/internal/protocols/2026-07-28.ts +152 -0
- package/src/internal/rpc.test.ts +156 -0
- package/src/internal/rpc.ts +189 -0
- package/src/internal/schema.ts +223 -0
- package/src/internal/stdioTransport.ts +63 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
|
+
//#region src/internal/schema.ts
|
|
3
|
+
/**
|
|
4
|
+
* Self-contained MCP wire schemas, both protocol eras. The single source of
|
|
5
|
+
* truth for the wire format; nothing MCP-shaped is imported from effect.
|
|
6
|
+
* Decodes are deliberately loose (unknown extra fields pass through) so
|
|
7
|
+
* spec-compliant servers with richer payloads never fail the client.
|
|
8
|
+
*/
|
|
9
|
+
/** Every protocol version this client can speak. */
|
|
10
|
+
const ProtocolVersion = Schema.Literals([
|
|
11
|
+
"2026-07-28",
|
|
12
|
+
"2025-11-25",
|
|
13
|
+
"2025-06-18"
|
|
14
|
+
]);
|
|
15
|
+
/** Newest version we speak: the stateless protocol, and what the probe tries first. */
|
|
16
|
+
const LATEST_VERSION = "2026-07-28";
|
|
17
|
+
/** The legacy handshake era we negotiate; 2025-11-25 is wire-compatible. */
|
|
18
|
+
const LEGACY_VERSION = "2025-06-18";
|
|
19
|
+
const isProtocolVersion = Schema.is(ProtocolVersion);
|
|
20
|
+
/** Narrow a server-offered version string to one we support. */
|
|
21
|
+
const asProtocolVersion = (raw) => isProtocolVersion(raw) ? Option.some(raw) : Option.none();
|
|
22
|
+
/**
|
|
23
|
+
* The JSON-RPC methods this client issues. Not to be confused with an HTTP
|
|
24
|
+
* method: on Streamable HTTP every one of these travels as a POST, and the
|
|
25
|
+
* name is mirrored into the `Mcp-Method` header.
|
|
26
|
+
*/
|
|
27
|
+
const McpMethod = Schema.Literals([
|
|
28
|
+
"server/discover",
|
|
29
|
+
"initialize",
|
|
30
|
+
"tools/list",
|
|
31
|
+
"tools/call"
|
|
32
|
+
]);
|
|
33
|
+
/** Modern `_meta` keys (SEP-2575): every request self-describes its protocol. */
|
|
34
|
+
const META_PROTOCOL_VERSION = "io.modelcontextprotocol/protocolVersion";
|
|
35
|
+
const META_CLIENT_INFO = "io.modelcontextprotocol/clientInfo";
|
|
36
|
+
const META_CLIENT_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
|
|
37
|
+
/** Servers identify themselves in each *result's* `_meta`, not at the top level. */
|
|
38
|
+
const META_SERVER_INFO = "io.modelcontextprotocol/serverInfo";
|
|
39
|
+
const CLIENT_INFO = {
|
|
40
|
+
name: "@effect-uai/mcp",
|
|
41
|
+
version: "0.12.1"
|
|
42
|
+
};
|
|
43
|
+
/** Modern JSON-RPC error codes. */
|
|
44
|
+
const CODE_HEADER_MISMATCH = -32020;
|
|
45
|
+
const CODE_MISSING_CLIENT_CAPABILITY = -32021;
|
|
46
|
+
const CODE_UNSUPPORTED_PROTOCOL_VERSION = -32022;
|
|
47
|
+
const CODE_METHOD_NOT_FOUND = -32601;
|
|
48
|
+
/**
|
|
49
|
+
* A reply carrying one of these proves the server speaks a modern version, so
|
|
50
|
+
* era detection corrects and retries instead of falling back to `initialize`.
|
|
51
|
+
*/
|
|
52
|
+
const MODERN_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
53
|
+
CODE_HEADER_MISMATCH,
|
|
54
|
+
CODE_MISSING_CLIENT_CAPABILITY,
|
|
55
|
+
CODE_UNSUPPORTED_PROTOCOL_VERSION
|
|
56
|
+
]);
|
|
57
|
+
const JsonRpcId = Schema.Union([Schema.Number, Schema.String]);
|
|
58
|
+
const JsonRpcErrorObject = Schema.Struct({
|
|
59
|
+
code: Schema.Number,
|
|
60
|
+
message: Schema.optional(Schema.String),
|
|
61
|
+
data: Schema.optional(Schema.Unknown)
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Any inbound frame: a reply (`id` + `result`/`error`), a server-initiated
|
|
65
|
+
* request (`method` + `id`), or a notification (`method`, no `id`). One
|
|
66
|
+
* loose struct so the reader can classify without a union decode.
|
|
67
|
+
*/
|
|
68
|
+
const InboundMessage = Schema.Struct({
|
|
69
|
+
id: Schema.optional(Schema.NullOr(JsonRpcId)),
|
|
70
|
+
result: Schema.optional(Schema.Unknown),
|
|
71
|
+
error: Schema.optional(JsonRpcErrorObject),
|
|
72
|
+
method: Schema.optional(Schema.String),
|
|
73
|
+
params: Schema.optional(Schema.Unknown)
|
|
74
|
+
});
|
|
75
|
+
const decodeInboundMessage = Schema.decodeUnknownEffect(InboundMessage);
|
|
76
|
+
const requestFrame = (id, method, params) => JSON.stringify({
|
|
77
|
+
jsonrpc: "2.0",
|
|
78
|
+
id,
|
|
79
|
+
method,
|
|
80
|
+
params: params ?? {}
|
|
81
|
+
});
|
|
82
|
+
const notificationFrame = (method, params) => JSON.stringify(params === void 0 ? {
|
|
83
|
+
jsonrpc: "2.0",
|
|
84
|
+
method
|
|
85
|
+
} : {
|
|
86
|
+
jsonrpc: "2.0",
|
|
87
|
+
method,
|
|
88
|
+
params
|
|
89
|
+
});
|
|
90
|
+
const resultFrame = (id, result) => JSON.stringify({
|
|
91
|
+
jsonrpc: "2.0",
|
|
92
|
+
id,
|
|
93
|
+
result
|
|
94
|
+
});
|
|
95
|
+
const errorFrame = (id, code, message) => JSON.stringify({
|
|
96
|
+
jsonrpc: "2.0",
|
|
97
|
+
id,
|
|
98
|
+
error: {
|
|
99
|
+
code,
|
|
100
|
+
message
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const ToolInfo = Schema.Struct({
|
|
104
|
+
name: Schema.String,
|
|
105
|
+
description: Schema.optional(Schema.String),
|
|
106
|
+
inputSchema: Schema.Record(Schema.String, Schema.Unknown)
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* Modern list results may carry cache metadata (`ttlMs` / `cacheScope`);
|
|
110
|
+
* v1 reads but does not act on them (input for a later refresh feature).
|
|
111
|
+
*/
|
|
112
|
+
const ListToolsResult = Schema.Struct({
|
|
113
|
+
tools: Schema.Array(ToolInfo),
|
|
114
|
+
nextCursor: Schema.optional(Schema.String),
|
|
115
|
+
ttlMs: Schema.optional(Schema.Number),
|
|
116
|
+
cacheScope: Schema.optional(Schema.String)
|
|
117
|
+
});
|
|
118
|
+
const decodeListToolsResult = Schema.decodeUnknownEffect(ListToolsResult);
|
|
119
|
+
const TextContent = Schema.Struct({
|
|
120
|
+
type: Schema.Literal("text"),
|
|
121
|
+
text: Schema.String
|
|
122
|
+
});
|
|
123
|
+
/** Non-text blocks (image / audio / resource) are placeholder-summarized in v1. */
|
|
124
|
+
const OtherContent = Schema.Struct({ type: Schema.String });
|
|
125
|
+
const ContentBlock = Schema.Union([TextContent, OtherContent]);
|
|
126
|
+
const isTextContent = Schema.is(TextContent);
|
|
127
|
+
const CallToolResult = Schema.Struct({
|
|
128
|
+
content: Schema.optionalKey(Schema.Array(ContentBlock)),
|
|
129
|
+
isError: Schema.optional(Schema.Boolean),
|
|
130
|
+
structuredContent: Schema.optional(Schema.Unknown),
|
|
131
|
+
resultType: Schema.optional(Schema.String)
|
|
132
|
+
});
|
|
133
|
+
const decodeCallToolResult = Schema.decodeUnknownEffect(CallToolResult);
|
|
134
|
+
const ServerInfo = Schema.Struct({
|
|
135
|
+
name: Schema.String,
|
|
136
|
+
version: Schema.optional(Schema.String),
|
|
137
|
+
title: Schema.optional(Schema.String)
|
|
138
|
+
});
|
|
139
|
+
/** The subset of a result's `_meta` we read. */
|
|
140
|
+
const ResultMeta = Schema.Struct({ [META_SERVER_INFO]: Schema.optional(ServerInfo) });
|
|
141
|
+
const DiscoverResult = Schema.Struct({
|
|
142
|
+
supportedVersions: Schema.Array(Schema.String),
|
|
143
|
+
capabilities: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
144
|
+
_meta: Schema.optional(ResultMeta),
|
|
145
|
+
serverInfo: Schema.optional(ServerInfo),
|
|
146
|
+
instructions: Schema.optional(Schema.String)
|
|
147
|
+
});
|
|
148
|
+
const decodeDiscoverResult = Schema.decodeUnknownEffect(DiscoverResult);
|
|
149
|
+
/**
|
|
150
|
+
* `data` of a `-32022` UnsupportedProtocolVersionError reply. Decoded, not
|
|
151
|
+
* hand-parsed: the shape is server-controlled and may carry extra fields.
|
|
152
|
+
*/
|
|
153
|
+
const UnsupportedVersionData = Schema.Struct({
|
|
154
|
+
supported: Schema.optional(Schema.Array(Schema.String)),
|
|
155
|
+
requested: Schema.optional(Schema.NullOr(Schema.String))
|
|
156
|
+
});
|
|
157
|
+
const decodeUnsupportedVersionData = Schema.decodeUnknownOption(UnsupportedVersionData);
|
|
158
|
+
const InitializeResult = Schema.Struct({
|
|
159
|
+
protocolVersion: Schema.String,
|
|
160
|
+
capabilities: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
161
|
+
serverInfo: Schema.optional(ServerInfo),
|
|
162
|
+
instructions: Schema.optional(Schema.String)
|
|
163
|
+
});
|
|
164
|
+
const decodeInitializeResult = Schema.decodeUnknownEffect(InitializeResult);
|
|
165
|
+
//#endregion
|
|
166
|
+
export { CLIENT_INFO, CODE_HEADER_MISMATCH, CODE_METHOD_NOT_FOUND, CODE_MISSING_CLIENT_CAPABILITY, CODE_UNSUPPORTED_PROTOCOL_VERSION, CallToolResult, ContentBlock, DiscoverResult, InboundMessage, InitializeResult, JsonRpcErrorObject, JsonRpcId, LATEST_VERSION, LEGACY_VERSION, ListToolsResult, META_CLIENT_CAPABILITIES, META_CLIENT_INFO, META_PROTOCOL_VERSION, META_SERVER_INFO, MODERN_ERROR_CODES, McpMethod, OtherContent, ProtocolVersion, ResultMeta, ServerInfo, TextContent, ToolInfo, UnsupportedVersionData, asProtocolVersion, decodeCallToolResult, decodeDiscoverResult, decodeInboundMessage, decodeInitializeResult, decodeListToolsResult, decodeUnsupportedVersionData, errorFrame, isTextContent, notificationFrame, requestFrame, resultFrame };
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.mjs","names":[],"sources":["../../src/internal/schema.ts"],"sourcesContent":["/**\n * Self-contained MCP wire schemas, both protocol eras. The single source of\n * truth for the wire format; nothing MCP-shaped is imported from effect.\n * Decodes are deliberately loose (unknown extra fields pass through) so\n * spec-compliant servers with richer payloads never fail the client.\n */\nimport { Option, Schema } from \"effect\"\n\n// ---------------------------------------------------------------------------\n// Protocol versions\n// ---------------------------------------------------------------------------\n\n/** Every protocol version this client can speak. */\nexport const ProtocolVersion = Schema.Literals([\"2026-07-28\", \"2025-11-25\", \"2025-06-18\"])\nexport type ProtocolVersion = typeof ProtocolVersion.Type\n\n/** Newest version we speak: the stateless protocol, and what the probe tries first. */\nexport const LATEST_VERSION = \"2026-07-28\" satisfies ProtocolVersion\n\n/** The legacy handshake era we negotiate; 2025-11-25 is wire-compatible. */\nexport const LEGACY_VERSION = \"2025-06-18\" satisfies ProtocolVersion\n\nconst isProtocolVersion = Schema.is(ProtocolVersion)\n\n/** Narrow a server-offered version string to one we support. */\nexport const asProtocolVersion = (raw: string): Option.Option<ProtocolVersion> =>\n isProtocolVersion(raw) ? Option.some(raw) : Option.none()\n\n/**\n * The JSON-RPC methods this client issues. Not to be confused with an HTTP\n * method: on Streamable HTTP every one of these travels as a POST, and the\n * name is mirrored into the `Mcp-Method` header.\n */\nexport const McpMethod = Schema.Literals([\n \"server/discover\",\n \"initialize\",\n \"tools/list\",\n \"tools/call\",\n])\nexport type McpMethod = typeof McpMethod.Type\n\n/** Modern `_meta` keys (SEP-2575): every request self-describes its protocol. */\nexport const META_PROTOCOL_VERSION = \"io.modelcontextprotocol/protocolVersion\"\nexport const META_CLIENT_INFO = \"io.modelcontextprotocol/clientInfo\"\nexport const META_CLIENT_CAPABILITIES = \"io.modelcontextprotocol/clientCapabilities\"\n/** Servers identify themselves in each *result's* `_meta`, not at the top level. */\nexport const META_SERVER_INFO = \"io.modelcontextprotocol/serverInfo\"\n\nexport const CLIENT_INFO = { name: \"@effect-uai/mcp\", version: \"0.12.1\" }\n\n/** Modern JSON-RPC error codes. */\nexport const CODE_HEADER_MISMATCH = -32020\nexport const CODE_MISSING_CLIENT_CAPABILITY = -32021\nexport const CODE_UNSUPPORTED_PROTOCOL_VERSION = -32022\nexport const CODE_METHOD_NOT_FOUND = -32601\n\n/**\n * A reply carrying one of these proves the server speaks a modern version, so\n * era detection corrects and retries instead of falling back to `initialize`.\n */\nexport const MODERN_ERROR_CODES: ReadonlySet<number> = new Set([\n CODE_HEADER_MISMATCH,\n CODE_MISSING_CLIENT_CAPABILITY,\n CODE_UNSUPPORTED_PROTOCOL_VERSION,\n])\n\n// ---------------------------------------------------------------------------\n// JSON-RPC envelope\n// ---------------------------------------------------------------------------\n\nexport const JsonRpcId = Schema.Union([Schema.Number, Schema.String])\nexport type JsonRpcId = typeof JsonRpcId.Type\n\nexport const JsonRpcErrorObject = Schema.Struct({\n code: Schema.Number,\n message: Schema.optional(Schema.String),\n data: Schema.optional(Schema.Unknown),\n})\nexport type JsonRpcErrorObject = typeof JsonRpcErrorObject.Type\n\n/**\n * Any inbound frame: a reply (`id` + `result`/`error`), a server-initiated\n * request (`method` + `id`), or a notification (`method`, no `id`). One\n * loose struct so the reader can classify without a union decode.\n */\nexport const InboundMessage = Schema.Struct({\n // Null is legal and meaningful: JSON-RPC uses it for errors raised before a\n // request could be attributed. Rejecting it would drop the frame entirely.\n id: Schema.optional(Schema.NullOr(JsonRpcId)),\n result: Schema.optional(Schema.Unknown),\n error: Schema.optional(JsonRpcErrorObject),\n method: Schema.optional(Schema.String),\n params: Schema.optional(Schema.Unknown),\n})\nexport type InboundMessage = typeof InboundMessage.Type\n\nexport const decodeInboundMessage = Schema.decodeUnknownEffect(InboundMessage)\n\n// --- outbound frame builders -----------------------------------------------\n\nexport const requestFrame = (id: JsonRpcId, method: string, params: unknown): string =>\n JSON.stringify({ jsonrpc: \"2.0\", id, method, params: params ?? {} })\n\nexport const notificationFrame = (method: string, params?: unknown): string =>\n JSON.stringify(\n params === undefined ? { jsonrpc: \"2.0\", method } : { jsonrpc: \"2.0\", method, params },\n )\n\nexport const resultFrame = (id: JsonRpcId, result: unknown): string =>\n JSON.stringify({ jsonrpc: \"2.0\", id, result })\n\nexport const errorFrame = (id: JsonRpcId, code: number, message: string): string =>\n JSON.stringify({ jsonrpc: \"2.0\", id, error: { code, message } })\n\n// ---------------------------------------------------------------------------\n// Shared: tools\n// ---------------------------------------------------------------------------\n\nexport const ToolInfo = Schema.Struct({\n name: Schema.String,\n description: Schema.optional(Schema.String),\n inputSchema: Schema.Record(Schema.String, Schema.Unknown),\n})\nexport type ToolInfo = typeof ToolInfo.Type\n\n/**\n * Modern list results may carry cache metadata (`ttlMs` / `cacheScope`);\n * v1 reads but does not act on them (input for a later refresh feature).\n */\nexport const ListToolsResult = Schema.Struct({\n tools: Schema.Array(ToolInfo),\n nextCursor: Schema.optional(Schema.String),\n ttlMs: Schema.optional(Schema.Number),\n cacheScope: Schema.optional(Schema.String),\n})\nexport type ListToolsResult = typeof ListToolsResult.Type\n\nexport const decodeListToolsResult = Schema.decodeUnknownEffect(ListToolsResult)\n\n// --- content blocks ---------------------------------------------------------\n\nexport const TextContent = Schema.Struct({\n type: Schema.Literal(\"text\"),\n text: Schema.String,\n})\nexport type TextContent = typeof TextContent.Type\n\n/** Non-text blocks (image / audio / resource) are placeholder-summarized in v1. */\nexport const OtherContent = Schema.Struct({\n type: Schema.String,\n})\n\nexport const ContentBlock = Schema.Union([TextContent, OtherContent])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const isTextContent = Schema.is(TextContent)\n\nexport const CallToolResult = Schema.Struct({\n content: Schema.optionalKey(Schema.Array(ContentBlock)),\n isError: Schema.optional(Schema.Boolean),\n structuredContent: Schema.optional(Schema.Unknown),\n // Required on modern results; absent on legacy ones.\n resultType: Schema.optional(Schema.String),\n})\nexport type CallToolResult = typeof CallToolResult.Type\n\nexport const decodeCallToolResult = Schema.decodeUnknownEffect(CallToolResult)\n\n// ---------------------------------------------------------------------------\n// Modern era (2026-07-28)\n// ---------------------------------------------------------------------------\n\nexport const ServerInfo = Schema.Struct({\n name: Schema.String,\n version: Schema.optional(Schema.String),\n title: Schema.optional(Schema.String),\n})\nexport type ServerInfo = typeof ServerInfo.Type\n\n/** The subset of a result's `_meta` we read. */\nexport const ResultMeta = Schema.Struct({\n [META_SERVER_INFO]: Schema.optional(ServerInfo),\n})\nexport type ResultMeta = typeof ResultMeta.Type\n\nexport const DiscoverResult = Schema.Struct({\n supportedVersions: Schema.Array(Schema.String),\n capabilities: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n // Spec-conformant servers put identity in `_meta`; a top-level `serverInfo`\n // is accepted too, since that is where the legacy handshake carries it.\n _meta: Schema.optional(ResultMeta),\n serverInfo: Schema.optional(ServerInfo),\n instructions: Schema.optional(Schema.String),\n})\nexport type DiscoverResult = typeof DiscoverResult.Type\n\nexport const decodeDiscoverResult = Schema.decodeUnknownEffect(DiscoverResult)\n\n/**\n * `data` of a `-32022` UnsupportedProtocolVersionError reply. Decoded, not\n * hand-parsed: the shape is server-controlled and may carry extra fields.\n */\nexport const UnsupportedVersionData = Schema.Struct({\n supported: Schema.optional(Schema.Array(Schema.String)),\n requested: Schema.optional(Schema.NullOr(Schema.String)),\n})\nexport type UnsupportedVersionData = typeof UnsupportedVersionData.Type\n\nexport const decodeUnsupportedVersionData = Schema.decodeUnknownOption(UnsupportedVersionData)\n\n// ---------------------------------------------------------------------------\n// Legacy era (2025-06-18 / 2025-11-25)\n// ---------------------------------------------------------------------------\n\nexport const InitializeResult = Schema.Struct({\n protocolVersion: Schema.String,\n capabilities: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n serverInfo: Schema.optional(ServerInfo),\n instructions: Schema.optional(Schema.String),\n})\nexport type InitializeResult = typeof InitializeResult.Type\n\nexport const decodeInitializeResult = Schema.decodeUnknownEffect(InitializeResult)\n"],"mappings":";;;;;;;;;AAaA,MAAa,kBAAkB,OAAO,SAAS;CAAC;CAAc;CAAc;AAAY,CAAC;;AAIzF,MAAa,iBAAiB;;AAG9B,MAAa,iBAAiB;AAE9B,MAAM,oBAAoB,OAAO,GAAG,eAAe;;AAGnD,MAAa,qBAAqB,QAChC,kBAAkB,GAAG,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK;;;;;;AAO1D,MAAa,YAAY,OAAO,SAAS;CACvC;CACA;CACA;CACA;AACF,CAAC;;AAID,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAChC,MAAa,2BAA2B;;AAExC,MAAa,mBAAmB;AAEhC,MAAa,cAAc;CAAE,MAAM;CAAmB,SAAS;AAAS;;AAGxE,MAAa,uBAAuB;AACpC,MAAa,iCAAiC;AAC9C,MAAa,oCAAoC;AACjD,MAAa,wBAAwB;;;;;AAMrC,MAAa,qCAA0C,IAAI,IAAI;CAC7D;CACA;CACA;AACF,CAAC;AAMD,MAAa,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,MAAM,CAAC;AAGpE,MAAa,qBAAqB,OAAO,OAAO;CAC9C,MAAM,OAAO;CACb,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,MAAM,OAAO,SAAS,OAAO,OAAO;AACtC,CAAC;;;;;;AAQD,MAAa,iBAAiB,OAAO,OAAO;CAG1C,IAAI,OAAO,SAAS,OAAO,OAAO,SAAS,CAAC;CAC5C,QAAQ,OAAO,SAAS,OAAO,OAAO;CACtC,OAAO,OAAO,SAAS,kBAAkB;CACzC,QAAQ,OAAO,SAAS,OAAO,MAAM;CACrC,QAAQ,OAAO,SAAS,OAAO,OAAO;AACxC,CAAC;AAGD,MAAa,uBAAuB,OAAO,oBAAoB,cAAc;AAI7E,MAAa,gBAAgB,IAAe,QAAgB,WAC1D,KAAK,UAAU;CAAE,SAAS;CAAO;CAAI;CAAQ,QAAQ,UAAU,CAAC;AAAE,CAAC;AAErE,MAAa,qBAAqB,QAAgB,WAChD,KAAK,UACH,WAAW,KAAA,IAAY;CAAE,SAAS;CAAO;AAAO,IAAI;CAAE,SAAS;CAAO;CAAQ;AAAO,CACvF;AAEF,MAAa,eAAe,IAAe,WACzC,KAAK,UAAU;CAAE,SAAS;CAAO;CAAI;AAAO,CAAC;AAE/C,MAAa,cAAc,IAAe,MAAc,YACtD,KAAK,UAAU;CAAE,SAAS;CAAO;CAAI,OAAO;EAAE;EAAM;CAAQ;AAAE,CAAC;AAMjE,MAAa,WAAW,OAAO,OAAO;CACpC,MAAM,OAAO;CACb,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,aAAa,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;AAC1D,CAAC;;;;;AAOD,MAAa,kBAAkB,OAAO,OAAO;CAC3C,OAAO,OAAO,MAAM,QAAQ;CAC5B,YAAY,OAAO,SAAS,OAAO,MAAM;CACzC,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO,SAAS,OAAO,MAAM;AAC3C,CAAC;AAGD,MAAa,wBAAwB,OAAO,oBAAoB,eAAe;AAI/E,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,MAAM;CAC3B,MAAM,OAAO;AACf,CAAC;;AAID,MAAa,eAAe,OAAO,OAAO,EACxC,MAAM,OAAO,OACf,CAAC;AAED,MAAa,eAAe,OAAO,MAAM,CAAC,aAAa,YAAY,CAAC;AAGpE,MAAa,gBAAgB,OAAO,GAAG,WAAW;AAElD,MAAa,iBAAiB,OAAO,OAAO;CAC1C,SAAS,OAAO,YAAY,OAAO,MAAM,YAAY,CAAC;CACtD,SAAS,OAAO,SAAS,OAAO,OAAO;CACvC,mBAAmB,OAAO,SAAS,OAAO,OAAO;CAEjD,YAAY,OAAO,SAAS,OAAO,MAAM;AAC3C,CAAC;AAGD,MAAa,uBAAuB,OAAO,oBAAoB,cAAc;AAM7E,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO;CACb,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,OAAO,OAAO,SAAS,OAAO,MAAM;AACtC,CAAC;;AAID,MAAa,aAAa,OAAO,OAAO,GACrC,mBAAmB,OAAO,SAAS,UAAU,EAChD,CAAC;AAGD,MAAa,iBAAiB,OAAO,OAAO;CAC1C,mBAAmB,OAAO,MAAM,OAAO,MAAM;CAC7C,cAAc,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAAC;CAG1E,OAAO,OAAO,SAAS,UAAU;CACjC,YAAY,OAAO,SAAS,UAAU;CACtC,cAAc,OAAO,SAAS,OAAO,MAAM;AAC7C,CAAC;AAGD,MAAa,uBAAuB,OAAO,oBAAoB,cAAc;;;;;AAM7E,MAAa,yBAAyB,OAAO,OAAO;CAClD,WAAW,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;CACtD,WAAW,OAAO,SAAS,OAAO,OAAO,OAAO,MAAM,CAAC;AACzD,CAAC;AAGD,MAAa,+BAA+B,OAAO,oBAAoB,sBAAsB;AAM7F,MAAa,mBAAmB,OAAO,OAAO;CAC5C,iBAAiB,OAAO;CACxB,cAAc,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAAC;CAC1E,YAAY,OAAO,SAAS,UAAU;CACtC,cAAc,OAAO,SAAS,OAAO,MAAM;AAC7C,CAAC;AAGD,MAAa,yBAAyB,OAAO,oBAAoB,gBAAgB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { i as McpError } from "../McpError-DWg9BlW5.mjs";
|
|
2
|
+
import { i as Transport } from "../rpc-Bq95Lio9.mjs";
|
|
3
|
+
import { Effect, Scope } from "effect";
|
|
4
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
5
|
+
//#region src/internal/stdioTransport.d.ts
|
|
6
|
+
type StdioConfig = {
|
|
7
|
+
readonly command: string;
|
|
8
|
+
readonly args?: ReadonlyArray<string>;
|
|
9
|
+
readonly env?: Record<string, string>;
|
|
10
|
+
readonly cwd?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const make: (config: StdioConfig) => Effect.Effect<Transport, McpError, Scope.Scope | ChildProcessSpawner.ChildProcessSpawner>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { StdioConfig, make };
|
|
15
|
+
//# sourceMappingURL=stdioTransport.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdioTransport.d.mts","names":[],"sources":["../../src/internal/stdioTransport.ts"],"mappings":";;;;;KAWY;WACD;WACA,OAAO;WACP,MAAM;WACN;;cAKE,OAAI,QACP,gBACP,OAAO,OAAO,WAAW,UAAU,MAAM,QAAQ,oBAAoB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { McpConnectFailed, McpTransportClosed } from "../McpError.mjs";
|
|
2
|
+
import { Effect, Queue, Stream } from "effect";
|
|
3
|
+
import * as JSONL from "@effect-uai/core/JSONL";
|
|
4
|
+
import { ChildProcess } from "effect/unstable/process";
|
|
5
|
+
//#region src/internal/stdioTransport.ts
|
|
6
|
+
/**
|
|
7
|
+
* stdio `Transport`: spawn the server, frame stdout as JSONL (one JSON message
|
|
8
|
+
* per line). Scoped, so the child is killed on scope close. Era-blind; the
|
|
9
|
+
* `meta.headers` a caller passes are HTTP-only and ignored here.
|
|
10
|
+
*/
|
|
11
|
+
const encoder = new TextEncoder();
|
|
12
|
+
const make = (config) => Effect.gen(function* () {
|
|
13
|
+
const outbound = yield* Queue.make();
|
|
14
|
+
const stdin = Stream.fromQueue(outbound);
|
|
15
|
+
const handle = yield* ChildProcess.make(config.command, [...config.args ?? []], {
|
|
16
|
+
...config.cwd !== void 0 ? { cwd: config.cwd } : {},
|
|
17
|
+
...config.env !== void 0 ? { env: config.env } : {},
|
|
18
|
+
stdin: {
|
|
19
|
+
stream: stdin,
|
|
20
|
+
endOnDone: true
|
|
21
|
+
},
|
|
22
|
+
stdout: "pipe",
|
|
23
|
+
stderr: "pipe",
|
|
24
|
+
killSignal: "SIGTERM",
|
|
25
|
+
forceKillAfter: "2 seconds"
|
|
26
|
+
}).pipe(Effect.mapError((cause) => new McpConnectFailed({
|
|
27
|
+
reason: `could not spawn ${config.command}`,
|
|
28
|
+
raw: cause
|
|
29
|
+
})));
|
|
30
|
+
yield* Effect.addFinalizer(() => Queue.end(outbound));
|
|
31
|
+
const send = (frame) => Queue.offer(outbound, encoder.encode(`${frame}\n`)).pipe(Effect.mapError((cause) => new McpTransportClosed({
|
|
32
|
+
reason: "server stdin closed",
|
|
33
|
+
raw: cause
|
|
34
|
+
})), Effect.asVoid);
|
|
35
|
+
return {
|
|
36
|
+
send,
|
|
37
|
+
messages: handle.stdout.pipe(JSONL.fromBytes, Stream.mapError((cause) => new McpTransportClosed({
|
|
38
|
+
reason: "server stdout closed",
|
|
39
|
+
raw: cause
|
|
40
|
+
})))
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { make };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=stdioTransport.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdioTransport.mjs","names":[],"sources":["../../src/internal/stdioTransport.ts"],"sourcesContent":["/**\n * stdio `Transport`: spawn the server, frame stdout as JSONL (one JSON message\n * per line). Scoped, so the child is killed on scope close. Era-blind; the\n * `meta.headers` a caller passes are HTTP-only and ignored here.\n */\nimport { Cause, Effect, Queue, type Scope, Stream } from \"effect\"\nimport { ChildProcess, ChildProcessSpawner } from \"effect/unstable/process\"\nimport * as JSONL from \"@effect-uai/core/JSONL\"\nimport { McpConnectFailed, type McpError, McpTransportClosed } from \"../McpError.js\"\nimport type { Transport } from \"./rpc.js\"\n\nexport type StdioConfig = {\n readonly command: string\n readonly args?: ReadonlyArray<string>\n readonly env?: Record<string, string>\n readonly cwd?: string\n}\n\nconst encoder = new TextEncoder()\n\nexport const make = (\n config: StdioConfig,\n): Effect.Effect<Transport, McpError, Scope.Scope | ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function* () {\n // Outbound frames go through a queue rendered as the child's stdin stream;\n // `Queue.end` on scope close lets the child see a clean EOF.\n const outbound = yield* Queue.make<Uint8Array, Cause.Done>()\n const stdin = Stream.fromQueue(outbound)\n\n const handle = yield* ChildProcess.make(config.command, [...(config.args ?? [])], {\n ...(config.cwd !== undefined ? { cwd: config.cwd } : {}),\n ...(config.env !== undefined ? { env: config.env } : {}),\n stdin: { stream: stdin, endOnDone: true },\n stdout: \"pipe\",\n stderr: \"pipe\",\n killSignal: \"SIGTERM\",\n forceKillAfter: \"2 seconds\",\n }).pipe(\n Effect.mapError(\n (cause) =>\n new McpConnectFailed({ reason: `could not spawn ${config.command}`, raw: cause }),\n ),\n )\n yield* Effect.addFinalizer(() => Queue.end(outbound))\n\n const send = (frame: string): Effect.Effect<void, McpError> =>\n Queue.offer(outbound, encoder.encode(`${frame}\\n`)).pipe(\n Effect.mapError(\n (cause) =>\n new McpTransportClosed({ reason: \"server stdin closed\", raw: cause }) as McpError,\n ),\n Effect.asVoid,\n )\n\n const messages = handle.stdout.pipe(\n JSONL.fromBytes,\n Stream.mapError(\n (cause) => new McpTransportClosed({ reason: \"server stdout closed\", raw: cause }),\n ),\n )\n\n return { send, messages } satisfies Transport\n })\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,UAAU,IAAI,YAAY;AAEhC,MAAa,QACX,WAEA,OAAO,IAAI,aAAa;CAGtB,MAAM,WAAW,OAAO,MAAM,KAA6B;CAC3D,MAAM,QAAQ,OAAO,UAAU,QAAQ;CAEvC,MAAM,SAAS,OAAO,aAAa,KAAK,OAAO,SAAS,CAAC,GAAI,OAAO,QAAQ,CAAC,CAAE,GAAG;EAChF,GAAI,OAAO,QAAQ,KAAA,IAAY,EAAE,KAAK,OAAO,IAAI,IAAI,CAAC;EACtD,GAAI,OAAO,QAAQ,KAAA,IAAY,EAAE,KAAK,OAAO,IAAI,IAAI,CAAC;EACtD,OAAO;GAAE,QAAQ;GAAO,WAAW;EAAK;EACxC,QAAQ;EACR,QAAQ;EACR,YAAY;EACZ,gBAAgB;CAClB,CAAC,CAAC,CAAC,KACD,OAAO,UACJ,UACC,IAAI,iBAAiB;EAAE,QAAQ,mBAAmB,OAAO;EAAW,KAAK;CAAM,CAAC,CACpF,CACF;CACA,OAAO,OAAO,mBAAmB,MAAM,IAAI,QAAQ,CAAC;CAEpD,MAAM,QAAQ,UACZ,MAAM,MAAM,UAAU,QAAQ,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,KAClD,OAAO,UACJ,UACC,IAAI,mBAAmB;EAAE,QAAQ;EAAuB,KAAK;CAAM,CAAC,CACxE,GACA,OAAO,MACT;CASF,OAAO;EAAE;EAAM,UAPE,OAAO,OAAO,KAC7B,MAAM,WACN,OAAO,UACJ,UAAU,IAAI,mBAAmB;GAAE,QAAQ;GAAwB,KAAK;EAAM,CAAC,CAClF,CAGoB;CAAE;AAC1B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { i as McpError } from "./McpError-DWg9BlW5.mjs";
|
|
2
|
+
import { C as ProtocolVersion, T as ServerInfo, x as McpMethod } from "./schema-D2oUNuo5.mjs";
|
|
3
|
+
import { n as McpConnection, r as SendMeta, t as Inbound } from "./rpc-Bq95Lio9.mjs";
|
|
4
|
+
import { Effect, Option, Scope } from "effect";
|
|
5
|
+
//#region src/internal/protocol.d.ts
|
|
6
|
+
type Protocol = {
|
|
7
|
+
readonly version: ProtocolVersion;
|
|
8
|
+
readonly serverInfo: ServerInfo;
|
|
9
|
+
/** Wrap outgoing params: modern adds the `_meta` envelope, legacy passes through. */
|
|
10
|
+
readonly envelope: (method: McpMethod, params: unknown) => unknown;
|
|
11
|
+
/** Per-request transport hints: modern headers, or the legacy session id. */
|
|
12
|
+
readonly meta: (method: McpMethod, params: unknown) => SendMeta;
|
|
13
|
+
/** Answer a server-initiated frame. Modern servers never send one. */
|
|
14
|
+
readonly onInbound: (inbound: Inbound) => Effect.Effect<void>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Probe for one protocol era. `None` means "not this era, try the next"; a
|
|
18
|
+
* failure means the server is this era but unusable (no mutual version).
|
|
19
|
+
*/
|
|
20
|
+
type ProtocolProbe = (connection: McpConnection) => Effect.Effect<Option.Option<Protocol>, McpError, Scope.Scope>;
|
|
21
|
+
/**
|
|
22
|
+
* A `-32020` / `-32021` / `-32022` reply, which is the spec's era
|
|
23
|
+
* discriminator: it proves the peer speaks a modern version, so the client
|
|
24
|
+
* corrects and retries rather than falling back to `initialize`. `supported`
|
|
25
|
+
* carries the versions a `-32022` offered, decoded through the schema so a
|
|
26
|
+
* server that adds fields cannot break it.
|
|
27
|
+
*/
|
|
28
|
+
type ModernRejection = {
|
|
29
|
+
readonly code: number;
|
|
30
|
+
readonly supported: ReadonlyArray<string>;
|
|
31
|
+
};
|
|
32
|
+
declare const modernRejection: (error: McpError) => Option.Option<ModernRejection>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { modernRejection as i, Protocol as n, ProtocolProbe as r, ModernRejection as t };
|
|
35
|
+
//# sourceMappingURL=protocol-kjC3iAMb.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-kjC3iAMb.d.mts","names":[],"sources":["../src/internal/protocol.ts"],"mappings":";;;;;KAqBY;WACD,SAAS;WACT,YAAY;;WAEZ,WAAW,QAAQ,WAAW;;WAE9B,OAAO,QAAQ,WAAW,oBAAoB;;WAE9C,YAAY,SAAS,YAAY,OAAO;;;;;;KAOvC,iBACV,YAAY,kBACT,OAAO,OAAO,OAAO,OAAO,WAAW,UAAU,MAAM;;;;;;;;KAWhD;WACD;WACA,WAAW;;cAGT,kBAAe,OAAW,aAAW,OAAO,OAAO"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { i as McpError } from "./McpError-DWg9BlW5.mjs";
|
|
2
|
+
import { f as JsonRpcId } from "./schema-D2oUNuo5.mjs";
|
|
3
|
+
import { Effect, Option, Scope, Stream } from "effect";
|
|
4
|
+
//#region src/internal/rpc.d.ts
|
|
5
|
+
/** Per-request transport hints (era headers on HTTP; stdio ignores them). */
|
|
6
|
+
type SendMeta = {
|
|
7
|
+
readonly headers?: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
/** The transport seam: one framed JSON message per `send` / `messages` element. */
|
|
10
|
+
type Transport = {
|
|
11
|
+
readonly send: (frame: string, meta?: SendMeta) => Effect.Effect<void, McpError>;
|
|
12
|
+
readonly messages: Stream.Stream<string, McpError>;
|
|
13
|
+
};
|
|
14
|
+
/** A server-initiated request (has `id`) or notification (no `id`). */
|
|
15
|
+
type Inbound = {
|
|
16
|
+
readonly id: Option.Option<JsonRpcId>;
|
|
17
|
+
readonly method: string;
|
|
18
|
+
readonly params: unknown;
|
|
19
|
+
};
|
|
20
|
+
type McpConnection = {
|
|
21
|
+
readonly request: (method: string, params?: unknown, meta?: SendMeta) => Effect.Effect<unknown, McpError>;
|
|
22
|
+
readonly notify: (method: string, params?: unknown, meta?: SendMeta) => Effect.Effect<void, McpError>;
|
|
23
|
+
/** Answer a server-initiated request (legacy era only). */
|
|
24
|
+
readonly respond: (id: JsonRpcId, result: unknown) => Effect.Effect<void, McpError>;
|
|
25
|
+
readonly respondError: (id: JsonRpcId, code: number, message: string) => Effect.Effect<void, McpError>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Open a scoped connection over an already-open transport. `onInbound`
|
|
29
|
+
* receives server-initiated frames; era.ts answers them via `transport.send`.
|
|
30
|
+
*/
|
|
31
|
+
declare const open: (transport: Transport, onInbound: (inbound: Inbound) => Effect.Effect<void>) => Effect.Effect<McpConnection, never, Scope.Scope>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { open as a, Transport as i, McpConnection as n, SendMeta as r, Inbound as t };
|
|
34
|
+
//# sourceMappingURL=rpc-Bq95Lio9.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-Bq95Lio9.d.mts","names":[],"sources":["../src/internal/rpc.ts"],"mappings":";;;;;KAmBY;WACD,UAAU;;;KAIT;WACD,OAAO,eAAe,OAAO,aAAa,OAAO,aAAa;WAC9D,UAAU,OAAO,eAAe;;;KAI/B;WACD,IAAI,OAAO,OAAO;WAClB;WACA;;KAGC;WACD,UACP,gBACA,kBACA,OAAO,aACJ,OAAO,gBAAgB;WACnB,SACP,gBACA,kBACA,OAAO,aACJ,OAAO,aAAa;;WAEhB,UAAU,IAAI,WAAW,oBAAoB,OAAO,aAAa;WACjE,eACP,IAAI,WACJ,cACA,oBACG,OAAO,aAAa;;;;;;cAoBd,OAAI,WACJ,WAAS,YACR,SAAS,YAAY,OAAO,iBACvC,OAAO,OAAO,sBAAsB,MAAM"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
|
+
//#region src/internal/schema.d.ts
|
|
3
|
+
/** Every protocol version this client can speak. */
|
|
4
|
+
declare const ProtocolVersion: Schema.Literals<readonly ["2026-07-28", "2025-11-25", "2025-06-18"]>;
|
|
5
|
+
type ProtocolVersion = typeof ProtocolVersion.Type;
|
|
6
|
+
/** Newest version we speak: the stateless protocol, and what the probe tries first. */
|
|
7
|
+
declare const LATEST_VERSION = "2026-07-28";
|
|
8
|
+
/** The legacy handshake era we negotiate; 2025-11-25 is wire-compatible. */
|
|
9
|
+
declare const LEGACY_VERSION = "2025-06-18";
|
|
10
|
+
/** Narrow a server-offered version string to one we support. */
|
|
11
|
+
declare const asProtocolVersion: (raw: string) => Option.Option<ProtocolVersion>;
|
|
12
|
+
/**
|
|
13
|
+
* The JSON-RPC methods this client issues. Not to be confused with an HTTP
|
|
14
|
+
* method: on Streamable HTTP every one of these travels as a POST, and the
|
|
15
|
+
* name is mirrored into the `Mcp-Method` header.
|
|
16
|
+
*/
|
|
17
|
+
declare const McpMethod: Schema.Literals<readonly ["server/discover", "initialize", "tools/list", "tools/call"]>;
|
|
18
|
+
type McpMethod = typeof McpMethod.Type;
|
|
19
|
+
/** Modern `_meta` keys (SEP-2575): every request self-describes its protocol. */
|
|
20
|
+
declare const META_PROTOCOL_VERSION = "io.modelcontextprotocol/protocolVersion";
|
|
21
|
+
declare const META_CLIENT_INFO = "io.modelcontextprotocol/clientInfo";
|
|
22
|
+
declare const META_CLIENT_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
|
|
23
|
+
/** Servers identify themselves in each *result's* `_meta`, not at the top level. */
|
|
24
|
+
declare const META_SERVER_INFO = "io.modelcontextprotocol/serverInfo";
|
|
25
|
+
declare const CLIENT_INFO: {
|
|
26
|
+
name: string;
|
|
27
|
+
version: string;
|
|
28
|
+
};
|
|
29
|
+
/** Modern JSON-RPC error codes. */
|
|
30
|
+
declare const CODE_HEADER_MISMATCH = -32020;
|
|
31
|
+
declare const CODE_MISSING_CLIENT_CAPABILITY = -32021;
|
|
32
|
+
declare const CODE_UNSUPPORTED_PROTOCOL_VERSION = -32022;
|
|
33
|
+
declare const CODE_METHOD_NOT_FOUND = -32601;
|
|
34
|
+
/**
|
|
35
|
+
* A reply carrying one of these proves the server speaks a modern version, so
|
|
36
|
+
* era detection corrects and retries instead of falling back to `initialize`.
|
|
37
|
+
*/
|
|
38
|
+
declare const MODERN_ERROR_CODES: ReadonlySet<number>;
|
|
39
|
+
declare const JsonRpcId: Schema.Union<readonly [Schema.Number, Schema.String]>;
|
|
40
|
+
type JsonRpcId = typeof JsonRpcId.Type;
|
|
41
|
+
declare const JsonRpcErrorObject: Schema.Struct<{
|
|
42
|
+
readonly code: Schema.Number;
|
|
43
|
+
readonly message: Schema.optional<Schema.String>;
|
|
44
|
+
readonly data: Schema.optional<Schema.Unknown>;
|
|
45
|
+
}>;
|
|
46
|
+
type JsonRpcErrorObject = typeof JsonRpcErrorObject.Type;
|
|
47
|
+
/**
|
|
48
|
+
* Any inbound frame: a reply (`id` + `result`/`error`), a server-initiated
|
|
49
|
+
* request (`method` + `id`), or a notification (`method`, no `id`). One
|
|
50
|
+
* loose struct so the reader can classify without a union decode.
|
|
51
|
+
*/
|
|
52
|
+
declare const InboundMessage: Schema.Struct<{
|
|
53
|
+
readonly id: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.Number, Schema.String]>>>;
|
|
54
|
+
readonly result: Schema.optional<Schema.Unknown>;
|
|
55
|
+
readonly error: Schema.optional<Schema.Struct<{
|
|
56
|
+
readonly code: Schema.Number;
|
|
57
|
+
readonly message: Schema.optional<Schema.String>;
|
|
58
|
+
readonly data: Schema.optional<Schema.Unknown>;
|
|
59
|
+
}>>;
|
|
60
|
+
readonly method: Schema.optional<Schema.String>;
|
|
61
|
+
readonly params: Schema.optional<Schema.Unknown>;
|
|
62
|
+
}>;
|
|
63
|
+
type InboundMessage = typeof InboundMessage.Type;
|
|
64
|
+
declare const decodeInboundMessage: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
65
|
+
readonly id?: string | number | null | undefined;
|
|
66
|
+
readonly result?: unknown;
|
|
67
|
+
readonly error?: {
|
|
68
|
+
readonly code: number;
|
|
69
|
+
readonly message?: string | undefined;
|
|
70
|
+
readonly data?: unknown;
|
|
71
|
+
} | undefined;
|
|
72
|
+
readonly method?: string | undefined;
|
|
73
|
+
readonly params?: unknown;
|
|
74
|
+
}, Schema.SchemaError, never>;
|
|
75
|
+
declare const requestFrame: (id: JsonRpcId, method: string, params: unknown) => string;
|
|
76
|
+
declare const notificationFrame: (method: string, params?: unknown) => string;
|
|
77
|
+
declare const resultFrame: (id: JsonRpcId, result: unknown) => string;
|
|
78
|
+
declare const errorFrame: (id: JsonRpcId, code: number, message: string) => string;
|
|
79
|
+
declare const ToolInfo: Schema.Struct<{
|
|
80
|
+
readonly name: Schema.String;
|
|
81
|
+
readonly description: Schema.optional<Schema.String>;
|
|
82
|
+
readonly inputSchema: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
83
|
+
}>;
|
|
84
|
+
type ToolInfo = typeof ToolInfo.Type;
|
|
85
|
+
/**
|
|
86
|
+
* Modern list results may carry cache metadata (`ttlMs` / `cacheScope`);
|
|
87
|
+
* v1 reads but does not act on them (input for a later refresh feature).
|
|
88
|
+
*/
|
|
89
|
+
declare const ListToolsResult: Schema.Struct<{
|
|
90
|
+
readonly tools: Schema.$Array<Schema.Struct<{
|
|
91
|
+
readonly name: Schema.String;
|
|
92
|
+
readonly description: Schema.optional<Schema.String>;
|
|
93
|
+
readonly inputSchema: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
94
|
+
}>>;
|
|
95
|
+
readonly nextCursor: Schema.optional<Schema.String>;
|
|
96
|
+
readonly ttlMs: Schema.optional<Schema.Number>;
|
|
97
|
+
readonly cacheScope: Schema.optional<Schema.String>;
|
|
98
|
+
}>;
|
|
99
|
+
type ListToolsResult = typeof ListToolsResult.Type;
|
|
100
|
+
declare const decodeListToolsResult: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
101
|
+
readonly tools: readonly {
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly description?: string | undefined;
|
|
104
|
+
readonly inputSchema: {
|
|
105
|
+
readonly [x: string]: unknown;
|
|
106
|
+
};
|
|
107
|
+
}[];
|
|
108
|
+
readonly nextCursor?: string | undefined;
|
|
109
|
+
readonly ttlMs?: number | undefined;
|
|
110
|
+
readonly cacheScope?: string | undefined;
|
|
111
|
+
}, Schema.SchemaError, never>;
|
|
112
|
+
declare const TextContent: Schema.Struct<{
|
|
113
|
+
readonly type: Schema.Literal<"text">;
|
|
114
|
+
readonly text: Schema.String;
|
|
115
|
+
}>;
|
|
116
|
+
type TextContent = typeof TextContent.Type;
|
|
117
|
+
/** Non-text blocks (image / audio / resource) are placeholder-summarized in v1. */
|
|
118
|
+
declare const OtherContent: Schema.Struct<{
|
|
119
|
+
readonly type: Schema.String;
|
|
120
|
+
}>;
|
|
121
|
+
declare const ContentBlock: Schema.Union<readonly [Schema.Struct<{
|
|
122
|
+
readonly type: Schema.Literal<"text">;
|
|
123
|
+
readonly text: Schema.String;
|
|
124
|
+
}>, Schema.Struct<{
|
|
125
|
+
readonly type: Schema.String;
|
|
126
|
+
}>]>;
|
|
127
|
+
type ContentBlock = typeof ContentBlock.Type;
|
|
128
|
+
declare const isTextContent: <I>(input: I) => input is I & {
|
|
129
|
+
readonly type: "text";
|
|
130
|
+
readonly text: string;
|
|
131
|
+
};
|
|
132
|
+
declare const CallToolResult: Schema.Struct<{
|
|
133
|
+
readonly content: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
134
|
+
readonly type: Schema.Literal<"text">;
|
|
135
|
+
readonly text: Schema.String;
|
|
136
|
+
}>, Schema.Struct<{
|
|
137
|
+
readonly type: Schema.String;
|
|
138
|
+
}>]>>>;
|
|
139
|
+
readonly isError: Schema.optional<Schema.Boolean>;
|
|
140
|
+
readonly structuredContent: Schema.optional<Schema.Unknown>;
|
|
141
|
+
readonly resultType: Schema.optional<Schema.String>;
|
|
142
|
+
}>;
|
|
143
|
+
type CallToolResult = typeof CallToolResult.Type;
|
|
144
|
+
declare const decodeCallToolResult: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
145
|
+
readonly content?: readonly ({
|
|
146
|
+
readonly type: "text";
|
|
147
|
+
readonly text: string;
|
|
148
|
+
} | {
|
|
149
|
+
readonly type: string;
|
|
150
|
+
})[];
|
|
151
|
+
readonly isError?: boolean | undefined;
|
|
152
|
+
readonly structuredContent?: unknown;
|
|
153
|
+
readonly resultType?: string | undefined;
|
|
154
|
+
}, Schema.SchemaError, never>;
|
|
155
|
+
declare const ServerInfo: Schema.Struct<{
|
|
156
|
+
readonly name: Schema.String;
|
|
157
|
+
readonly version: Schema.optional<Schema.String>;
|
|
158
|
+
readonly title: Schema.optional<Schema.String>;
|
|
159
|
+
}>;
|
|
160
|
+
type ServerInfo = typeof ServerInfo.Type;
|
|
161
|
+
/** The subset of a result's `_meta` we read. */
|
|
162
|
+
declare const ResultMeta: Schema.Struct<{
|
|
163
|
+
readonly "io.modelcontextprotocol/serverInfo": Schema.optional<Schema.Struct<{
|
|
164
|
+
readonly name: Schema.String;
|
|
165
|
+
readonly version: Schema.optional<Schema.String>;
|
|
166
|
+
readonly title: Schema.optional<Schema.String>;
|
|
167
|
+
}>>;
|
|
168
|
+
}>;
|
|
169
|
+
type ResultMeta = typeof ResultMeta.Type;
|
|
170
|
+
declare const DiscoverResult: Schema.Struct<{
|
|
171
|
+
readonly supportedVersions: Schema.$Array<Schema.String>;
|
|
172
|
+
readonly capabilities: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
173
|
+
readonly _meta: Schema.optional<Schema.Struct<{
|
|
174
|
+
readonly "io.modelcontextprotocol/serverInfo": Schema.optional<Schema.Struct<{
|
|
175
|
+
readonly name: Schema.String;
|
|
176
|
+
readonly version: Schema.optional<Schema.String>;
|
|
177
|
+
readonly title: Schema.optional<Schema.String>;
|
|
178
|
+
}>>;
|
|
179
|
+
}>>;
|
|
180
|
+
readonly serverInfo: Schema.optional<Schema.Struct<{
|
|
181
|
+
readonly name: Schema.String;
|
|
182
|
+
readonly version: Schema.optional<Schema.String>;
|
|
183
|
+
readonly title: Schema.optional<Schema.String>;
|
|
184
|
+
}>>;
|
|
185
|
+
readonly instructions: Schema.optional<Schema.String>;
|
|
186
|
+
}>;
|
|
187
|
+
type DiscoverResult = typeof DiscoverResult.Type;
|
|
188
|
+
declare const decodeDiscoverResult: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
189
|
+
readonly supportedVersions: readonly string[];
|
|
190
|
+
readonly capabilities?: {
|
|
191
|
+
readonly [x: string]: unknown;
|
|
192
|
+
} | undefined;
|
|
193
|
+
readonly _meta?: {
|
|
194
|
+
readonly "io.modelcontextprotocol/serverInfo"?: {
|
|
195
|
+
readonly name: string;
|
|
196
|
+
readonly version?: string | undefined;
|
|
197
|
+
readonly title?: string | undefined;
|
|
198
|
+
} | undefined;
|
|
199
|
+
} | undefined;
|
|
200
|
+
readonly serverInfo?: {
|
|
201
|
+
readonly name: string;
|
|
202
|
+
readonly version?: string | undefined;
|
|
203
|
+
readonly title?: string | undefined;
|
|
204
|
+
} | undefined;
|
|
205
|
+
readonly instructions?: string | undefined;
|
|
206
|
+
}, Schema.SchemaError, never>;
|
|
207
|
+
/**
|
|
208
|
+
* `data` of a `-32022` UnsupportedProtocolVersionError reply. Decoded, not
|
|
209
|
+
* hand-parsed: the shape is server-controlled and may carry extra fields.
|
|
210
|
+
*/
|
|
211
|
+
declare const UnsupportedVersionData: Schema.Struct<{
|
|
212
|
+
readonly supported: Schema.optional<Schema.$Array<Schema.String>>;
|
|
213
|
+
readonly requested: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
214
|
+
}>;
|
|
215
|
+
type UnsupportedVersionData = typeof UnsupportedVersionData.Type;
|
|
216
|
+
declare const decodeUnsupportedVersionData: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Option.Option<{
|
|
217
|
+
readonly supported?: readonly string[] | undefined;
|
|
218
|
+
readonly requested?: string | null | undefined;
|
|
219
|
+
}>;
|
|
220
|
+
declare const InitializeResult: Schema.Struct<{
|
|
221
|
+
readonly protocolVersion: Schema.String;
|
|
222
|
+
readonly capabilities: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
223
|
+
readonly serverInfo: Schema.optional<Schema.Struct<{
|
|
224
|
+
readonly name: Schema.String;
|
|
225
|
+
readonly version: Schema.optional<Schema.String>;
|
|
226
|
+
readonly title: Schema.optional<Schema.String>;
|
|
227
|
+
}>>;
|
|
228
|
+
readonly instructions: Schema.optional<Schema.String>;
|
|
229
|
+
}>;
|
|
230
|
+
type InitializeResult = typeof InitializeResult.Type;
|
|
231
|
+
declare const decodeInitializeResult: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
232
|
+
readonly protocolVersion: string;
|
|
233
|
+
readonly capabilities?: {
|
|
234
|
+
readonly [x: string]: unknown;
|
|
235
|
+
} | undefined;
|
|
236
|
+
readonly serverInfo?: {
|
|
237
|
+
readonly name: string;
|
|
238
|
+
readonly version?: string | undefined;
|
|
239
|
+
readonly title?: string | undefined;
|
|
240
|
+
} | undefined;
|
|
241
|
+
readonly instructions?: string | undefined;
|
|
242
|
+
}, Schema.SchemaError, never>;
|
|
243
|
+
//#endregion
|
|
244
|
+
export { decodeCallToolResult as A, resultFrame as B, ProtocolVersion as C, ToolInfo as D, TextContent as E, decodeUnsupportedVersionData as F, errorFrame as I, isTextContent as L, decodeInboundMessage as M, decodeInitializeResult as N, UnsupportedVersionData as O, decodeListToolsResult as P, notificationFrame as R, OtherContent as S, ServerInfo as T, META_CLIENT_INFO as _, CODE_UNSUPPORTED_PROTOCOL_VERSION as a, MODERN_ERROR_CODES as b, DiscoverResult as c, JsonRpcErrorObject as d, JsonRpcId as f, META_CLIENT_CAPABILITIES as g, ListToolsResult as h, CODE_MISSING_CLIENT_CAPABILITY as i, decodeDiscoverResult as j, asProtocolVersion as k, InboundMessage as l, LEGACY_VERSION as m, CODE_HEADER_MISMATCH as n, CallToolResult as o, LATEST_VERSION as p, CODE_METHOD_NOT_FOUND as r, ContentBlock as s, CLIENT_INFO as t, InitializeResult as u, META_PROTOCOL_VERSION as v, ResultMeta as w, McpMethod as x, META_SERVER_INFO as y, requestFrame as z };
|
|
245
|
+
//# sourceMappingURL=schema-D2oUNuo5.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-D2oUNuo5.d.mts","names":[],"sources":["../src/internal/schema.ts"],"mappings":";;;cAaa,iBAAe,OAAA;KAChB,yBAAyB,gBAAgB;;cAGxC;;cAGA;;cAKA,oBAAiB,gBAAkB,OAAO,OAAO;;;;;;cAQjD,WAAS,OAAA;KAMV,mBAAmB,UAAU;;cAG5B;cACA;cACA;;cAEA;cAEA;EAAgB;EAAyB;;;cAGzC;cACA;cACA;cACA;;;;;cAMA,oBAAoB;cAUpB,WAAS,OAAA,gBAAA,OAAA,QAAA,OAAA;KACV,mBAAmB,UAAU;cAE5B,oBAAkB,OAAA;;;;;KAKnB,4BAA4B,mBAAmB;;;;;;cAO9C,gBAAc,OAAA;;;;;;;;;;;KASf,wBAAwB,eAAe;cAEtC,uBAAoB,gBAAA,qCAAA,yCAAA;;;;;;;;;;GAA6C,OAAA;cAIjE,eAAY,IAAQ,WAAS,gBAAgB;cAG7C,oBAAiB,gBAAkB;cAKnC,cAAW,IAAQ,WAAS;cAG5B,aAAU,IAAQ,WAAS,cAAc;cAOzC,UAAQ,OAAA;;;;;KAKT,kBAAkB,SAAS;;;;;cAM1B,iBAAe,OAAA;;;;;;;;;;KAMhB,yBAAyB,gBAAgB;cAExC,wBAAqB,gBAAA,qCAAA,yCAAA;;;;;;;;;;;GAA8C,OAAA;cAInE,aAAW,OAAA;;;;KAIZ,qBAAqB,YAAY;;cAGhC,cAAY,OAAA;iBAAZ,OAAA;;cAIA,cAAY,OAAA,gBAAA,OAAA;;;;;;KACb,sBAAsB,aAAa;cAElC,gBAAa,GAAA,OAAA,MAAA,SAAA;;;;cAEb,gBAAc,OAAA;;;;;;;;;;;KAOf,wBAAwB,eAAe;cAEtC,uBAAoB,gBAAA,qCAAA,yCAAA;;;;;;;;;;GAA6C,OAAA;cAMjE,YAAU,OAAA;;;;;KAKX,oBAAoB,WAAW;;cAG9B,YAAU,OAAA;;;;;;;KAGX,oBAAoB,WAAW;cAE9B,gBAAc,OAAA;;;;;;;;;;;;;;;;;KASf,wBAAwB,eAAe;cAEtC,uBAAoB,gBAAA,qCAAA,yCAAA;;;;;;;;;;;;;;;;;;GAA6C,OAAA;;;;;cAMjE,wBAAsB,OAAA;;;;KAIvB,gCAAgC,uBAAuB;cAEtD,+BAA4B,gBAAA,qCAAA,iBAAA,OAAA;;;;cAM5B,kBAAgB,OAAA;;;;;;;;;;KAMjB,0BAA0B,iBAAiB;cAE1C,yBAAsB,gBAAA,qCAAA,yCAAA;;;;;;;;;;;GAA+C,OAAA"}
|