gitx.do 0.1.1 → 0.1.2
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 +40 -353
- package/dist/do/logger.d.ts +50 -0
- package/dist/do/logger.d.ts.map +1 -0
- package/dist/do/logger.js +122 -0
- package/dist/do/logger.js.map +1 -0
- package/dist/{durable-object → do}/schema.d.ts +3 -3
- package/dist/do/schema.d.ts.map +1 -0
- package/dist/{durable-object → do}/schema.js +4 -3
- package/dist/do/schema.js.map +1 -0
- package/dist/do/types.d.ts +267 -0
- package/dist/do/types.d.ts.map +1 -0
- package/dist/do/types.js +62 -0
- package/dist/do/types.js.map +1 -0
- package/dist/index.d.ts +14 -469
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -483
- package/dist/index.js.map +1 -1
- package/package.json +13 -21
- package/dist/cli/commands/add.d.ts +0 -176
- package/dist/cli/commands/add.d.ts.map +0 -1
- package/dist/cli/commands/add.js +0 -979
- package/dist/cli/commands/add.js.map +0 -1
- package/dist/cli/commands/blame.d.ts +0 -259
- package/dist/cli/commands/blame.d.ts.map +0 -1
- package/dist/cli/commands/blame.js +0 -609
- package/dist/cli/commands/blame.js.map +0 -1
- package/dist/cli/commands/branch.d.ts +0 -249
- package/dist/cli/commands/branch.d.ts.map +0 -1
- package/dist/cli/commands/branch.js +0 -693
- package/dist/cli/commands/branch.js.map +0 -1
- package/dist/cli/commands/checkout.d.ts +0 -73
- package/dist/cli/commands/checkout.d.ts.map +0 -1
- package/dist/cli/commands/checkout.js +0 -725
- package/dist/cli/commands/checkout.js.map +0 -1
- package/dist/cli/commands/commit.d.ts +0 -182
- package/dist/cli/commands/commit.d.ts.map +0 -1
- package/dist/cli/commands/commit.js +0 -457
- package/dist/cli/commands/commit.js.map +0 -1
- package/dist/cli/commands/diff.d.ts +0 -464
- package/dist/cli/commands/diff.d.ts.map +0 -1
- package/dist/cli/commands/diff.js +0 -959
- package/dist/cli/commands/diff.js.map +0 -1
- package/dist/cli/commands/log.d.ts +0 -239
- package/dist/cli/commands/log.d.ts.map +0 -1
- package/dist/cli/commands/log.js +0 -535
- package/dist/cli/commands/log.js.map +0 -1
- package/dist/cli/commands/merge.d.ts +0 -106
- package/dist/cli/commands/merge.d.ts.map +0 -1
- package/dist/cli/commands/merge.js +0 -852
- package/dist/cli/commands/merge.js.map +0 -1
- package/dist/cli/commands/review.d.ts +0 -457
- package/dist/cli/commands/review.d.ts.map +0 -1
- package/dist/cli/commands/review.js +0 -558
- package/dist/cli/commands/review.js.map +0 -1
- package/dist/cli/commands/stash.d.ts +0 -157
- package/dist/cli/commands/stash.d.ts.map +0 -1
- package/dist/cli/commands/stash.js +0 -655
- package/dist/cli/commands/stash.js.map +0 -1
- package/dist/cli/commands/status.d.ts +0 -269
- package/dist/cli/commands/status.d.ts.map +0 -1
- package/dist/cli/commands/status.js +0 -492
- package/dist/cli/commands/status.js.map +0 -1
- package/dist/cli/commands/web.d.ts +0 -199
- package/dist/cli/commands/web.d.ts.map +0 -1
- package/dist/cli/commands/web.js +0 -697
- package/dist/cli/commands/web.js.map +0 -1
- package/dist/cli/fs-adapter.d.ts +0 -656
- package/dist/cli/fs-adapter.d.ts.map +0 -1
- package/dist/cli/fs-adapter.js +0 -1177
- package/dist/cli/fs-adapter.js.map +0 -1
- package/dist/cli/fsx-cli-adapter.d.ts +0 -359
- package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
- package/dist/cli/fsx-cli-adapter.js +0 -619
- package/dist/cli/fsx-cli-adapter.js.map +0 -1
- package/dist/cli/index.d.ts +0 -387
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -579
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/ui/components/DiffView.d.ts +0 -12
- package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
- package/dist/cli/ui/components/DiffView.js +0 -11
- package/dist/cli/ui/components/DiffView.js.map +0 -1
- package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
- package/dist/cli/ui/components/ErrorDisplay.js +0 -11
- package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
- package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
- package/dist/cli/ui/components/FuzzySearch.js +0 -12
- package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
- package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
- package/dist/cli/ui/components/LoadingSpinner.js +0 -10
- package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
- package/dist/cli/ui/components/NavigationList.d.ts +0 -14
- package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
- package/dist/cli/ui/components/NavigationList.js +0 -11
- package/dist/cli/ui/components/NavigationList.js.map +0 -1
- package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
- package/dist/cli/ui/components/ScrollableContent.js +0 -11
- package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
- package/dist/cli/ui/components/index.d.ts +0 -7
- package/dist/cli/ui/components/index.d.ts.map +0 -1
- package/dist/cli/ui/components/index.js +0 -9
- package/dist/cli/ui/components/index.js.map +0 -1
- package/dist/cli/ui/terminal-ui.d.ts +0 -85
- package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
- package/dist/cli/ui/terminal-ui.js +0 -121
- package/dist/cli/ui/terminal-ui.js.map +0 -1
- package/dist/do/BashModule.d.ts +0 -871
- package/dist/do/BashModule.d.ts.map +0 -1
- package/dist/do/BashModule.js +0 -1143
- package/dist/do/BashModule.js.map +0 -1
- package/dist/do/FsModule.d.ts +0 -612
- package/dist/do/FsModule.d.ts.map +0 -1
- package/dist/do/FsModule.js +0 -1120
- package/dist/do/FsModule.js.map +0 -1
- package/dist/do/GitModule.d.ts +0 -635
- package/dist/do/GitModule.d.ts.map +0 -1
- package/dist/do/GitModule.js +0 -784
- package/dist/do/GitModule.js.map +0 -1
- package/dist/do/GitRepoDO.d.ts +0 -281
- package/dist/do/GitRepoDO.d.ts.map +0 -1
- package/dist/do/GitRepoDO.js +0 -479
- package/dist/do/GitRepoDO.js.map +0 -1
- package/dist/do/bash-ast.d.ts +0 -246
- package/dist/do/bash-ast.d.ts.map +0 -1
- package/dist/do/bash-ast.js +0 -888
- package/dist/do/bash-ast.js.map +0 -1
- package/dist/do/container-executor.d.ts +0 -491
- package/dist/do/container-executor.d.ts.map +0 -1
- package/dist/do/container-executor.js +0 -731
- package/dist/do/container-executor.js.map +0 -1
- package/dist/do/index.d.ts +0 -53
- package/dist/do/index.d.ts.map +0 -1
- package/dist/do/index.js +0 -91
- package/dist/do/index.js.map +0 -1
- package/dist/do/tiered-storage.d.ts +0 -403
- package/dist/do/tiered-storage.d.ts.map +0 -1
- package/dist/do/tiered-storage.js +0 -689
- package/dist/do/tiered-storage.js.map +0 -1
- package/dist/do/withBash.d.ts +0 -231
- package/dist/do/withBash.d.ts.map +0 -1
- package/dist/do/withBash.js +0 -244
- package/dist/do/withBash.js.map +0 -1
- package/dist/do/withFs.d.ts +0 -237
- package/dist/do/withFs.d.ts.map +0 -1
- package/dist/do/withFs.js +0 -387
- package/dist/do/withFs.js.map +0 -1
- package/dist/do/withGit.d.ts +0 -180
- package/dist/do/withGit.d.ts.map +0 -1
- package/dist/do/withGit.js +0 -271
- package/dist/do/withGit.js.map +0 -1
- package/dist/durable-object/object-store.d.ts +0 -633
- package/dist/durable-object/object-store.d.ts.map +0 -1
- package/dist/durable-object/object-store.js +0 -1164
- package/dist/durable-object/object-store.js.map +0 -1
- package/dist/durable-object/schema.d.ts.map +0 -1
- package/dist/durable-object/schema.js.map +0 -1
- package/dist/durable-object/wal.d.ts +0 -416
- package/dist/durable-object/wal.d.ts.map +0 -1
- package/dist/durable-object/wal.js +0 -445
- package/dist/durable-object/wal.js.map +0 -1
- package/dist/mcp/adapter.d.ts +0 -772
- package/dist/mcp/adapter.d.ts.map +0 -1
- package/dist/mcp/adapter.js +0 -895
- package/dist/mcp/adapter.js.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
- package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
- package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
- package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
- package/dist/mcp/sandbox/object-store-proxy.js +0 -30
- package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
- package/dist/mcp/sandbox/template.d.ts +0 -17
- package/dist/mcp/sandbox/template.d.ts.map +0 -1
- package/dist/mcp/sandbox/template.js +0 -71
- package/dist/mcp/sandbox/template.js.map +0 -1
- package/dist/mcp/sandbox.d.ts +0 -764
- package/dist/mcp/sandbox.d.ts.map +0 -1
- package/dist/mcp/sandbox.js +0 -1362
- package/dist/mcp/sandbox.js.map +0 -1
- package/dist/mcp/sdk-adapter.d.ts +0 -835
- package/dist/mcp/sdk-adapter.d.ts.map +0 -1
- package/dist/mcp/sdk-adapter.js +0 -974
- package/dist/mcp/sdk-adapter.js.map +0 -1
- package/dist/mcp/tools/do.d.ts +0 -32
- package/dist/mcp/tools/do.d.ts.map +0 -1
- package/dist/mcp/tools/do.js +0 -117
- package/dist/mcp/tools/do.js.map +0 -1
- package/dist/mcp/tools.d.ts +0 -548
- package/dist/mcp/tools.d.ts.map +0 -1
- package/dist/mcp/tools.js +0 -3170
- package/dist/mcp/tools.js.map +0 -1
- package/dist/ops/blame.d.ts +0 -551
- package/dist/ops/blame.d.ts.map +0 -1
- package/dist/ops/blame.js +0 -1037
- package/dist/ops/blame.js.map +0 -1
- package/dist/ops/branch.d.ts +0 -766
- package/dist/ops/branch.d.ts.map +0 -1
- package/dist/ops/branch.js +0 -950
- package/dist/ops/branch.js.map +0 -1
- package/dist/ops/commit-traversal.d.ts +0 -349
- package/dist/ops/commit-traversal.d.ts.map +0 -1
- package/dist/ops/commit-traversal.js +0 -821
- package/dist/ops/commit-traversal.js.map +0 -1
- package/dist/ops/commit.d.ts +0 -555
- package/dist/ops/commit.d.ts.map +0 -1
- package/dist/ops/commit.js +0 -826
- package/dist/ops/commit.js.map +0 -1
- package/dist/ops/merge-base.d.ts +0 -397
- package/dist/ops/merge-base.d.ts.map +0 -1
- package/dist/ops/merge-base.js +0 -691
- package/dist/ops/merge-base.js.map +0 -1
- package/dist/ops/merge.d.ts +0 -855
- package/dist/ops/merge.d.ts.map +0 -1
- package/dist/ops/merge.js +0 -1551
- package/dist/ops/merge.js.map +0 -1
- package/dist/ops/tag.d.ts +0 -247
- package/dist/ops/tag.d.ts.map +0 -1
- package/dist/ops/tag.js +0 -649
- package/dist/ops/tag.js.map +0 -1
- package/dist/ops/tree-builder.d.ts +0 -178
- package/dist/ops/tree-builder.d.ts.map +0 -1
- package/dist/ops/tree-builder.js +0 -271
- package/dist/ops/tree-builder.js.map +0 -1
- package/dist/ops/tree-diff.d.ts +0 -291
- package/dist/ops/tree-diff.d.ts.map +0 -1
- package/dist/ops/tree-diff.js +0 -705
- package/dist/ops/tree-diff.js.map +0 -1
- package/dist/pack/delta.d.ts +0 -248
- package/dist/pack/delta.d.ts.map +0 -1
- package/dist/pack/delta.js +0 -740
- package/dist/pack/delta.js.map +0 -1
- package/dist/pack/format.d.ts +0 -446
- package/dist/pack/format.d.ts.map +0 -1
- package/dist/pack/format.js +0 -572
- package/dist/pack/format.js.map +0 -1
- package/dist/pack/full-generation.d.ts +0 -612
- package/dist/pack/full-generation.d.ts.map +0 -1
- package/dist/pack/full-generation.js +0 -1378
- package/dist/pack/full-generation.js.map +0 -1
- package/dist/pack/generation.d.ts +0 -441
- package/dist/pack/generation.d.ts.map +0 -1
- package/dist/pack/generation.js +0 -707
- package/dist/pack/generation.js.map +0 -1
- package/dist/pack/index.d.ts +0 -502
- package/dist/pack/index.d.ts.map +0 -1
- package/dist/pack/index.js +0 -833
- package/dist/pack/index.js.map +0 -1
- package/dist/refs/branch.d.ts +0 -683
- package/dist/refs/branch.d.ts.map +0 -1
- package/dist/refs/branch.js +0 -881
- package/dist/refs/branch.js.map +0 -1
- package/dist/refs/storage.d.ts +0 -833
- package/dist/refs/storage.d.ts.map +0 -1
- package/dist/refs/storage.js +0 -1023
- package/dist/refs/storage.js.map +0 -1
- package/dist/refs/tag.d.ts +0 -860
- package/dist/refs/tag.d.ts.map +0 -1
- package/dist/refs/tag.js +0 -996
- package/dist/refs/tag.js.map +0 -1
- package/dist/storage/backend.d.ts +0 -425
- package/dist/storage/backend.d.ts.map +0 -1
- package/dist/storage/backend.js +0 -41
- package/dist/storage/backend.js.map +0 -1
- package/dist/storage/fsx-adapter.d.ts +0 -204
- package/dist/storage/fsx-adapter.d.ts.map +0 -1
- package/dist/storage/fsx-adapter.js +0 -518
- package/dist/storage/fsx-adapter.js.map +0 -1
- package/dist/storage/lru-cache.d.ts +0 -691
- package/dist/storage/lru-cache.d.ts.map +0 -1
- package/dist/storage/lru-cache.js +0 -813
- package/dist/storage/lru-cache.js.map +0 -1
- package/dist/storage/object-index.d.ts +0 -585
- package/dist/storage/object-index.d.ts.map +0 -1
- package/dist/storage/object-index.js +0 -532
- package/dist/storage/object-index.js.map +0 -1
- package/dist/storage/r2-pack.d.ts +0 -1257
- package/dist/storage/r2-pack.d.ts.map +0 -1
- package/dist/storage/r2-pack.js +0 -1773
- package/dist/storage/r2-pack.js.map +0 -1
- package/dist/tiered/cdc-pipeline.d.ts +0 -1888
- package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
- package/dist/tiered/cdc-pipeline.js +0 -1880
- package/dist/tiered/cdc-pipeline.js.map +0 -1
- package/dist/tiered/migration.d.ts +0 -1104
- package/dist/tiered/migration.d.ts.map +0 -1
- package/dist/tiered/migration.js +0 -1217
- package/dist/tiered/migration.js.map +0 -1
- package/dist/tiered/parquet-writer.d.ts +0 -1145
- package/dist/tiered/parquet-writer.d.ts.map +0 -1
- package/dist/tiered/parquet-writer.js +0 -1183
- package/dist/tiered/parquet-writer.js.map +0 -1
- package/dist/tiered/read-path.d.ts +0 -835
- package/dist/tiered/read-path.d.ts.map +0 -1
- package/dist/tiered/read-path.js +0 -487
- package/dist/tiered/read-path.js.map +0 -1
- package/dist/types/capability.d.ts +0 -1385
- package/dist/types/capability.d.ts.map +0 -1
- package/dist/types/capability.js +0 -36
- package/dist/types/capability.js.map +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/types/index.js.map +0 -1
- package/dist/types/interfaces.d.ts +0 -673
- package/dist/types/interfaces.d.ts.map +0 -1
- package/dist/types/interfaces.js +0 -26
- package/dist/types/interfaces.js.map +0 -1
- package/dist/types/objects.d.ts +0 -692
- package/dist/types/objects.d.ts.map +0 -1
- package/dist/types/objects.js +0 -837
- package/dist/types/objects.js.map +0 -1
- package/dist/types/storage.d.ts +0 -603
- package/dist/types/storage.d.ts.map +0 -1
- package/dist/types/storage.js +0 -191
- package/dist/types/storage.js.map +0 -1
- package/dist/types/worker-loader.d.ts +0 -60
- package/dist/types/worker-loader.d.ts.map +0 -1
- package/dist/types/worker-loader.js +0 -62
- package/dist/types/worker-loader.js.map +0 -1
- package/dist/utils/hash.d.ts +0 -198
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/hash.js +0 -272
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/sha1.d.ts +0 -325
- package/dist/utils/sha1.d.ts.map +0 -1
- package/dist/utils/sha1.js +0 -635
- package/dist/utils/sha1.js.map +0 -1
- package/dist/wire/capabilities.d.ts +0 -1044
- package/dist/wire/capabilities.d.ts.map +0 -1
- package/dist/wire/capabilities.js +0 -941
- package/dist/wire/capabilities.js.map +0 -1
- package/dist/wire/path-security.d.ts +0 -157
- package/dist/wire/path-security.d.ts.map +0 -1
- package/dist/wire/path-security.js +0 -307
- package/dist/wire/path-security.js.map +0 -1
- package/dist/wire/pkt-line.d.ts +0 -345
- package/dist/wire/pkt-line.d.ts.map +0 -1
- package/dist/wire/pkt-line.js +0 -381
- package/dist/wire/pkt-line.js.map +0 -1
- package/dist/wire/receive-pack.d.ts +0 -1059
- package/dist/wire/receive-pack.d.ts.map +0 -1
- package/dist/wire/receive-pack.js +0 -1414
- package/dist/wire/receive-pack.js.map +0 -1
- package/dist/wire/smart-http.d.ts +0 -799
- package/dist/wire/smart-http.d.ts.map +0 -1
- package/dist/wire/smart-http.js +0 -945
- package/dist/wire/smart-http.js.map +0 -1
- package/dist/wire/upload-pack.d.ts +0 -727
- package/dist/wire/upload-pack.d.ts.map +0 -1
- package/dist/wire/upload-pack.js +0 -1141
- package/dist/wire/upload-pack.js.map +0 -1
|
@@ -1,835 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview MCP SDK Adapter
|
|
3
|
-
*
|
|
4
|
-
* This module provides a full-featured adapter for the MCP SDK,
|
|
5
|
-
* including SDK initialization, tool registration, request/response
|
|
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
|
|
48
|
-
*/
|
|
49
|
-
import { type MCPToolResult } from './tools';
|
|
50
|
-
/**
|
|
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}
|
|
59
|
-
*/
|
|
60
|
-
export declare enum MCPSDKErrorCode {
|
|
61
|
-
/** Parse error - Invalid JSON (-32700) */
|
|
62
|
-
PARSE_ERROR = -32700,
|
|
63
|
-
/** Invalid Request - Not a valid Request object (-32600) */
|
|
64
|
-
INVALID_REQUEST = -32600,
|
|
65
|
-
/** Method not found - Method does not exist (-32601) */
|
|
66
|
-
METHOD_NOT_FOUND = -32601,
|
|
67
|
-
/** Invalid params - Invalid method parameters (-32602) */
|
|
68
|
-
INVALID_PARAMS = -32602,
|
|
69
|
-
/** Internal error - Internal JSON-RPC error (-32603) */
|
|
70
|
-
INTERNAL_ERROR = -32603,
|
|
71
|
-
/** Tool not found - Requested tool does not exist (-32001) */
|
|
72
|
-
TOOL_NOT_FOUND = -32001,
|
|
73
|
-
/** Resource not found - Requested resource does not exist (-32002) */
|
|
74
|
-
RESOURCE_NOT_FOUND = -32002,
|
|
75
|
-
/** Prompt not found - Requested prompt does not exist (-32003) */
|
|
76
|
-
PROMPT_NOT_FOUND = -32003,
|
|
77
|
-
/** Capability not supported - Capability is not enabled (-32004) */
|
|
78
|
-
CAPABILITY_NOT_SUPPORTED = -32004
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
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
|
-
* )
|
|
95
|
-
*/
|
|
96
|
-
export declare class MCPSDKError extends Error {
|
|
97
|
-
/** The error code */
|
|
98
|
-
code: MCPSDKErrorCode;
|
|
99
|
-
/** Optional additional error data */
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
112
|
-
toJSONRPC(): {
|
|
113
|
-
code: number;
|
|
114
|
-
message: string;
|
|
115
|
-
data?: unknown;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Transport type.
|
|
120
|
-
* @description Supported transport mechanisms for MCP communication.
|
|
121
|
-
* @typedef {'stdio' | 'sse' | 'http' | 'custom'} MCPSDKTransportType
|
|
122
|
-
*/
|
|
123
|
-
export type MCPSDKTransportType = 'stdio' | 'sse' | 'http' | 'custom';
|
|
124
|
-
/**
|
|
125
|
-
* Connection state.
|
|
126
|
-
* @description Represents the current state of the adapter connection.
|
|
127
|
-
* @typedef {'disconnected' | 'initializing' | 'connected'} MCPSDKConnectionState
|
|
128
|
-
*/
|
|
129
|
-
export type MCPSDKConnectionState = 'disconnected' | 'initializing' | 'connected';
|
|
130
|
-
/**
|
|
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
|
|
138
|
-
*/
|
|
139
|
-
export interface MCPSDKTransport {
|
|
140
|
-
/** Transport type identifier */
|
|
141
|
-
type: MCPSDKTransportType;
|
|
142
|
-
/** Send data through the transport */
|
|
143
|
-
send?: (data: string) => void;
|
|
144
|
-
/** Receive data from the transport */
|
|
145
|
-
receive?: () => Promise<string>;
|
|
146
|
-
/** Close the transport connection */
|
|
147
|
-
close?: () => void;
|
|
148
|
-
/** Check if transport is connected */
|
|
149
|
-
isConnected: () => boolean;
|
|
150
|
-
/** Handle an HTTP-style request (for HTTP/SSE transports) */
|
|
151
|
-
handleRequest?: (request: unknown) => Promise<{
|
|
152
|
-
status: number;
|
|
153
|
-
headers: Record<string, string>;
|
|
154
|
-
body?: string;
|
|
155
|
-
}>;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Logger interface.
|
|
159
|
-
*
|
|
160
|
-
* @description
|
|
161
|
-
* Interface for logging implementations. All methods are optional,
|
|
162
|
-
* allowing partial logger implementations.
|
|
163
|
-
*
|
|
164
|
-
* @interface MCPSDKLogger
|
|
165
|
-
*/
|
|
166
|
-
export interface MCPSDKLogger {
|
|
167
|
-
/** Log error messages */
|
|
168
|
-
error?: (message: string, ...args: unknown[]) => void;
|
|
169
|
-
/** Log warning messages */
|
|
170
|
-
warn?: (message: string, ...args: unknown[]) => void;
|
|
171
|
-
/** Log info messages */
|
|
172
|
-
info?: (message: string, ...args: unknown[]) => void;
|
|
173
|
-
/** Log debug messages */
|
|
174
|
-
debug?: (message: string, ...args: unknown[]) => void;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Capabilities configuration.
|
|
178
|
-
*
|
|
179
|
-
* @description
|
|
180
|
-
* Server capabilities that can be advertised to clients during initialization.
|
|
181
|
-
*
|
|
182
|
-
* @interface MCPSDKCapabilities
|
|
183
|
-
*/
|
|
184
|
-
export interface MCPSDKCapabilities {
|
|
185
|
-
/** Tool-related capabilities */
|
|
186
|
-
tools?: {
|
|
187
|
-
listChanged?: boolean;
|
|
188
|
-
};
|
|
189
|
-
/** Resource-related capabilities */
|
|
190
|
-
resources?: {
|
|
191
|
-
subscribe?: boolean;
|
|
192
|
-
};
|
|
193
|
-
/** Prompt-related capabilities */
|
|
194
|
-
prompts?: Record<string, unknown>;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
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
|
-
* }
|
|
212
|
-
*/
|
|
213
|
-
export interface MCPSDKAdapterConfig {
|
|
214
|
-
/** Server name (default: 'gitx.do') */
|
|
215
|
-
name?: string;
|
|
216
|
-
/** Server version (default: '0.0.1') */
|
|
217
|
-
version?: string;
|
|
218
|
-
/** Vendor identifier (default: 'gitx.do') */
|
|
219
|
-
vendor?: string;
|
|
220
|
-
/** Supported transport types (default: ['stdio']) */
|
|
221
|
-
transports?: MCPSDKTransportType[];
|
|
222
|
-
/** MCP protocol version (default: '2024-11-05') */
|
|
223
|
-
protocolVersion?: string;
|
|
224
|
-
/** Server capabilities */
|
|
225
|
-
capabilities?: MCPSDKCapabilities;
|
|
226
|
-
/** Optional logger implementation */
|
|
227
|
-
logger?: MCPSDKLogger;
|
|
228
|
-
/** Execution mode affecting error verbosity (default: 'development') */
|
|
229
|
-
mode?: 'development' | 'production';
|
|
230
|
-
/** Ping interval in milliseconds */
|
|
231
|
-
pingInterval?: number;
|
|
232
|
-
/** Ping timeout in milliseconds */
|
|
233
|
-
pingTimeout?: number;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
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
|
-
* }
|
|
253
|
-
*/
|
|
254
|
-
export interface MCPSDKToolContext {
|
|
255
|
-
/** Report progress to the client */
|
|
256
|
-
reportProgress: (progress: number, total: number) => Promise<void>;
|
|
257
|
-
/** Check if the request has been cancelled */
|
|
258
|
-
isCancelled: () => boolean;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
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
|
|
268
|
-
*/
|
|
269
|
-
export interface MCPSDKToolRegistration {
|
|
270
|
-
/** Unique tool name */
|
|
271
|
-
name: string;
|
|
272
|
-
/** Human-readable description */
|
|
273
|
-
description: string;
|
|
274
|
-
/** JSON Schema for input validation */
|
|
275
|
-
inputSchema: {
|
|
276
|
-
type: string;
|
|
277
|
-
properties?: Record<string, unknown>;
|
|
278
|
-
required?: string[];
|
|
279
|
-
};
|
|
280
|
-
/** Handler with context for progress/cancellation */
|
|
281
|
-
handler: (params: Record<string, unknown>, context: MCPSDKToolContext) => Promise<MCPToolResult>;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Session information.
|
|
285
|
-
*
|
|
286
|
-
* @description
|
|
287
|
-
* Information about the current client session established during initialization.
|
|
288
|
-
*
|
|
289
|
-
* @interface MCPSDKSession
|
|
290
|
-
*/
|
|
291
|
-
export interface MCPSDKSession {
|
|
292
|
-
/** Unique session identifier */
|
|
293
|
-
id: string;
|
|
294
|
-
/** Client information from initialization */
|
|
295
|
-
clientInfo: {
|
|
296
|
-
name: string;
|
|
297
|
-
version: string;
|
|
298
|
-
};
|
|
299
|
-
/** Client capabilities */
|
|
300
|
-
clientCapabilities: {
|
|
301
|
-
sampling?: Record<string, unknown>;
|
|
302
|
-
roots?: {
|
|
303
|
-
listChanged?: boolean;
|
|
304
|
-
};
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Client initialization request.
|
|
309
|
-
*
|
|
310
|
-
* @description
|
|
311
|
-
* Request sent by client during protocol initialization.
|
|
312
|
-
*
|
|
313
|
-
* @interface MCPClientInitializeRequest
|
|
314
|
-
*/
|
|
315
|
-
export interface MCPClientInitializeRequest {
|
|
316
|
-
/** Requested protocol version */
|
|
317
|
-
protocolVersion: string;
|
|
318
|
-
/** Client identification */
|
|
319
|
-
clientInfo: {
|
|
320
|
-
name: string;
|
|
321
|
-
version: string;
|
|
322
|
-
};
|
|
323
|
-
/** Client capabilities */
|
|
324
|
-
capabilities: Record<string, unknown>;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Tools call request.
|
|
328
|
-
*
|
|
329
|
-
* @description
|
|
330
|
-
* Request to execute a registered tool.
|
|
331
|
-
*
|
|
332
|
-
* @interface MCPToolsCallRequest
|
|
333
|
-
*/
|
|
334
|
-
export interface MCPToolsCallRequest {
|
|
335
|
-
/** Name of the tool to call */
|
|
336
|
-
name: string;
|
|
337
|
-
/** Arguments to pass to the tool */
|
|
338
|
-
arguments: Record<string, unknown>;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
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
|
|
348
|
-
*/
|
|
349
|
-
export interface MCPToolsCallResult extends MCPToolResult {
|
|
350
|
-
/** Optional request ID for tracking */
|
|
351
|
-
requestId?: string;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Pending request for graceful shutdown.
|
|
355
|
-
* @internal
|
|
356
|
-
*/
|
|
357
|
-
interface PendingRequest {
|
|
358
|
-
complete: () => Promise<void>;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Progress event.
|
|
362
|
-
* @internal
|
|
363
|
-
*/
|
|
364
|
-
interface ProgressEvent {
|
|
365
|
-
progress: number;
|
|
366
|
-
total: number;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
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()
|
|
394
|
-
*/
|
|
395
|
-
export declare class MCPSDKAdapter {
|
|
396
|
-
/** @internal */
|
|
397
|
-
private config;
|
|
398
|
-
/** @internal */
|
|
399
|
-
private connectionState;
|
|
400
|
-
/** @internal */
|
|
401
|
-
private tools;
|
|
402
|
-
/** @internal */
|
|
403
|
-
private toolIdCounter;
|
|
404
|
-
/** @internal */
|
|
405
|
-
private session;
|
|
406
|
-
/** @internal */
|
|
407
|
-
private stateChangeListeners;
|
|
408
|
-
/** @internal */
|
|
409
|
-
private connectedListeners;
|
|
410
|
-
/** @internal */
|
|
411
|
-
private disconnectedListeners;
|
|
412
|
-
/** @internal */
|
|
413
|
-
private notificationListeners;
|
|
414
|
-
/** @internal */
|
|
415
|
-
private progressListeners;
|
|
416
|
-
/** @internal */
|
|
417
|
-
private errorListeners;
|
|
418
|
-
/** @internal */
|
|
419
|
-
private pongListeners;
|
|
420
|
-
/** @internal */
|
|
421
|
-
private connectionTimeoutListeners;
|
|
422
|
-
/** @internal */
|
|
423
|
-
private pendingRequests;
|
|
424
|
-
/** @internal */
|
|
425
|
-
private currentRequestId;
|
|
426
|
-
/** Current transport connection */
|
|
427
|
-
transport: MCPSDKTransport | null;
|
|
428
|
-
/** @internal */
|
|
429
|
-
private clientResponsive;
|
|
430
|
-
/** @internal */
|
|
431
|
-
private pingTimeoutId;
|
|
432
|
-
/** Whether to cleanup tools on shutdown */
|
|
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
|
-
*/
|
|
448
|
-
constructor(config?: MCPSDKAdapterConfig);
|
|
449
|
-
/**
|
|
450
|
-
* Get the adapter configuration.
|
|
451
|
-
* @returns Copy of the current configuration
|
|
452
|
-
*/
|
|
453
|
-
getConfig(): MCPSDKAdapterConfig;
|
|
454
|
-
/**
|
|
455
|
-
* Get supported transports.
|
|
456
|
-
* @returns Array of supported transport types
|
|
457
|
-
*/
|
|
458
|
-
getSupportedTransports(): MCPSDKTransportType[];
|
|
459
|
-
/**
|
|
460
|
-
* Get protocol version.
|
|
461
|
-
* @returns The MCP protocol version string
|
|
462
|
-
*/
|
|
463
|
-
getProtocolVersion(): string;
|
|
464
|
-
/**
|
|
465
|
-
* Get SDK version.
|
|
466
|
-
* @returns The SDK version string
|
|
467
|
-
*/
|
|
468
|
-
getSDKVersion(): string;
|
|
469
|
-
/**
|
|
470
|
-
* Get capabilities.
|
|
471
|
-
* @returns Copy of the server capabilities configuration
|
|
472
|
-
*/
|
|
473
|
-
getCapabilities(): MCPSDKCapabilities;
|
|
474
|
-
/**
|
|
475
|
-
* Get connection state.
|
|
476
|
-
* @returns Current connection state
|
|
477
|
-
*/
|
|
478
|
-
getConnectionState(): MCPSDKConnectionState;
|
|
479
|
-
/**
|
|
480
|
-
* Set connection state and notify listeners.
|
|
481
|
-
* @internal
|
|
482
|
-
*/
|
|
483
|
-
private setConnectionState;
|
|
484
|
-
/**
|
|
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
|
-
* })
|
|
491
|
-
*/
|
|
492
|
-
onStateChange(listener: (state: MCPSDKConnectionState) => void): void;
|
|
493
|
-
/**
|
|
494
|
-
* Register a connected listener.
|
|
495
|
-
* @param listener - Callback invoked when connection is established
|
|
496
|
-
*/
|
|
497
|
-
onConnected(listener: () => void): void;
|
|
498
|
-
/**
|
|
499
|
-
* Register a disconnected listener.
|
|
500
|
-
* @param listener - Callback invoked when connection is lost
|
|
501
|
-
*/
|
|
502
|
-
onDisconnected(listener: () => void): void;
|
|
503
|
-
/**
|
|
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
|
|
507
|
-
*/
|
|
508
|
-
onNotification(type: string, listener: () => void): void;
|
|
509
|
-
/**
|
|
510
|
-
* Emit a notification.
|
|
511
|
-
* @internal
|
|
512
|
-
*/
|
|
513
|
-
private emitNotification;
|
|
514
|
-
/**
|
|
515
|
-
* Register a progress listener.
|
|
516
|
-
* @param listener - Callback invoked when tool reports progress
|
|
517
|
-
*/
|
|
518
|
-
onProgress(listener: (progress: ProgressEvent) => void): void;
|
|
519
|
-
/**
|
|
520
|
-
* Register an error listener.
|
|
521
|
-
* @param listener - Callback invoked when an error occurs
|
|
522
|
-
*/
|
|
523
|
-
onError(listener: (error: MCPSDKError) => void): void;
|
|
524
|
-
/**
|
|
525
|
-
* Register a pong listener.
|
|
526
|
-
* @param listener - Callback invoked when pong response is received
|
|
527
|
-
*/
|
|
528
|
-
onPong(listener: () => void): void;
|
|
529
|
-
/**
|
|
530
|
-
* Register a connection timeout listener.
|
|
531
|
-
* @param listener - Callback invoked when connection times out
|
|
532
|
-
*/
|
|
533
|
-
onConnectionTimeout(listener: () => void): void;
|
|
534
|
-
/**
|
|
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()
|
|
546
|
-
*/
|
|
547
|
-
start(): Promise<void>;
|
|
548
|
-
/**
|
|
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
|
|
556
|
-
*/
|
|
557
|
-
connect(transport: MCPSDKTransport): Promise<void>;
|
|
558
|
-
/**
|
|
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 })
|
|
573
|
-
*/
|
|
574
|
-
shutdown(options?: {
|
|
575
|
-
graceful?: boolean;
|
|
576
|
-
timeout?: number;
|
|
577
|
-
cleanup?: boolean;
|
|
578
|
-
}): Promise<void>;
|
|
579
|
-
/**
|
|
580
|
-
* Wait for all pending requests to complete.
|
|
581
|
-
* @internal
|
|
582
|
-
*/
|
|
583
|
-
private waitForPendingRequests;
|
|
584
|
-
/**
|
|
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
|
|
594
|
-
*/
|
|
595
|
-
handleClientInitialize(request: MCPClientInitializeRequest): Promise<{
|
|
596
|
-
serverInfo: {
|
|
597
|
-
name: string;
|
|
598
|
-
version: string;
|
|
599
|
-
};
|
|
600
|
-
capabilities: MCPSDKCapabilities;
|
|
601
|
-
}>;
|
|
602
|
-
/**
|
|
603
|
-
* Get current session.
|
|
604
|
-
* @returns Current session or null if not initialized
|
|
605
|
-
*/
|
|
606
|
-
getSession(): MCPSDKSession | null;
|
|
607
|
-
/**
|
|
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
|
-
* })
|
|
626
|
-
*/
|
|
627
|
-
registerTool(registration: MCPSDKToolRegistration): void;
|
|
628
|
-
/**
|
|
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
|
|
638
|
-
*/
|
|
639
|
-
registerTools(registrations: MCPSDKToolRegistration[]): void;
|
|
640
|
-
/**
|
|
641
|
-
* Unregister a tool.
|
|
642
|
-
* @param name - Name of the tool to unregister
|
|
643
|
-
*/
|
|
644
|
-
unregisterTool(name: string): void;
|
|
645
|
-
/**
|
|
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
|
|
649
|
-
*/
|
|
650
|
-
getTool(name: string): (Omit<MCPSDKToolRegistration, 'handler'> & {
|
|
651
|
-
id: string;
|
|
652
|
-
}) | undefined;
|
|
653
|
-
/**
|
|
654
|
-
* List all tools.
|
|
655
|
-
* @returns Array of tool metadata (without handlers)
|
|
656
|
-
*/
|
|
657
|
-
listTools(): Array<Omit<MCPSDKToolRegistration, 'handler'> & {
|
|
658
|
-
id: string;
|
|
659
|
-
}>;
|
|
660
|
-
/**
|
|
661
|
-
* Register gitdo tools.
|
|
662
|
-
*
|
|
663
|
-
* @description
|
|
664
|
-
* Convenience method that registers all built-in git tools.
|
|
665
|
-
* Skips tools that are already registered.
|
|
666
|
-
*/
|
|
667
|
-
registerGitdoTools(): void;
|
|
668
|
-
/**
|
|
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
|
|
677
|
-
*/
|
|
678
|
-
handleToolsList(options?: {
|
|
679
|
-
cursor?: string;
|
|
680
|
-
}): Promise<{
|
|
681
|
-
tools: Array<{
|
|
682
|
-
name: string;
|
|
683
|
-
description: string;
|
|
684
|
-
inputSchema: {
|
|
685
|
-
type: string;
|
|
686
|
-
properties?: Record<string, unknown>;
|
|
687
|
-
required?: string[];
|
|
688
|
-
};
|
|
689
|
-
}>;
|
|
690
|
-
nextCursor?: string;
|
|
691
|
-
}>;
|
|
692
|
-
/**
|
|
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
|
|
710
|
-
*/
|
|
711
|
-
handleToolsCall(request: MCPToolsCallRequest): Promise<MCPToolsCallResult> & {
|
|
712
|
-
requestId: string;
|
|
713
|
-
};
|
|
714
|
-
/**
|
|
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
|
|
722
|
-
*/
|
|
723
|
-
cancelRequest(requestId: string | undefined): void;
|
|
724
|
-
/**
|
|
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
|
|
733
|
-
*/
|
|
734
|
-
handleMessage(message: string): Promise<string>;
|
|
735
|
-
/**
|
|
736
|
-
* Handle a single JSON-RPC message
|
|
737
|
-
*/
|
|
738
|
-
private handleSingleMessage;
|
|
739
|
-
/**
|
|
740
|
-
* Simulate a pending request (for testing).
|
|
741
|
-
* @internal
|
|
742
|
-
*/
|
|
743
|
-
simulatePendingRequest(): PendingRequest;
|
|
744
|
-
/**
|
|
745
|
-
* Simulate an internal error (for testing).
|
|
746
|
-
* @internal
|
|
747
|
-
*/
|
|
748
|
-
simulateInternalError(error: Error): void;
|
|
749
|
-
/**
|
|
750
|
-
* Send ping to check client responsiveness.
|
|
751
|
-
*/
|
|
752
|
-
sendPing(): void;
|
|
753
|
-
/**
|
|
754
|
-
* Simulate client becoming unresponsive (for testing).
|
|
755
|
-
* @internal
|
|
756
|
-
*/
|
|
757
|
-
simulateClientUnresponsive(): void;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
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' })
|
|
775
|
-
*/
|
|
776
|
-
export declare const MCPSDKTransport: {
|
|
777
|
-
createStdio(_options?: {
|
|
778
|
-
stdin?: {
|
|
779
|
-
on: unknown;
|
|
780
|
-
read: unknown;
|
|
781
|
-
pipe: unknown;
|
|
782
|
-
};
|
|
783
|
-
stdout?: {
|
|
784
|
-
write: unknown;
|
|
785
|
-
end: unknown;
|
|
786
|
-
};
|
|
787
|
-
}): MCPSDKTransport;
|
|
788
|
-
createSSE(_options: {
|
|
789
|
-
endpoint: string;
|
|
790
|
-
}): MCPSDKTransport & {
|
|
791
|
-
handleRequest: (request: unknown) => Promise<{
|
|
792
|
-
status: number;
|
|
793
|
-
headers: Record<string, string>;
|
|
794
|
-
body?: string;
|
|
795
|
-
}>;
|
|
796
|
-
};
|
|
797
|
-
createHTTP(_options: {
|
|
798
|
-
endpoint: string;
|
|
799
|
-
}): MCPSDKTransport & {
|
|
800
|
-
handleRequest: (request: {
|
|
801
|
-
method: string;
|
|
802
|
-
body: string;
|
|
803
|
-
headers: Record<string, string>;
|
|
804
|
-
}) => Promise<{
|
|
805
|
-
status: number;
|
|
806
|
-
headers: Record<string, string>;
|
|
807
|
-
body?: string;
|
|
808
|
-
}>;
|
|
809
|
-
};
|
|
810
|
-
};
|
|
811
|
-
/**
|
|
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()
|
|
832
|
-
*/
|
|
833
|
-
export declare function createMCPSDKAdapter(config?: MCPSDKAdapterConfig): MCPSDKAdapter;
|
|
834
|
-
export {};
|
|
835
|
-
//# sourceMappingURL=sdk-adapter.d.ts.map
|