@fractaal/pi-mcp 0.86.9 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +60 -5
- package/dist/auth-provider.d.ts +4 -0
- package/dist/auth-provider.d.ts.map +1 -1
- package/dist/auth-provider.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -5
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +117 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +153 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/input-schema.d.ts +7 -0
- package/dist/input-schema.d.ts.map +1 -0
- package/dist/input-schema.js +13 -0
- package/dist/input-schema.js.map +1 -0
- package/dist/naming.d.ts +18 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +29 -0
- package/dist/naming.js.map +1 -0
- package/dist/oauth/auth-provider.d.ts +52 -0
- package/dist/oauth/auth-provider.d.ts.map +1 -0
- package/dist/oauth/auth-provider.js +97 -0
- package/dist/oauth/auth-provider.js.map +1 -0
- package/dist/oauth/callback.d.ts.map +1 -1
- package/dist/oauth/callback.js +5 -1
- package/dist/oauth/callback.js.map +1 -1
- package/dist/oauth/client-settings.d.ts +107 -0
- package/dist/oauth/client-settings.d.ts.map +1 -0
- package/dist/oauth/client-settings.js +114 -0
- package/dist/oauth/client-settings.js.map +1 -0
- package/dist/oauth/discovery.d.ts +3 -0
- package/dist/oauth/discovery.d.ts.map +1 -1
- package/dist/oauth/discovery.js +9 -6
- package/dist/oauth/discovery.js.map +1 -1
- package/dist/oauth/errors.d.ts +10 -2
- package/dist/oauth/errors.d.ts.map +1 -1
- package/dist/oauth/errors.js +13 -1
- package/dist/oauth/errors.js.map +1 -1
- package/dist/oauth/flow.d.ts +14 -0
- package/dist/oauth/flow.d.ts.map +1 -1
- package/dist/oauth/flow.js +52 -15
- package/dist/oauth/flow.js.map +1 -1
- package/dist/oauth/index.d.ts +5 -1
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +4 -1
- package/dist/oauth/index.js.map +1 -1
- package/dist/oauth/loopback.d.ts +51 -0
- package/dist/oauth/loopback.d.ts.map +1 -0
- package/dist/oauth/loopback.js +98 -0
- package/dist/oauth/loopback.js.map +1 -0
- package/dist/oauth/sign-in.d.ts +73 -0
- package/dist/oauth/sign-in.d.ts.map +1 -0
- package/dist/oauth/sign-in.js +182 -0
- package/dist/oauth/sign-in.js.map +1 -0
- package/dist/oauth/types.d.ts +1 -0
- package/dist/oauth/types.d.ts.map +1 -1
- package/dist/oauth/types.js +9 -5
- package/dist/oauth/types.js.map +1 -1
- package/dist/output-limit.d.ts +24 -0
- package/dist/output-limit.d.ts.map +1 -0
- package/dist/output-limit.js +58 -0
- package/dist/output-limit.js.map +1 -0
- package/dist/protocol/content.d.ts +2 -1
- package/dist/protocol/content.d.ts.map +1 -1
- package/dist/protocol/content.js.map +1 -1
- package/dist/transports/lines.d.ts +34 -0
- package/dist/transports/lines.d.ts.map +1 -0
- package/dist/transports/lines.js +85 -0
- package/dist/transports/lines.js.map +1 -0
- package/dist/transports/pipe.d.ts +49 -0
- package/dist/transports/pipe.d.ts.map +1 -0
- package/dist/transports/pipe.js +96 -0
- package/dist/transports/pipe.js.map +1 -0
- package/dist/transports/stdio.d.ts +1 -4
- package/dist/transports/stdio.d.ts.map +1 -1
- package/dist/transports/stdio.js +20 -51
- package/dist/transports/stdio.js.map +1 -1
- package/dist/transports/streamable-http.d.ts +9 -2
- package/dist/transports/streamable-http.d.ts.map +1 -1
- package/dist/transports/streamable-http.js +105 -30
- package/dist/transports/streamable-http.js.map +1 -1
- package/dist/transports/transport.d.ts +9 -1
- package/dist/transports/transport.d.ts.map +1 -1
- package/dist/transports/transport.js.map +1 -1
- package/package.json +4 -5
- /package/{LICENSES → THIRD_PARTY_NOTICES}/modelcontextprotocol-typescript-sdk.txt +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.6.0] - 2026-11-06
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added `PipeTransport`, MCP's stdio transport over a program started by the caller through an `McpPipe` (`write`, `closeStdin`, `close`, `exited`), for example `@earendil-works/pi-env`'s `openProcess()` on another machine. `StdioTransport` and `PipeTransport` share the newline-delimited framing and the stderr tail.
|
|
8
|
+
- Added MCP OAuth sign-in in two halves (`@earendil-works/pi-mcp/oauth`), moved from pi's coding agent: `startMcpSignIn()` refreshes the stored tokens or returns the authorization URL, and `completeMcpSignIn()` exchanges the code later, possibly in another request with the same state store. The code comes from a loopback callback server (`listenForLoopbackSignIn()`, `waitForLoopbackSignIn()`), the application's own callback route, or a pasted redirect URL (`responseFromRedirectUrl()`). Client ID Metadata Documents (`clientMetadataDocuments`) and the client name are the caller's. Aborting a sign-in's `signal` also stops `startMcpSignIn()` while it waits for the refresh lock; a store's `withRefreshLock()` throws `McpRefreshLockBusyError` when another process holds the lock too long, which makes `startMcpSignIn()` skip the refresh, while any other lock failure fails the sign-in. Also added `createMcpAuthProvider()`, which refreshes tokens once across requests and, through `McpOAuthServerStore.withRefreshLock()`, across processes; its `redirectUrl` option names a redirect URI the application signs in with, so tokens from a Client ID Metadata Document that lists only an https callback route can be refreshed. Also added the `refreshOnly` option of `authorizeMcp()`, which refreshes without registering a client or replacing a pending authorization's `state` and PKCE verifier.
|
|
9
|
+
- Added helpers that let applications name and configure MCP tools like pi's coding agent, moved from it: `createMcpToolName()` (`mcp__<server>__<tool>`, sanitized, with a hash suffix for long or colliding names) and `mcpNamespace()`; `normalizeMcpInputSchema()`, which makes an input schema an object schema; `limitMcpContent()` and `MCP_OUTPUT_MAX_BYTES`, which cut model-facing text over 20KB in the middle and optionally save the full text through a caller's `McpOutputSaver`; and `validateMcpServerConfig()`, which validates one entry of the `mcpServers` configuration shape (stdio, Streamable HTTP, `oauth`, `enabled`, `description`, `timeout`), returns the entry tagged with its transport, and keeps the application's own fields for it to check afterwards. `isMcpServerOverride()` recognizes entries that only override a server defined elsewhere.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- The third-party licenses are in `THIRD_PARTY_NOTICES/`, renamed from `LICENSES/`, which Vite's license notices read as the package's license file, failing browser builds that bundle the package.
|
|
14
|
+
- Fixed Streamable HTTP `application/json` responses bypassing `maxMessageBytes`; oversized JSON responses are now cancelled and rejected like oversized SSE events ([#11335](https://github.com/earendil-works/pi/issues/11335))
|
|
15
|
+
- Fixed Streamable HTTP errors reading the whole HTTP error body; only the first 8 KiB kept in the error is read, and the rest is cancelled
|
|
16
|
+
- Fixed `OAuthCallbackServer.close()` waiting for minutes when the browser kept an unused connection open to the callback port, for example a preconnect. It now closes the remaining connections ([#11311](https://github.com/earendil-works/pi/issues/11311))
|
|
17
|
+
|
|
18
|
+
## [1.5.0] - 2026-11-02
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- README: the `AgentTool` wrapping example passes the MCP input schema as plain JSON Schema instead of through TypeBox's `Type.Unsafe`.
|
|
23
|
+
|
|
24
|
+
## [1.4.1] - 2026-10-24
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- OAuth metadata parsing and `startAuthorization()` now accept only `http:` and `https:` URLs. Before, a server could supply a `file:` or custom protocol authorization endpoint (for example `search-ms:`), which the platform URL handler would launch on sign-in.
|
|
29
|
+
- Fixed the excerpt of an HTTP error body in Streamable HTTP errors keeping the whole response body alive ([#9265](https://github.com/earendil-works/pi/issues/9265))
|
|
30
|
+
|
|
31
|
+
## [1.4.0] - 2026-10-21
|
|
32
|
+
|
|
33
|
+
## [1.3.0] - 2026-10-15
|
|
34
|
+
|
|
35
|
+
## [1.2.0] - 2026-10-12
|
|
36
|
+
|
|
37
|
+
### Breaking Changes
|
|
38
|
+
|
|
39
|
+
- Changed `CallToolResult.structuredContent` from `Record<string, unknown>` to `unknown`: `callTool()` now accepts any JSON value as structured content, including arrays and `null`, as MCP 2026-07-28 allows, instead of failing with "Invalid MCP tools/call structured content" ([#10416](https://github.com/earendil-works/pi/issues/10416))
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- Fixed `authorizeMcp()` exchanging an authorization code whose `iss` parameter could not be checked because no authorization server metadata was discovered. It now throws `OAuthIssuerMismatchError`, whose `expected` is `undefined` in that case (RFC 9207). Reported by [@AizenvoltPrime](https://github.com/AizenvoltPrime)
|
|
44
|
+
- Fixed `StreamableHttpTransport` retrying a request after an authorization refresh even though the caller had already cancelled it or it had timed out, so the server still executed it. `McpTransport.send()` now takes an optional `signal`, which `McpClient` aborts once a request settles ([#10598](https://github.com/earendil-works/pi/issues/10598))
|
|
45
|
+
|
|
46
|
+
## [1.1.0] - 2026-10-07
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- Added a `signal` option to `authorizeMcp()`, `registerClient()`, the token request functions, and the discovery functions, which aborts their requests. An aborted refresh no longer falls back to a new authorization ([#10565](https://github.com/earendil-works/pi/issues/10565))
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- Fixed `StreamableHttpTransport.close()` calling `AuthProvider.token()`, which could refresh tokens over the network before the session DELETE and delay closing; the DELETE now reuses the token of the last request ([#10565](https://github.com/earendil-works/pi/issues/10565))
|
|
55
|
+
|
|
3
56
|
## [0.86.9] - 2026-10-09
|
|
4
57
|
|
|
5
58
|
## [0.86.8] - 2026-10-09
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A small, standalone Model Context Protocol client. It does not depend on the official MCP SDK or other pi packages.
|
|
4
4
|
|
|
5
|
-
The package provides a transport-neutral client core, stdio and Streamable HTTP transports, and an in-memory testing transport.
|
|
5
|
+
The package provides a transport-neutral client core, stdio and Streamable HTTP transports, a stdio transport over a pipe to a program started elsewhere, and an in-memory testing transport.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
@@ -27,6 +27,24 @@ await client.close();
|
|
|
27
27
|
|
|
28
28
|
For a remote server, use `new StreamableHttpTransport({ url, headers })`. Fetch can be injected for proxying or custom networking.
|
|
29
29
|
|
|
30
|
+
An MCP transport owns framing and I/O. It delivers individual JSON-RPC messages to `McpClient`; the client owns request correlation, initialization, timeouts, cancellation, server requests, and protocol-level helpers.
|
|
31
|
+
|
|
32
|
+
### Stdio servers started elsewhere
|
|
33
|
+
|
|
34
|
+
`PipeTransport` speaks MCP's stdio framing over a program that something else starts, for example on another machine. `open` starts the program, connects its stdout and stderr to the given handlers, and returns an `McpPipe` (`write`, `closeStdin`, `close` to kill, and an `exited` promise). `@earendil-works/pi-env`'s `openProcess()` returns one, without an adapter:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { openProcess } from "@earendil-works/pi-env";
|
|
38
|
+
import { PipeTransport } from "@earendil-works/pi-mcp";
|
|
39
|
+
|
|
40
|
+
const transport = new PipeTransport({
|
|
41
|
+
open: (handlers) => openProcess(connection, { cwd, argv, ...handlers }),
|
|
42
|
+
});
|
|
43
|
+
await client.connect(transport);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Closing the transport closes the program's stdin and kills it if it has not exited after `closeTimeoutMs` (default 2000). The transport closes when the program ends.
|
|
47
|
+
|
|
30
48
|
### Tools for an LLM
|
|
31
49
|
|
|
32
50
|
`toLlmContent(result)` converts a `CallToolResult` to text and image content for a model, in the shape of `@earendil-works/pi-ai`'s `TextContent` and `ImageContent`. Text and images pass through, embedded text and image resources are unwrapped, and audio, resource links, and binary resources become short text placeholders. A result without content blocks but with `structuredContent` becomes its JSON.
|
|
@@ -36,7 +54,6 @@ Wrapping an MCP tool as a `pi-agent-core` `AgentTool`:
|
|
|
36
54
|
```typescript
|
|
37
55
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
38
56
|
import { toLlmContent } from "@earendil-works/pi-mcp";
|
|
39
|
-
import { Type } from "typebox";
|
|
40
57
|
|
|
41
58
|
const tools: AgentTool[] = (await client.listTools()).map((tool) => ({
|
|
42
59
|
// Providers allow at most 64 characters of [A-Za-z0-9_-].
|
|
@@ -44,7 +61,7 @@ const tools: AgentTool[] = (await client.listTools()).map((tool) => ({
|
|
|
44
61
|
label: tool.title ?? tool.name,
|
|
45
62
|
description: tool.description ?? tool.name,
|
|
46
63
|
// Providers require an object schema, and some reject one without `properties`.
|
|
47
|
-
parameters:
|
|
64
|
+
parameters: { ...tool.inputSchema, type: "object", properties: tool.inputSchema.properties ?? {} },
|
|
48
65
|
execute: async (_toolCallId, params, signal) => {
|
|
49
66
|
const result = await client.callTool(tool.name, params as Record<string, unknown>, { signal });
|
|
50
67
|
// MCP reports tool failures in the result instead of as a protocol error.
|
|
@@ -53,6 +70,8 @@ const tools: AgentTool[] = (await client.listTools()).map((tool) => ({
|
|
|
53
70
|
}));
|
|
54
71
|
```
|
|
55
72
|
|
|
73
|
+
For applications that name tools like pi's coding agent: `createMcpToolName(server, tool, isTaken)` builds `mcp__<server>__<tool>`, limited to the characters and the 64-character length providers accept, with a hash suffix for long names and for names `isTaken` reports as used by another tool. `mcpNamespace(server)` is the prefix of a server's tool names. `normalizeMcpInputSchema()` turns an input schema into an object schema with `properties`, and `limitMcpContent(content, saveOutput)` keeps model-facing text within `MCP_OUTPUT_MAX_BYTES` (20KB) by cutting its middle; `saveOutput`, when given, stores the full text and returns the path the model can read it from.
|
|
74
|
+
|
|
56
75
|
The [mcp-codemode example](https://github.com/earendil-works/pi/tree/main/packages/agent/examples/mcp-codemode) also forwards progress, passes `structuredContent` through, and lets `@earendil-works/pi-codemode` scripts call the tools.
|
|
57
76
|
|
|
58
77
|
### OAuth
|
|
@@ -109,9 +128,44 @@ await connected;
|
|
|
109
128
|
|
|
110
129
|
Inject `McpOAuthStateStore` into `McpOAuthProvider` for durable credentials. The package does not open a browser or choose where credentials are stored.
|
|
111
130
|
|
|
112
|
-
|
|
131
|
+
#### Sign-in in two halves
|
|
113
132
|
|
|
114
|
-
|
|
133
|
+
`startMcpSignIn()` and `completeMcpSignIn()` run the sign-in pi uses, split so the second half can run in another request with the same state store (an `McpOAuthServerStore`: a state store with a refresh lock). The caller picks the redirect URI: a loopback one, or an https callback route of its own. `startMcpSignIn()` first tries to refresh the stored tokens under the store's refresh lock, so never call it while holding that lock; its `redirect` result is plain data the application can persist until the response arrives. Pass `completeMcpSignIn()` the same options, including the redirect URI you chose (not `started.redirectUrl`, which may be a variant specific to the MCP server).
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { completeMcpSignIn, responseFromRedirectUrl, startMcpSignIn } from "@earendil-works/pi-mcp/oauth";
|
|
137
|
+
|
|
138
|
+
const signIn = { serverUrl, store, settings: {}, redirectUrl: "https://app.example/mcp/callback", clientName: "My app" };
|
|
139
|
+
const started = await startMcpSignIn(signIn);
|
|
140
|
+
if (started.kind === "redirect") {
|
|
141
|
+
// Send the browser to started.authorizationUrl; keep `started` until the response arrives.
|
|
142
|
+
// Later, a callback route builds { code, state, iss } from its query; a pasted URL goes through:
|
|
143
|
+
const response = responseFromRedirectUrl(pastedUrl, started);
|
|
144
|
+
await completeMcpSignIn({ ...signIn, authorization: started, response });
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
For a browser on the same machine, `listenForLoopbackSignIn()` starts a loopback callback server and returns its redirect URI, and `waitForLoopbackSignIn()` waits for the response on it or for a pasted redirect URL. `clientMetadataDocuments` lets authorization servers that support Client ID Metadata Documents identify the application by a document it publishes instead of registering a client. `createMcpAuthProvider()` is the matching `AuthProvider` for connections: it refreshes the stored tokens and throws `McpOAuthAuthorizationRequiredError` when the user has to sign in.
|
|
149
|
+
|
|
150
|
+
The OAuth implementation is adapted from the MIT-licensed Model Context Protocol TypeScript SDK v1.29.0. Its license is included under `THIRD_PARTY_NOTICES/`.
|
|
151
|
+
|
|
152
|
+
### Configuration
|
|
153
|
+
|
|
154
|
+
`validateMcpServerConfig(name, entry, options)` validates one entry of the `mcpServers` shape that MCP clients share: stdio servers (`command`, `args`, `env`, `cwd`), Streamable HTTP servers (`url`, `headers`, `oauth`), and `enabled`, `description`, and `timeout`. It returns `{ kind: "stdio" | "http", config }` or `{ kind: "invalid", error }`. Fields it does not know stay in `config`, typed `unknown`, for the application to check afterwards, depending on `kind` where it matters. Resolving `${VAR}` references and relative paths is left to the application. `oauth.clientRegistration: "cimd"` is accepted only with `options.checkMetadataDocumentCallback`, which checks that the application's Client ID Metadata Documents list the callback.
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { validateMcpServerConfig } from "@earendil-works/pi-mcp";
|
|
158
|
+
|
|
159
|
+
for (const [name, entry] of Object.entries(file.mcpServers)) {
|
|
160
|
+
const result = validateMcpServerConfig(name, entry);
|
|
161
|
+
if (result.kind === "invalid") errors.push(result.error);
|
|
162
|
+
else if (result.config.shared !== undefined && typeof result.config.shared !== "boolean") {
|
|
163
|
+
errors.push(`server "${name}": shared must be a boolean`);
|
|
164
|
+
} else servers.set(name, result);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`isMcpServerOverride(entry)` is true for entries without `command`, `url`, or `type`, which applications treat as overriding a few fields of a server defined in another file.
|
|
115
169
|
|
|
116
170
|
## Supported protocol surface
|
|
117
171
|
|
|
@@ -124,6 +178,7 @@ An MCP transport owns framing and I/O. It delivers individual JSON-RPC messages
|
|
|
124
178
|
- request cancellation
|
|
125
179
|
- Streamable HTTP sessions, the server-to-client GET stream with reconnection, and resumption of dropped response streams with `Last-Event-ID`
|
|
126
180
|
- stdio shutdown per the spec (close stdin, then SIGTERM, then SIGKILL), applied to the server's whole process group
|
|
181
|
+
- stdio over a caller-provided pipe (`PipeTransport`)
|
|
127
182
|
- server `ping` and `roots/list` requests
|
|
128
183
|
- logging and tool-list-change notifications through the generic notification API
|
|
129
184
|
- OAuth protected-resource and authorization-server discovery
|
package/dist/auth-provider.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export interface UnauthorizedContext {
|
|
|
9
9
|
}
|
|
10
10
|
/** Supplies bearer tokens to an MCP HTTP transport and may refresh them after a 401 response. */
|
|
11
11
|
export interface AuthProvider {
|
|
12
|
+
/**
|
|
13
|
+
* Token for the next request. May refresh it over the network first, so the transport calls it only
|
|
14
|
+
* before requests whose answer it waits for. Closing a session reuses the token of the last request.
|
|
15
|
+
*/
|
|
12
16
|
token(): Promise<string | undefined>;
|
|
13
17
|
onUnauthorized?(context: UnauthorizedContext): Promise<void>;
|
|
14
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEtF,MAAM,WAAW,mBAAmB;IACnC,wFAAwF;IACxF,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,GAAG,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;IAChB,+HAA+H;IAC/H,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC5B,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACrC,cAAc,CAAC,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D"}
|
|
1
|
+
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEtF,MAAM,WAAW,mBAAmB;IACnC,wFAAwF;IACxF,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,GAAG,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;IAChB,+HAA+H;IAC/H,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACrC,cAAc,CAAC,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"","sourcesContent":["export type McpFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;\n\nexport interface UnauthorizedContext {\n\t/** The 401 response, or a 403 response whose challenge reports `insufficient_scope`. */\n\tresponse: Response;\n\tserverUrl: URL;\n\tfetch: McpFetch;\n\t/** Access token the rejected request carried, if any. A different current token means another request already refreshed it. */\n\ttoken?: string;\n}\n\n/** Supplies bearer tokens to an MCP HTTP transport and may refresh them after a 401 response. */\nexport interface AuthProvider {\n\ttoken(): Promise<string | undefined>;\n\tonUnauthorized?(context: UnauthorizedContext): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"","sourcesContent":["export type McpFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;\n\nexport interface UnauthorizedContext {\n\t/** The 401 response, or a 403 response whose challenge reports `insufficient_scope`. */\n\tresponse: Response;\n\tserverUrl: URL;\n\tfetch: McpFetch;\n\t/** Access token the rejected request carried, if any. A different current token means another request already refreshed it. */\n\ttoken?: string;\n}\n\n/** Supplies bearer tokens to an MCP HTTP transport and may refresh them after a 401 response. */\nexport interface AuthProvider {\n\t/**\n\t * Token for the next request. May refresh it over the network first, so the transport calls it only\n\t * before requests whose answer it waits for. Closing a session reuses the token of the last request.\n\t */\n\ttoken(): Promise<string | undefined>;\n\tonUnauthorized?(context: UnauthorizedContext): Promise<void>;\n}\n"]}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAkB5D,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAErB,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,kBAAkB,EAEvB,KAAK,wBAAwB,EAC7B,KAAK,IAAI,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK9D,KAAK,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAClE,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AACtD,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAC5C,KAAK,aAAa,GAAG,MAAM,IAAI,CAAC;AAChC,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAExG,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACvD,YAAY,CAAC,EAAE,kBAAkB,CAA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nE,qBAAqB,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAQxF;IAED,4DAA4D;IACtD,yBAAyB,CAC9B,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,2BAA2B,CAAC,CAStC;IAEK,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE5F;YAEa,QAAQ;IAetB,6CAA6C;YAC/B,OAAO;IAqBf,QAAQ,CACb,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAIzB;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAM3B;YAEa,eAAe;YAkDf,cAAc;IAY5B,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,cAAc;YAWR,aAAa;IAgC3B,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,oBAAoB;IAI5B,0GAA0G;IAC1G,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,yBAAyB;CAGjC"}
|
package/dist/client.js
CHANGED
|
@@ -57,14 +57,14 @@ function validateReadResourceResult(value) {
|
|
|
57
57
|
}
|
|
58
58
|
return value;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* `content` is required by the spec, but servers that only return `structuredContent` omit it (the SDK defaults it too).
|
|
62
|
+
* `structuredContent` may be any JSON value, as MCP 2026-07-28 allows.
|
|
63
|
+
*/
|
|
61
64
|
function validateCallToolResult(value) {
|
|
62
65
|
if (!isObject(value) || (value.content !== undefined && !Array.isArray(value.content))) {
|
|
63
66
|
throw new McpError(JSON_RPC_ERROR_CODES.invalidRequest, "Invalid MCP tools/call result");
|
|
64
67
|
}
|
|
65
|
-
if (value.structuredContent !== undefined && !isObject(value.structuredContent)) {
|
|
66
|
-
throw new McpError(JSON_RPC_ERROR_CODES.invalidRequest, "Invalid MCP tools/call structured content");
|
|
67
|
-
}
|
|
68
68
|
return (value.content === undefined ? { ...value, content: [] } : value);
|
|
69
69
|
}
|
|
70
70
|
export class McpClient {
|
|
@@ -265,6 +265,7 @@ export class McpClient {
|
|
|
265
265
|
signal: options.signal,
|
|
266
266
|
// The spec forbids cancelling `initialize`.
|
|
267
267
|
onAbort: () => this.cancelPending(id, new McpAbortError(), method !== "initialize", String(options.signal?.reason ?? "Aborted")),
|
|
268
|
+
sendController: new AbortController(),
|
|
268
269
|
cancellable: method !== "initialize",
|
|
269
270
|
onProgress: options.onProgress,
|
|
270
271
|
progressToken,
|
|
@@ -274,7 +275,9 @@ export class McpClient {
|
|
|
274
275
|
this.progressRequests.set(progressToken, id);
|
|
275
276
|
options.signal?.addEventListener("abort", entry.onAbort, { once: true });
|
|
276
277
|
this.armTimeout(id, entry);
|
|
277
|
-
transport
|
|
278
|
+
transport
|
|
279
|
+
.send(message, { signal: entry.sendController.signal })
|
|
280
|
+
.catch((error) => this.cancelPending(id, error, false));
|
|
278
281
|
});
|
|
279
282
|
}
|
|
280
283
|
async notifyInternal(method, params, allowConnecting) {
|
|
@@ -415,6 +418,7 @@ export class McpClient {
|
|
|
415
418
|
if (entry.progressToken !== undefined)
|
|
416
419
|
this.progressRequests.delete(entry.progressToken);
|
|
417
420
|
entry.signal?.removeEventListener("abort", entry.onAbort);
|
|
421
|
+
entry.sendController.abort();
|
|
418
422
|
}
|
|
419
423
|
rejectPending(error) {
|
|
420
424
|
for (const [id, entry] of this.p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C,OAAO,aAAa,EAAE,CAAC;gBACxB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;IAEO,SAAS,CAAC,KAAc;QAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,cAAc;YAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC;IAEO,yBAAyB;QAChC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;IAC3D,CAAC;CACD","sourcesContent":["import type { CallToolResult } from \"./protocol/content.ts\";\nimport {\n\tisJsonRpcId,\n\tisJsonRpcNotification,\n\tisJsonRpcRequest,\n\tisJsonRpcResponse,\n\tisObject,\n\tJSON_RPC_ERROR_CODES,\n\ttype JsonRpcId,\n\ttype JsonRpcMessage,\n\ttype JsonRpcRequest,\n\ttype JsonRpcResponse,\n\tMcpAbortError,\n\tMcpConnectionClosedError,\n\tMcpError,\n\tMcpTimeoutError,\n\ttoError,\n} from \"./protocol/jsonrpc.ts\";\nimport {\n\ttype ClientCapabilities,\n\ttype Implementation,\n\ttype InitializeResult,\n\tLATEST_PROTOCOL_VERSION,\n\ttype ListResourcesResult,\n\ttype ListResourceTemplatesResult,\n\ttype ProgressNotification,\n\ttype ReadResourceResult,\n\ttype Resource,\n\ttype ResourceTemplate,\n\ttype Root,\n\ttype ServerCapabilities,\n\tSUPPORTED_PROTOCOL_VERSIONS,\n\ttype SupportedProtocolVersion,\n\ttype Tool,\n} from \"./protocol/types.ts\";\nimport type { McpTransport } from \"./transports/transport.ts\";\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\nconst MAX_LIST_PAGES = 1_000;\n\ntype ClientState = \"idle\" | \"connecting\" | \"connected\" | \"closed\";\ntype NotificationListener = (params: unknown) => void;\ntype ErrorListener = (error: Error) => void;\ntype CloseListener = () => void;\ntype RequestHandler = (params: unknown, context: { signal: AbortSignal }) => unknown | Promise<unknown>;\n\nexport interface McpClientOptions extends Implementation {\n\tcapabilities?: ClientCapabilities;\n\tprotocolVersion?: SupportedProtocolVersion;\n\trequestTimeoutMs?: number;\n\troots?: readonly Root[] | (() => readonly Root[] | Promise<readonly Root[]>);\n}\n\nexport interface McpRequestOptions {\n\tsignal?: AbortSignal;\n\ttimeoutMs?: number;\n\tonProgress?: (progress: ProgressNotification) => void;\n}\n\ninterface PendingRequest {\n\tresolve: (value: unknown) => void;\n\treject: (reason: unknown) => void;\n\ttimeoutMs: number;\n\ttimer: ReturnType<typeof setTimeout> | undefined;\n\tsignal: AbortSignal | undefined;\n\tonAbort: () => void;\n\tcancellable: boolean;\n\tonProgress: ((progress: ProgressNotification) => void) | undefined;\n\tprogressToken: JsonRpcId | undefined;\n}\n\nfunction validateInitializeResult(value: unknown): InitializeResult {\n\tif (\n\t\t!isObject(value) ||\n\t\ttypeof value.protocolVersion !== \"string\" ||\n\t\t!isObject(value.capabilities) ||\n\t\t!isObject(value.serverInfo) ||\n\t\ttypeof value.serverInfo.name !== \"string\" ||\n\t\ttypeof value.serverInfo.version !== \"string\" ||\n\t\t(value.instructions !== undefined && typeof value.instructions !== \"string\")\n\t) {\n\t\tthrow new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Invalid MCP initialize result\");\n\t}\n\treturn value as unknown as InitializeResult;\n}\n\nfunction invalid(message: string): McpError {\n\treturn new McpError(JSON_RPC_ERROR_CODES.invalidRequest, message);\n}\n\n/** One page of a paginated list: the items under `key`, each checked by `isItem`. */\nfunction validateListPage(\n\tmethod: string,\n\tkey: string,\n\tvalue: unknown,\n\tisItem: (item: Record<string, unknown>) => boolean,\n): { items: Record<string, unknown>[]; nextCursor?: string } {\n\tconst items = isObject(value) ? value[key] : undefined;\n\tif (!isObject(value) || !Array.isArray(items)) throw invalid(`Invalid MCP ${method} result`);\n\tfor (const item of items) {\n\t\tif (!isObject(item) || !isItem(item)) throw invalid(`Invalid entry in MCP ${method} result`);\n\t}\n\t// Some servers end pagination with `null` or `\"\"` instead of omitting the cursor.\n\tconst nextCursor = value.nextCursor === null || value.nextCursor === \"\" ? undefined : value.nextCursor;\n\tif (nextCursor !== undefined && typeof nextCursor !== \"string\") throw invalid(`Invalid MCP ${method} cursor`);\n\treturn { items, ...(nextCursor === undefined ? {} : { nextCursor }) };\n}\n\nconst isTool = (tool: Record<string, unknown>) => typeof tool.name === \"string\" && isObject(tool.inputSchema);\n// `name` is required by the spec, but some servers omit it; the URI stands in.\nconst isResource = (resource: Record<string, unknown>) =>\n\ttypeof resource.uri === \"string\" && (resource.name === undefined || typeof resource.name === \"string\");\nconst isResourceTemplate = (template: Record<string, unknown>) =>\n\ttypeof template.uriTemplate === \"string\" && (template.name === undefined || typeof template.name === \"string\");\n\nfunction toResource(item: Record<string, unknown>): Resource {\n\treturn { ...item, name: item.name ?? item.uri } as Resource;\n}\n\nfunction toResourceTemplate(item: Record<string, unknown>): ResourceTemplate {\n\treturn { ...item, name: item.name ?? item.uriTemplate } as ResourceTemplate;\n}\n\nfunction pageCursor(page: { nextCursor?: string }): { nextCursor?: string } {\n\treturn page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor };\n}\n\nfunction validateReadResourceResult(value: unknown): ReadResourceResult {\n\tif (!isObject(value) || !Array.isArray(value.contents)) throw invalid(\"Invalid MCP resources/read result\");\n\tfor (const contents of value.contents) {\n\t\tif (\n\t\t\t!isObject(contents) ||\n\t\t\ttypeof contents.uri !== \"string\" ||\n\t\t\t(typeof contents.text !== \"string\" && typeof contents.blob !== \"string\")\n\t\t) {\n\t\t\tthrow invalid(\"Invalid contents in MCP resources/read result\");\n\t\t}\n\t}\n\treturn value as unknown as ReadResourceResult;\n}\n\n/** `content` is required by the spec, but servers that only return `structuredContent` omit it (the SDK defaults it too). */\nfunction validateCallToolResult(value: unknown): CallToolResult {\n\tif (!isObject(value) || (value.content !== undefined && !Array.isArray(value.content))) {\n\t\tthrow new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Invalid MCP tools/call result\");\n\t}\n\tif (value.structuredContent !== undefined && !isObject(value.structuredContent)) {\n\t\tthrow new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Invalid MCP tools/call structured content\");\n\t}\n\treturn (value.content === undefined ? { ...value, content: [] } : value) as unknown as CallToolResult;\n}\n\nexport class McpClient {\n\treadonly options: Readonly<McpClientOptions>;\n\tprivate state: ClientState = \"idle\";\n\tprivate transport: McpTransport | undefined;\n\tprivate nextRequestId = 1;\n\tprivate serverInfoValue: Implementation | undefined;\n\tprivate serverCapabilitiesValue: ServerCapabilities | undefined;\n\tprivate instructionsValue: string | undefined;\n\tprivate protocolVersionValue: string | undefined;\n\tprivate pending = new Map<JsonRpcId, PendingRequest>();\n\tprivate progressRequests = new Map<JsonRpcId, JsonRpcId>();\n\tprivate incoming = new Map<JsonRpcId, AbortController>();\n\tprivate requestHandlers = new Map<string, RequestHandler>();\n\tprivate notificationListeners = new Map<string, Set<NotificationListener>>();\n\tprivate errorListeners = new Set<ErrorListener>();\n\tprivate closeListeners = new Set<CloseListener>();\n\tprivate disposers: (() => void)[] = [];\n\n\tconstructor(options: McpClientOptions) {\n\t\tthis.options = Object.freeze({ ...options });\n\t\tthis.requestHandlers.set(\"ping\", () => ({}));\n\t\tconst roots = options.roots;\n\t\tif (roots) {\n\t\t\tthis.requestHandlers.set(\"roots/list\", async () => ({\n\t\t\t\troots: [...(typeof roots === \"function\" ? await roots() : roots)],\n\t\t\t}));\n\t\t}\n\t}\n\n\tget connectionState(): ClientState {\n\t\treturn this.state;\n\t}\n\n\tget serverInfo(): Implementation | undefined {\n\t\treturn this.serverInfoValue;\n\t}\n\n\tget serverCapabilities(): ServerCapabilities | undefined {\n\t\treturn this.serverCapabilitiesValue;\n\t}\n\n\tget instructions(): string | undefined {\n\t\treturn this.instructionsValue;\n\t}\n\n\tget protocolVersion(): string | undefined {\n\t\treturn this.protocolVersionValue;\n\t}\n\n\tasync connect(transport: McpTransport): Promise<InitializeResult> {\n\t\tif (this.state !== \"idle\") throw new Error(`Cannot connect MCP client in ${this.state} state`);\n\t\tthis.state = \"connecting\";\n\t\tthis.transport = transport;\n\t\tthis.disposers = [\n\t\t\ttransport.onMessage((message) => this.handleMessage(message)),\n\t\t\t// Transport errors are reported only. Pending requests fail when the transport closes.\n\t\t\ttransport.onError((error) => this.emitError(error)),\n\t\t\ttransport.onClose(() => this.handleTransportClose()),\n\t\t];\n\n\t\ttry {\n\t\t\tawait transport.start();\n\t\t\tconst capabilities: ClientCapabilities = { ...this.options.capabilities };\n\t\t\tif (this.options.roots && capabilities.roots === undefined) capabilities.roots = {};\n\t\t\tconst result = validateInitializeResult(\n\t\t\t\tawait this.requestInternal(\n\t\t\t\t\t\"initialize\",\n\t\t\t\t\t{\n\t\t\t\t\t\tprotocolVersion: this.options.protocolVersion ?? LATEST_PROTOCOL_VERSION,\n\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t\tclientInfo: {\n\t\t\t\t\t\t\tname: this.options.name,\n\t\t\t\t\t\t\tversion: this.options.version,\n\t\t\t\t\t\t\t...(this.options.title === undefined ? {} : { title: this.options.title }),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{},\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (!(SUPPORTED_PROTOCOL_VERSIONS as readonly string[]).includes(result.protocolVersion)) {\n\t\t\t\tthrow new Error(`MCP server selected unsupported protocol version ${result.protocolVersion}`);\n\t\t\t}\n\t\t\tthis.protocolVersionValue = result.protocolVersion;\n\t\t\tthis.serverInfoValue = result.serverInfo;\n\t\t\tthis.serverCapabilitiesValue = result.capabilities;\n\t\t\tthis.instructionsValue = result.instructions;\n\t\t\ttransport.setProtocolVersion?.(result.protocolVersion);\n\t\t\tawait this.notifyInternal(\"notifications/initialized\", undefined, true);\n\t\t\tthis.state = \"connected\";\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait this.close().catch(() => {});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\trequest<Result = unknown>(\n\t\tmethod: string,\n\t\tparams?: Record<string, unknown>,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<Result> {\n\t\treturn this.requestInternal(method, params, options, false) as Promise<Result>;\n\t}\n\n\tnotify(method: string, params?: Record<string, unknown>): Promise<void> {\n\t\treturn this.notifyInternal(method, params, false);\n\t}\n\n\tsetRequestHandler(method: string, handler: RequestHandler): () => void {\n\t\tthis.requestHandlers.set(method, handler);\n\t\treturn () => {\n\t\t\tif (this.requestHandlers.get(method) === handler) this.requestHandlers.delete(method);\n\t\t};\n\t}\n\n\tonNotification(method: string, listener: NotificationListener): () => void {\n\t\tconst listeners = this.notificationListeners.get(method) ?? new Set<NotificationListener>();\n\t\tthis.notificationListeners.set(method, listeners);\n\t\tlisteners.add(listener);\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0) this.notificationListeners.delete(method);\n\t\t};\n\t}\n\n\tonError(listener: ErrorListener): () => void {\n\t\tthis.errorListeners.add(listener);\n\t\treturn () => this.errorListeners.delete(listener);\n\t}\n\n\t/** Called once when the connection closes, whether the transport dropped or `close()` was called. */\n\tonClose(listener: CloseListener): () => void {\n\t\tthis.closeListeners.add(listener);\n\t\treturn () => this.closeListeners.delete(listener);\n\t}\n\n\tasync ping(options: McpRequestOptions = {}): Promise<void> {\n\t\tawait this.request(\"ping\", undefined, options);\n\t}\n\n\tasync listTools(options: McpRequestOptions = {}): Promise<Tool[]> {\n\t\treturn (await this.listAll(\"tools/list\", \"tools\", isTool, options)) as unknown as Tool[];\n\t}\n\n\t/** Every resource, following `nextCursor` through all pages. */\n\tasync listResources(options: McpRequestOptions = {}): Promise<Resource[]> {\n\t\treturn (await this.listAll(\"resources/list\", \"resources\", isResource, options)).map(toResource);\n\t}\n\n\t/** One page of resources, starting at `cursor`. */\n\tasync listResourcesPage(cursor?: string, options: McpRequestOptions = {}): Promise<ListResourcesResult> {\n\t\tconst page = await this.listPage(\"resources/list\", \"resources\", isResource, cursor, options);\n\t\treturn { resources: page.items.map(toResource), ...pageCursor(page) };\n\t}\n\n\t/** Every resource template, following `nextCursor` through all pages. */\n\tasync listResourceTemplates(options: McpRequestOptions = {}): Promise<ResourceTemplate[]> {\n\t\tconst templates = await this.listAll(\n\t\t\t\"resources/templates/list\",\n\t\t\t\"resourceTemplates\",\n\t\t\tisResourceTemplate,\n\t\t\toptions,\n\t\t);\n\t\treturn templates.map(toResourceTemplate);\n\t}\n\n\t/** One page of resource templates, starting at `cursor`. */\n\tasync listResourceTemplatesPage(\n\t\tcursor?: string,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<ListResourceTemplatesResult> {\n\t\tconst page = await this.listPage(\n\t\t\t\"resources/templates/list\",\n\t\t\t\"resourceTemplates\",\n\t\t\tisResourceTemplate,\n\t\t\tcursor,\n\t\t\toptions,\n\t\t);\n\t\treturn { resourceTemplates: page.items.map(toResourceTemplate), ...pageCursor(page) };\n\t}\n\n\tasync readResource(uri: string, options: McpRequestOptions = {}): Promise<ReadResourceResult> {\n\t\treturn validateReadResourceResult(await this.request(\"resources/read\", { uri }, options));\n\t}\n\n\tprivate async listPage(\n\t\tmethod: string,\n\t\tkey: string,\n\t\tisItem: (item: Record<string, unknown>) => boolean,\n\t\tcursor: string | undefined,\n\t\toptions: McpRequestOptions,\n\t): Promise<{ items: Record<string, unknown>[]; nextCursor?: string }> {\n\t\treturn validateListPage(\n\t\t\tmethod,\n\t\t\tkey,\n\t\t\tawait this.request(method, cursor === undefined ? undefined : { cursor }, options),\n\t\t\tisItem,\n\t\t);\n\t}\n\n\t/** Every item of a paginated list method. */\n\tprivate async listAll(\n\t\tmethod: string,\n\t\tkey: string,\n\t\tisItem: (item: Record<string, unknown>) => boolean,\n\t\toptions: McpRequestOptions,\n\t): Promise<Record<string, unknown>[]> {\n\t\tconst items: Record<string, unknown>[] = [];\n\t\tconst cursors = new Set<string>();\n\t\tlet cursor: string | undefined;\n\t\tfor (let pageNumber = 0; pageNumber < MAX_LIST_PAGES; pageNumber++) {\n\t\t\tconst page = await this.listPage(method, key, isItem, cursor, options);\n\t\t\titems.push(...page.items);\n\t\t\tif (page.nextCursor === undefined) return items;\n\t\t\tif (cursors.has(page.nextCursor))\n\t\t\t\tthrow new Error(`MCP ${method} returned duplicate cursor: ${page.nextCursor}`);\n\t\t\tcursors.add(page.nextCursor);\n\t\t\tcursor = page.nextCursor;\n\t\t}\n\t\tthrow new Error(`MCP ${method} exceeded ${MAX_LIST_PAGES} pages`);\n\t}\n\n\tasync callTool(\n\t\tname: string,\n\t\targs?: Record<string, unknown>,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<CallToolResult> {\n\t\treturn validateCallToolResult(\n\t\t\tawait this.request(\"tools/call\", { name, ...(args === undefined ? {} : { arguments: args }) }, options),\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\tconst transport = this.transport;\n\t\tthis.transport = undefined;\n\t\tthis.disposeTransportListeners();\n\t\tthis.markClosed(new McpConnectionClosedError());\n\t\tawait transport?.close();\n\t}\n\n\tprivate async requestInternal(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown> | undefined,\n\t\toptions: McpRequestOptions,\n\t\tallowConnecting: boolean,\n\t): Promise<unknown> {\n\t\tconst transport = this.requireTransport(allowConnecting);\n\t\tif (options.signal?.aborted) throw new McpAbortError();\n\t\tconst id = this.nextRequestId++;\n\t\tconst progressToken = options.onProgress ? id : undefined;\n\t\tconst requestParams =\n\t\t\tprogressToken === undefined\n\t\t\t\t? params\n\t\t\t\t: { ...params, _meta: { ...(isObject(params?._meta) ? params._meta : {}), progressToken } };\n\t\tconst message: JsonRpcRequest = {\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tid,\n\t\t\tmethod,\n\t\t\t...(requestParams === undefined ? {} : { params: requestParams }),\n\t\t};\n\t\treturn new Promise<unknown>((resolve, reject) => {\n\t\t\tconst entry: PendingRequest = {\n\t\t\t\tresolve,\n\t\t\t\treject,\n\t\t\t\ttimeoutMs: options.timeoutMs ?? this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,\n\t\t\t\ttimer: undefined,\n\t\t\t\tsignal: options.signal,\n\t\t\t\t// The spec forbids cancelling `initialize`.\n\t\t\t\tonAbort: () =>\n\t\t\t\t\tthis.cancelPending(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tnew McpAbortError(),\n\t\t\t\t\t\tmethod !== \"initialize\",\n\t\t\t\t\t\tString(options.signal?.reason ?? \"Aborted\"),\n\t\t\t\t\t),\n\t\t\t\tcancellable: method !== \"initialize\",\n\t\t\t\tonProgress: options.onProgress,\n\t\t\t\tprogressToken,\n\t\t\t};\n\t\t\tthis.pending.set(id, entry);\n\t\t\tif (progressToken !== undefined) this.progressRequests.set(progressToken, id);\n\t\t\toptions.signal?.addEventListener(\"abort\", entry.onAbort, { once: true });\n\t\t\tthis.armTimeout(id, entry);\n\t\t\ttransport.send(message).catch((error) => this.cancelPending(id, error, false));\n\t\t});\n\t}\n\n\tprivate async notifyInternal(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown> | undefined,\n\t\tallowConnecting: boolean,\n\t): Promise<void> {\n\t\tawait this.requireTransport(allowConnecting).send({\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tmethod,\n\t\t\t...(params === undefined ? {} : { params }),\n\t\t});\n\t}\n\n\tprivate requireTransport(allowConnecting: boolean): McpTransport {\n\t\tif (this.transport && (this.state === \"connected\" || (allowConnecting && this.state === \"connecting\"))) {\n\t\t\treturn this.transport;\n\t\t}\n\t\tthrow new McpConnectionClosedError(`MCP client is ${this.state}`);\n\t}\n\n\tprivate handleMessage(message: JsonRpcMessage): void {\n\t\tif (isJsonRpcResponse(message)) {\n\t\t\tthis.handleResponse(message);\n\t\t\treturn;\n\t\t}\n\t\tif (isJsonRpcRequest(message)) {\n\t\t\tvoid this.handleRequest(message);\n\t\t\treturn;\n\t\t}\n\t\tif (isJsonRpcNotification(message)) {\n\t\t\tthis.handleNotification(message.method, message.params);\n\t\t\treturn;\n\t\t}\n\t\tthis.emitError(new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Received invalid JSON-RPC message\"));\n\t}\n\n\tprivate handleResponse(message: JsonRpcResponse): void {\n\t\tconst entry = this.pending.get(message.id);\n\t\tif (!entry) {\n\t\t\tthis.emitError(new Error(`Received response for unknown MCP request ${String(message.id)}`));\n\t\t\treturn;\n\t\t}\n\t\tthis.removePending(message.id, entry);\n\t\tif (\"error\" in message) entry.reject(new McpError(message.error.code, message.error.message, message.error.data));\n\t\telse entry.resolve(message.result);\n\t}\n\n\tprivate async handleRequest(message: JsonRpcRequest): Promise<void> {\n\t\tconst transport = this.transport;\n\t\tif (!transport) return;\n\t\tconst handler = this.requestHandlers.get(message.method);\n\t\tif (!handler) {\n\t\t\tawait transport\n\t\t\t\t.send({\n\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\tid: message.id,\n\t\t\t\t\terror: { code: JSON_RPC_ERROR_CODES.methodNotFound, message: `Method not found: ${message.method}` },\n\t\t\t\t})\n\t\t\t\t.catch((error) => this.emitError(error));\n\t\t\treturn;\n\t\t}\n\t\tconst controller = new AbortController();\n\t\tthis.incoming.set(message.id, controller);\n\t\ttry {\n\t\t\tconst result = await handler(message.params, { signal: controller.signal });\n\t\t\tawait transport.send({ jsonrpc: \"2.0\", id: message.id, result: result ?? {} });\n\t\t} catch (error) {\n\t\t\tconst responseError =\n\t\t\t\terror instanceof McpError\n\t\t\t\t\t? { code: error.code, message: error.message, data: error.data }\n\t\t\t\t\t: { code: JSON_RPC_ERROR_CODES.internalError, message: toError(error).message };\n\t\t\tawait transport\n\t\t\t\t.send({ jsonrpc: \"2.0\", id: message.id, error: responseError })\n\t\t\t\t.catch((sendError) => this.emitError(sendError));\n\t\t} finally {\n\t\t\tthis.incoming.delete(message.id);\n\t\t}\n\t}\n\n\tprivate handleNotification(method: string, params: unknown): void {\n\t\tif (method === \"notifications/progress\") this.handleProgress(params);\n\t\telse if (method === \"notifications/cancelled\") this.handleCancelled(params);\n\t\tfor (const listener of this.notificationListeners.get(method) ?? []) {\n\t\t\ttry {\n\t\t\t\tlistener(params);\n\t\t\t} catch (error) {\n\t\t\t\tthis.emitError(error);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleProgress(params: unknown): void {\n\t\tif (!isObject(params) || !isJsonRpcId(params.progressToken) || typeof params.progress !== \"number\") return;\n\t\tconst requestId = this.progressRequests.get(params.progressToken);\n\t\tconst entry = requestId === undefined ? undefined : this.pending.get(requestId);\n\t\tif (requestId === undefined || !entry) return;\n\t\tthis.armTimeout(requestId, entry);\n\t\ttry {\n\t\t\tentry.onProgress?.(params as unknown as ProgressNotification);\n\t\t} catch (error) {\n\t\t\tthis.emitError(error);\n\t\t}\n\t}\n\n\tprivate handleCancelled(params: unknown): void {\n\t\tif (isObject(params) && isJsonRpcId(params.requestId)) this.incoming.get(params.requestId)?.abort(params.reason);\n\t}\n\n\tprivate armTimeout(id: JsonRpcId, entry: PendingRequest): void {\n\t\tif (entry.timer) clearTimeout(entry.timer);\n\t\tif (!Number.isFinite(entry.timeoutMs) || entry.timeoutMs <= 0) return;\n\t\tentry.timer = setTimeout(() => {\n\t\t\tthis.cancelPending(id, new McpTimeoutError(entry.timeoutMs), entry.cancellable, \"Request timed out\");\n\t\t}, entry.timeoutMs);\n\t}\n\n\tprivate cancelPending(id: JsonRpcId, error: unknown, notifyServer: boolean, reason?: string): void {\n\t\tconst entry = this.pending.get(id);\n\t\tif (!entry) return;\n\t\tthis.removePending(id, entry);\n\t\tentry.reject(error);\n\t\tif (notifyServer && this.transport) {\n\t\t\tvoid this.transport\n\t\t\t\t.send({\n\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\tmethod: \"notifications/cancelled\",\n\t\t\t\t\tparams: { requestId: id, ...(reason ? { reason } : {}) },\n\t\t\t\t})\n\t\t\t\t.catch((sendError) => this.emitError(sendError));\n\t\t}\n\t}\n\n\tprivate removePending(id: JsonRpcId, entry: PendingRequest): void {\n\t\tthis.pending.delete(id);\n\t\tif (entry.timer) clearTimeout(entry.timer);\n\t\tif (entry.progressToken !== undefined) this.progressRequests.delete(entry.progressToken);\n\t\tentry.signal?.removeEventListener(\"abort\", entry.onAbort);\n\t}\n\n\tprivate rejectPending(error: unknown): void {\n\t\tfor (const [id, entry] of this.pending) {\n\t\t\tthis.removePending(id, entry);\n\t\t\tentry.reject(error);\n\t\t}\n\t}\n\n\tprivate handleTransportClose(): void {\n\t\tthis.markClosed(new McpConnectionClosedError());\n\t}\n\n\t/** Idempotent: rejects in-flight requests, aborts server requests we are serving, and flips the state. */\n\tprivate markClosed(error: Error): void {\n\t\tconst wasClosed = this.state === \"closed\";\n\t\tthis.state = \"closed\";\n\t\tthis.rejectPending(error);\n\t\tfor (const controller of this.incoming.values()) controller.abort(error);\n\t\tthis.incoming.clear();\n\t\tif (wasClosed) return;\n\t\tfor (const listener of [...this.closeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (listenerError) {\n\t\t\t\tthis.emitError(listenerError);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate emitError(error: unknown): void {\n\t\tconst normalized = toError(error);\n\t\tfor (const listener of this.errorListeners) listener(normalized);\n\t}\n\n\tprivate disposeTransportListeners(): void {\n\t\tfor (const dispose of this.disposers.splice(0)) dispose();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACN,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,oBAAoB,EAKpB,aAAa,EACb,wBAAwB,EACxB,QAAQ,EACR,eAAe,EACf,OAAO,GACP,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIN,uBAAuB,EASvB,2BAA2B,GAG3B,MAAM,qBAAqB,C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C3D,CAAC;CACD","sourcesContent":["import type { CallToolResult } from \"./protocol/content.ts\";\nimport {\n\tisJsonRpcId,\n\tisJsonRpcNotification,\n\tisJsonRpcRequest,\n\tisJsonRpcResponse,\n\tisObject,\n\tJSON_RPC_ERROR_CODES,\n\ttype JsonRpcId,\n\ttype JsonRpcMessage,\n\ttype JsonRpcRequest,\n\ttype JsonRpcResponse,\n\tMcpAbortError,\n\tMcpConnectionClosedError,\n\tMcpError,\n\tMcpTimeoutError,\n\ttoError,\n} from \"./protocol/jsonrpc.ts\";\nimport {\n\ttype ClientCapabilities,\n\ttype Implementation,\n\ttype InitializeResult,\n\tLATEST_PROTOCOL_VERSION,\n\ttype ListResourcesResult,\n\ttype ListResourceTemplatesResult,\n\ttype ProgressNotification,\n\ttype ReadResourceResult,\n\ttype Resource,\n\ttype ResourceTemplate,\n\ttype Root,\n\ttype ServerCapabilities,\n\tSUPPORTED_PROTOCOL_VERSIONS,\n\ttype SupportedProtocolVersion,\n\ttype Tool,\n} from \"./protocol/types.ts\";\nimport type { McpTransport } from \"./transports/transport.ts\";\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\nconst MAX_LIST_PAGES = 1_000;\n\ntype ClientState = \"idle\" | \"connecting\" | \"connected\" | \"closed\";\ntype NotificationListener = (params: unknown) => void;\ntype ErrorListener = (error: Error) => void;\ntype CloseListener = () => void;\ntype RequestHandler = (params: unknown, context: { signal: AbortSignal }) => unknown | Promise<unknown>;\n\nexport interface McpClientOptions extends Implementation {\n\tcapabilities?: ClientCapabilities;\n\tprotocolVersion?: SupportedProtocolVersion;\n\trequestTimeoutMs?: number;\n\troots?: readonly Root[] | (() => readonly Root[] | Promise<readonly Root[]>);\n}\n\nexport interface McpRequestOptions {\n\tsignal?: AbortSignal;\n\ttimeoutMs?: number;\n\tonProgress?: (progress: ProgressNotification) => void;\n}\n\ninterface PendingRequest {\n\tresolve: (value: unknown) => void;\n\treject: (reason: unknown) => void;\n\ttimeoutMs: number;\n\ttimer: ReturnType<typeof setTimeout> | undefined;\n\tsignal: AbortSignal | undefined;\n\tonAbort: () => void;\n\t/** Aborted when the request settles, so the transport does not dispatch (or retry) it afterwards. */\n\tsendController: AbortController;\n\tcancellable: boolean;\n\tonProgress: ((progress: ProgressNotification) => void) | undefined;\n\tprogressToken: JsonRpcId | undefined;\n}\n\nfunction validateInitializeResult(value: unknown): InitializeResult {\n\tif (\n\t\t!isObject(value) ||\n\t\ttypeof value.protocolVersion !== \"string\" ||\n\t\t!isObject(value.capabilities) ||\n\t\t!isObject(value.serverInfo) ||\n\t\ttypeof value.serverInfo.name !== \"string\" ||\n\t\ttypeof value.serverInfo.version !== \"string\" ||\n\t\t(value.instructions !== undefined && typeof value.instructions !== \"string\")\n\t) {\n\t\tthrow new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Invalid MCP initialize result\");\n\t}\n\treturn value as unknown as InitializeResult;\n}\n\nfunction invalid(message: string): McpError {\n\treturn new McpError(JSON_RPC_ERROR_CODES.invalidRequest, message);\n}\n\n/** One page of a paginated list: the items under `key`, each checked by `isItem`. */\nfunction validateListPage(\n\tmethod: string,\n\tkey: string,\n\tvalue: unknown,\n\tisItem: (item: Record<string, unknown>) => boolean,\n): { items: Record<string, unknown>[]; nextCursor?: string } {\n\tconst items = isObject(value) ? value[key] : undefined;\n\tif (!isObject(value) || !Array.isArray(items)) throw invalid(`Invalid MCP ${method} result`);\n\tfor (const item of items) {\n\t\tif (!isObject(item) || !isItem(item)) throw invalid(`Invalid entry in MCP ${method} result`);\n\t}\n\t// Some servers end pagination with `null` or `\"\"` instead of omitting the cursor.\n\tconst nextCursor = value.nextCursor === null || value.nextCursor === \"\" ? undefined : value.nextCursor;\n\tif (nextCursor !== undefined && typeof nextCursor !== \"string\") throw invalid(`Invalid MCP ${method} cursor`);\n\treturn { items, ...(nextCursor === undefined ? {} : { nextCursor }) };\n}\n\nconst isTool = (tool: Record<string, unknown>) => typeof tool.name === \"string\" && isObject(tool.inputSchema);\n// `name` is required by the spec, but some servers omit it; the URI stands in.\nconst isResource = (resource: Record<string, unknown>) =>\n\ttypeof resource.uri === \"string\" && (resource.name === undefined || typeof resource.name === \"string\");\nconst isResourceTemplate = (template: Record<string, unknown>) =>\n\ttypeof template.uriTemplate === \"string\" && (template.name === undefined || typeof template.name === \"string\");\n\nfunction toResource(item: Record<string, unknown>): Resource {\n\treturn { ...item, name: item.name ?? item.uri } as Resource;\n}\n\nfunction toResourceTemplate(item: Record<string, unknown>): ResourceTemplate {\n\treturn { ...item, name: item.name ?? item.uriTemplate } as ResourceTemplate;\n}\n\nfunction pageCursor(page: { nextCursor?: string }): { nextCursor?: string } {\n\treturn page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor };\n}\n\nfunction validateReadResourceResult(value: unknown): ReadResourceResult {\n\tif (!isObject(value) || !Array.isArray(value.contents)) throw invalid(\"Invalid MCP resources/read result\");\n\tfor (const contents of value.contents) {\n\t\tif (\n\t\t\t!isObject(contents) ||\n\t\t\ttypeof contents.uri !== \"string\" ||\n\t\t\t(typeof contents.text !== \"string\" && typeof contents.blob !== \"string\")\n\t\t) {\n\t\t\tthrow invalid(\"Invalid contents in MCP resources/read result\");\n\t\t}\n\t}\n\treturn value as unknown as ReadResourceResult;\n}\n\n/**\n * `content` is required by the spec, but servers that only return `structuredContent` omit it (the SDK defaults it too).\n * `structuredContent` may be any JSON value, as MCP 2026-07-28 allows.\n */\nfunction validateCallToolResult(value: unknown): CallToolResult {\n\tif (!isObject(value) || (value.content !== undefined && !Array.isArray(value.content))) {\n\t\tthrow new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Invalid MCP tools/call result\");\n\t}\n\treturn (value.content === undefined ? { ...value, content: [] } : value) as unknown as CallToolResult;\n}\n\nexport class McpClient {\n\treadonly options: Readonly<McpClientOptions>;\n\tprivate state: ClientState = \"idle\";\n\tprivate transport: McpTransport | undefined;\n\tprivate nextRequestId = 1;\n\tprivate serverInfoValue: Implementation | undefined;\n\tprivate serverCapabilitiesValue: ServerCapabilities | undefined;\n\tprivate instructionsValue: string | undefined;\n\tprivate protocolVersionValue: string | undefined;\n\tprivate pending = new Map<JsonRpcId, PendingRequest>();\n\tprivate progressRequests = new Map<JsonRpcId, JsonRpcId>();\n\tprivate incoming = new Map<JsonRpcId, AbortController>();\n\tprivate requestHandlers = new Map<string, RequestHandler>();\n\tprivate notificationListeners = new Map<string, Set<NotificationListener>>();\n\tprivate errorListeners = new Set<ErrorListener>();\n\tprivate closeListeners = new Set<CloseListener>();\n\tprivate disposers: (() => void)[] = [];\n\n\tconstructor(options: McpClientOptions) {\n\t\tthis.options = Object.freeze({ ...options });\n\t\tthis.requestHandlers.set(\"ping\", () => ({}));\n\t\tconst roots = options.roots;\n\t\tif (roots) {\n\t\t\tthis.requestHandlers.set(\"roots/list\", async () => ({\n\t\t\t\troots: [...(typeof roots === \"function\" ? await roots() : roots)],\n\t\t\t}));\n\t\t}\n\t}\n\n\tget connectionState(): ClientState {\n\t\treturn this.state;\n\t}\n\n\tget serverInfo(): Implementation | undefined {\n\t\treturn this.serverInfoValue;\n\t}\n\n\tget serverCapabilities(): ServerCapabilities | undefined {\n\t\treturn this.serverCapabilitiesValue;\n\t}\n\n\tget instructions(): string | undefined {\n\t\treturn this.instructionsValue;\n\t}\n\n\tget protocolVersion(): string | undefined {\n\t\treturn this.protocolVersionValue;\n\t}\n\n\tasync connect(transport: McpTransport): Promise<InitializeResult> {\n\t\tif (this.state !== \"idle\") throw new Error(`Cannot connect MCP client in ${this.state} state`);\n\t\tthis.state = \"connecting\";\n\t\tthis.transport = transport;\n\t\tthis.disposers = [\n\t\t\ttransport.onMessage((message) => this.handleMessage(message)),\n\t\t\t// Transport errors are reported only. Pending requests fail when the transport closes.\n\t\t\ttransport.onError((error) => this.emitError(error)),\n\t\t\ttransport.onClose(() => this.handleTransportClose()),\n\t\t];\n\n\t\ttry {\n\t\t\tawait transport.start();\n\t\t\tconst capabilities: ClientCapabilities = { ...this.options.capabilities };\n\t\t\tif (this.options.roots && capabilities.roots === undefined) capabilities.roots = {};\n\t\t\tconst result = validateInitializeResult(\n\t\t\t\tawait this.requestInternal(\n\t\t\t\t\t\"initialize\",\n\t\t\t\t\t{\n\t\t\t\t\t\tprotocolVersion: this.options.protocolVersion ?? LATEST_PROTOCOL_VERSION,\n\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t\tclientInfo: {\n\t\t\t\t\t\t\tname: this.options.name,\n\t\t\t\t\t\t\tversion: this.options.version,\n\t\t\t\t\t\t\t...(this.options.title === undefined ? {} : { title: this.options.title }),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{},\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (!(SUPPORTED_PROTOCOL_VERSIONS as readonly string[]).includes(result.protocolVersion)) {\n\t\t\t\tthrow new Error(`MCP server selected unsupported protocol version ${result.protocolVersion}`);\n\t\t\t}\n\t\t\tthis.protocolVersionValue = result.protocolVersion;\n\t\t\tthis.serverInfoValue = result.serverInfo;\n\t\t\tthis.serverCapabilitiesValue = result.capabilities;\n\t\t\tthis.instructionsValue = result.instructions;\n\t\t\ttransport.setProtocolVersion?.(result.protocolVersion);\n\t\t\tawait this.notifyInternal(\"notifications/initialized\", undefined, true);\n\t\t\tthis.state = \"connected\";\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait this.close().catch(() => {});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\trequest<Result = unknown>(\n\t\tmethod: string,\n\t\tparams?: Record<string, unknown>,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<Result> {\n\t\treturn this.requestInternal(method, params, options, false) as Promise<Result>;\n\t}\n\n\tnotify(method: string, params?: Record<string, unknown>): Promise<void> {\n\t\treturn this.notifyInternal(method, params, false);\n\t}\n\n\tsetRequestHandler(method: string, handler: RequestHandler): () => void {\n\t\tthis.requestHandlers.set(method, handler);\n\t\treturn () => {\n\t\t\tif (this.requestHandlers.get(method) === handler) this.requestHandlers.delete(method);\n\t\t};\n\t}\n\n\tonNotification(method: string, listener: NotificationListener): () => void {\n\t\tconst listeners = this.notificationListeners.get(method) ?? new Set<NotificationListener>();\n\t\tthis.notificationListeners.set(method, listeners);\n\t\tlisteners.add(listener);\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0) this.notificationListeners.delete(method);\n\t\t};\n\t}\n\n\tonError(listener: ErrorListener): () => void {\n\t\tthis.errorListeners.add(listener);\n\t\treturn () => this.errorListeners.delete(listener);\n\t}\n\n\t/** Called once when the connection closes, whether the transport dropped or `close()` was called. */\n\tonClose(listener: CloseListener): () => void {\n\t\tthis.closeListeners.add(listener);\n\t\treturn () => this.closeListeners.delete(listener);\n\t}\n\n\tasync ping(options: McpRequestOptions = {}): Promise<void> {\n\t\tawait this.request(\"ping\", undefined, options);\n\t}\n\n\tasync listTools(options: McpRequestOptions = {}): Promise<Tool[]> {\n\t\treturn (await this.listAll(\"tools/list\", \"tools\", isTool, options)) as unknown as Tool[];\n\t}\n\n\t/** Every resource, following `nextCursor` through all pages. */\n\tasync listResources(options: McpRequestOptions = {}): Promise<Resource[]> {\n\t\treturn (await this.listAll(\"resources/list\", \"resources\", isResource, options)).map(toResource);\n\t}\n\n\t/** One page of resources, starting at `cursor`. */\n\tasync listResourcesPage(cursor?: string, options: McpRequestOptions = {}): Promise<ListResourcesResult> {\n\t\tconst page = await this.listPage(\"resources/list\", \"resources\", isResource, cursor, options);\n\t\treturn { resources: page.items.map(toResource), ...pageCursor(page) };\n\t}\n\n\t/** Every resource template, following `nextCursor` through all pages. */\n\tasync listResourceTemplates(options: McpRequestOptions = {}): Promise<ResourceTemplate[]> {\n\t\tconst templates = await this.listAll(\n\t\t\t\"resources/templates/list\",\n\t\t\t\"resourceTemplates\",\n\t\t\tisResourceTemplate,\n\t\t\toptions,\n\t\t);\n\t\treturn templates.map(toResourceTemplate);\n\t}\n\n\t/** One page of resource templates, starting at `cursor`. */\n\tasync listResourceTemplatesPage(\n\t\tcursor?: string,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<ListResourceTemplatesResult> {\n\t\tconst page = await this.listPage(\n\t\t\t\"resources/templates/list\",\n\t\t\t\"resourceTemplates\",\n\t\t\tisResourceTemplate,\n\t\t\tcursor,\n\t\t\toptions,\n\t\t);\n\t\treturn { resourceTemplates: page.items.map(toResourceTemplate), ...pageCursor(page) };\n\t}\n\n\tasync readResource(uri: string, options: McpRequestOptions = {}): Promise<ReadResourceResult> {\n\t\treturn validateReadResourceResult(await this.request(\"resources/read\", { uri }, options));\n\t}\n\n\tprivate async listPage(\n\t\tmethod: string,\n\t\tkey: string,\n\t\tisItem: (item: Record<string, unknown>) => boolean,\n\t\tcursor: string | undefined,\n\t\toptions: McpRequestOptions,\n\t): Promise<{ items: Record<string, unknown>[]; nextCursor?: string }> {\n\t\treturn validateListPage(\n\t\t\tmethod,\n\t\t\tkey,\n\t\t\tawait this.request(method, cursor === undefined ? undefined : { cursor }, options),\n\t\t\tisItem,\n\t\t);\n\t}\n\n\t/** Every item of a paginated list method. */\n\tprivate async listAll(\n\t\tmethod: string,\n\t\tkey: string,\n\t\tisItem: (item: Record<string, unknown>) => boolean,\n\t\toptions: McpRequestOptions,\n\t): Promise<Record<string, unknown>[]> {\n\t\tconst items: Record<string, unknown>[] = [];\n\t\tconst cursors = new Set<string>();\n\t\tlet cursor: string | undefined;\n\t\tfor (let pageNumber = 0; pageNumber < MAX_LIST_PAGES; pageNumber++) {\n\t\t\tconst page = await this.listPage(method, key, isItem, cursor, options);\n\t\t\titems.push(...page.items);\n\t\t\tif (page.nextCursor === undefined) return items;\n\t\t\tif (cursors.has(page.nextCursor))\n\t\t\t\tthrow new Error(`MCP ${method} returned duplicate cursor: ${page.nextCursor}`);\n\t\t\tcursors.add(page.nextCursor);\n\t\t\tcursor = page.nextCursor;\n\t\t}\n\t\tthrow new Error(`MCP ${method} exceeded ${MAX_LIST_PAGES} pages`);\n\t}\n\n\tasync callTool(\n\t\tname: string,\n\t\targs?: Record<string, unknown>,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<CallToolResult> {\n\t\treturn validateCallToolResult(\n\t\t\tawait this.request(\"tools/call\", { name, ...(args === undefined ? {} : { arguments: args }) }, options),\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\tconst transport = this.transport;\n\t\tthis.transport = undefined;\n\t\tthis.disposeTransportListeners();\n\t\tthis.markClosed(new McpConnectionClosedError());\n\t\tawait transport?.close();\n\t}\n\n\tprivate async requestInternal(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown> | undefined,\n\t\toptions: McpRequestOptions,\n\t\tallowConnecting: boolean,\n\t): Promise<unknown> {\n\t\tconst transport = this.requireTransport(allowConnecting);\n\t\tif (options.signal?.aborted) throw new McpAbortError();\n\t\tconst id = this.nextRequestId++;\n\t\tconst progressToken = options.onProgress ? id : undefined;\n\t\tconst requestParams =\n\t\t\tprogressToken === undefined\n\t\t\t\t? params\n\t\t\t\t: { ...params, _meta: { ...(isObject(params?._meta) ? params._meta : {}), progressToken } };\n\t\tconst message: JsonRpcRequest = {\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tid,\n\t\t\tmethod,\n\t\t\t...(requestParams === undefined ? {} : { params: requestParams }),\n\t\t};\n\t\treturn new Promise<unknown>((resolve, reject) => {\n\t\t\tconst entry: PendingRequest = {\n\t\t\t\tresolve,\n\t\t\t\treject,\n\t\t\t\ttimeoutMs: options.timeoutMs ?? this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,\n\t\t\t\ttimer: undefined,\n\t\t\t\tsignal: options.signal,\n\t\t\t\t// The spec forbids cancelling `initialize`.\n\t\t\t\tonAbort: () =>\n\t\t\t\t\tthis.cancelPending(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tnew McpAbortError(),\n\t\t\t\t\t\tmethod !== \"initialize\",\n\t\t\t\t\t\tString(options.signal?.reason ?? \"Aborted\"),\n\t\t\t\t\t),\n\t\t\t\tsendController: new AbortController(),\n\t\t\t\tcancellable: method !== \"initialize\",\n\t\t\t\tonProgress: options.onProgress,\n\t\t\t\tprogressToken,\n\t\t\t};\n\t\t\tthis.pending.set(id, entry);\n\t\t\tif (progressToken !== undefined) this.progressRequests.set(progressToken, id);\n\t\t\toptions.signal?.addEventListener(\"abort\", entry.onAbort, { once: true });\n\t\t\tthis.armTimeout(id, entry);\n\t\t\ttransport\n\t\t\t\t.send(message, { signal: entry.sendController.signal })\n\t\t\t\t.catch((error) => this.cancelPending(id, error, false));\n\t\t});\n\t}\n\n\tprivate async notifyInternal(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown> | undefined,\n\t\tallowConnecting: boolean,\n\t): Promise<void> {\n\t\tawait this.requireTransport(allowConnecting).send({\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tmethod,\n\t\t\t...(params === undefined ? {} : { params }),\n\t\t});\n\t}\n\n\tprivate requireTransport(allowConnecting: boolean): McpTransport {\n\t\tif (this.transport && (this.state === \"connected\" || (allowConnecting && this.state === \"connecting\"))) {\n\t\t\treturn this.transport;\n\t\t}\n\t\tthrow new McpConnectionClosedError(`MCP client is ${this.state}`);\n\t}\n\n\tprivate handleMessage(message: JsonRpcMessage): void {\n\t\tif (isJsonRpcResponse(message)) {\n\t\t\tthis.handleResponse(message);\n\t\t\treturn;\n\t\t}\n\t\tif (isJsonRpcRequest(message)) {\n\t\t\tvoid this.handleRequest(message);\n\t\t\treturn;\n\t\t}\n\t\tif (isJsonRpcNotification(message)) {\n\t\t\tthis.handleNotification(message.method, message.params);\n\t\t\treturn;\n\t\t}\n\t\tthis.emitError(new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Received invalid JSON-RPC message\"));\n\t}\n\n\tprivate handleResponse(message: JsonRpcResponse): void {\n\t\tconst entry = this.pending.get(message.id);\n\t\tif (!entry) {\n\t\t\tthis.emitError(new Error(`Received response for unknown MCP request ${String(message.id)}`));\n\t\t\treturn;\n\t\t}\n\t\tthis.removePending(message.id, entry);\n\t\tif (\"error\" in message) entry.reject(new McpError(message.error.code, message.error.message, message.error.data));\n\t\telse entry.resolve(message.result);\n\t}\n\n\tprivate async handleRequest(message: JsonRpcRequest): Promise<void> {\n\t\tconst transport = this.transport;\n\t\tif (!transport) return;\n\t\tconst handler = this.requestHandlers.get(message.method);\n\t\tif (!handler) {\n\t\t\tawait transport\n\t\t\t\t.send({\n\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\tid: message.id,\n\t\t\t\t\terror: { code: JSON_RPC_ERROR_CODES.methodNotFound, message: `Method not found: ${message.method}` },\n\t\t\t\t})\n\t\t\t\t.catch((error) => this.emitError(error));\n\t\t\treturn;\n\t\t}\n\t\tconst controller = new AbortController();\n\t\tthis.incoming.set(message.id, controller);\n\t\ttry {\n\t\t\tconst result = await handler(message.params, { signal: controller.signal });\n\t\t\tawait transport.send({ jsonrpc: \"2.0\", id: message.id, result: result ?? {} });\n\t\t} catch (error) {\n\t\t\tconst responseError =\n\t\t\t\terror instanceof McpError\n\t\t\t\t\t? { code: error.code, message: error.message, data: error.data }\n\t\t\t\t\t: { code: JSON_RPC_ERROR_CODES.internalError, message: toError(error).message };\n\t\t\tawait transport\n\t\t\t\t.send({ jsonrpc: \"2.0\", id: message.id, error: responseError })\n\t\t\t\t.catch((sendError) => this.emitError(sendError));\n\t\t} finally {\n\t\t\tthis.incoming.delete(message.id);\n\t\t}\n\t}\n\n\tprivate handleNotification(method: string, params: unknown): void {\n\t\tif (method === \"notifications/progress\") this.handleProgress(params);\n\t\telse if (method === \"notifications/cancelled\") this.handleCancelled(params);\n\t\tfor (const listener of this.notificationListeners.get(method) ?? []) {\n\t\t\ttry {\n\t\t\t\tlistener(params);\n\t\t\t} catch (error) {\n\t\t\t\tthis.emitError(error);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleProgress(params: unknown): void {\n\t\tif (!isObject(params) || !isJsonRpcId(params.progressToken) || typeof params.progress !== \"number\") return;\n\t\tconst requestId = this.progressRequests.get(params.progressToken);\n\t\tconst entry = requestId === undefined ? undefined : this.pending.get(requestId);\n\t\tif (requestId === undefined || !entry) return;\n\t\tthis.armTimeout(requestId, entry);\n\t\ttry {\n\t\t\tentry.onProgress?.(params as unknown as ProgressNotification);\n\t\t} catch (error) {\n\t\t\tthis.emitError(error);\n\t\t}\n\t}\n\n\tprivate handleCancelled(params: unknown): void {\n\t\tif (isObject(params) && isJsonRpcId(params.requestId)) this.incoming.get(params.requestId)?.abort(params.reason);\n\t}\n\n\tprivate armTimeout(id: JsonRpcId, entry: PendingRequest): void {\n\t\tif (entry.timer) clearTimeout(entry.timer);\n\t\tif (!Number.isFinite(entry.timeoutMs) || entry.timeoutMs <= 0) return;\n\t\tentry.timer = setTimeout(() => {\n\t\t\tthis.cancelPending(id, new McpTimeoutError(entry.timeoutMs), entry.cancellable, \"Request timed out\");\n\t\t}, entry.timeoutMs);\n\t}\n\n\tprivate cancelPending(id: JsonRpcId, error: unknown, notifyServer: boolean, reason?: string): void {\n\t\tconst entry = this.pending.get(id);\n\t\tif (!entry) return;\n\t\tthis.removePending(id, entry);\n\t\tentry.reject(error);\n\t\tif (notifyServer && this.transport) {\n\t\t\tvoid this.transport\n\t\t\t\t.send({\n\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\tmethod: \"notifications/cancelled\",\n\t\t\t\t\tparams: { requestId: id, ...(reason ? { reason } : {}) },\n\t\t\t\t})\n\t\t\t\t.catch((sendError) => this.emitError(sendError));\n\t\t}\n\t}\n\n\tprivate removePending(id: JsonRpcId, entry: PendingRequest): void {\n\t\tthis.pending.delete(id);\n\t\tif (entry.timer) clearTimeout(entry.timer);\n\t\tif (entry.progressToken !== undefined) this.progressRequests.delete(entry.progressToken);\n\t\tentry.signal?.removeEventListener(\"abort\", entry.onAbort);\n\t\tentry.sendController.abort();\n\t}\n\n\tprivate rejectPending(error: unknown): void {\n\t\tfor (const [id, entry] of this.pending) {\n\t\t\tthis.removePending(id, entry);\n\t\t\tentry.reject(error);\n\t\t}\n\t}\n\n\tprivate handleTransportClose(): void {\n\t\tthis.markClosed(new McpConnectionClosedError());\n\t}\n\n\t/** Idempotent: rejects in-flight requests, aborts server requests we are serving, and flips the state. */\n\tprivate markClosed(error: Error): void {\n\t\tconst wasClosed = this.state === \"closed\";\n\t\tthis.state = \"closed\";\n\t\tthis.rejectPending(error);\n\t\tfor (const controller of this.incoming.values()) controller.abort(error);\n\t\tthis.incoming.clear();\n\t\tif (wasClosed) return;\n\t\tfor (const listener of [...this.closeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (listenerError) {\n\t\t\t\tthis.emitError(listenerError);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate emitError(error: unknown): void {\n\t\tconst normalized = toError(error);\n\t\tfor (const listener of this.errorListeners) listener(normalized);\n\t}\n\n\tprivate disposeTransportListeners(): void {\n\t\tfor (const dispose of this.disposers.splice(0)) dispose();\n\t}\n}\n"]}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `mcpServers` configuration shape that MCP clients share, so configurations can be copied between
|
|
3
|
+
* them: stdio servers (`command`, `args`, `env`, `cwd`), Streamable HTTP servers (`url`, `headers`,
|
|
4
|
+
* `oauth`), and `enabled`, `description` and `timeout` for both.
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "mcpServers": {
|
|
9
|
+
* "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "."] },
|
|
10
|
+
* "docs": { "url": "https://example.com/mcp", "headers": { "Authorization": "Bearer ${DOCS_TOKEN}" } }
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Applications add fields of their own: {@link validateMcpServerConfig} keeps fields it does not know
|
|
16
|
+
* for the caller to check afterwards.
|
|
17
|
+
*/
|
|
18
|
+
/** Fields every server entry may have. */
|
|
19
|
+
interface McpServerConfigBase {
|
|
20
|
+
/** What the server offers, in a sentence. */
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Set to false to keep the entry without connecting. Default: true. */
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
/** Per-request timeout in seconds. */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
}
|
|
27
|
+
/** A server started as a local program that speaks MCP over stdin and stdout. */
|
|
28
|
+
export interface McpStdioServerConfig extends McpServerConfigBase {
|
|
29
|
+
type?: "stdio";
|
|
30
|
+
command: string;
|
|
31
|
+
args?: string[];
|
|
32
|
+
/** Added to the environment. The application decides whether values may reference variables (`${NAME}`). */
|
|
33
|
+
env?: Record<string, string>;
|
|
34
|
+
/** The application decides what relative paths resolve against. */
|
|
35
|
+
cwd?: string;
|
|
36
|
+
}
|
|
37
|
+
/** OAuth client settings for servers that do not support dynamic client registration. */
|
|
38
|
+
export interface McpOAuthConfig {
|
|
39
|
+
/** Pre-registered client id. Without it, the application registers a client with the authorization server. */
|
|
40
|
+
clientId?: string;
|
|
41
|
+
/** As configured; the application decides whether it may reference variables. */
|
|
42
|
+
clientSecret?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Port of the loopback callback server, for clients registered with a fixed redirect URI. Without
|
|
45
|
+
* `callbackUrl`, the redirect URI is `http://127.0.0.1:<port>/callback`.
|
|
46
|
+
*/
|
|
47
|
+
callbackPort?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Redirect URI registered for `clientId`, for example `http://localhost:8080/oauth/callback`. It must
|
|
50
|
+
* be an `http` URI on `localhost`, `127.0.0.1`, or `[::1]`. Without a port, the callback server
|
|
51
|
+
* listens on `callbackPort` or a free port, which is added to the URI (RFC 8252).
|
|
52
|
+
*/
|
|
53
|
+
callbackUrl?: string;
|
|
54
|
+
/** Scopes to request, separated by spaces. Default: the scopes the server advertises. */
|
|
55
|
+
scope?: string;
|
|
56
|
+
/** `client_name` sent with dynamic client registration. Default: the application's name. */
|
|
57
|
+
clientName?: string;
|
|
58
|
+
/**
|
|
59
|
+
* How the application identifies itself without `clientId`. `auto` (default): its Client ID Metadata
|
|
60
|
+
* Document when the authorization server supports them for public clients, otherwise dynamic client
|
|
61
|
+
* registration. `cimd`: always the document, and sign-in fails without support. `dcr`: always
|
|
62
|
+
* dynamic client registration.
|
|
63
|
+
*/
|
|
64
|
+
clientRegistration?: "auto" | "dcr" | "cimd";
|
|
65
|
+
/**
|
|
66
|
+
* Authorization server metadata document (RFC 8414 or OpenID Connect discovery) to use instead of
|
|
67
|
+
* discovery through the server, for servers that advertise a wrong authorization server or none.
|
|
68
|
+
* The document is trusted as configured. Must use https, except on loopback hosts.
|
|
69
|
+
*/
|
|
70
|
+
authServerMetadataUrl?: string;
|
|
71
|
+
}
|
|
72
|
+
/** A server reached over Streamable HTTP. */
|
|
73
|
+
export interface McpHttpServerConfig extends McpServerConfigBase {
|
|
74
|
+
type?: "http";
|
|
75
|
+
url: string;
|
|
76
|
+
/** Sent with every request. The application decides whether values may reference variables. */
|
|
77
|
+
headers?: Record<string, string>;
|
|
78
|
+
oauth?: McpOAuthConfig;
|
|
79
|
+
}
|
|
80
|
+
/** One entry of the `mcpServers` shape: a stdio or a Streamable HTTP server. */
|
|
81
|
+
export type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig;
|
|
82
|
+
/**
|
|
83
|
+
* A validated server entry, tagged with its transport, or why it is invalid. The config is the entry
|
|
84
|
+
* as given: fields the validator does not know are kept, unchecked, for the caller to check.
|
|
85
|
+
*/
|
|
86
|
+
export type McpServerConfigResult = {
|
|
87
|
+
kind: "stdio";
|
|
88
|
+
config: McpStdioServerConfig & Record<string, unknown>;
|
|
89
|
+
} | {
|
|
90
|
+
kind: "http";
|
|
91
|
+
config: McpHttpServerConfig & Record<string, unknown>;
|
|
92
|
+
} | {
|
|
93
|
+
kind: "invalid";
|
|
94
|
+
error: string;
|
|
95
|
+
};
|
|
96
|
+
/** What the application adds to the validation of server entries. */
|
|
97
|
+
export interface McpServerConfigOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Checks the `oauth.callbackUrl` (undefined: none configured) of an entry with
|
|
100
|
+
* `oauth.clientRegistration: "cimd"`: the application's Client ID Metadata Documents must list it.
|
|
101
|
+
* Returns an error message. Without this check, `"cimd"` is refused.
|
|
102
|
+
*/
|
|
103
|
+
checkMetadataDocumentCallback?(callbackUrl: string | undefined): string | undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Validate one entry of the `mcpServers` shape (configuration files are a trust boundary). Server
|
|
107
|
+
* names are letters, digits, `_` and `-`, which tool names and namespaces are built from.
|
|
108
|
+
*/
|
|
109
|
+
export declare function validateMcpServerConfig(name: string, raw: unknown, options?: McpServerConfigOptions): McpServerConfigResult;
|
|
110
|
+
/**
|
|
111
|
+
* Whether an entry overrides a server defined elsewhere instead of defining one: it has no `command`,
|
|
112
|
+
* `url` or `type`. Applications let a less trusted file (a project's) override a few fields, such as
|
|
113
|
+
* `enabled`, of a server a trusted file defines; which fields is theirs to decide.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isMcpServerOverride(entry: Record<string, unknown>): boolean;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,0CAA0C;AAC1C,UAAU,mBAAmB;IAC5B,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,iFAAiF;AACjF,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAChE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC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