@ny4n/mcp 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES/modelcontextprotocol-typescript-sdk.txt +21 -0
- package/README.md +135 -2
- package/dist/auth-provider.d.ts +19 -0
- package/dist/auth-provider.d.ts.map +1 -0
- package/dist/auth-provider.js +2 -0
- package/dist/auth-provider.js.map +1 -0
- package/dist/client.d.ts +89 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +457 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/oauth/callback.d.ts +48 -0
- package/dist/oauth/callback.d.ts.map +1 -0
- package/dist/oauth/callback.js +115 -0
- package/dist/oauth/callback.js.map +1 -0
- package/dist/oauth/discovery.d.ts +30 -0
- package/dist/oauth/discovery.d.ts.map +1 -0
- package/dist/oauth/discovery.js +156 -0
- package/dist/oauth/discovery.js.map +1 -0
- package/dist/oauth/errors.d.ts +25 -0
- package/dist/oauth/errors.d.ts.map +1 -0
- package/dist/oauth/errors.js +48 -0
- package/dist/oauth/errors.js.map +1 -0
- package/dist/oauth/flow.d.ts +102 -0
- package/dist/oauth/flow.d.ts.map +1 -0
- package/dist/oauth/flow.js +334 -0
- package/dist/oauth/flow.js.map +1 -0
- package/dist/oauth/index.d.ts +7 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +6 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/provider.d.ts +62 -0
- package/dist/oauth/provider.d.ts.map +1 -0
- package/dist/oauth/provider.js +118 -0
- package/dist/oauth/provider.js.map +1 -0
- package/dist/oauth/types.d.ts +82 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/types.js +109 -0
- package/dist/oauth/types.js.map +1 -0
- package/dist/protocol/content.d.ts +82 -0
- package/dist/protocol/content.d.ts.map +1 -0
- package/dist/protocol/content.js +41 -0
- package/dist/protocol/content.js.map +1 -0
- package/dist/protocol/jsonrpc.d.ts +59 -0
- package/dist/protocol/jsonrpc.d.ts.map +1 -0
- package/dist/protocol/jsonrpc.js +67 -0
- package/dist/protocol/jsonrpc.js.map +1 -0
- package/dist/protocol/types.d.ts +123 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +7 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/transports/in-memory.d.ts +19 -0
- package/dist/transports/in-memory.d.ts.map +1 -0
- package/dist/transports/in-memory.js +50 -0
- package/dist/transports/in-memory.js.map +1 -0
- package/dist/transports/stdio.d.ts +32 -0
- package/dist/transports/stdio.d.ts.map +1 -0
- package/dist/transports/stdio.js +201 -0
- package/dist/transports/stdio.js.map +1 -0
- package/dist/transports/streamable-http.d.ts +99 -0
- package/dist/transports/streamable-http.d.ts.map +1 -0
- package/dist/transports/streamable-http.js +459 -0
- package/dist/transports/streamable-http.js.map +1 -0
- package/dist/transports/transport.d.ts +28 -0
- package/dist/transports/transport.d.ts.map +1 -0
- package/dist/transports/transport.js +38 -0
- package/dist/transports/transport.js.map +1 -0
- package/package.json +59 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mario Zechner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Anthropic, PBC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,136 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ny4n/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A small, standalone Model Context Protocol client. It does not depend on the official MCP SDK or other nyan packages.
|
|
4
|
+
|
|
5
|
+
The package provides a transport-neutral client core, stdio and Streamable HTTP transports, and an in-memory testing transport.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { McpClient, StdioTransport } from "@ny4n/mcp";
|
|
11
|
+
|
|
12
|
+
const transport = new StdioTransport({
|
|
13
|
+
command: "npx",
|
|
14
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"],
|
|
15
|
+
});
|
|
16
|
+
const client = new McpClient({
|
|
17
|
+
name: "my-client",
|
|
18
|
+
version: "1.0.0",
|
|
19
|
+
roots: [{ uri: "file:///workspace", name: "workspace" }],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await client.connect(transport);
|
|
23
|
+
const tools = await client.listTools();
|
|
24
|
+
const result = await client.callTool("search", { query: "MCP" });
|
|
25
|
+
await client.close();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For a remote server, use `new StreamableHttpTransport({ url, headers })`. Fetch can be injected for proxying or custom networking.
|
|
29
|
+
|
|
30
|
+
### Tools for an LLM
|
|
31
|
+
|
|
32
|
+
`toLlmContent(result)` converts a `CallToolResult` to text and image content for a model, in the shape of `@ny4n/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.
|
|
33
|
+
|
|
34
|
+
Wrapping an MCP tool as a `@ny4n/agent-core` `AgentTool`:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import type { AgentTool } from "@ny4n/agent-core";
|
|
38
|
+
import { toLlmContent } from "@ny4n/mcp";
|
|
39
|
+
import { Type } from "typebox";
|
|
40
|
+
|
|
41
|
+
const tools: AgentTool[] = (await client.listTools()).map((tool) => ({
|
|
42
|
+
// Providers allow at most 64 characters of [A-Za-z0-9_-].
|
|
43
|
+
name: `mcp_${tool.name}`.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 64),
|
|
44
|
+
label: tool.title ?? tool.name,
|
|
45
|
+
description: tool.description ?? tool.name,
|
|
46
|
+
// Providers require an object schema, and some reject one without `properties`.
|
|
47
|
+
parameters: Type.Unsafe({ ...tool.inputSchema, type: "object", properties: tool.inputSchema.properties ?? {} }),
|
|
48
|
+
execute: async (_toolCallId, params, signal) => {
|
|
49
|
+
const result = await client.callTool(tool.name, params as Record<string, unknown>, { signal });
|
|
50
|
+
// MCP reports tool failures in the result instead of as a protocol error.
|
|
51
|
+
return { content: toLlmContent(result), details: undefined, isError: result.isError === true };
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The [mcp-codemode example](https://github.com/blxzer77/nyan/tree/main/packages/agent/examples/mcp-codemode) also forwards progress, passes `structuredContent` through, and lets `@ny4n/codemode` scripts call the tools.
|
|
57
|
+
|
|
58
|
+
### OAuth
|
|
59
|
+
|
|
60
|
+
`@ny4n/mcp/oauth` provides the MCP OAuth client subset without depending on the official SDK:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { McpClient, StreamableHttpTransport } from "@ny4n/mcp";
|
|
64
|
+
import {
|
|
65
|
+
adaptOAuthProvider,
|
|
66
|
+
authorizeMcp,
|
|
67
|
+
McpOAuthAuthorizationRequiredError,
|
|
68
|
+
McpOAuthProvider,
|
|
69
|
+
OAuthCallbackServer,
|
|
70
|
+
} from "@ny4n/mcp/oauth";
|
|
71
|
+
|
|
72
|
+
const serverUrl = "https://mcp.example.com/mcp";
|
|
73
|
+
const callback = await OAuthCallbackServer.listen();
|
|
74
|
+
let authorizationUrl: URL | undefined;
|
|
75
|
+
const oauth = new McpOAuthProvider({
|
|
76
|
+
serverUrl,
|
|
77
|
+
redirectUrl: callback.redirectUrl,
|
|
78
|
+
clientMetadata: { client_name: "My MCP client" },
|
|
79
|
+
onRedirect: (url) => {
|
|
80
|
+
authorizationUrl = url;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const connect = () => {
|
|
85
|
+
const client = new McpClient({ name: "my-client", version: "1.0.0" });
|
|
86
|
+
return {
|
|
87
|
+
client,
|
|
88
|
+
connected: client.connect(
|
|
89
|
+
new StreamableHttpTransport({ url: serverUrl, authProvider: adaptOAuthProvider(oauth) }),
|
|
90
|
+
),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const first = connect();
|
|
95
|
+
try {
|
|
96
|
+
await first.connected;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (!(error instanceof McpOAuthAuthorizationRequiredError)) throw error;
|
|
99
|
+
const state = await oauth.state();
|
|
100
|
+
const result = callback.waitForCallback(state);
|
|
101
|
+
// Open authorizationUrl in the user's browser here.
|
|
102
|
+
const { code } = await result;
|
|
103
|
+
await authorizeMcp(oauth, { serverUrl, authorizationCode: code });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const { client, connected } = connect();
|
|
107
|
+
await connected;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Inject `McpOAuthStateStore` into `McpOAuthProvider` for durable credentials. The package does not open a browser or choose where credentials are stored.
|
|
111
|
+
|
|
112
|
+
The OAuth implementation is adapted from the MIT-licensed Model Context Protocol TypeScript SDK v1.29.0. Its license is included under `LICENSES/`.
|
|
113
|
+
|
|
114
|
+
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.
|
|
115
|
+
|
|
116
|
+
## Supported protocol surface
|
|
117
|
+
|
|
118
|
+
- MCP protocol version `2025-11-25`, accepting servers that negotiate `2025-06-18`, `2025-03-26`, or `2024-11-05`
|
|
119
|
+
- initialization and `notifications/initialized`
|
|
120
|
+
- ping
|
|
121
|
+
- paginated `tools/list`
|
|
122
|
+
- `tools/call`, including structured content
|
|
123
|
+
- progress notifications and timeout renewal
|
|
124
|
+
- request cancellation
|
|
125
|
+
- Streamable HTTP sessions, the server-to-client GET stream with reconnection, and resumption of dropped response streams with `Last-Event-ID`
|
|
126
|
+
- stdio shutdown per the spec (close stdin, then SIGTERM, then SIGKILL), applied to the server's whole process group
|
|
127
|
+
- server `ping` and `roots/list` requests
|
|
128
|
+
- logging and tool-list-change notifications through the generic notification API
|
|
129
|
+
- OAuth protected-resource and authorization-server discovery
|
|
130
|
+
- PKCE authorization code flow, dynamic client registration, token refresh (one refresh shared by concurrent 401s), and step-up authorization for `insufficient_scope`
|
|
131
|
+
|
|
132
|
+
Batch JSON-RPC messages, legacy HTTP+SSE, servers, sampling, and tasks are outside the initial core.
|
|
133
|
+
|
|
134
|
+
## Testing
|
|
135
|
+
|
|
136
|
+
`@ny4n/mcp/testing` exports `createInMemoryTransportPair()` for client and adapter tests.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type McpFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
export interface UnauthorizedContext {
|
|
3
|
+
/** The 401 response, or a 403 response whose challenge reports `insufficient_scope`. */
|
|
4
|
+
response: Response;
|
|
5
|
+
serverUrl: URL;
|
|
6
|
+
fetch: McpFetch;
|
|
7
|
+
/** Access token the rejected request carried, if any. A different current token means another request already refreshed it. */
|
|
8
|
+
token?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Supplies bearer tokens to an MCP HTTP transport and may refresh them after a 401 response. */
|
|
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
|
+
*/
|
|
16
|
+
token(): Promise<string | undefined>;
|
|
17
|
+
onUnauthorized?(context: UnauthorizedContext): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=auth-provider.d.ts.map
|
|
@@ -0,0 +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;;;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"}
|
|
@@ -0,0 +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\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
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { CallToolResult } from "./protocol/content.ts";
|
|
2
|
+
import { type ClientCapabilities, type Implementation, type InitializeResult, type ListResourcesResult, type ListResourceTemplatesResult, type ProgressNotification, type ReadResourceResult, type Resource, type ResourceTemplate, type Root, type ServerCapabilities, type SupportedProtocolVersion, type Tool } from "./protocol/types.ts";
|
|
3
|
+
import type { McpTransport } from "./transports/transport.ts";
|
|
4
|
+
type ClientState = "idle" | "connecting" | "connected" | "closed";
|
|
5
|
+
type NotificationListener = (params: unknown) => void;
|
|
6
|
+
type ErrorListener = (error: Error) => void;
|
|
7
|
+
type CloseListener = () => void;
|
|
8
|
+
type RequestHandler = (params: unknown, context: {
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
}) => unknown | Promise<unknown>;
|
|
11
|
+
export interface McpClientOptions extends Implementation {
|
|
12
|
+
capabilities?: ClientCapabilities;
|
|
13
|
+
protocolVersion?: SupportedProtocolVersion;
|
|
14
|
+
requestTimeoutMs?: number;
|
|
15
|
+
roots?: readonly Root[] | (() => readonly Root[] | Promise<readonly Root[]>);
|
|
16
|
+
}
|
|
17
|
+
export interface McpRequestOptions {
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
onProgress?: (progress: ProgressNotification) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare class McpClient {
|
|
23
|
+
readonly options: Readonly<McpClientOptions>;
|
|
24
|
+
private state;
|
|
25
|
+
private transport;
|
|
26
|
+
private nextRequestId;
|
|
27
|
+
private serverInfoValue;
|
|
28
|
+
private serverCapabilitiesValue;
|
|
29
|
+
private instructionsValue;
|
|
30
|
+
private protocolVersionValue;
|
|
31
|
+
private pending;
|
|
32
|
+
private progressRequests;
|
|
33
|
+
private incoming;
|
|
34
|
+
private requestHandlers;
|
|
35
|
+
private notificationListeners;
|
|
36
|
+
private errorListeners;
|
|
37
|
+
private closeListeners;
|
|
38
|
+
private disposers;
|
|
39
|
+
constructor(options: McpClientOptions);
|
|
40
|
+
get connectionState(): ClientState;
|
|
41
|
+
get serverInfo(): Implementation | undefined;
|
|
42
|
+
get serverCapabilities(): ServerCapabilities | undefined;
|
|
43
|
+
get instructions(): string | undefined;
|
|
44
|
+
get protocolVersion(): string | undefined;
|
|
45
|
+
connect(transport: McpTransport): Promise<InitializeResult>;
|
|
46
|
+
request<Result = unknown>(method: string, params?: Record<string, unknown>, options?: McpRequestOptions): Promise<Result>;
|
|
47
|
+
notify(method: string, params?: Record<string, unknown>): Promise<void>;
|
|
48
|
+
setRequestHandler(method: string, handler: RequestHandler): () => void;
|
|
49
|
+
onNotification(method: string, listener: NotificationListener): () => void;
|
|
50
|
+
onError(listener: ErrorListener): () => void;
|
|
51
|
+
/** Called once when the connection closes, whether the transport dropped or `close()` was called. */
|
|
52
|
+
onClose(listener: CloseListener): () => void;
|
|
53
|
+
ping(options?: McpRequestOptions): Promise<void>;
|
|
54
|
+
listTools(options?: McpRequestOptions): Promise<Tool[]>;
|
|
55
|
+
/** Every resource, following `nextCursor` through all pages. */
|
|
56
|
+
listResources(options?: McpRequestOptions): Promise<Resource[]>;
|
|
57
|
+
/** One page of resources, starting at `cursor`. */
|
|
58
|
+
listResourcesPage(cursor?: string, options?: McpRequestOptions): Promise<ListResourcesResult>;
|
|
59
|
+
/** Every resource template, following `nextCursor` through all pages. */
|
|
60
|
+
listResourceTemplates(options?: McpRequestOptions): Promise<ResourceTemplate[]>;
|
|
61
|
+
/** One page of resource templates, starting at `cursor`. */
|
|
62
|
+
listResourceTemplatesPage(cursor?: string, options?: McpRequestOptions): Promise<ListResourceTemplatesResult>;
|
|
63
|
+
readResource(uri: string, options?: McpRequestOptions): Promise<ReadResourceResult>;
|
|
64
|
+
private listPage;
|
|
65
|
+
/** Every item of a paginated list method. */
|
|
66
|
+
private listAll;
|
|
67
|
+
callTool(name: string, args?: Record<string, unknown>, options?: McpRequestOptions): Promise<CallToolResult>;
|
|
68
|
+
close(): Promise<void>;
|
|
69
|
+
private requestInternal;
|
|
70
|
+
private notifyInternal;
|
|
71
|
+
private requireTransport;
|
|
72
|
+
private handleMessage;
|
|
73
|
+
private handleResponse;
|
|
74
|
+
private handleRequest;
|
|
75
|
+
private handleNotification;
|
|
76
|
+
private handleProgress;
|
|
77
|
+
private handleCancelled;
|
|
78
|
+
private armTimeout;
|
|
79
|
+
private cancelPending;
|
|
80
|
+
private removePending;
|
|
81
|
+
private rejectPending;
|
|
82
|
+
private handleTransportClose;
|
|
83
|
+
/** Idempotent: rejects in-flight requests, aborts server requests we are serving, and flips the state. */
|
|
84
|
+
private markClosed;
|
|
85
|
+
private emitError;
|
|
86
|
+
private disposeTransportListeners;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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,2B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