gitx.do 0.0.1 → 0.0.3
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/dist/cli/commands/blame.d.ts +259 -0
- package/dist/cli/commands/blame.d.ts.map +1 -0
- package/dist/cli/commands/blame.js +609 -0
- package/dist/cli/commands/blame.js.map +1 -0
- package/dist/cli/commands/branch.d.ts +249 -0
- package/dist/cli/commands/branch.d.ts.map +1 -0
- package/dist/cli/commands/branch.js +693 -0
- package/dist/cli/commands/branch.js.map +1 -0
- package/dist/cli/commands/commit.d.ts +182 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +437 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/diff.d.ts +464 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +958 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/log.d.ts +239 -0
- package/dist/cli/commands/log.d.ts.map +1 -0
- package/dist/cli/commands/log.js +535 -0
- package/dist/cli/commands/log.js.map +1 -0
- package/dist/cli/commands/review.d.ts +457 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +533 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/status.d.ts +269 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +493 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/web.d.ts +199 -0
- package/dist/cli/commands/web.d.ts.map +1 -0
- package/dist/cli/commands/web.js +696 -0
- package/dist/cli/commands/web.js.map +1 -0
- package/dist/cli/fs-adapter.d.ts +656 -0
- package/dist/cli/fs-adapter.d.ts.map +1 -0
- package/dist/cli/fs-adapter.js +1179 -0
- package/dist/cli/fs-adapter.js.map +1 -0
- package/dist/cli/index.d.ts +387 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +523 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/ui/components/DiffView.d.ts +7 -0
- package/dist/cli/ui/components/DiffView.d.ts.map +1 -0
- package/dist/cli/ui/components/DiffView.js +11 -0
- package/dist/cli/ui/components/DiffView.js.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts +6 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.js +11 -0
- package/dist/cli/ui/components/ErrorDisplay.js.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts +9 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.js +12 -0
- package/dist/cli/ui/components/FuzzySearch.js.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts +6 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.js +10 -0
- package/dist/cli/ui/components/LoadingSpinner.js.map +1 -0
- package/dist/cli/ui/components/NavigationList.d.ts +9 -0
- package/dist/cli/ui/components/NavigationList.d.ts.map +1 -0
- package/dist/cli/ui/components/NavigationList.js +11 -0
- package/dist/cli/ui/components/NavigationList.js.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts +8 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.js +11 -0
- package/dist/cli/ui/components/ScrollableContent.js.map +1 -0
- package/dist/cli/ui/components/index.d.ts +7 -0
- package/dist/cli/ui/components/index.d.ts.map +1 -0
- package/dist/cli/ui/components/index.js +9 -0
- package/dist/cli/ui/components/index.js.map +1 -0
- package/dist/cli/ui/terminal-ui.d.ts +52 -0
- package/dist/cli/ui/terminal-ui.d.ts.map +1 -0
- package/dist/cli/ui/terminal-ui.js +121 -0
- package/dist/cli/ui/terminal-ui.js.map +1 -0
- package/dist/durable-object/object-store.d.ts +401 -23
- package/dist/durable-object/object-store.d.ts.map +1 -1
- package/dist/durable-object/object-store.js +414 -25
- package/dist/durable-object/object-store.js.map +1 -1
- package/dist/durable-object/schema.d.ts +188 -0
- package/dist/durable-object/schema.d.ts.map +1 -1
- package/dist/durable-object/schema.js +160 -0
- package/dist/durable-object/schema.js.map +1 -1
- package/dist/durable-object/wal.d.ts +336 -31
- package/dist/durable-object/wal.d.ts.map +1 -1
- package/dist/durable-object/wal.js +272 -27
- package/dist/durable-object/wal.js.map +1 -1
- package/dist/index.d.ts +379 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +379 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/adapter.d.ts +579 -38
- package/dist/mcp/adapter.d.ts.map +1 -1
- package/dist/mcp/adapter.js +426 -33
- package/dist/mcp/adapter.js.map +1 -1
- package/dist/mcp/sandbox.d.ts +532 -29
- package/dist/mcp/sandbox.d.ts.map +1 -1
- package/dist/mcp/sandbox.js +389 -22
- package/dist/mcp/sandbox.js.map +1 -1
- package/dist/mcp/sdk-adapter.d.ts +478 -56
- package/dist/mcp/sdk-adapter.d.ts.map +1 -1
- package/dist/mcp/sdk-adapter.js +346 -44
- package/dist/mcp/sdk-adapter.js.map +1 -1
- package/dist/mcp/tools.d.ts +445 -30
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +363 -33
- package/dist/mcp/tools.js.map +1 -1
- package/dist/ops/blame.d.ts +424 -21
- package/dist/ops/blame.d.ts.map +1 -1
- package/dist/ops/blame.js +303 -20
- package/dist/ops/blame.js.map +1 -1
- package/dist/ops/branch.d.ts +583 -32
- package/dist/ops/branch.d.ts.map +1 -1
- package/dist/ops/branch.js +365 -23
- package/dist/ops/branch.js.map +1 -1
- package/dist/ops/commit-traversal.d.ts +164 -24
- package/dist/ops/commit-traversal.d.ts.map +1 -1
- package/dist/ops/commit-traversal.js +68 -2
- package/dist/ops/commit-traversal.js.map +1 -1
- package/dist/ops/commit.d.ts +387 -53
- package/dist/ops/commit.d.ts.map +1 -1
- package/dist/ops/commit.js +249 -29
- package/dist/ops/commit.js.map +1 -1
- package/dist/ops/merge-base.d.ts +195 -21
- package/dist/ops/merge-base.d.ts.map +1 -1
- package/dist/ops/merge-base.js +122 -12
- package/dist/ops/merge-base.js.map +1 -1
- package/dist/ops/merge.d.ts +600 -130
- package/dist/ops/merge.d.ts.map +1 -1
- package/dist/ops/merge.js +408 -60
- package/dist/ops/merge.js.map +1 -1
- package/dist/ops/tag.d.ts +67 -2
- package/dist/ops/tag.d.ts.map +1 -1
- package/dist/ops/tag.js +42 -1
- package/dist/ops/tag.js.map +1 -1
- package/dist/ops/tree-builder.d.ts +102 -6
- package/dist/ops/tree-builder.d.ts.map +1 -1
- package/dist/ops/tree-builder.js +30 -5
- package/dist/ops/tree-builder.js.map +1 -1
- package/dist/ops/tree-diff.d.ts +50 -2
- package/dist/ops/tree-diff.d.ts.map +1 -1
- package/dist/ops/tree-diff.js +50 -2
- package/dist/ops/tree-diff.js.map +1 -1
- package/dist/pack/delta.d.ts +211 -39
- package/dist/pack/delta.d.ts.map +1 -1
- package/dist/pack/delta.js +232 -46
- package/dist/pack/delta.js.map +1 -1
- package/dist/pack/format.d.ts +390 -28
- package/dist/pack/format.d.ts.map +1 -1
- package/dist/pack/format.js +344 -33
- package/dist/pack/format.js.map +1 -1
- package/dist/pack/full-generation.d.ts +313 -28
- package/dist/pack/full-generation.d.ts.map +1 -1
- package/dist/pack/full-generation.js +238 -19
- package/dist/pack/full-generation.js.map +1 -1
- package/dist/pack/generation.d.ts +346 -23
- package/dist/pack/generation.d.ts.map +1 -1
- package/dist/pack/generation.js +269 -21
- package/dist/pack/generation.js.map +1 -1
- package/dist/pack/index.d.ts +407 -86
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +351 -70
- package/dist/pack/index.js.map +1 -1
- package/dist/refs/branch.d.ts +517 -71
- package/dist/refs/branch.d.ts.map +1 -1
- package/dist/refs/branch.js +410 -26
- package/dist/refs/branch.js.map +1 -1
- package/dist/refs/storage.d.ts +610 -57
- package/dist/refs/storage.d.ts.map +1 -1
- package/dist/refs/storage.js +481 -29
- package/dist/refs/storage.js.map +1 -1
- package/dist/refs/tag.d.ts +677 -67
- package/dist/refs/tag.d.ts.map +1 -1
- package/dist/refs/tag.js +497 -30
- package/dist/refs/tag.js.map +1 -1
- package/dist/storage/lru-cache.d.ts +556 -53
- package/dist/storage/lru-cache.d.ts.map +1 -1
- package/dist/storage/lru-cache.js +439 -36
- package/dist/storage/lru-cache.js.map +1 -1
- package/dist/storage/object-index.d.ts +483 -38
- package/dist/storage/object-index.d.ts.map +1 -1
- package/dist/storage/object-index.js +388 -22
- package/dist/storage/object-index.js.map +1 -1
- package/dist/storage/r2-pack.d.ts +957 -94
- package/dist/storage/r2-pack.d.ts.map +1 -1
- package/dist/storage/r2-pack.js +756 -48
- package/dist/storage/r2-pack.js.map +1 -1
- package/dist/tiered/cdc-pipeline.d.ts +1610 -38
- package/dist/tiered/cdc-pipeline.d.ts.map +1 -1
- package/dist/tiered/cdc-pipeline.js +1131 -22
- package/dist/tiered/cdc-pipeline.js.map +1 -1
- package/dist/tiered/migration.d.ts +903 -41
- package/dist/tiered/migration.d.ts.map +1 -1
- package/dist/tiered/migration.js +646 -24
- package/dist/tiered/migration.js.map +1 -1
- package/dist/tiered/parquet-writer.d.ts +944 -47
- package/dist/tiered/parquet-writer.d.ts.map +1 -1
- package/dist/tiered/parquet-writer.js +667 -39
- package/dist/tiered/parquet-writer.js.map +1 -1
- package/dist/tiered/read-path.d.ts +728 -34
- package/dist/tiered/read-path.d.ts.map +1 -1
- package/dist/tiered/read-path.js +310 -27
- package/dist/tiered/read-path.js.map +1 -1
- package/dist/types/objects.d.ts +457 -0
- package/dist/types/objects.d.ts.map +1 -1
- package/dist/types/objects.js +305 -4
- package/dist/types/objects.js.map +1 -1
- package/dist/types/storage.d.ts +407 -35
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types/storage.js +27 -3
- package/dist/types/storage.js.map +1 -1
- package/dist/utils/hash.d.ts +133 -12
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +133 -12
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/sha1.d.ts +102 -9
- package/dist/utils/sha1.d.ts.map +1 -1
- package/dist/utils/sha1.js +114 -11
- package/dist/utils/sha1.js.map +1 -1
- package/dist/wire/capabilities.d.ts +896 -88
- package/dist/wire/capabilities.d.ts.map +1 -1
- package/dist/wire/capabilities.js +566 -62
- package/dist/wire/capabilities.js.map +1 -1
- package/dist/wire/pkt-line.d.ts +293 -15
- package/dist/wire/pkt-line.d.ts.map +1 -1
- package/dist/wire/pkt-line.js +251 -15
- package/dist/wire/pkt-line.js.map +1 -1
- package/dist/wire/receive-pack.d.ts +814 -64
- package/dist/wire/receive-pack.d.ts.map +1 -1
- package/dist/wire/receive-pack.js +542 -41
- package/dist/wire/receive-pack.js.map +1 -1
- package/dist/wire/smart-http.d.ts +575 -97
- package/dist/wire/smart-http.d.ts.map +1 -1
- package/dist/wire/smart-http.js +337 -46
- package/dist/wire/smart-http.js.map +1 -1
- package/dist/wire/upload-pack.d.ts +492 -98
- package/dist/wire/upload-pack.d.ts.map +1 -1
- package/dist/wire/upload-pack.js +347 -59
- package/dist/wire/upload-pack.js.map +1 -1
- package/package.json +10 -2
|
@@ -1,32 +1,114 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP SDK Adapter
|
|
2
|
+
* @fileoverview MCP SDK Adapter
|
|
3
3
|
*
|
|
4
4
|
* This module provides a full-featured adapter for the MCP SDK,
|
|
5
5
|
* including SDK initialization, tool registration, request/response
|
|
6
6
|
* handling, error propagation, and connection lifecycle management.
|
|
7
|
+
*
|
|
8
|
+
* The SDK adapter extends the basic adapter with:
|
|
9
|
+
* - Multiple transport support (stdio, SSE, HTTP)
|
|
10
|
+
* - Connection state management and events
|
|
11
|
+
* - Request cancellation and progress reporting
|
|
12
|
+
* - Session management with client information
|
|
13
|
+
* - Ping/pong health checking
|
|
14
|
+
* - Graceful shutdown with pending request handling
|
|
15
|
+
*
|
|
16
|
+
* @module mcp/sdk-adapter
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create and start an SDK adapter
|
|
20
|
+
* import { createMCPSDKAdapter, MCPSDKTransport } from './sdk-adapter'
|
|
21
|
+
*
|
|
22
|
+
* const adapter = createMCPSDKAdapter({
|
|
23
|
+
* name: 'git-mcp-server',
|
|
24
|
+
* version: '1.0.0',
|
|
25
|
+
* transports: ['stdio', 'http'],
|
|
26
|
+
* capabilities: { tools: { listChanged: true } }
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* adapter.registerGitdoTools()
|
|
30
|
+
* await adapter.start()
|
|
31
|
+
*
|
|
32
|
+
* // Connect with a transport
|
|
33
|
+
* const transport = MCPSDKTransport.createStdio()
|
|
34
|
+
* await adapter.connect(transport)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Handle tool calls with progress
|
|
38
|
+
* const result = adapter.handleToolsCall({
|
|
39
|
+
* name: 'git_log',
|
|
40
|
+
* arguments: { maxCount: 100 }
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* adapter.onProgress((event) => {
|
|
44
|
+
* console.log(`Progress: ${event.progress}/${event.total}`)
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* const output = await result
|
|
7
48
|
*/
|
|
8
49
|
import { type MCPToolResult } from './tools';
|
|
9
50
|
/**
|
|
10
|
-
* MCP SDK Error codes - JSON-RPC 2.0 standard codes and MCP-specific codes
|
|
51
|
+
* MCP SDK Error codes - JSON-RPC 2.0 standard codes and MCP-specific codes.
|
|
52
|
+
*
|
|
53
|
+
* @description
|
|
54
|
+
* Enumeration of error codes used in MCP SDK responses. Follows JSON-RPC 2.0
|
|
55
|
+
* specification for standard errors and defines MCP-specific codes for
|
|
56
|
+
* resource, tool, and prompt operations.
|
|
57
|
+
*
|
|
58
|
+
* @enum {number}
|
|
11
59
|
*/
|
|
12
60
|
export declare enum MCPSDKErrorCode {
|
|
61
|
+
/** Parse error - Invalid JSON (-32700) */
|
|
13
62
|
PARSE_ERROR = -32700,
|
|
63
|
+
/** Invalid Request - Not a valid Request object (-32600) */
|
|
14
64
|
INVALID_REQUEST = -32600,
|
|
65
|
+
/** Method not found - Method does not exist (-32601) */
|
|
15
66
|
METHOD_NOT_FOUND = -32601,
|
|
67
|
+
/** Invalid params - Invalid method parameters (-32602) */
|
|
16
68
|
INVALID_PARAMS = -32602,
|
|
69
|
+
/** Internal error - Internal JSON-RPC error (-32603) */
|
|
17
70
|
INTERNAL_ERROR = -32603,
|
|
71
|
+
/** Tool not found - Requested tool does not exist (-32001) */
|
|
18
72
|
TOOL_NOT_FOUND = -32001,
|
|
73
|
+
/** Resource not found - Requested resource does not exist (-32002) */
|
|
19
74
|
RESOURCE_NOT_FOUND = -32002,
|
|
75
|
+
/** Prompt not found - Requested prompt does not exist (-32003) */
|
|
20
76
|
PROMPT_NOT_FOUND = -32003,
|
|
77
|
+
/** Capability not supported - Capability is not enabled (-32004) */
|
|
21
78
|
CAPABILITY_NOT_SUPPORTED = -32004
|
|
22
79
|
}
|
|
23
80
|
/**
|
|
24
|
-
* MCP SDK Error class
|
|
81
|
+
* MCP SDK Error class.
|
|
82
|
+
*
|
|
83
|
+
* @description
|
|
84
|
+
* Error class for MCP SDK operations. Encapsulates error code, message,
|
|
85
|
+
* and optional data. Can be converted to JSON-RPC format.
|
|
86
|
+
*
|
|
87
|
+
* @class MCPSDKError
|
|
88
|
+
* @extends Error
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* throw new MCPSDKError(
|
|
92
|
+
* MCPSDKErrorCode.TOOL_NOT_FOUND,
|
|
93
|
+
* 'Tool "unknown" not found'
|
|
94
|
+
* )
|
|
25
95
|
*/
|
|
26
96
|
export declare class MCPSDKError extends Error {
|
|
97
|
+
/** The error code */
|
|
27
98
|
code: MCPSDKErrorCode;
|
|
99
|
+
/** Optional additional error data */
|
|
28
100
|
data?: unknown;
|
|
101
|
+
/**
|
|
102
|
+
* Create a new MCP SDK error.
|
|
103
|
+
* @param code - The error code
|
|
104
|
+
* @param message - Human-readable error message
|
|
105
|
+
* @param data - Optional additional data
|
|
106
|
+
*/
|
|
29
107
|
constructor(code: MCPSDKErrorCode, message: string, data?: unknown);
|
|
108
|
+
/**
|
|
109
|
+
* Convert to JSON-RPC error format.
|
|
110
|
+
* @returns Object suitable for JSON-RPC error responses
|
|
111
|
+
*/
|
|
30
112
|
toJSONRPC(): {
|
|
31
113
|
code: number;
|
|
32
114
|
message: string;
|
|
@@ -34,22 +116,38 @@ export declare class MCPSDKError extends Error {
|
|
|
34
116
|
};
|
|
35
117
|
}
|
|
36
118
|
/**
|
|
37
|
-
* Transport type
|
|
119
|
+
* Transport type.
|
|
120
|
+
* @description Supported transport mechanisms for MCP communication.
|
|
121
|
+
* @typedef {'stdio' | 'sse' | 'http' | 'custom'} MCPSDKTransportType
|
|
38
122
|
*/
|
|
39
123
|
export type MCPSDKTransportType = 'stdio' | 'sse' | 'http' | 'custom';
|
|
40
124
|
/**
|
|
41
|
-
* Connection state
|
|
125
|
+
* Connection state.
|
|
126
|
+
* @description Represents the current state of the adapter connection.
|
|
127
|
+
* @typedef {'disconnected' | 'initializing' | 'connected'} MCPSDKConnectionState
|
|
42
128
|
*/
|
|
43
129
|
export type MCPSDKConnectionState = 'disconnected' | 'initializing' | 'connected';
|
|
44
130
|
/**
|
|
45
|
-
* MCP SDK Transport interface
|
|
131
|
+
* MCP SDK Transport interface.
|
|
132
|
+
*
|
|
133
|
+
* @description
|
|
134
|
+
* Interface for transport implementations that handle sending and receiving
|
|
135
|
+
* MCP messages. Different transports (stdio, SSE, HTTP) implement this interface.
|
|
136
|
+
*
|
|
137
|
+
* @interface MCPSDKTransport
|
|
46
138
|
*/
|
|
47
139
|
export interface MCPSDKTransport {
|
|
140
|
+
/** Transport type identifier */
|
|
48
141
|
type: MCPSDKTransportType;
|
|
142
|
+
/** Send data through the transport */
|
|
49
143
|
send?: (data: string) => void;
|
|
144
|
+
/** Receive data from the transport */
|
|
50
145
|
receive?: () => Promise<string>;
|
|
146
|
+
/** Close the transport connection */
|
|
51
147
|
close?: () => void;
|
|
148
|
+
/** Check if transport is connected */
|
|
52
149
|
isConnected: () => boolean;
|
|
150
|
+
/** Handle an HTTP-style request (for HTTP/SSE transports) */
|
|
53
151
|
handleRequest?: (request: unknown) => Promise<{
|
|
54
152
|
status: number;
|
|
55
153
|
headers: Record<string, string>;
|
|
@@ -57,70 +155,148 @@ export interface MCPSDKTransport {
|
|
|
57
155
|
}>;
|
|
58
156
|
}
|
|
59
157
|
/**
|
|
60
|
-
* Logger interface
|
|
158
|
+
* Logger interface.
|
|
159
|
+
*
|
|
160
|
+
* @description
|
|
161
|
+
* Interface for logging implementations. All methods are optional,
|
|
162
|
+
* allowing partial logger implementations.
|
|
163
|
+
*
|
|
164
|
+
* @interface MCPSDKLogger
|
|
61
165
|
*/
|
|
62
166
|
export interface MCPSDKLogger {
|
|
167
|
+
/** Log error messages */
|
|
63
168
|
error?: (message: string, ...args: unknown[]) => void;
|
|
169
|
+
/** Log warning messages */
|
|
64
170
|
warn?: (message: string, ...args: unknown[]) => void;
|
|
171
|
+
/** Log info messages */
|
|
65
172
|
info?: (message: string, ...args: unknown[]) => void;
|
|
173
|
+
/** Log debug messages */
|
|
66
174
|
debug?: (message: string, ...args: unknown[]) => void;
|
|
67
175
|
}
|
|
68
176
|
/**
|
|
69
|
-
* Capabilities configuration
|
|
177
|
+
* Capabilities configuration.
|
|
178
|
+
*
|
|
179
|
+
* @description
|
|
180
|
+
* Server capabilities that can be advertised to clients during initialization.
|
|
181
|
+
*
|
|
182
|
+
* @interface MCPSDKCapabilities
|
|
70
183
|
*/
|
|
71
184
|
export interface MCPSDKCapabilities {
|
|
185
|
+
/** Tool-related capabilities */
|
|
72
186
|
tools?: {
|
|
73
187
|
listChanged?: boolean;
|
|
74
188
|
};
|
|
189
|
+
/** Resource-related capabilities */
|
|
75
190
|
resources?: {
|
|
76
191
|
subscribe?: boolean;
|
|
77
192
|
};
|
|
193
|
+
/** Prompt-related capabilities */
|
|
78
194
|
prompts?: Record<string, unknown>;
|
|
79
195
|
}
|
|
80
196
|
/**
|
|
81
|
-
* SDK Adapter configuration
|
|
197
|
+
* SDK Adapter configuration.
|
|
198
|
+
*
|
|
199
|
+
* @description
|
|
200
|
+
* Configuration options for creating an MCP SDK adapter instance.
|
|
201
|
+
*
|
|
202
|
+
* @interface MCPSDKAdapterConfig
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* const config: MCPSDKAdapterConfig = {
|
|
206
|
+
* name: 'my-server',
|
|
207
|
+
* version: '1.0.0',
|
|
208
|
+
* transports: ['stdio', 'http'],
|
|
209
|
+
* capabilities: { tools: { listChanged: true } },
|
|
210
|
+
* mode: 'production'
|
|
211
|
+
* }
|
|
82
212
|
*/
|
|
83
213
|
export interface MCPSDKAdapterConfig {
|
|
214
|
+
/** Server name (default: 'gitx.do') */
|
|
84
215
|
name?: string;
|
|
216
|
+
/** Server version (default: '0.0.1') */
|
|
85
217
|
version?: string;
|
|
218
|
+
/** Vendor identifier (default: 'gitx.do') */
|
|
86
219
|
vendor?: string;
|
|
220
|
+
/** Supported transport types (default: ['stdio']) */
|
|
87
221
|
transports?: MCPSDKTransportType[];
|
|
222
|
+
/** MCP protocol version (default: '2024-11-05') */
|
|
88
223
|
protocolVersion?: string;
|
|
224
|
+
/** Server capabilities */
|
|
89
225
|
capabilities?: MCPSDKCapabilities;
|
|
226
|
+
/** Optional logger implementation */
|
|
90
227
|
logger?: MCPSDKLogger;
|
|
228
|
+
/** Execution mode affecting error verbosity (default: 'development') */
|
|
91
229
|
mode?: 'development' | 'production';
|
|
230
|
+
/** Ping interval in milliseconds */
|
|
92
231
|
pingInterval?: number;
|
|
232
|
+
/** Ping timeout in milliseconds */
|
|
93
233
|
pingTimeout?: number;
|
|
94
234
|
}
|
|
95
235
|
/**
|
|
96
|
-
* Tool handler context
|
|
236
|
+
* Tool handler context.
|
|
237
|
+
*
|
|
238
|
+
* @description
|
|
239
|
+
* Context provided to tool handlers for reporting progress and
|
|
240
|
+
* checking cancellation status.
|
|
241
|
+
*
|
|
242
|
+
* @interface MCPSDKToolContext
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* const handler = async (params, context: MCPSDKToolContext) => {
|
|
246
|
+
* for (let i = 0; i < 100; i++) {
|
|
247
|
+
* if (context.isCancelled()) break
|
|
248
|
+
* await context.reportProgress(i, 100)
|
|
249
|
+
* // ... do work
|
|
250
|
+
* }
|
|
251
|
+
* return { content: [{ type: 'text', text: 'Done' }] }
|
|
252
|
+
* }
|
|
97
253
|
*/
|
|
98
254
|
export interface MCPSDKToolContext {
|
|
255
|
+
/** Report progress to the client */
|
|
99
256
|
reportProgress: (progress: number, total: number) => Promise<void>;
|
|
257
|
+
/** Check if the request has been cancelled */
|
|
100
258
|
isCancelled: () => boolean;
|
|
101
259
|
}
|
|
102
260
|
/**
|
|
103
|
-
* Tool registration
|
|
261
|
+
* Tool registration.
|
|
262
|
+
*
|
|
263
|
+
* @description
|
|
264
|
+
* Complete tool definition for SDK adapter registration.
|
|
265
|
+
* Includes context-aware handler for progress/cancellation support.
|
|
266
|
+
*
|
|
267
|
+
* @interface MCPSDKToolRegistration
|
|
104
268
|
*/
|
|
105
269
|
export interface MCPSDKToolRegistration {
|
|
270
|
+
/** Unique tool name */
|
|
106
271
|
name: string;
|
|
272
|
+
/** Human-readable description */
|
|
107
273
|
description: string;
|
|
274
|
+
/** JSON Schema for input validation */
|
|
108
275
|
inputSchema: {
|
|
109
276
|
type: string;
|
|
110
277
|
properties?: Record<string, unknown>;
|
|
111
278
|
required?: string[];
|
|
112
279
|
};
|
|
280
|
+
/** Handler with context for progress/cancellation */
|
|
113
281
|
handler: (params: Record<string, unknown>, context: MCPSDKToolContext) => Promise<MCPToolResult>;
|
|
114
282
|
}
|
|
115
283
|
/**
|
|
116
|
-
* Session information
|
|
284
|
+
* Session information.
|
|
285
|
+
*
|
|
286
|
+
* @description
|
|
287
|
+
* Information about the current client session established during initialization.
|
|
288
|
+
*
|
|
289
|
+
* @interface MCPSDKSession
|
|
117
290
|
*/
|
|
118
291
|
export interface MCPSDKSession {
|
|
292
|
+
/** Unique session identifier */
|
|
119
293
|
id: string;
|
|
294
|
+
/** Client information from initialization */
|
|
120
295
|
clientInfo: {
|
|
121
296
|
name: string;
|
|
122
297
|
version: string;
|
|
123
298
|
};
|
|
299
|
+
/** Client capabilities */
|
|
124
300
|
clientCapabilities: {
|
|
125
301
|
sampling?: Record<string, unknown>;
|
|
126
302
|
roots?: {
|
|
@@ -129,140 +305,271 @@ export interface MCPSDKSession {
|
|
|
129
305
|
};
|
|
130
306
|
}
|
|
131
307
|
/**
|
|
132
|
-
* Client initialization request
|
|
308
|
+
* Client initialization request.
|
|
309
|
+
*
|
|
310
|
+
* @description
|
|
311
|
+
* Request sent by client during protocol initialization.
|
|
312
|
+
*
|
|
313
|
+
* @interface MCPClientInitializeRequest
|
|
133
314
|
*/
|
|
134
315
|
export interface MCPClientInitializeRequest {
|
|
316
|
+
/** Requested protocol version */
|
|
135
317
|
protocolVersion: string;
|
|
318
|
+
/** Client identification */
|
|
136
319
|
clientInfo: {
|
|
137
320
|
name: string;
|
|
138
321
|
version: string;
|
|
139
322
|
};
|
|
323
|
+
/** Client capabilities */
|
|
140
324
|
capabilities: Record<string, unknown>;
|
|
141
325
|
}
|
|
142
326
|
/**
|
|
143
|
-
* Tools call request
|
|
327
|
+
* Tools call request.
|
|
328
|
+
*
|
|
329
|
+
* @description
|
|
330
|
+
* Request to execute a registered tool.
|
|
331
|
+
*
|
|
332
|
+
* @interface MCPToolsCallRequest
|
|
144
333
|
*/
|
|
145
334
|
export interface MCPToolsCallRequest {
|
|
335
|
+
/** Name of the tool to call */
|
|
146
336
|
name: string;
|
|
337
|
+
/** Arguments to pass to the tool */
|
|
147
338
|
arguments: Record<string, unknown>;
|
|
148
339
|
}
|
|
149
340
|
/**
|
|
150
|
-
* Tools call result with request ID
|
|
341
|
+
* Tools call result with request ID.
|
|
342
|
+
*
|
|
343
|
+
* @description
|
|
344
|
+
* Extended tool result that includes the request ID for tracking.
|
|
345
|
+
*
|
|
346
|
+
* @interface MCPToolsCallResult
|
|
347
|
+
* @extends MCPToolResult
|
|
151
348
|
*/
|
|
152
349
|
export interface MCPToolsCallResult extends MCPToolResult {
|
|
350
|
+
/** Optional request ID for tracking */
|
|
153
351
|
requestId?: string;
|
|
154
352
|
}
|
|
155
353
|
/**
|
|
156
|
-
* Pending request for graceful shutdown
|
|
354
|
+
* Pending request for graceful shutdown.
|
|
355
|
+
* @internal
|
|
157
356
|
*/
|
|
158
357
|
interface PendingRequest {
|
|
159
358
|
complete: () => Promise<void>;
|
|
160
359
|
}
|
|
161
360
|
/**
|
|
162
|
-
* Progress event
|
|
361
|
+
* Progress event.
|
|
362
|
+
* @internal
|
|
163
363
|
*/
|
|
164
364
|
interface ProgressEvent {
|
|
165
365
|
progress: number;
|
|
166
366
|
total: number;
|
|
167
367
|
}
|
|
168
368
|
/**
|
|
169
|
-
* MCP SDK Adapter class
|
|
369
|
+
* MCP SDK Adapter class.
|
|
370
|
+
*
|
|
371
|
+
* @description
|
|
372
|
+
* Full-featured MCP adapter with advanced features including:
|
|
373
|
+
* - Multiple transport support (stdio, SSE, HTTP)
|
|
374
|
+
* - Connection lifecycle management with events
|
|
375
|
+
* - Request tracking, cancellation, and progress reporting
|
|
376
|
+
* - Session management with client capabilities
|
|
377
|
+
* - Health checking via ping/pong
|
|
378
|
+
* - Graceful shutdown with request draining
|
|
379
|
+
*
|
|
380
|
+
* @class MCPSDKAdapter
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* const adapter = new MCPSDKAdapter({
|
|
384
|
+
* name: 'git-server',
|
|
385
|
+
* version: '1.0.0',
|
|
386
|
+
* capabilities: { tools: { listChanged: true } }
|
|
387
|
+
* })
|
|
388
|
+
*
|
|
389
|
+
* adapter.onConnected(() => console.log('Connected!'))
|
|
390
|
+
* adapter.onError((err) => console.error(err))
|
|
391
|
+
*
|
|
392
|
+
* adapter.registerGitdoTools()
|
|
393
|
+
* await adapter.start()
|
|
170
394
|
*/
|
|
171
395
|
export declare class MCPSDKAdapter {
|
|
396
|
+
/** @internal */
|
|
172
397
|
private config;
|
|
398
|
+
/** @internal */
|
|
173
399
|
private connectionState;
|
|
400
|
+
/** @internal */
|
|
174
401
|
private tools;
|
|
402
|
+
/** @internal */
|
|
175
403
|
private toolIdCounter;
|
|
404
|
+
/** @internal */
|
|
176
405
|
private session;
|
|
406
|
+
/** @internal */
|
|
177
407
|
private stateChangeListeners;
|
|
408
|
+
/** @internal */
|
|
178
409
|
private connectedListeners;
|
|
410
|
+
/** @internal */
|
|
179
411
|
private disconnectedListeners;
|
|
412
|
+
/** @internal */
|
|
180
413
|
private notificationListeners;
|
|
414
|
+
/** @internal */
|
|
181
415
|
private progressListeners;
|
|
416
|
+
/** @internal */
|
|
182
417
|
private errorListeners;
|
|
418
|
+
/** @internal */
|
|
183
419
|
private pongListeners;
|
|
420
|
+
/** @internal */
|
|
184
421
|
private connectionTimeoutListeners;
|
|
422
|
+
/** @internal */
|
|
185
423
|
private pendingRequests;
|
|
424
|
+
/** @internal */
|
|
186
425
|
private currentRequestId;
|
|
426
|
+
/** Current transport connection */
|
|
187
427
|
transport: MCPSDKTransport | null;
|
|
428
|
+
/** @internal */
|
|
188
429
|
private clientResponsive;
|
|
430
|
+
/** @internal */
|
|
189
431
|
private pingTimeoutId;
|
|
432
|
+
/** Whether to cleanup tools on shutdown */
|
|
190
433
|
cleanupOnShutdown: boolean;
|
|
434
|
+
/**
|
|
435
|
+
* Create a new MCP SDK adapter.
|
|
436
|
+
*
|
|
437
|
+
* @param config - Optional configuration options
|
|
438
|
+
* @throws {Error} If name is explicitly set to empty string
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* const adapter = new MCPSDKAdapter({
|
|
442
|
+
* name: 'my-server',
|
|
443
|
+
* version: '1.0.0',
|
|
444
|
+
* mode: 'production',
|
|
445
|
+
* logger: console
|
|
446
|
+
* })
|
|
447
|
+
*/
|
|
191
448
|
constructor(config?: MCPSDKAdapterConfig);
|
|
192
449
|
/**
|
|
193
|
-
* Get the adapter configuration
|
|
450
|
+
* Get the adapter configuration.
|
|
451
|
+
* @returns Copy of the current configuration
|
|
194
452
|
*/
|
|
195
453
|
getConfig(): MCPSDKAdapterConfig;
|
|
196
454
|
/**
|
|
197
|
-
* Get supported transports
|
|
455
|
+
* Get supported transports.
|
|
456
|
+
* @returns Array of supported transport types
|
|
198
457
|
*/
|
|
199
458
|
getSupportedTransports(): MCPSDKTransportType[];
|
|
200
459
|
/**
|
|
201
|
-
* Get protocol version
|
|
460
|
+
* Get protocol version.
|
|
461
|
+
* @returns The MCP protocol version string
|
|
202
462
|
*/
|
|
203
463
|
getProtocolVersion(): string;
|
|
204
464
|
/**
|
|
205
|
-
* Get SDK version
|
|
465
|
+
* Get SDK version.
|
|
466
|
+
* @returns The SDK version string
|
|
206
467
|
*/
|
|
207
468
|
getSDKVersion(): string;
|
|
208
469
|
/**
|
|
209
|
-
* Get capabilities
|
|
470
|
+
* Get capabilities.
|
|
471
|
+
* @returns Copy of the server capabilities configuration
|
|
210
472
|
*/
|
|
211
473
|
getCapabilities(): MCPSDKCapabilities;
|
|
212
474
|
/**
|
|
213
|
-
* Get connection state
|
|
475
|
+
* Get connection state.
|
|
476
|
+
* @returns Current connection state
|
|
214
477
|
*/
|
|
215
478
|
getConnectionState(): MCPSDKConnectionState;
|
|
216
479
|
/**
|
|
217
|
-
* Set connection state and notify listeners
|
|
480
|
+
* Set connection state and notify listeners.
|
|
481
|
+
* @internal
|
|
218
482
|
*/
|
|
219
483
|
private setConnectionState;
|
|
220
484
|
/**
|
|
221
|
-
* Register a state change listener
|
|
485
|
+
* Register a state change listener.
|
|
486
|
+
* @param listener - Callback invoked when connection state changes
|
|
487
|
+
* @example
|
|
488
|
+
* adapter.onStateChange((state) => {
|
|
489
|
+
* console.log(`State changed to: ${state}`)
|
|
490
|
+
* })
|
|
222
491
|
*/
|
|
223
492
|
onStateChange(listener: (state: MCPSDKConnectionState) => void): void;
|
|
224
493
|
/**
|
|
225
|
-
* Register a connected listener
|
|
494
|
+
* Register a connected listener.
|
|
495
|
+
* @param listener - Callback invoked when connection is established
|
|
226
496
|
*/
|
|
227
497
|
onConnected(listener: () => void): void;
|
|
228
498
|
/**
|
|
229
|
-
* Register a disconnected listener
|
|
499
|
+
* Register a disconnected listener.
|
|
500
|
+
* @param listener - Callback invoked when connection is lost
|
|
230
501
|
*/
|
|
231
502
|
onDisconnected(listener: () => void): void;
|
|
232
503
|
/**
|
|
233
|
-
* Register a notification listener
|
|
504
|
+
* Register a notification listener.
|
|
505
|
+
* @param type - Notification type to listen for (e.g., 'tools/list_changed')
|
|
506
|
+
* @param listener - Callback invoked when notification is emitted
|
|
234
507
|
*/
|
|
235
508
|
onNotification(type: string, listener: () => void): void;
|
|
236
509
|
/**
|
|
237
|
-
* Emit a notification
|
|
510
|
+
* Emit a notification.
|
|
511
|
+
* @internal
|
|
238
512
|
*/
|
|
239
513
|
private emitNotification;
|
|
240
514
|
/**
|
|
241
|
-
* Register a progress listener
|
|
515
|
+
* Register a progress listener.
|
|
516
|
+
* @param listener - Callback invoked when tool reports progress
|
|
242
517
|
*/
|
|
243
518
|
onProgress(listener: (progress: ProgressEvent) => void): void;
|
|
244
519
|
/**
|
|
245
|
-
* Register an error listener
|
|
520
|
+
* Register an error listener.
|
|
521
|
+
* @param listener - Callback invoked when an error occurs
|
|
246
522
|
*/
|
|
247
523
|
onError(listener: (error: MCPSDKError) => void): void;
|
|
248
524
|
/**
|
|
249
|
-
* Register a pong listener
|
|
525
|
+
* Register a pong listener.
|
|
526
|
+
* @param listener - Callback invoked when pong response is received
|
|
250
527
|
*/
|
|
251
528
|
onPong(listener: () => void): void;
|
|
252
529
|
/**
|
|
253
|
-
* Register a connection timeout listener
|
|
530
|
+
* Register a connection timeout listener.
|
|
531
|
+
* @param listener - Callback invoked when connection times out
|
|
254
532
|
*/
|
|
255
533
|
onConnectionTimeout(listener: () => void): void;
|
|
256
534
|
/**
|
|
257
|
-
* Start the adapter
|
|
535
|
+
* Start the adapter.
|
|
536
|
+
*
|
|
537
|
+
* @description
|
|
538
|
+
* Initializes the adapter and transitions to connected state.
|
|
539
|
+
* Must be called before handling any requests.
|
|
540
|
+
*
|
|
541
|
+
* @returns Promise that resolves when started
|
|
542
|
+
* @throws {Error} If adapter is already started
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* await adapter.start()
|
|
258
546
|
*/
|
|
259
547
|
start(): Promise<void>;
|
|
260
548
|
/**
|
|
261
|
-
* Connect with a transport
|
|
549
|
+
* Connect with a transport.
|
|
550
|
+
*
|
|
551
|
+
* @description
|
|
552
|
+
* Attaches a transport and starts the adapter if not already running.
|
|
553
|
+
*
|
|
554
|
+
* @param transport - The transport to connect with
|
|
555
|
+
* @returns Promise that resolves when connected
|
|
262
556
|
*/
|
|
263
557
|
connect(transport: MCPSDKTransport): Promise<void>;
|
|
264
558
|
/**
|
|
265
|
-
* Shutdown the adapter
|
|
559
|
+
* Shutdown the adapter.
|
|
560
|
+
*
|
|
561
|
+
* @description
|
|
562
|
+
* Gracefully shuts down the adapter, optionally waiting for pending
|
|
563
|
+
* requests and cleaning up registered tools.
|
|
564
|
+
*
|
|
565
|
+
* @param options - Shutdown options
|
|
566
|
+
* @param options.graceful - If true, wait for pending requests
|
|
567
|
+
* @param options.timeout - Max time to wait for pending requests (ms)
|
|
568
|
+
* @param options.cleanup - If true, clear all registered tools
|
|
569
|
+
* @returns Promise that resolves when shutdown is complete
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* await adapter.shutdown({ graceful: true, timeout: 5000, cleanup: true })
|
|
266
573
|
*/
|
|
267
574
|
shutdown(options?: {
|
|
268
575
|
graceful?: boolean;
|
|
@@ -270,11 +577,20 @@ export declare class MCPSDKAdapter {
|
|
|
270
577
|
cleanup?: boolean;
|
|
271
578
|
}): Promise<void>;
|
|
272
579
|
/**
|
|
273
|
-
* Wait for all pending requests to complete
|
|
580
|
+
* Wait for all pending requests to complete.
|
|
581
|
+
* @internal
|
|
274
582
|
*/
|
|
275
583
|
private waitForPendingRequests;
|
|
276
584
|
/**
|
|
277
|
-
* Handle client initialization
|
|
585
|
+
* Handle client initialization.
|
|
586
|
+
*
|
|
587
|
+
* @description
|
|
588
|
+
* Processes the client's initialize request, validates protocol version,
|
|
589
|
+
* and creates a session.
|
|
590
|
+
*
|
|
591
|
+
* @param request - Client initialization request
|
|
592
|
+
* @returns Server info and capabilities
|
|
593
|
+
* @throws {MCPSDKError} If protocol version is incompatible
|
|
278
594
|
*/
|
|
279
595
|
handleClientInitialize(request: MCPClientInitializeRequest): Promise<{
|
|
280
596
|
serverInfo: {
|
|
@@ -284,39 +600,80 @@ export declare class MCPSDKAdapter {
|
|
|
284
600
|
capabilities: MCPSDKCapabilities;
|
|
285
601
|
}>;
|
|
286
602
|
/**
|
|
287
|
-
* Get current session
|
|
603
|
+
* Get current session.
|
|
604
|
+
* @returns Current session or null if not initialized
|
|
288
605
|
*/
|
|
289
606
|
getSession(): MCPSDKSession | null;
|
|
290
607
|
/**
|
|
291
|
-
* Register a tool
|
|
608
|
+
* Register a tool.
|
|
609
|
+
*
|
|
610
|
+
* @description
|
|
611
|
+
* Adds a tool to the adapter's registry. Emits tools/list_changed notification.
|
|
612
|
+
*
|
|
613
|
+
* @param registration - Tool registration details
|
|
614
|
+
* @throws {Error} If schema type is invalid
|
|
615
|
+
* @throws {Error} If tool with same name already exists
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* adapter.registerTool({
|
|
619
|
+
* name: 'my_tool',
|
|
620
|
+
* description: 'Does something',
|
|
621
|
+
* inputSchema: { type: 'object', properties: {} },
|
|
622
|
+
* handler: async (params, ctx) => ({
|
|
623
|
+
* content: [{ type: 'text', text: 'Done' }]
|
|
624
|
+
* })
|
|
625
|
+
* })
|
|
292
626
|
*/
|
|
293
627
|
registerTool(registration: MCPSDKToolRegistration): void;
|
|
294
628
|
/**
|
|
295
|
-
* Register multiple tools
|
|
629
|
+
* Register multiple tools.
|
|
630
|
+
*
|
|
631
|
+
* @description
|
|
632
|
+
* Batch registers multiple tools. More efficient than registering
|
|
633
|
+
* individually as it only emits one notification.
|
|
634
|
+
*
|
|
635
|
+
* @param registrations - Array of tool registrations
|
|
636
|
+
* @throws {Error} If any schema type is invalid
|
|
637
|
+
* @throws {Error} If any tool name already exists
|
|
296
638
|
*/
|
|
297
639
|
registerTools(registrations: MCPSDKToolRegistration[]): void;
|
|
298
640
|
/**
|
|
299
|
-
* Unregister a tool
|
|
641
|
+
* Unregister a tool.
|
|
642
|
+
* @param name - Name of the tool to unregister
|
|
300
643
|
*/
|
|
301
644
|
unregisterTool(name: string): void;
|
|
302
645
|
/**
|
|
303
|
-
* Get a tool by name
|
|
646
|
+
* Get a tool by name.
|
|
647
|
+
* @param name - Name of the tool to retrieve
|
|
648
|
+
* @returns Tool metadata (without handler) or undefined if not found
|
|
304
649
|
*/
|
|
305
650
|
getTool(name: string): (Omit<MCPSDKToolRegistration, 'handler'> & {
|
|
306
651
|
id: string;
|
|
307
652
|
}) | undefined;
|
|
308
653
|
/**
|
|
309
|
-
* List all tools
|
|
654
|
+
* List all tools.
|
|
655
|
+
* @returns Array of tool metadata (without handlers)
|
|
310
656
|
*/
|
|
311
657
|
listTools(): Array<Omit<MCPSDKToolRegistration, 'handler'> & {
|
|
312
658
|
id: string;
|
|
313
659
|
}>;
|
|
314
660
|
/**
|
|
315
|
-
* Register gitdo tools
|
|
661
|
+
* Register gitdo tools.
|
|
662
|
+
*
|
|
663
|
+
* @description
|
|
664
|
+
* Convenience method that registers all built-in git tools.
|
|
665
|
+
* Skips tools that are already registered.
|
|
316
666
|
*/
|
|
317
667
|
registerGitdoTools(): void;
|
|
318
668
|
/**
|
|
319
|
-
* Handle tools/list request
|
|
669
|
+
* Handle tools/list request.
|
|
670
|
+
*
|
|
671
|
+
* @description
|
|
672
|
+
* Returns paginated list of registered tools. Supports cursor-based pagination.
|
|
673
|
+
*
|
|
674
|
+
* @param options - Pagination options
|
|
675
|
+
* @param options.cursor - Pagination cursor from previous response
|
|
676
|
+
* @returns Paginated tool list with optional next cursor
|
|
320
677
|
*/
|
|
321
678
|
handleToolsList(options?: {
|
|
322
679
|
cursor?: string;
|
|
@@ -333,17 +690,46 @@ export declare class MCPSDKAdapter {
|
|
|
333
690
|
nextCursor?: string;
|
|
334
691
|
}>;
|
|
335
692
|
/**
|
|
336
|
-
* Handle tools/call request
|
|
693
|
+
* Handle tools/call request.
|
|
694
|
+
*
|
|
695
|
+
* @description
|
|
696
|
+
* Executes a tool and returns the result. Provides progress reporting
|
|
697
|
+
* and cancellation support through the tool context.
|
|
698
|
+
*
|
|
699
|
+
* @param request - Tool call request with name and arguments
|
|
700
|
+
* @returns Promise with result and requestId for tracking
|
|
701
|
+
* @throws {MCPSDKError} If tool not found or parameters invalid
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* const call = adapter.handleToolsCall({
|
|
705
|
+
* name: 'git_status',
|
|
706
|
+
* arguments: { short: true }
|
|
707
|
+
* })
|
|
708
|
+
* console.log(`Request ID: ${call.requestId}`)
|
|
709
|
+
* const result = await call
|
|
337
710
|
*/
|
|
338
711
|
handleToolsCall(request: MCPToolsCallRequest): Promise<MCPToolsCallResult> & {
|
|
339
712
|
requestId: string;
|
|
340
713
|
};
|
|
341
714
|
/**
|
|
342
|
-
* Cancel a request
|
|
715
|
+
* Cancel a request.
|
|
716
|
+
*
|
|
717
|
+
* @description
|
|
718
|
+
* Marks a pending request as cancelled. The tool handler can check
|
|
719
|
+
* cancellation status via context.isCancelled().
|
|
720
|
+
*
|
|
721
|
+
* @param requestId - The request ID to cancel
|
|
343
722
|
*/
|
|
344
723
|
cancelRequest(requestId: string | undefined): void;
|
|
345
724
|
/**
|
|
346
|
-
* Handle raw JSON-RPC message
|
|
725
|
+
* Handle raw JSON-RPC message.
|
|
726
|
+
*
|
|
727
|
+
* @description
|
|
728
|
+
* Parses and processes a raw JSON-RPC message string. Routes to
|
|
729
|
+
* appropriate handlers based on the method.
|
|
730
|
+
*
|
|
731
|
+
* @param message - Raw JSON-RPC message string
|
|
732
|
+
* @returns JSON-RPC response string
|
|
347
733
|
*/
|
|
348
734
|
handleMessage(message: string): Promise<string>;
|
|
349
735
|
/**
|
|
@@ -351,24 +737,41 @@ export declare class MCPSDKAdapter {
|
|
|
351
737
|
*/
|
|
352
738
|
private handleSingleMessage;
|
|
353
739
|
/**
|
|
354
|
-
* Simulate a pending request (for testing)
|
|
740
|
+
* Simulate a pending request (for testing).
|
|
741
|
+
* @internal
|
|
355
742
|
*/
|
|
356
743
|
simulatePendingRequest(): PendingRequest;
|
|
357
744
|
/**
|
|
358
|
-
* Simulate an internal error (for testing)
|
|
745
|
+
* Simulate an internal error (for testing).
|
|
746
|
+
* @internal
|
|
359
747
|
*/
|
|
360
748
|
simulateInternalError(error: Error): void;
|
|
361
749
|
/**
|
|
362
|
-
* Send ping
|
|
750
|
+
* Send ping to check client responsiveness.
|
|
363
751
|
*/
|
|
364
752
|
sendPing(): void;
|
|
365
753
|
/**
|
|
366
|
-
* Simulate client becoming unresponsive (for testing)
|
|
754
|
+
* Simulate client becoming unresponsive (for testing).
|
|
755
|
+
* @internal
|
|
367
756
|
*/
|
|
368
757
|
simulateClientUnresponsive(): void;
|
|
369
758
|
}
|
|
370
759
|
/**
|
|
371
|
-
* Transport factory
|
|
760
|
+
* Transport factory.
|
|
761
|
+
*
|
|
762
|
+
* @description
|
|
763
|
+
* Factory object for creating transport instances. Provides methods
|
|
764
|
+
* for creating stdio, SSE, and HTTP transports.
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* // Create a stdio transport
|
|
768
|
+
* const transport = MCPSDKTransport.createStdio()
|
|
769
|
+
*
|
|
770
|
+
* // Create an SSE transport
|
|
771
|
+
* const sseTransport = MCPSDKTransport.createSSE({ endpoint: '/sse' })
|
|
772
|
+
*
|
|
773
|
+
* // Create an HTTP transport
|
|
774
|
+
* const httpTransport = MCPSDKTransport.createHTTP({ endpoint: '/api' })
|
|
372
775
|
*/
|
|
373
776
|
export declare const MCPSDKTransport: {
|
|
374
777
|
createStdio(_options?: {
|
|
@@ -406,7 +809,26 @@ export declare const MCPSDKTransport: {
|
|
|
406
809
|
};
|
|
407
810
|
};
|
|
408
811
|
/**
|
|
409
|
-
* Factory function to create an MCP SDK adapter
|
|
812
|
+
* Factory function to create an MCP SDK adapter.
|
|
813
|
+
*
|
|
814
|
+
* @description
|
|
815
|
+
* Convenience function for creating a new MCP SDK adapter instance.
|
|
816
|
+
* Equivalent to using `new MCPSDKAdapter(config)`.
|
|
817
|
+
*
|
|
818
|
+
* @param config - Optional adapter configuration
|
|
819
|
+
* @returns A new MCPSDKAdapter instance
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* import { createMCPSDKAdapter } from './sdk-adapter'
|
|
823
|
+
*
|
|
824
|
+
* const adapter = createMCPSDKAdapter({
|
|
825
|
+
* name: 'git-server',
|
|
826
|
+
* version: '1.0.0',
|
|
827
|
+
* capabilities: { tools: { listChanged: true } }
|
|
828
|
+
* })
|
|
829
|
+
*
|
|
830
|
+
* adapter.registerGitdoTools()
|
|
831
|
+
* await adapter.start()
|
|
410
832
|
*/
|
|
411
833
|
export declare function createMCPSDKAdapter(config?: MCPSDKAdapterConfig): MCPSDKAdapter;
|
|
412
834
|
export {};
|