toolcraft 0.0.5 → 0.0.7
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/README.md +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +77 -59
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +13 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +7 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +13 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.js +26 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +27 -0
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +16 -0
- package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
- package/node_modules/@poe-code/agent-defs/package.json +20 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +5 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +552 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +58 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +46 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +31 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +140 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +72 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +73 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +45 -0
- package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +52 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +46 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +28 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +170 -0
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +156 -0
- package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
- package/node_modules/@poe-code/config-mutations/package.json +33 -0
- package/node_modules/@poe-code/file-lock/README.md +52 -0
- package/node_modules/@poe-code/file-lock/dist/index.d.ts +1 -0
- package/node_modules/@poe-code/file-lock/dist/index.js +1 -0
- package/node_modules/@poe-code/file-lock/dist/lock.d.ts +27 -0
- package/node_modules/@poe-code/file-lock/dist/lock.js +203 -0
- package/node_modules/@poe-code/file-lock/package.json +23 -0
- package/node_modules/auth-store/README.md +47 -0
- package/node_modules/auth-store/dist/create-secret-store.d.ts +2 -0
- package/node_modules/auth-store/dist/create-secret-store.js +35 -0
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +39 -0
- package/node_modules/auth-store/dist/encrypted-file-store.js +156 -0
- package/node_modules/auth-store/dist/index.d.ts +7 -0
- package/node_modules/auth-store/dist/index.js +4 -0
- package/node_modules/auth-store/dist/keychain-store.d.ts +22 -0
- package/node_modules/auth-store/dist/keychain-store.js +111 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +10 -0
- package/node_modules/auth-store/dist/provider-store.js +28 -0
- package/node_modules/auth-store/dist/types.d.ts +20 -0
- package/node_modules/auth-store/dist/types.js +1 -0
- package/node_modules/auth-store/package.json +25 -0
- package/node_modules/mcp-oauth/README.md +31 -0
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +14 -0
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +97 -0
- package/node_modules/mcp-oauth/dist/client/authorization-state.d.ts +8 -0
- package/node_modules/mcp-oauth/dist/client/authorization-state.js +34 -0
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.d.ts +3 -0
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +491 -0
- package/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +20 -0
- package/node_modules/mcp-oauth/dist/client/loopback-authorization.js +169 -0
- package/node_modules/mcp-oauth/dist/client/pkce.d.ts +2 -0
- package/node_modules/mcp-oauth/dist/client/pkce.js +7 -0
- package/node_modules/mcp-oauth/dist/client/token-endpoint.d.ts +40 -0
- package/node_modules/mcp-oauth/dist/client/token-endpoint.js +143 -0
- package/node_modules/mcp-oauth/dist/client/types.d.ts +113 -0
- package/node_modules/mcp-oauth/dist/client/types.js +1 -0
- package/node_modules/mcp-oauth/dist/index.d.ts +10 -0
- package/node_modules/mcp-oauth/dist/index.js +7 -0
- package/node_modules/mcp-oauth/dist/resource-indicator.d.ts +1 -0
- package/node_modules/mcp-oauth/dist/resource-indicator.js +11 -0
- package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.d.ts +27 -0
- package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +259 -0
- package/node_modules/mcp-oauth/dist/types.compile-check.d.ts +1 -0
- package/node_modules/mcp-oauth/dist/types.compile-check.js +22 -0
- package/node_modules/mcp-oauth/package.json +31 -0
- package/node_modules/tiny-mcp-client/.turbo/turbo-build.log +4 -0
- package/node_modules/tiny-mcp-client/dist/index.d.ts +2 -0
- package/node_modules/tiny-mcp-client/dist/index.js +1 -0
- package/node_modules/tiny-mcp-client/dist/internal.d.ts +547 -0
- package/node_modules/tiny-mcp-client/dist/internal.js +2404 -0
- package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.js +37 -0
- package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.js +50 -0
- package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.js +50 -0
- package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.js +51 -0
- package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.js +89 -0
- package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.js +56 -0
- package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.js +145 -0
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.d.ts +24 -0
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.js +385 -0
- package/node_modules/tiny-mcp-client/package.json +22 -0
- package/node_modules/tiny-mcp-client/src/http-oauth.integration.test.ts +823 -0
- package/node_modules/tiny-mcp-client/src/http-oauth.test.ts +882 -0
- package/node_modules/tiny-mcp-client/src/index.ts +94 -0
- package/node_modules/tiny-mcp-client/src/internal.ts +3566 -0
- package/node_modules/tiny-mcp-client/src/jsonrpc-types.compile-check.ts +66 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-http-transport.integration.test.ts +222 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-sdk.test.ts +1294 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-tiny-stdio-test-server-tools.test.ts +143 -0
- package/node_modules/tiny-mcp-client/src/mcp-lifecycle-types.compile-check.ts +65 -0
- package/node_modules/tiny-mcp-client/src/mcp-prompt-types.compile-check.ts +66 -0
- package/node_modules/tiny-mcp-client/src/mcp-resource-types.compile-check.ts +70 -0
- package/node_modules/tiny-mcp-client/src/mcp-tool-types.compile-check.ts +117 -0
- package/node_modules/tiny-mcp-client/src/mcp-transport-types.compile-check.ts +75 -0
- package/node_modules/tiny-mcp-client/src/mcp-utility-types.compile-check.ts +181 -0
- package/node_modules/tiny-mcp-client/src/mock-servers.test.ts +980 -0
- package/node_modules/tiny-mcp-client/src/oauth-discovery.ts +583 -0
- package/node_modules/tiny-mcp-client/src/transports.test.ts +8139 -0
- package/node_modules/tiny-mcp-client/src/utilities.test.ts +372 -0
- package/node_modules/tiny-mcp-client/tsconfig.json +11 -0
- package/package.json +24 -11
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createInMemoryTransportPair, discoverOAuthMetadata, createSdkTestPair, createTestPair, ERROR_INTERNAL, ERROR_INVALID_PARAMS, ERROR_INVALID_REQUEST, ERROR_METHOD_NOT_FOUND, ERROR_PARSE, HttpTransport, JsonRpcMessageLayer, McpClient, McpError, OAuthMetadataDiscovery, StdioTransport, } from "./internal.js";
|
|
2
|
+
export type { AudioContent, BlobResourceContents, CallToolOptions, CallToolParams, CallToolResult, ClientCapabilities, CompleteArgument, CompleteParams, CompleteResult, Completion, ContentItem, CreateMessageParams, CreateMessageResult, EmbeddedResource, GetPromptParams, GetPromptResult, HttpTransportFetch, HttpTransportOptions, ImageContent, Implementation, IncludeContext, InitializeParams, InitializeResult, InMemoryTransportPair, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcRequestOptions, JsonRpcResponse, JsonRpcSuccessResponse, LogLevel, LogMessage, McpClientConnection, McpClientOptions, McpTransport, McpTransportClosedEvent, ModelHint, ModelPreferences, OAuthAuthorizationServerMetadata, OAuthClientProvider, OAuthClientProviderOptions, OAuthDiscoveryCache, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthSessionStore, OAuthProtectedResourceMetadata, OAuthUnauthorizedChallenge, PaginatedParams, PaginatedResult, ProgressParams, ProgressToken, Prompt, PromptArgument, PromptMessage, PromptReference, ReadResourceParams, RequestId, Resource, ResourceContents, ResourceReference, ResourceTemplate, Root, SamplingMessage, SdkTestPair, ServerCapabilities, StdioSpawn, StdioTransportOptions, TextContent, TextResourceContents, Tool, ToolAnnotations, StoredOAuthSession, } from "./internal.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createInMemoryTransportPair, discoverOAuthMetadata, createSdkTestPair, createTestPair, ERROR_INTERNAL, ERROR_INVALID_PARAMS, ERROR_INVALID_REQUEST, ERROR_METHOD_NOT_FOUND, ERROR_PARSE, HttpTransport, JsonRpcMessageLayer, McpClient, McpError, OAuthMetadataDiscovery, StdioTransport, } from "./internal.js";
|
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams, SpawnOptions } from "node:child_process";
|
|
2
|
+
import type { Readable, Writable } from "node:stream";
|
|
3
|
+
import type { JSONRPCMessage as SdkJsonRpcMessage } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { type OAuthClientProviderOptions } from "mcp-oauth";
|
|
5
|
+
import type { Server as TinyStdioMcpServer } from "tiny-stdio-mcp-server";
|
|
6
|
+
import type { OAuthDiscoveryCache } from "./oauth-discovery.js";
|
|
7
|
+
export { OAuthMetadataDiscovery, discoverOAuthMetadata, parseBearerWwwAuthenticateHeader, resolveAuthorizationServerMetadataUrl, resolveProtectedResourceMetadataUrl, } from "./oauth-discovery.js";
|
|
8
|
+
export { createAuthStoreSessionStore, createDefaultOAuthClientProvider, } from "mcp-oauth";
|
|
9
|
+
export type { OAuthDiscoveryCache, } from "./oauth-discovery.js";
|
|
10
|
+
export type { OAuthAuthorizationServerMetadata, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthUnauthorizedChallenge } from "./oauth-discovery.js";
|
|
11
|
+
export type { DefaultOAuthClientProviderOptions, OAuthClientProvider, OAuthClientProviderOptions, OAuthSessionStore, StoredOAuthSession, } from "mcp-oauth";
|
|
12
|
+
export type RequestId = number | string;
|
|
13
|
+
export interface Implementation {
|
|
14
|
+
name: string;
|
|
15
|
+
version: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ClientCapabilities {
|
|
18
|
+
roots?: {
|
|
19
|
+
listChanged?: boolean;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
sampling?: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
experimental?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface ServerCapabilities {
|
|
28
|
+
prompts?: {
|
|
29
|
+
listChanged?: boolean;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
resources?: {
|
|
33
|
+
subscribe?: boolean;
|
|
34
|
+
listChanged?: boolean;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
tools?: {
|
|
38
|
+
listChanged?: boolean;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
logging?: {
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
completions?: {
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
};
|
|
47
|
+
experimental?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
export interface InitializeParams {
|
|
50
|
+
protocolVersion: string;
|
|
51
|
+
capabilities: ClientCapabilities;
|
|
52
|
+
clientInfo: Implementation;
|
|
53
|
+
}
|
|
54
|
+
export interface InitializeResult {
|
|
55
|
+
protocolVersion: string;
|
|
56
|
+
capabilities: ServerCapabilities;
|
|
57
|
+
serverInfo: Implementation;
|
|
58
|
+
instructions?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface McpClientOptions {
|
|
61
|
+
clientInfo: Implementation;
|
|
62
|
+
capabilities?: ClientCapabilities;
|
|
63
|
+
onToolsChanged?: () => void | Promise<void>;
|
|
64
|
+
onResourcesChanged?: () => void | Promise<void>;
|
|
65
|
+
onResourceUpdated?: (uri: string) => void | Promise<void>;
|
|
66
|
+
onPromptsChanged?: () => void | Promise<void>;
|
|
67
|
+
onLog?: (message: LogMessage) => void | Promise<void>;
|
|
68
|
+
onProgress?: (params: ProgressParams) => void | Promise<void>;
|
|
69
|
+
onSamplingRequest?: (params: CreateMessageParams) => CreateMessageResult | Promise<CreateMessageResult>;
|
|
70
|
+
onRootsList?: () => Root[] | Promise<Root[]>;
|
|
71
|
+
}
|
|
72
|
+
export declare class McpClient {
|
|
73
|
+
private currentState;
|
|
74
|
+
private currentServerCapabilities;
|
|
75
|
+
private currentServerInfo;
|
|
76
|
+
private currentInstructions;
|
|
77
|
+
private readonly options;
|
|
78
|
+
private transport;
|
|
79
|
+
private messageLayer;
|
|
80
|
+
constructor(options: McpClientOptions);
|
|
81
|
+
get state(): "disconnected" | "initializing" | "ready" | "closed";
|
|
82
|
+
get serverCapabilities(): ServerCapabilities | null;
|
|
83
|
+
get serverInfo(): Implementation | null;
|
|
84
|
+
get instructions(): string | undefined;
|
|
85
|
+
private getMessageLayerOrThrow;
|
|
86
|
+
connect(transport: McpTransport): Promise<InitializeResult>;
|
|
87
|
+
private getServerCapabilitiesOrThrow;
|
|
88
|
+
listTools(params?: PaginatedParams): Promise<{
|
|
89
|
+
tools: Tool[];
|
|
90
|
+
nextCursor?: string;
|
|
91
|
+
}>;
|
|
92
|
+
callTool(params: CallToolParams, options?: CallToolOptions): Promise<CallToolResult>;
|
|
93
|
+
listResources(params?: PaginatedParams): Promise<{
|
|
94
|
+
resources: Resource[];
|
|
95
|
+
nextCursor?: string;
|
|
96
|
+
}>;
|
|
97
|
+
listResourceTemplates(params?: PaginatedParams): Promise<{
|
|
98
|
+
resourceTemplates: ResourceTemplate[];
|
|
99
|
+
nextCursor?: string;
|
|
100
|
+
}>;
|
|
101
|
+
readResource(params: ReadResourceParams): Promise<{
|
|
102
|
+
contents: ResourceContents[];
|
|
103
|
+
}>;
|
|
104
|
+
subscribe(uri: string): Promise<void>;
|
|
105
|
+
unsubscribe(uri: string): Promise<void>;
|
|
106
|
+
listPrompts(params?: PaginatedParams): Promise<{
|
|
107
|
+
prompts: Prompt[];
|
|
108
|
+
nextCursor?: string;
|
|
109
|
+
}>;
|
|
110
|
+
getPrompt(params: GetPromptParams): Promise<GetPromptResult>;
|
|
111
|
+
complete(params: CompleteParams): Promise<CompleteResult>;
|
|
112
|
+
setLogLevel(level: LogLevel): Promise<void>;
|
|
113
|
+
cancel(requestId: RequestId, reason?: string): Promise<void>;
|
|
114
|
+
sendRootsChanged(): Promise<void>;
|
|
115
|
+
ping(): Promise<void>;
|
|
116
|
+
close(): Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
export interface Tool {
|
|
119
|
+
name: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
inputSchema: Record<string, unknown>;
|
|
122
|
+
annotations?: ToolAnnotations;
|
|
123
|
+
}
|
|
124
|
+
export interface ToolAnnotations {
|
|
125
|
+
title?: string;
|
|
126
|
+
readOnlyHint?: boolean;
|
|
127
|
+
destructiveHint?: boolean;
|
|
128
|
+
idempotentHint?: boolean;
|
|
129
|
+
openWorldHint?: boolean;
|
|
130
|
+
}
|
|
131
|
+
export interface CallToolParams {
|
|
132
|
+
name: string;
|
|
133
|
+
arguments?: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
export interface CallToolOptions {
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
progressToken?: ProgressToken;
|
|
138
|
+
}
|
|
139
|
+
export interface ReadResourceParams {
|
|
140
|
+
uri: string;
|
|
141
|
+
}
|
|
142
|
+
export interface Resource {
|
|
143
|
+
uri: string;
|
|
144
|
+
name: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
mimeType?: string;
|
|
147
|
+
size?: number;
|
|
148
|
+
}
|
|
149
|
+
export interface ResourceTemplate {
|
|
150
|
+
uriTemplate: string;
|
|
151
|
+
name: string;
|
|
152
|
+
description?: string;
|
|
153
|
+
mimeType?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface PaginatedParams {
|
|
156
|
+
cursor?: string;
|
|
157
|
+
}
|
|
158
|
+
export interface PaginatedResult {
|
|
159
|
+
nextCursor?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface TextResourceContents {
|
|
162
|
+
uri: string;
|
|
163
|
+
mimeType?: string;
|
|
164
|
+
text: string;
|
|
165
|
+
}
|
|
166
|
+
export interface BlobResourceContents {
|
|
167
|
+
uri: string;
|
|
168
|
+
mimeType?: string;
|
|
169
|
+
blob: string;
|
|
170
|
+
}
|
|
171
|
+
export type ResourceContents = TextResourceContents | BlobResourceContents;
|
|
172
|
+
export interface TextContent {
|
|
173
|
+
type: "text";
|
|
174
|
+
text: string;
|
|
175
|
+
}
|
|
176
|
+
export interface ImageContent {
|
|
177
|
+
type: "image";
|
|
178
|
+
data: string;
|
|
179
|
+
mimeType: string;
|
|
180
|
+
}
|
|
181
|
+
export interface AudioContent {
|
|
182
|
+
type: "audio";
|
|
183
|
+
data: string;
|
|
184
|
+
mimeType: string;
|
|
185
|
+
}
|
|
186
|
+
export interface EmbeddedResource {
|
|
187
|
+
type: "resource";
|
|
188
|
+
resource: ResourceContents;
|
|
189
|
+
}
|
|
190
|
+
export type ContentItem = TextContent | ImageContent | AudioContent | EmbeddedResource;
|
|
191
|
+
export interface Prompt {
|
|
192
|
+
name: string;
|
|
193
|
+
description?: string;
|
|
194
|
+
arguments?: PromptArgument[];
|
|
195
|
+
}
|
|
196
|
+
export interface PromptArgument {
|
|
197
|
+
name: string;
|
|
198
|
+
description?: string;
|
|
199
|
+
required?: boolean;
|
|
200
|
+
}
|
|
201
|
+
export interface PromptMessage {
|
|
202
|
+
role: "user" | "assistant";
|
|
203
|
+
content: ContentItem;
|
|
204
|
+
}
|
|
205
|
+
export interface GetPromptResult {
|
|
206
|
+
description?: string;
|
|
207
|
+
messages: PromptMessage[];
|
|
208
|
+
}
|
|
209
|
+
export interface GetPromptParams {
|
|
210
|
+
name: string;
|
|
211
|
+
arguments?: Record<string, string>;
|
|
212
|
+
}
|
|
213
|
+
export interface CallToolResult {
|
|
214
|
+
content: ContentItem[];
|
|
215
|
+
isError?: boolean;
|
|
216
|
+
}
|
|
217
|
+
export interface Root {
|
|
218
|
+
uri: string;
|
|
219
|
+
name?: string;
|
|
220
|
+
}
|
|
221
|
+
export type LogLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
|
|
222
|
+
export interface LogMessage {
|
|
223
|
+
level: LogLevel;
|
|
224
|
+
logger?: string;
|
|
225
|
+
data: unknown;
|
|
226
|
+
}
|
|
227
|
+
export type ProgressToken = RequestId;
|
|
228
|
+
export interface ProgressParams {
|
|
229
|
+
progressToken: ProgressToken;
|
|
230
|
+
progress: number;
|
|
231
|
+
total?: number;
|
|
232
|
+
message?: string;
|
|
233
|
+
}
|
|
234
|
+
export interface ModelHint {
|
|
235
|
+
name?: string;
|
|
236
|
+
}
|
|
237
|
+
export interface ModelPreferences {
|
|
238
|
+
hints?: ModelHint[];
|
|
239
|
+
costPriority?: number;
|
|
240
|
+
speedPriority?: number;
|
|
241
|
+
intelligencePriority?: number;
|
|
242
|
+
}
|
|
243
|
+
export interface SamplingMessage {
|
|
244
|
+
role: "user" | "assistant";
|
|
245
|
+
content: ContentItem | ContentItem[];
|
|
246
|
+
}
|
|
247
|
+
export type IncludeContext = "none" | "thisServer" | "allServers";
|
|
248
|
+
export interface CreateMessageParams {
|
|
249
|
+
messages: SamplingMessage[];
|
|
250
|
+
modelPreferences?: ModelPreferences;
|
|
251
|
+
systemPrompt?: string;
|
|
252
|
+
includeContext?: IncludeContext;
|
|
253
|
+
temperature?: number;
|
|
254
|
+
maxTokens: number;
|
|
255
|
+
stopSequences?: string[];
|
|
256
|
+
metadata?: Record<string, unknown>;
|
|
257
|
+
}
|
|
258
|
+
export interface CreateMessageResult {
|
|
259
|
+
model: string;
|
|
260
|
+
content: ContentItem | ContentItem[];
|
|
261
|
+
role: "user" | "assistant";
|
|
262
|
+
stopReason: string;
|
|
263
|
+
}
|
|
264
|
+
export interface PromptReference {
|
|
265
|
+
type: "ref/prompt";
|
|
266
|
+
name: string;
|
|
267
|
+
}
|
|
268
|
+
export interface ResourceReference {
|
|
269
|
+
type: "ref/resource";
|
|
270
|
+
uri: string;
|
|
271
|
+
}
|
|
272
|
+
export interface CompleteArgument {
|
|
273
|
+
name: string;
|
|
274
|
+
value: string;
|
|
275
|
+
}
|
|
276
|
+
export interface CompleteParams {
|
|
277
|
+
ref: PromptReference | ResourceReference;
|
|
278
|
+
argument: CompleteArgument;
|
|
279
|
+
}
|
|
280
|
+
export interface Completion {
|
|
281
|
+
values: string[];
|
|
282
|
+
hasMore?: boolean;
|
|
283
|
+
total?: number;
|
|
284
|
+
}
|
|
285
|
+
export interface CompleteResult {
|
|
286
|
+
completion: Completion;
|
|
287
|
+
}
|
|
288
|
+
export declare const ERROR_PARSE = -32700;
|
|
289
|
+
export declare const ERROR_INVALID_REQUEST = -32600;
|
|
290
|
+
export declare const ERROR_METHOD_NOT_FOUND = -32601;
|
|
291
|
+
export declare const ERROR_INVALID_PARAMS = -32602;
|
|
292
|
+
export declare const ERROR_INTERNAL = -32603;
|
|
293
|
+
export interface McpTransportClosedEvent {
|
|
294
|
+
reason: Error;
|
|
295
|
+
code?: number;
|
|
296
|
+
signal?: NodeJS.Signals;
|
|
297
|
+
}
|
|
298
|
+
export interface McpTransport {
|
|
299
|
+
readable: Readable;
|
|
300
|
+
writable: Writable;
|
|
301
|
+
closed: Promise<McpTransportClosedEvent>;
|
|
302
|
+
dispose(reason?: Error): void;
|
|
303
|
+
}
|
|
304
|
+
export interface InMemoryServerTransport {
|
|
305
|
+
readable: Readable;
|
|
306
|
+
writable: Writable;
|
|
307
|
+
}
|
|
308
|
+
export interface InMemoryTransportPair {
|
|
309
|
+
clientTransport: McpTransport;
|
|
310
|
+
serverTransport: InMemoryServerTransport;
|
|
311
|
+
}
|
|
312
|
+
export declare function createInMemoryTransportPair(): InMemoryTransportPair;
|
|
313
|
+
interface SdkTransportAdapterInput {
|
|
314
|
+
onclose?: () => void;
|
|
315
|
+
onerror?: (error: Error) => void;
|
|
316
|
+
onmessage?: (message: SdkJsonRpcMessage, extra?: any) => void;
|
|
317
|
+
start(): Promise<void>;
|
|
318
|
+
close(): Promise<void>;
|
|
319
|
+
send(message: SdkJsonRpcMessage): Promise<void>;
|
|
320
|
+
}
|
|
321
|
+
export interface McpClientConnection {
|
|
322
|
+
connect(transport: McpTransport): Promise<void>;
|
|
323
|
+
close(): Promise<void>;
|
|
324
|
+
}
|
|
325
|
+
interface SdkServerConnection {
|
|
326
|
+
connect(transport: unknown): Promise<void>;
|
|
327
|
+
}
|
|
328
|
+
export interface SdkTestPair<TClient extends McpClientConnection> {
|
|
329
|
+
client: TClient;
|
|
330
|
+
cleanup: () => Promise<void>;
|
|
331
|
+
}
|
|
332
|
+
export declare class SdkTransportAdapter implements McpTransport {
|
|
333
|
+
readonly readable: Readable;
|
|
334
|
+
readonly writable: Writable;
|
|
335
|
+
readonly closed: Promise<McpTransportClosedEvent>;
|
|
336
|
+
private readonly sdkTransport;
|
|
337
|
+
private readonly readStream;
|
|
338
|
+
private readonly writeStream;
|
|
339
|
+
private resolveClosed;
|
|
340
|
+
private disposed;
|
|
341
|
+
constructor(sdkTransport: SdkTransportAdapterInput);
|
|
342
|
+
dispose(reason?: Error): void;
|
|
343
|
+
private consumeWrittenLines;
|
|
344
|
+
}
|
|
345
|
+
export declare function createSdkTestPair<TClient extends McpClientConnection>(server: SdkServerConnection, createClient: () => TClient): Promise<SdkTestPair<TClient>>;
|
|
346
|
+
export declare function createMockEchoToolServer(): Promise<SdkServerConnection>;
|
|
347
|
+
export declare function createMockMultiToolServer(): Promise<SdkServerConnection>;
|
|
348
|
+
export declare function createMockPaginatedToolsServer(): Promise<SdkServerConnection>;
|
|
349
|
+
export declare function createMockResourceServer(): Promise<SdkServerConnection>;
|
|
350
|
+
export declare function createMockSubscribableResourceServer(): Promise<SdkServerConnection & {
|
|
351
|
+
triggerResourceUpdated: (uri: string, updatedText?: string) => Promise<void>;
|
|
352
|
+
triggerResourceListChanged: () => Promise<void>;
|
|
353
|
+
}>;
|
|
354
|
+
export declare function createMockPromptServer(): Promise<SdkServerConnection>;
|
|
355
|
+
export declare function createMockCompletionServer(): Promise<SdkServerConnection>;
|
|
356
|
+
export declare function createMockProgressServer(): Promise<SdkServerConnection>;
|
|
357
|
+
export interface MockSlowToolServerOptions {
|
|
358
|
+
delayMs?: number;
|
|
359
|
+
pollIntervalMs?: number;
|
|
360
|
+
}
|
|
361
|
+
export declare function createMockSlowToolServer(options?: MockSlowToolServerOptions): Promise<SdkServerConnection & {
|
|
362
|
+
wasStarted: () => boolean;
|
|
363
|
+
getStartedRequestIds: () => RequestId[];
|
|
364
|
+
wasCancelled: () => boolean;
|
|
365
|
+
getCancelledRequestIds: () => RequestId[];
|
|
366
|
+
}>;
|
|
367
|
+
export declare function createMockErrorServer(): Promise<SdkServerConnection>;
|
|
368
|
+
export declare function createMockSamplingServer(): Promise<SdkServerConnection>;
|
|
369
|
+
export declare function createMockRootsServer(): Promise<SdkServerConnection>;
|
|
370
|
+
export declare function createMockLoggingServer(): Promise<SdkServerConnection>;
|
|
371
|
+
export declare function createMockFullFeaturedServer(): Promise<SdkServerConnection>;
|
|
372
|
+
export declare function createTestPair<TClient extends McpClientConnection>(server: TinyStdioMcpServer, createClient: () => TClient): Promise<SdkTestPair<TClient>>;
|
|
373
|
+
export type StdioSpawn = (command: string, args: ReadonlyArray<string>, options: SpawnOptions) => ChildProcessWithoutNullStreams;
|
|
374
|
+
export interface StdioTransportOptions {
|
|
375
|
+
command: string;
|
|
376
|
+
args?: string[];
|
|
377
|
+
cwd?: string;
|
|
378
|
+
env?: NodeJS.ProcessEnv;
|
|
379
|
+
spawn?: StdioSpawn;
|
|
380
|
+
}
|
|
381
|
+
export type HttpTransportFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
382
|
+
export interface HttpTransportOptions {
|
|
383
|
+
url: string;
|
|
384
|
+
headers?: HeadersInit;
|
|
385
|
+
fetch?: HttpTransportFetch;
|
|
386
|
+
oauth?: OAuthClientProviderOptions;
|
|
387
|
+
oauthDiscoveryCache?: OAuthDiscoveryCache;
|
|
388
|
+
}
|
|
389
|
+
export declare class StdioTransport implements McpTransport {
|
|
390
|
+
readonly readable: Readable;
|
|
391
|
+
readonly writable: Writable;
|
|
392
|
+
readonly closed: Promise<McpTransportClosedEvent>;
|
|
393
|
+
private readonly child;
|
|
394
|
+
private disposed;
|
|
395
|
+
private stderrOutput;
|
|
396
|
+
private static readonly STDERR_MAX_LENGTH;
|
|
397
|
+
constructor({ command, args, cwd, env, spawn: spawnProcess, }: StdioTransportOptions);
|
|
398
|
+
getStderrOutput(): string;
|
|
399
|
+
dispose(reason?: Error): void;
|
|
400
|
+
}
|
|
401
|
+
export declare class HttpTransport implements McpTransport {
|
|
402
|
+
readonly readable: Readable;
|
|
403
|
+
readonly writable: Writable;
|
|
404
|
+
readonly closed: Promise<McpTransportClosedEvent>;
|
|
405
|
+
private readonly url;
|
|
406
|
+
private readonly headers;
|
|
407
|
+
private readonly fetchImpl;
|
|
408
|
+
private readonly readStream;
|
|
409
|
+
private readonly writeStream;
|
|
410
|
+
private resolveClosed;
|
|
411
|
+
private sessionId;
|
|
412
|
+
private lastEventId;
|
|
413
|
+
private getSseStreamStarted;
|
|
414
|
+
private disposed;
|
|
415
|
+
private readonly oauthProvider;
|
|
416
|
+
private readonly oauthMetadataDiscovery;
|
|
417
|
+
private readonly inFlightFetchAbortControllers;
|
|
418
|
+
private readonly openSseReaders;
|
|
419
|
+
constructor({ url, headers, fetch: fetchImpl, oauth, oauthDiscoveryCache, }: HttpTransportOptions);
|
|
420
|
+
dispose(reason?: Error): void;
|
|
421
|
+
private abortInFlightFetches;
|
|
422
|
+
private cancelOpenSseReaders;
|
|
423
|
+
private fetchWithAbort;
|
|
424
|
+
private consumeWrittenLines;
|
|
425
|
+
private createPostHeaders;
|
|
426
|
+
private createGetHeaders;
|
|
427
|
+
private createDeleteHeaders;
|
|
428
|
+
private authorizeRequestHeaders;
|
|
429
|
+
private captureSessionId;
|
|
430
|
+
private maybeOpenGetSseStream;
|
|
431
|
+
private terminateSession;
|
|
432
|
+
private sendSessionTerminationRequest;
|
|
433
|
+
private consumeGetSseStream;
|
|
434
|
+
private throwForPostHttpError;
|
|
435
|
+
private maybeHandleUnauthorizedResponse;
|
|
436
|
+
private forwardResponseMessages;
|
|
437
|
+
private forwardSseResponseMessages;
|
|
438
|
+
private forwardJsonResponseMessage;
|
|
439
|
+
private writeSseMessages;
|
|
440
|
+
private writeReadableLine;
|
|
441
|
+
private fetchWithOAuthRetry;
|
|
442
|
+
private readOAuthChallengeError;
|
|
443
|
+
}
|
|
444
|
+
export interface JsonRpcRequest {
|
|
445
|
+
jsonrpc: "2.0";
|
|
446
|
+
id: RequestId;
|
|
447
|
+
method: string;
|
|
448
|
+
params?: unknown;
|
|
449
|
+
}
|
|
450
|
+
export interface JsonRpcNotification {
|
|
451
|
+
jsonrpc: "2.0";
|
|
452
|
+
method: string;
|
|
453
|
+
params?: unknown;
|
|
454
|
+
}
|
|
455
|
+
export interface JsonRpcErrorObject {
|
|
456
|
+
code: number;
|
|
457
|
+
message: string;
|
|
458
|
+
data?: unknown;
|
|
459
|
+
}
|
|
460
|
+
export declare class McpError extends Error {
|
|
461
|
+
readonly code: number;
|
|
462
|
+
readonly data?: unknown;
|
|
463
|
+
constructor(code: number, message: string, data?: unknown);
|
|
464
|
+
}
|
|
465
|
+
export interface JsonRpcSuccessResponse {
|
|
466
|
+
jsonrpc: "2.0";
|
|
467
|
+
id: RequestId;
|
|
468
|
+
result: unknown;
|
|
469
|
+
}
|
|
470
|
+
export interface JsonRpcErrorResponse {
|
|
471
|
+
jsonrpc: "2.0";
|
|
472
|
+
id: RequestId;
|
|
473
|
+
error: JsonRpcErrorObject;
|
|
474
|
+
}
|
|
475
|
+
export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
|
476
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
|
|
477
|
+
export type ParsedJsonRpcMessage = {
|
|
478
|
+
type: "request";
|
|
479
|
+
message: JsonRpcRequest;
|
|
480
|
+
} | {
|
|
481
|
+
type: "notification";
|
|
482
|
+
message: JsonRpcNotification;
|
|
483
|
+
} | {
|
|
484
|
+
type: "response";
|
|
485
|
+
message: JsonRpcResponse;
|
|
486
|
+
} | {
|
|
487
|
+
type: "invalid";
|
|
488
|
+
id: RequestId | null;
|
|
489
|
+
error: McpError;
|
|
490
|
+
};
|
|
491
|
+
export declare function serializeJsonRpcMessage(message: JsonRpcMessage): string;
|
|
492
|
+
export declare function readLines(stream: Readable): AsyncGenerator<string>;
|
|
493
|
+
export interface ParsedSseMessage {
|
|
494
|
+
data: string;
|
|
495
|
+
id?: string;
|
|
496
|
+
}
|
|
497
|
+
export declare class SseParser {
|
|
498
|
+
private buffer;
|
|
499
|
+
private eventType;
|
|
500
|
+
private dataLines;
|
|
501
|
+
private eventId;
|
|
502
|
+
private hasEventId;
|
|
503
|
+
private _lastEventId;
|
|
504
|
+
get lastEventId(): string | undefined;
|
|
505
|
+
push(chunk: string): ParsedSseMessage[];
|
|
506
|
+
flush(): ParsedSseMessage[];
|
|
507
|
+
private consumeLine;
|
|
508
|
+
private emitEvent;
|
|
509
|
+
private resetEvent;
|
|
510
|
+
}
|
|
511
|
+
export interface JsonRpcRequestOptions {
|
|
512
|
+
timeoutMs?: number;
|
|
513
|
+
onRequestId?: (requestId: RequestId) => void;
|
|
514
|
+
}
|
|
515
|
+
interface JsonRpcRequestContext {
|
|
516
|
+
id: RequestId;
|
|
517
|
+
method: string;
|
|
518
|
+
}
|
|
519
|
+
type JsonRpcRequestHandler = (params: unknown, context: JsonRpcRequestContext) => unknown | Promise<unknown>;
|
|
520
|
+
interface JsonRpcNotificationContext {
|
|
521
|
+
method: string;
|
|
522
|
+
}
|
|
523
|
+
type JsonRpcNotificationHandler = (params: unknown, context: JsonRpcNotificationContext) => unknown | Promise<unknown>;
|
|
524
|
+
export declare class JsonRpcMessageLayer {
|
|
525
|
+
readonly requestTimeoutMs: number;
|
|
526
|
+
private readonly input;
|
|
527
|
+
private readonly output;
|
|
528
|
+
private readonly inputClosedReason;
|
|
529
|
+
private nextRequestId;
|
|
530
|
+
private disposedError;
|
|
531
|
+
private readonly pendingRequests;
|
|
532
|
+
private readonly activeIncomingRequests;
|
|
533
|
+
private readonly requestHandlers;
|
|
534
|
+
private readonly notificationHandlers;
|
|
535
|
+
constructor(input: Readable, output: Writable, requestTimeoutMs?: number, inputClosedReason?: Promise<Error>);
|
|
536
|
+
sendNotification(method: string, params?: unknown): void;
|
|
537
|
+
onRequest(method: string, handler: JsonRpcRequestHandler): void;
|
|
538
|
+
onNotification(method: string, handler: JsonRpcNotificationHandler): void;
|
|
539
|
+
sendRequest(method: string, params?: unknown, options?: JsonRpcRequestOptions): Promise<unknown>;
|
|
540
|
+
dispose(reason?: Error): void;
|
|
541
|
+
private consumeInput;
|
|
542
|
+
private resolveInputStreamClosedReason;
|
|
543
|
+
private processParsedMessage;
|
|
544
|
+
private handleIncomingRequest;
|
|
545
|
+
private handleCancellationNotification;
|
|
546
|
+
}
|
|
547
|
+
export declare function parseJsonRpcMessage(line: string): ParsedJsonRpcMessage;
|