@smthrs/mcp 0.0.0-stage → 1.0.0-rc.4
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/CHANGELOG.md +121 -0
- package/LICENSE +21 -0
- package/README.md +111 -2
- package/dist/cjs/Diagnostics.d.ts +46 -0
- package/dist/cjs/Diagnostics.d.ts.map +1 -0
- package/dist/cjs/Diagnostics.js +29 -0
- package/dist/cjs/Diagnostics.js.map +7 -0
- package/dist/cjs/McpClient.d.ts +304 -0
- package/dist/cjs/McpClient.d.ts.map +1 -0
- package/dist/cjs/McpClient.js +622 -0
- package/dist/cjs/McpClient.js.map +7 -0
- package/dist/cjs/McpError.d.ts +44 -0
- package/dist/cjs/McpError.d.ts.map +1 -0
- package/dist/cjs/McpError.js +41 -0
- package/dist/cjs/McpError.js.map +7 -0
- package/dist/cjs/McpFlows.d.ts +113 -0
- package/dist/cjs/McpFlows.d.ts.map +1 -0
- package/dist/cjs/McpFlows.js +127 -0
- package/dist/cjs/McpFlows.js.map +7 -0
- package/dist/cjs/index.d.ts +39 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/DiagnosticReporter.d.ts +17 -0
- package/dist/cjs/internal/DiagnosticReporter.d.ts.map +1 -0
- package/dist/cjs/internal/DiagnosticReporter.js +56 -0
- package/dist/cjs/internal/DiagnosticReporter.js.map +7 -0
- package/dist/cjs/internal/HttpTransport.d.ts +67 -0
- package/dist/cjs/internal/HttpTransport.d.ts.map +1 -0
- package/dist/cjs/internal/HttpTransport.js +298 -0
- package/dist/cjs/internal/HttpTransport.js.map +7 -0
- package/dist/cjs/internal/JsonLimits.d.ts +29 -0
- package/dist/cjs/internal/JsonLimits.d.ts.map +1 -0
- package/dist/cjs/internal/JsonLimits.js +51 -0
- package/dist/cjs/internal/JsonLimits.js.map +7 -0
- package/dist/cjs/internal/Limits.d.ts +36 -0
- package/dist/cjs/internal/Limits.d.ts.map +1 -0
- package/dist/cjs/internal/Limits.js +34 -0
- package/dist/cjs/internal/Limits.js.map +7 -0
- package/dist/cjs/internal/Rpc.d.ts +141 -0
- package/dist/cjs/internal/Rpc.d.ts.map +1 -0
- package/dist/cjs/internal/Rpc.js +92 -0
- package/dist/cjs/internal/Rpc.js.map +7 -0
- package/dist/cjs/internal/StdioTransport.d.ts +78 -0
- package/dist/cjs/internal/StdioTransport.d.ts.map +1 -0
- package/dist/cjs/internal/StdioTransport.js +310 -0
- package/dist/cjs/internal/StdioTransport.js.map +7 -0
- package/dist/cjs/internal/Transport.d.ts +87 -0
- package/dist/cjs/internal/Transport.d.ts.map +1 -0
- package/dist/cjs/internal/Transport.js +116 -0
- package/dist/cjs/internal/Transport.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/Diagnostics.d.ts +46 -0
- package/dist/esm/Diagnostics.d.ts.map +1 -0
- package/dist/esm/Diagnostics.js +26 -0
- package/dist/esm/Diagnostics.js.map +1 -0
- package/dist/esm/McpClient.d.ts +304 -0
- package/dist/esm/McpClient.d.ts.map +1 -0
- package/dist/esm/McpClient.js +671 -0
- package/dist/esm/McpClient.js.map +1 -0
- package/dist/esm/McpError.d.ts +44 -0
- package/dist/esm/McpError.d.ts.map +1 -0
- package/dist/esm/McpError.js +43 -0
- package/dist/esm/McpError.js.map +1 -0
- package/dist/esm/McpFlows.d.ts +113 -0
- package/dist/esm/McpFlows.d.ts.map +1 -0
- package/dist/esm/McpFlows.js +168 -0
- package/dist/esm/McpFlows.js.map +1 -0
- package/dist/esm/index.d.ts +39 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +39 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/DiagnosticReporter.d.ts +17 -0
- package/dist/esm/internal/DiagnosticReporter.d.ts.map +1 -0
- package/dist/esm/internal/DiagnosticReporter.js +44 -0
- package/dist/esm/internal/DiagnosticReporter.js.map +1 -0
- package/dist/esm/internal/HttpTransport.d.ts +67 -0
- package/dist/esm/internal/HttpTransport.d.ts.map +1 -0
- package/dist/esm/internal/HttpTransport.js +266 -0
- package/dist/esm/internal/HttpTransport.js.map +1 -0
- package/dist/esm/internal/JsonLimits.d.ts +29 -0
- package/dist/esm/internal/JsonLimits.d.ts.map +1 -0
- package/dist/esm/internal/JsonLimits.js +55 -0
- package/dist/esm/internal/JsonLimits.js.map +1 -0
- package/dist/esm/internal/Limits.d.ts +36 -0
- package/dist/esm/internal/Limits.d.ts.map +1 -0
- package/dist/esm/internal/Limits.js +41 -0
- package/dist/esm/internal/Limits.js.map +1 -0
- package/dist/esm/internal/Rpc.d.ts +141 -0
- package/dist/esm/internal/Rpc.d.ts.map +1 -0
- package/dist/esm/internal/Rpc.js +129 -0
- package/dist/esm/internal/Rpc.js.map +1 -0
- package/dist/esm/internal/StdioTransport.d.ts +78 -0
- package/dist/esm/internal/StdioTransport.d.ts.map +1 -0
- package/dist/esm/internal/StdioTransport.js +332 -0
- package/dist/esm/internal/StdioTransport.js.map +1 -0
- package/dist/esm/internal/Transport.d.ts +87 -0
- package/dist/esm/internal/Transport.d.ts.map +1 -0
- package/dist/esm/internal/Transport.js +146 -0
- package/dist/esm/internal/Transport.js.map +1 -0
- package/docs/README.md +139 -0
- package/docs/api.md +469 -0
- package/docs/concepts/the-session.md +135 -0
- package/docs/concepts/tools-as-flows.md +116 -0
- package/docs/guides/bound-an-untrusted-server.md +158 -0
- package/docs/guides/configure-servers-for-the-cli.md +167 -0
- package/docs/guides/connect-a-server.md +161 -0
- package/docs/guides/grant-authority-to-mcp-tools.md +130 -0
- package/docs/guides/handle-a-failed-tool-call.md +125 -0
- package/docs/guides/select-the-tools-a-run-sees.md +92 -0
- package/docs/guides/testing.md +132 -0
- package/docs/guides/validate-structured-output.md +103 -0
- package/docs/installation.md +117 -0
- package/docs/quickstart.md +200 -0
- package/docs/troubleshooting.md +316 -0
- package/package.json +157 -3
- package/src/Diagnostics.ts +47 -0
- package/src/McpClient.ts +985 -0
- package/src/McpError.ts +52 -0
- package/src/McpFlows.ts +211 -0
- package/src/index.ts +42 -0
- package/src/internal/DiagnosticReporter.ts +47 -0
- package/src/internal/HttpTransport.ts +400 -0
- package/src/internal/JsonLimits.ts +53 -0
- package/src/internal/Limits.ts +48 -0
- package/src/internal/Rpc.ts +219 -0
- package/src/internal/StdioTransport.ts +491 -0
- package/src/internal/Transport.ts +178 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-only access to untrusted MCP diagnostics, separate from model-facing
|
|
3
|
+
* errors. Merely logging or JSON-encoding an event cannot expose its detail.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-rc.0
|
|
6
|
+
*/
|
|
7
|
+
import { Context, Layer } from "effect";
|
|
8
|
+
import type { Redacted } from "effect";
|
|
9
|
+
/**
|
|
10
|
+
* One bounded diagnostic from a connection. Detail can contain credentials,
|
|
11
|
+
* private tool arguments, or arbitrary server text. Only an explicitly trusted
|
|
12
|
+
* local host should unwrap it; never forward it to agents, journals, or logs.
|
|
13
|
+
*
|
|
14
|
+
* @category models
|
|
15
|
+
* @since 1.0.0-rc.0
|
|
16
|
+
*/
|
|
17
|
+
export interface Event {
|
|
18
|
+
readonly server: string;
|
|
19
|
+
readonly source: "spawn" | "stderr" | "transport" | "remote-error" | "invalid-response" | "invalid-arguments";
|
|
20
|
+
/** At most 16 KiB of UTF-8 text; never the original unbounded value. */
|
|
21
|
+
readonly detail: Redacted.Redacted<string>;
|
|
22
|
+
readonly truncated: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare const Diagnostics_base: Context.ServiceClass<Diagnostics, "@smthrs/mcp/Diagnostics", {
|
|
25
|
+
readonly report: (event: Event) => void;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Optional diagnostic observer, captured when a connection is opened. The
|
|
29
|
+
* synchronous callback must not block; throws are isolated from the protocol.
|
|
30
|
+
* Absent this service, raw diagnostics are discarded, not logged implicitly.
|
|
31
|
+
*
|
|
32
|
+
* @category services
|
|
33
|
+
* @since 1.0.0-rc.0
|
|
34
|
+
*/
|
|
35
|
+
export declare class Diagnostics extends Diagnostics_base {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Installs a trusted host observer. Inspecting detail requires an explicit
|
|
39
|
+
* `Redacted.value` call and responsibility for its destination and retention.
|
|
40
|
+
*
|
|
41
|
+
* @category layers
|
|
42
|
+
* @since 1.0.0-rc.0
|
|
43
|
+
*/
|
|
44
|
+
export declare const layer: (report: (event: Event) => void) => Layer.Layer<Diagnostics>;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=Diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Diagnostics.d.ts","sourceRoot":"","sources":["../../src/Diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAA;IAC7G,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC1C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC5B;;qBAWkB,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;AATzC;;;;;;;GAOG;AACH,qBAAa,WAAY,SAAQ,gBAEF;CAAG;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CACtC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-only access to untrusted MCP diagnostics, separate from model-facing
|
|
3
|
+
* errors. Merely logging or JSON-encoding an event cannot expose its detail.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-rc.0
|
|
6
|
+
*/
|
|
7
|
+
import { Context, Layer } from "effect";
|
|
8
|
+
/**
|
|
9
|
+
* Optional diagnostic observer, captured when a connection is opened. The
|
|
10
|
+
* synchronous callback must not block; throws are isolated from the protocol.
|
|
11
|
+
* Absent this service, raw diagnostics are discarded, not logged implicitly.
|
|
12
|
+
*
|
|
13
|
+
* @category services
|
|
14
|
+
* @since 1.0.0-rc.0
|
|
15
|
+
*/
|
|
16
|
+
export class Diagnostics extends Context.Service()("@smthrs/mcp/Diagnostics") {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Installs a trusted host observer. Inspecting detail requires an explicit
|
|
20
|
+
* `Redacted.value` call and responsibility for its destination and retention.
|
|
21
|
+
*
|
|
22
|
+
* @category layers
|
|
23
|
+
* @since 1.0.0-rc.0
|
|
24
|
+
*/
|
|
25
|
+
export const layer = (report) => Layer.succeed(Diagnostics)({ report });
|
|
26
|
+
//# sourceMappingURL=Diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Diagnostics.js","sourceRoot":"","sources":["../../src/Diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAmBvC;;;;;;;GAOG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAE5C,CAAC,yBAAyB,CAAC;CAAG;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAA8B,EAA4B,EAAE,CAChF,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA","sourcesContent":["/**\n * Host-only access to untrusted MCP diagnostics, separate from model-facing\n * errors. Merely logging or JSON-encoding an event cannot expose its detail.\n *\n * @since 1.0.0-rc.0\n */\n\nimport { Context, Layer } from \"effect\"\nimport type { Redacted } from \"effect\"\n\n/**\n * One bounded diagnostic from a connection. Detail can contain credentials,\n * private tool arguments, or arbitrary server text. Only an explicitly trusted\n * local host should unwrap it; never forward it to agents, journals, or logs.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Event {\n readonly server: string\n readonly source: \"spawn\" | \"stderr\" | \"transport\" | \"remote-error\" | \"invalid-response\" | \"invalid-arguments\"\n /** At most 16 KiB of UTF-8 text; never the original unbounded value. */\n readonly detail: Redacted.Redacted<string>\n readonly truncated: boolean\n}\n\n/**\n * Optional diagnostic observer, captured when a connection is opened. The\n * synchronous callback must not block; throws are isolated from the protocol.\n * Absent this service, raw diagnostics are discarded, not logged implicitly.\n *\n * @category services\n * @since 1.0.0-rc.0\n */\nexport class Diagnostics extends Context.Service<Diagnostics, {\n readonly report: (event: Event) => void\n}>()(\"@smthrs/mcp/Diagnostics\") {}\n\n/**\n * Installs a trusted host observer. Inspecting detail requires an explicit\n * `Redacted.value` call and responsibility for its destination and retention.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (report: (event: Event) => void): Layer.Layer<Diagnostics> =>\n Layer.succeed(Diagnostics)({ report })\n"]}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal MCP client covering the `initialize` handshake, `tools/list`, and
|
|
3
|
+
* `tools/call`, over stdio or Streamable HTTP.
|
|
4
|
+
*
|
|
5
|
+
* This is deliberately not a general MCP SDK. Smithers has exactly one
|
|
6
|
+
* consumer of an MCP session: {@link McpFlows}, which needs a tool catalog
|
|
7
|
+
* and a way to invoke one entry from it, so the client exposes only that.
|
|
8
|
+
* Resources, prompts, sampling, and roots are not wired up; add them here
|
|
9
|
+
* when a flow adapter needs them, not speculatively.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0-rc.0
|
|
12
|
+
*/
|
|
13
|
+
import { Effect, Schema, Scope } from "effect";
|
|
14
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
15
|
+
import type { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
16
|
+
import * as HttpTransport from "./internal/HttpTransport.ts";
|
|
17
|
+
import * as StdioTransport from "./internal/StdioTransport.ts";
|
|
18
|
+
import { McpError } from "./McpError.ts";
|
|
19
|
+
/**
|
|
20
|
+
* One remote tool as the server describes it.
|
|
21
|
+
*
|
|
22
|
+
* @category models
|
|
23
|
+
* @since 1.0.0-rc.0
|
|
24
|
+
*/
|
|
25
|
+
export interface ToolDescription {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly description: string | undefined;
|
|
28
|
+
/** The tool's parameter shape, as a JSON Schema document with `type: "object"`. */
|
|
29
|
+
readonly inputSchema: Record<string, unknown>;
|
|
30
|
+
/** The tool's structured result shape, when the server disclosed one. */
|
|
31
|
+
readonly outputSchema: Record<string, unknown> | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The result of one `tools/call`.
|
|
35
|
+
*
|
|
36
|
+
* MCP tool content is a small union (text, image, embedded resource, …); this
|
|
37
|
+
* client passes every block through by shape rather than modeling the union,
|
|
38
|
+
* since {@link McpFlows} only needs to hand the blocks back to the caller.
|
|
39
|
+
*
|
|
40
|
+
* @category models
|
|
41
|
+
* @since 1.0.0-rc.0
|
|
42
|
+
*/
|
|
43
|
+
export interface ToolResult {
|
|
44
|
+
readonly content: ReadonlyArray<Record<string, unknown>>;
|
|
45
|
+
readonly isError: boolean;
|
|
46
|
+
readonly structuredContent: Record<string, unknown> | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A live MCP session, holding the tool catalog fetched at connect time and a
|
|
50
|
+
* way to call one of its entries.
|
|
51
|
+
*
|
|
52
|
+
* @category models
|
|
53
|
+
* @since 1.0.0-rc.0
|
|
54
|
+
*/
|
|
55
|
+
export interface McpClient {
|
|
56
|
+
readonly server: string;
|
|
57
|
+
readonly tools: ReadonlyArray<ToolDescription>;
|
|
58
|
+
/**
|
|
59
|
+
* Calls one catalogued tool. An unknown name fails with `tool_not_found`
|
|
60
|
+
* before a JSON-RPC frame is written. Declared structured output is checked
|
|
61
|
+
* against the supported output-schema subset before it is returned.
|
|
62
|
+
*/
|
|
63
|
+
readonly callTool: (name: string, args: Record<string, unknown>) => Effect.Effect<ToolResult, McpError>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Session and catalog limits shared by every transport.
|
|
67
|
+
*
|
|
68
|
+
* @category models
|
|
69
|
+
* @since 1.0.0-rc.1
|
|
70
|
+
*/
|
|
71
|
+
export interface ClientOptions {
|
|
72
|
+
/** The name this server is known by, for flow naming and error messages. */
|
|
73
|
+
readonly server: string;
|
|
74
|
+
/** Deadline for each initialize/catalog request. See {@link defaultHandshakeTimeoutMs}. */
|
|
75
|
+
readonly handshakeTimeoutMs?: number | undefined;
|
|
76
|
+
/** Maximum tools accepted across every catalog page. See {@link defaultMaxTools}. */
|
|
77
|
+
readonly maxTools?: number | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Maximum UTF-8 bytes in a tool name. Names also cannot be `.` or `..`, or
|
|
80
|
+
* contain `/`, a control or format character (Unicode categories Cc and Cf,
|
|
81
|
+
* which include bidi and zero-width marks), U+2028, U+2029, or a lone
|
|
82
|
+
* surrogate. See {@link defaultMaxToolNameBytes}.
|
|
83
|
+
*/
|
|
84
|
+
readonly maxToolNameBytes?: number | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Maximum UTF-8 bytes of one tool's model-facing text: its description plus
|
|
87
|
+
* its JSON-encoded `inputSchema`. See {@link defaultMaxToolDocumentBytes}.
|
|
88
|
+
*/
|
|
89
|
+
readonly maxToolDocumentBytes?: number | undefined;
|
|
90
|
+
/** Maximum pages walked while fetching the catalog. See {@link defaultMaxCatalogPages}. */
|
|
91
|
+
readonly maxCatalogPages?: number | undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A server spawned as a child process and spoken to over its stdio.
|
|
95
|
+
*
|
|
96
|
+
* @category models
|
|
97
|
+
* @since 1.0.0-rc.1
|
|
98
|
+
*/
|
|
99
|
+
export interface StdioConnectOptions extends StdioTransport.ConnectOptions, ClientOptions {
|
|
100
|
+
readonly url?: never;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Supplies the bearer credential for a Streamable HTTP server. `token` runs
|
|
104
|
+
* once per HTTP message, so a provider can rotate the credential; its failure
|
|
105
|
+
* fails that message unchanged.
|
|
106
|
+
*
|
|
107
|
+
* @category models
|
|
108
|
+
* @since 1.0.0-rc.1
|
|
109
|
+
*/
|
|
110
|
+
export type AuthProvider = HttpTransport.AuthProvider;
|
|
111
|
+
/**
|
|
112
|
+
* A remote server reached over MCP Streamable HTTP through the `HttpClient`
|
|
113
|
+
* in context.
|
|
114
|
+
*
|
|
115
|
+
* @category models
|
|
116
|
+
* @since 1.0.0-rc.1
|
|
117
|
+
*/
|
|
118
|
+
export interface HttpConnectOptions extends HttpTransport.ConnectOptions, ClientOptions {
|
|
119
|
+
readonly command?: never;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Options accepted by {@link connect}: a stdio command or an HTTP `url`.
|
|
123
|
+
*
|
|
124
|
+
* @category models
|
|
125
|
+
* @since 1.0.0-rc.0
|
|
126
|
+
*/
|
|
127
|
+
export type ConnectOptions = StdioConnectOptions | HttpConnectOptions;
|
|
128
|
+
/**
|
|
129
|
+
* The services {@link connect} needs for the given options: a process spawner
|
|
130
|
+
* for stdio, an `HttpClient` for a `url`.
|
|
131
|
+
*
|
|
132
|
+
* @category models
|
|
133
|
+
* @since 1.0.0-rc.1
|
|
134
|
+
*/
|
|
135
|
+
export type Requirements<O extends ConnectOptions> = O extends {
|
|
136
|
+
readonly url: string;
|
|
137
|
+
} ? HttpClient.HttpClient : ChildProcessSpawner;
|
|
138
|
+
/**
|
|
139
|
+
* Authoritative decoder for a persisted stdio MCP server entry.
|
|
140
|
+
*
|
|
141
|
+
* The schema requires non-empty server and command names, string arguments,
|
|
142
|
+
* a plain string-valued environment record, and positive-integer limits.
|
|
143
|
+
*
|
|
144
|
+
* @category schemas
|
|
145
|
+
* @since 1.0.0-rc.0
|
|
146
|
+
*/
|
|
147
|
+
export declare const ConnectOptionsSchema: Schema.Struct<{
|
|
148
|
+
readonly server: Schema.NonEmptyString;
|
|
149
|
+
readonly command: Schema.NonEmptyString;
|
|
150
|
+
readonly args: Schema.$Array<Schema.String>;
|
|
151
|
+
readonly cwd: Schema.optional<Schema.NonEmptyString>;
|
|
152
|
+
readonly env: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
153
|
+
readonly handshakeTimeoutMs: Schema.optional<Schema.Int>;
|
|
154
|
+
readonly requestTimeoutMs: Schema.optional<Schema.Int>;
|
|
155
|
+
readonly queueCapacity: Schema.optional<Schema.Int>;
|
|
156
|
+
readonly maxFrameBytes: Schema.optional<Schema.Int>;
|
|
157
|
+
readonly maxOutboundFrameBytes: Schema.optional<Schema.Int>;
|
|
158
|
+
readonly maxStderrBytes: Schema.optional<Schema.Int>;
|
|
159
|
+
readonly maxTools: Schema.optional<Schema.Int>;
|
|
160
|
+
readonly maxToolNameBytes: Schema.optional<Schema.Int>;
|
|
161
|
+
readonly maxToolDocumentBytes: Schema.optional<Schema.Int>;
|
|
162
|
+
readonly maxCatalogPages: Schema.optional<Schema.Int>;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Authoritative decoder for a persisted Streamable HTTP MCP server entry.
|
|
166
|
+
*
|
|
167
|
+
* The schema requires a non-empty server name, an absolute `http:` or
|
|
168
|
+
* `https:` `url` without userinfo, and positive-integer limits. A bearer
|
|
169
|
+
* credential is never stored in the entry: `bearerTokenEnv` names the
|
|
170
|
+
* environment variable the host reads it from and turns into an
|
|
171
|
+
* {@link AuthProvider}.
|
|
172
|
+
*
|
|
173
|
+
* @category schemas
|
|
174
|
+
* @since 1.0.0-rc.1
|
|
175
|
+
*/
|
|
176
|
+
export declare const HttpConnectOptionsSchema: Schema.Struct<{
|
|
177
|
+
readonly server: Schema.NonEmptyString;
|
|
178
|
+
readonly url: Schema.String;
|
|
179
|
+
readonly bearerTokenEnv: Schema.optionalKey<Schema.String>;
|
|
180
|
+
readonly handshakeTimeoutMs: Schema.optional<Schema.Int>;
|
|
181
|
+
readonly requestTimeoutMs: Schema.optional<Schema.Int>;
|
|
182
|
+
readonly maxFrameBytes: Schema.optional<Schema.Int>;
|
|
183
|
+
readonly maxOutboundFrameBytes: Schema.optional<Schema.Int>;
|
|
184
|
+
readonly maxTools: Schema.optional<Schema.Int>;
|
|
185
|
+
readonly maxToolNameBytes: Schema.optional<Schema.Int>;
|
|
186
|
+
readonly maxToolDocumentBytes: Schema.optional<Schema.Int>;
|
|
187
|
+
readonly maxCatalogPages: Schema.optional<Schema.Int>;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Frozen identity disclosed to every MCP server during initialization.
|
|
191
|
+
*
|
|
192
|
+
* @category constants
|
|
193
|
+
* @since 1.0.0-rc.0
|
|
194
|
+
*/
|
|
195
|
+
export declare const clientInfo: {
|
|
196
|
+
readonly name: string;
|
|
197
|
+
readonly version: string;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* MCP revisions whose `tools/list` and `tools/call` shapes this client
|
|
201
|
+
* decodes. The frozen list always proposes `2025-06-18` first.
|
|
202
|
+
*
|
|
203
|
+
* @category constants
|
|
204
|
+
* @since 1.0.0-rc.0
|
|
205
|
+
*/
|
|
206
|
+
export declare const supportedProtocolVersions: ReadonlyArray<string>;
|
|
207
|
+
/**
|
|
208
|
+
* Default deadline for each MCP handshake request.
|
|
209
|
+
*
|
|
210
|
+
* @category constants
|
|
211
|
+
* @since 1.0.0-rc.0
|
|
212
|
+
*/
|
|
213
|
+
export declare const defaultHandshakeTimeoutMs = 10000;
|
|
214
|
+
/**
|
|
215
|
+
* Default deadline for each tool request.
|
|
216
|
+
*
|
|
217
|
+
* @category constants
|
|
218
|
+
* @since 1.0.0-rc.0
|
|
219
|
+
*/
|
|
220
|
+
export declare const defaultRequestTimeoutMs = 120000;
|
|
221
|
+
/**
|
|
222
|
+
* Default number of outbound frames allowed to wait in memory.
|
|
223
|
+
*
|
|
224
|
+
* @category constants
|
|
225
|
+
* @since 1.0.0-rc.0
|
|
226
|
+
*/
|
|
227
|
+
export declare const defaultQueueCapacity = 64;
|
|
228
|
+
/**
|
|
229
|
+
* Default maximum inbound JSON-RPC frame size.
|
|
230
|
+
*
|
|
231
|
+
* @category constants
|
|
232
|
+
* @since 1.0.0-rc.0
|
|
233
|
+
*/
|
|
234
|
+
export declare const defaultMaxFrameBytes: number;
|
|
235
|
+
/**
|
|
236
|
+
* Default maximum outbound JSON-RPC frame size.
|
|
237
|
+
*
|
|
238
|
+
* @category constants
|
|
239
|
+
* @since 1.0.0-rc.0
|
|
240
|
+
*/
|
|
241
|
+
export declare const defaultMaxOutboundFrameBytes: number;
|
|
242
|
+
/**
|
|
243
|
+
* Default maximum child-stderr tail retained for connection diagnostics.
|
|
244
|
+
*
|
|
245
|
+
* @category constants
|
|
246
|
+
* @since 1.0.0-rc.0
|
|
247
|
+
*/
|
|
248
|
+
export declare const defaultMaxStderrBytes = 2048;
|
|
249
|
+
/**
|
|
250
|
+
* Default maximum number of tools in a remote catalog.
|
|
251
|
+
*
|
|
252
|
+
* @category constants
|
|
253
|
+
* @since 1.0.0-rc.0
|
|
254
|
+
*/
|
|
255
|
+
export declare const defaultMaxTools = 256;
|
|
256
|
+
/**
|
|
257
|
+
* Default maximum UTF-8 byte length of one remote tool name.
|
|
258
|
+
*
|
|
259
|
+
* @category constants
|
|
260
|
+
* @since 1.0.0-rc.0
|
|
261
|
+
*/
|
|
262
|
+
export declare const defaultMaxToolNameBytes = 128;
|
|
263
|
+
/**
|
|
264
|
+
* Default maximum UTF-8 bytes of one tool's description plus its JSON-encoded
|
|
265
|
+
* `inputSchema`, the server-authored text a model reads for that tool.
|
|
266
|
+
*
|
|
267
|
+
* @category constants
|
|
268
|
+
* @since 1.0.0-rc.1
|
|
269
|
+
*/
|
|
270
|
+
export declare const defaultMaxToolDocumentBytes = 65536;
|
|
271
|
+
/**
|
|
272
|
+
* Default maximum number of remote catalog pages.
|
|
273
|
+
*
|
|
274
|
+
* @category constants
|
|
275
|
+
* @since 1.0.0-rc.0
|
|
276
|
+
*/
|
|
277
|
+
export declare const defaultMaxCatalogPages = 32;
|
|
278
|
+
/**
|
|
279
|
+
* Maximum nested JSON containers, including the JSON-RPC envelope. Fixed so
|
|
280
|
+
* accepted server schemas and values remain safe for recursive consumers.
|
|
281
|
+
*
|
|
282
|
+
* @category constants
|
|
283
|
+
* @since 1.0.0-rc.0
|
|
284
|
+
*/
|
|
285
|
+
export declare const maxJsonDepth = 128;
|
|
286
|
+
/**
|
|
287
|
+
* Connects to an MCP server over stdio (`command`) or Streamable HTTP (`url`),
|
|
288
|
+
* completes the `initialize` handshake, and fetches its tool catalog once, up
|
|
289
|
+
* front. Failed or interrupted setup closes its subprocess, I/O fibers, or
|
|
290
|
+
* HTTP session before returning to the caller; a successful session stays
|
|
291
|
+
* open until the caller scope closes.
|
|
292
|
+
*
|
|
293
|
+
* The tool catalog is a snapshot: a server that changes its tools after
|
|
294
|
+
* connecting (a `notifications/tools/list_changed` push) is not re-polled.
|
|
295
|
+
* {@link McpFlows} rebuilds by reconnecting to refresh.
|
|
296
|
+
* Catalog input schemas must declare `type: "object"`. A later tool result may
|
|
297
|
+
* omit `content` when it carries `structuredContent`; a declared output schema
|
|
298
|
+
* is enforced for the documented keyword subset.
|
|
299
|
+
*
|
|
300
|
+
* @category constructors
|
|
301
|
+
* @since 1.0.0-rc.0
|
|
302
|
+
*/
|
|
303
|
+
export declare const connect: <O extends ConnectOptions>(options: O) => Effect.Effect<McpClient, McpError, Requirements<O> | Scope.Scope>;
|
|
304
|
+
//# sourceMappingURL=McpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpClient.d.ts","sourceRoot":"","sources":["../../src/McpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,MAAM,EAAgB,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAEtF,OAAO,KAAK,aAAa,MAAM,6BAA6B,CAAA;AAG5D,OAAO,KAAK,cAAc,MAAM,8BAA8B,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,mFAAmF;IACnF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7C,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAC3D;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACxD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAChE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,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