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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/mcp/adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/mcp/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,oBAAY,YAAY;IACtB,uDAAuD;IACvD,WAAW,SAAS;IACpB,6EAA6E;IAC7E,eAAe,S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H,OAAO,CAAC,kBAAkB;IAkD1B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;;;;OAKG;YACW,mBAAmB;IA0CjC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;;;;OAKG;YACW,gBAAgB;IAmC9B;;;;;;;;OAQG;IACH,OAAO,CAAC,aAAa;CAgBtB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,UAAU,CAErE"}
|
package/dist/mcp/adapter.js
CHANGED
|
@@ -1,41 +1,142 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP (Model Context Protocol) SDK Adapter
|
|
2
|
+
* @fileoverview MCP (Model Context Protocol) SDK Adapter
|
|
3
3
|
*
|
|
4
4
|
* This module provides an adapter that bridges the MCP protocol to git operations,
|
|
5
5
|
* handling request/response, tool registration/invocation, resource listing,
|
|
6
|
-
* and error handling.
|
|
6
|
+
* and error handling. It implements the JSON-RPC 2.0 specification for MCP
|
|
7
|
+
* communication.
|
|
8
|
+
*
|
|
9
|
+
* The adapter supports:
|
|
10
|
+
* - Tool registration and invocation with schema validation
|
|
11
|
+
* - Resource registration and reading
|
|
12
|
+
* - Prompt registration and retrieval
|
|
13
|
+
* - Standard and custom MCP error codes
|
|
14
|
+
* - Batch request processing
|
|
15
|
+
* - Capability negotiation
|
|
16
|
+
*
|
|
17
|
+
* @module mcp/adapter
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Create and configure an MCP adapter
|
|
21
|
+
* import { createMCPAdapter, MCPAdapter } from './adapter'
|
|
22
|
+
*
|
|
23
|
+
* const adapter = createMCPAdapter({
|
|
24
|
+
* name: 'my-git-server',
|
|
25
|
+
* version: '1.0.0',
|
|
26
|
+
* capabilities: ['tools', 'resources']
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* // Register git tools and start
|
|
30
|
+
* adapter.registerGitTools()
|
|
31
|
+
* await adapter.start()
|
|
32
|
+
*
|
|
33
|
+
* // Handle incoming requests
|
|
34
|
+
* const response = await adapter.handleRequest({
|
|
35
|
+
* jsonrpc: '2.0',
|
|
36
|
+
* id: 1,
|
|
37
|
+
* method: 'tools/list',
|
|
38
|
+
* params: {}
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Handle raw JSON requests
|
|
43
|
+
* const rawResponse = await adapter.handleRawRequest(
|
|
44
|
+
* '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'
|
|
45
|
+
* )
|
|
7
46
|
*/
|
|
8
47
|
import { gitTools } from './tools';
|
|
9
48
|
/**
|
|
10
|
-
* JSON-RPC 2.0 error codes and MCP-specific error codes
|
|
49
|
+
* JSON-RPC 2.0 error codes and MCP-specific error codes.
|
|
50
|
+
*
|
|
51
|
+
* @description
|
|
52
|
+
* Enumeration of error codes used in MCP responses. Includes standard
|
|
53
|
+
* JSON-RPC 2.0 error codes (negative 32xxx range) and MCP-specific
|
|
54
|
+
* error codes for resource, tool, and prompt operations.
|
|
55
|
+
*
|
|
56
|
+
* @enum {number}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Using error codes in responses
|
|
60
|
+
* if (!tool) {
|
|
61
|
+
* return {
|
|
62
|
+
* jsonrpc: '2.0',
|
|
63
|
+
* id: requestId,
|
|
64
|
+
* error: {
|
|
65
|
+
* code: MCPErrorCode.TOOL_NOT_FOUND,
|
|
66
|
+
* message: 'Tool not found'
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* }
|
|
11
70
|
*/
|
|
12
71
|
export var MCPErrorCode;
|
|
13
72
|
(function (MCPErrorCode) {
|
|
14
|
-
|
|
73
|
+
/** Parse error - Invalid JSON was received (-32700) */
|
|
15
74
|
MCPErrorCode[MCPErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
75
|
+
/** Invalid Request - The JSON sent is not a valid Request object (-32600) */
|
|
16
76
|
MCPErrorCode[MCPErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
77
|
+
/** Method not found - The method does not exist or is not available (-32601) */
|
|
17
78
|
MCPErrorCode[MCPErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
79
|
+
/** Invalid params - Invalid method parameter(s) (-32602) */
|
|
18
80
|
MCPErrorCode[MCPErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
81
|
+
/** Internal error - Internal JSON-RPC error (-32603) */
|
|
19
82
|
MCPErrorCode[MCPErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
20
|
-
|
|
83
|
+
/** Resource not found - The requested resource does not exist (-32001) */
|
|
21
84
|
MCPErrorCode[MCPErrorCode["RESOURCE_NOT_FOUND"] = -32001] = "RESOURCE_NOT_FOUND";
|
|
22
|
-
|
|
85
|
+
/** Tool not found - Maps to METHOD_NOT_FOUND as tools are methods (-32601) */
|
|
23
86
|
MCPErrorCode[MCPErrorCode["TOOL_NOT_FOUND"] = -32601] = "TOOL_NOT_FOUND";
|
|
87
|
+
/** Prompt not found - The requested prompt does not exist (-32003) */
|
|
24
88
|
MCPErrorCode[MCPErrorCode["PROMPT_NOT_FOUND"] = -32003] = "PROMPT_NOT_FOUND";
|
|
89
|
+
/** Capability not supported - The requested capability is not enabled (-32004) */
|
|
25
90
|
MCPErrorCode[MCPErrorCode["CAPABILITY_NOT_SUPPORTED"] = -32004] = "CAPABILITY_NOT_SUPPORTED";
|
|
26
91
|
})(MCPErrorCode || (MCPErrorCode = {}));
|
|
27
92
|
/**
|
|
28
|
-
* Custom error class for MCP errors
|
|
93
|
+
* Custom error class for MCP errors.
|
|
94
|
+
*
|
|
95
|
+
* @description
|
|
96
|
+
* Error class that encapsulates MCP error information including a numeric
|
|
97
|
+
* error code, human-readable message, and optional additional data. Can be
|
|
98
|
+
* serialized to JSON-RPC error format using the toJSON() method.
|
|
99
|
+
*
|
|
100
|
+
* @class MCPError
|
|
101
|
+
* @extends Error
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* // Throw an MCP error
|
|
105
|
+
* throw new MCPError(
|
|
106
|
+
* MCPErrorCode.TOOL_NOT_FOUND,
|
|
107
|
+
* 'Tool "unknown_tool" not found',
|
|
108
|
+
* { toolName: 'unknown_tool' }
|
|
109
|
+
* )
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Convert to JSON-RPC error format
|
|
113
|
+
* const error = new MCPError(MCPErrorCode.INVALID_PARAMS, 'Missing required field')
|
|
114
|
+
* const jsonError = error.toJSON()
|
|
115
|
+
* // { code: -32602, message: 'Missing required field' }
|
|
29
116
|
*/
|
|
30
117
|
export class MCPError extends Error {
|
|
118
|
+
/** The MCP error code */
|
|
31
119
|
code;
|
|
120
|
+
/** Optional additional error data */
|
|
32
121
|
data;
|
|
122
|
+
/**
|
|
123
|
+
* Create a new MCP error.
|
|
124
|
+
*
|
|
125
|
+
* @param code - The MCP error code
|
|
126
|
+
* @param message - Human-readable error message
|
|
127
|
+
* @param data - Optional additional error data
|
|
128
|
+
*/
|
|
33
129
|
constructor(code, message, data) {
|
|
34
130
|
super(message);
|
|
35
131
|
this.code = code;
|
|
36
132
|
this.data = data;
|
|
37
133
|
this.name = 'MCPError';
|
|
38
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert the error to JSON-RPC error format.
|
|
137
|
+
*
|
|
138
|
+
* @returns Object suitable for JSON-RPC error responses
|
|
139
|
+
*/
|
|
39
140
|
toJSON() {
|
|
40
141
|
const result = {
|
|
41
142
|
code: this.code,
|
|
@@ -48,14 +149,64 @@ export class MCPError extends Error {
|
|
|
48
149
|
}
|
|
49
150
|
}
|
|
50
151
|
/**
|
|
51
|
-
* MCP Adapter class that bridges MCP protocol to git operations
|
|
152
|
+
* MCP Adapter class that bridges MCP protocol to git operations.
|
|
153
|
+
*
|
|
154
|
+
* @description
|
|
155
|
+
* The main adapter class that handles MCP protocol communication. It manages
|
|
156
|
+
* tool, resource, and prompt registrations, processes JSON-RPC requests,
|
|
157
|
+
* and returns properly formatted responses.
|
|
158
|
+
*
|
|
159
|
+
* The adapter supports the following MCP methods:
|
|
160
|
+
* - initialize: Server initialization and capability negotiation
|
|
161
|
+
* - tools/list: List all registered tools
|
|
162
|
+
* - tools/call: Invoke a registered tool
|
|
163
|
+
* - resources/list: List all registered resources
|
|
164
|
+
* - resources/read: Read a resource's content
|
|
165
|
+
* - prompts/list: List all registered prompts
|
|
166
|
+
* - prompts/get: Get a prompt's generated messages
|
|
167
|
+
*
|
|
168
|
+
* @class MCPAdapter
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* // Create and use an adapter
|
|
172
|
+
* const adapter = new MCPAdapter({
|
|
173
|
+
* name: 'my-server',
|
|
174
|
+
* version: '1.0.0',
|
|
175
|
+
* capabilities: ['tools']
|
|
176
|
+
* })
|
|
177
|
+
*
|
|
178
|
+
* adapter.registerGitTools()
|
|
179
|
+
* await adapter.start()
|
|
180
|
+
*
|
|
181
|
+
* const response = await adapter.handleRequest({
|
|
182
|
+
* jsonrpc: '2.0',
|
|
183
|
+
* id: 1,
|
|
184
|
+
* method: 'tools/list'
|
|
185
|
+
* })
|
|
52
186
|
*/
|
|
53
187
|
export class MCPAdapter {
|
|
188
|
+
/** @internal */
|
|
54
189
|
config;
|
|
190
|
+
/** @internal */
|
|
55
191
|
initialized = false;
|
|
192
|
+
/** @internal */
|
|
56
193
|
tools = new Map();
|
|
194
|
+
/** @internal */
|
|
57
195
|
resources = new Map();
|
|
196
|
+
/** @internal */
|
|
58
197
|
prompts = new Map();
|
|
198
|
+
/**
|
|
199
|
+
* Create a new MCP adapter instance.
|
|
200
|
+
*
|
|
201
|
+
* @param config - Optional configuration options
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* const adapter = new MCPAdapter({
|
|
205
|
+
* name: 'git-mcp-server',
|
|
206
|
+
* version: '2.0.0',
|
|
207
|
+
* capabilities: ['tools', 'resources', 'prompts']
|
|
208
|
+
* })
|
|
209
|
+
*/
|
|
59
210
|
constructor(config) {
|
|
60
211
|
this.config = {
|
|
61
212
|
name: config?.name || 'gitx.do',
|
|
@@ -64,25 +215,64 @@ export class MCPAdapter {
|
|
|
64
215
|
};
|
|
65
216
|
}
|
|
66
217
|
/**
|
|
67
|
-
* Get the server configuration
|
|
218
|
+
* Get the server configuration.
|
|
219
|
+
*
|
|
220
|
+
* @description
|
|
221
|
+
* Returns a copy of the current server configuration including name,
|
|
222
|
+
* version, and enabled capabilities.
|
|
223
|
+
*
|
|
224
|
+
* @returns A copy of the server configuration
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* const config = adapter.getConfig()
|
|
228
|
+
* console.log(`Server: ${config.name} v${config.version}`)
|
|
68
229
|
*/
|
|
69
230
|
getConfig() {
|
|
70
231
|
return { ...this.config };
|
|
71
232
|
}
|
|
72
233
|
/**
|
|
73
|
-
* Check if adapter has a specific capability
|
|
234
|
+
* Check if adapter has a specific capability.
|
|
235
|
+
*
|
|
236
|
+
* @description
|
|
237
|
+
* Tests whether a specific capability is enabled for this adapter.
|
|
238
|
+
* Used internally to determine which methods are available.
|
|
239
|
+
*
|
|
240
|
+
* @param capability - The capability to check ('tools', 'resources', or 'prompts')
|
|
241
|
+
* @returns True if the capability is enabled
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* if (adapter.hasCapability('resources')) {
|
|
245
|
+
* adapter.registerResource(myResource)
|
|
246
|
+
* }
|
|
74
247
|
*/
|
|
75
248
|
hasCapability(capability) {
|
|
76
249
|
return this.config.capabilities.includes(capability);
|
|
77
250
|
}
|
|
78
251
|
/**
|
|
79
|
-
* Check if the adapter is initialized
|
|
252
|
+
* Check if the adapter is initialized.
|
|
253
|
+
*
|
|
254
|
+
* @description
|
|
255
|
+
* Returns whether the adapter has been started and is ready to handle requests.
|
|
256
|
+
*
|
|
257
|
+
* @returns True if the adapter is initialized and running
|
|
80
258
|
*/
|
|
81
259
|
isInitialized() {
|
|
82
260
|
return this.initialized;
|
|
83
261
|
}
|
|
84
262
|
/**
|
|
85
|
-
* Start the MCP adapter
|
|
263
|
+
* Start the MCP adapter.
|
|
264
|
+
*
|
|
265
|
+
* @description
|
|
266
|
+
* Initializes the adapter and prepares it to handle requests.
|
|
267
|
+
* Must be called before processing any MCP requests.
|
|
268
|
+
*
|
|
269
|
+
* @returns Promise that resolves when the adapter is started
|
|
270
|
+
* @throws {Error} If the adapter is already started
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* const adapter = new MCPAdapter()
|
|
274
|
+
* await adapter.start()
|
|
275
|
+
* // Adapter is now ready to handle requests
|
|
86
276
|
*/
|
|
87
277
|
async start() {
|
|
88
278
|
if (this.initialized) {
|
|
@@ -91,7 +281,19 @@ export class MCPAdapter {
|
|
|
91
281
|
this.initialized = true;
|
|
92
282
|
}
|
|
93
283
|
/**
|
|
94
|
-
* Stop the MCP adapter
|
|
284
|
+
* Stop the MCP adapter.
|
|
285
|
+
*
|
|
286
|
+
* @description
|
|
287
|
+
* Shuts down the adapter and clears all registered tools, resources,
|
|
288
|
+
* and prompts. After stopping, the adapter must be restarted before
|
|
289
|
+
* handling new requests.
|
|
290
|
+
*
|
|
291
|
+
* @returns Promise that resolves when the adapter is stopped
|
|
292
|
+
* @throws {Error} If the adapter is not currently running
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* await adapter.stop()
|
|
296
|
+
* // All registrations are cleared
|
|
95
297
|
*/
|
|
96
298
|
async stop() {
|
|
97
299
|
if (!this.initialized) {
|
|
@@ -103,7 +305,25 @@ export class MCPAdapter {
|
|
|
103
305
|
this.prompts.clear();
|
|
104
306
|
}
|
|
105
307
|
/**
|
|
106
|
-
* Register a tool
|
|
308
|
+
* Register a tool.
|
|
309
|
+
*
|
|
310
|
+
* @description
|
|
311
|
+
* Adds a tool to the adapter's registry. The tool will be available
|
|
312
|
+
* for listing via tools/list and invocation via tools/call.
|
|
313
|
+
*
|
|
314
|
+
* @param toolInfo - The tool definition to register
|
|
315
|
+
* @returns void
|
|
316
|
+
* @throws {Error} If a tool with the same name is already registered
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* adapter.registerTool({
|
|
320
|
+
* name: 'my_tool',
|
|
321
|
+
* description: 'Does something',
|
|
322
|
+
* inputSchema: { type: 'object', properties: {} },
|
|
323
|
+
* handler: async (params) => ({
|
|
324
|
+
* content: [{ type: 'text', text: 'Done' }]
|
|
325
|
+
* })
|
|
326
|
+
* })
|
|
107
327
|
*/
|
|
108
328
|
registerTool(toolInfo) {
|
|
109
329
|
if (this.tools.has(toolInfo.name)) {
|
|
@@ -112,7 +332,18 @@ export class MCPAdapter {
|
|
|
112
332
|
this.tools.set(toolInfo.name, toolInfo);
|
|
113
333
|
}
|
|
114
334
|
/**
|
|
115
|
-
* Unregister a tool by name
|
|
335
|
+
* Unregister a tool by name.
|
|
336
|
+
*
|
|
337
|
+
* @description
|
|
338
|
+
* Removes a tool from the adapter's registry. The tool will no longer
|
|
339
|
+
* be available for listing or invocation.
|
|
340
|
+
*
|
|
341
|
+
* @param name - The name of the tool to unregister
|
|
342
|
+
* @returns void
|
|
343
|
+
* @throws {Error} If no tool with the given name exists
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* adapter.unregisterTool('my_tool')
|
|
116
347
|
*/
|
|
117
348
|
unregisterTool(name) {
|
|
118
349
|
if (!this.tools.has(name)) {
|
|
@@ -121,7 +352,19 @@ export class MCPAdapter {
|
|
|
121
352
|
this.tools.delete(name);
|
|
122
353
|
}
|
|
123
354
|
/**
|
|
124
|
-
* List all registered tools (without handlers)
|
|
355
|
+
* List all registered tools (without handlers).
|
|
356
|
+
*
|
|
357
|
+
* @description
|
|
358
|
+
* Returns an array of all registered tools with their metadata.
|
|
359
|
+
* Handler functions are omitted for serialization safety.
|
|
360
|
+
*
|
|
361
|
+
* @returns Array of tool definitions without handlers
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* const tools = adapter.listTools()
|
|
365
|
+
* for (const tool of tools) {
|
|
366
|
+
* console.log(`${tool.name}: ${tool.description}`)
|
|
367
|
+
* }
|
|
125
368
|
*/
|
|
126
369
|
listTools() {
|
|
127
370
|
const result = [];
|
|
@@ -135,7 +378,20 @@ export class MCPAdapter {
|
|
|
135
378
|
return result;
|
|
136
379
|
}
|
|
137
380
|
/**
|
|
138
|
-
* Get a tool by name (without handler)
|
|
381
|
+
* Get a tool by name (without handler).
|
|
382
|
+
*
|
|
383
|
+
* @description
|
|
384
|
+
* Retrieves a single tool's metadata by name. Returns undefined if
|
|
385
|
+
* the tool is not found.
|
|
386
|
+
*
|
|
387
|
+
* @param name - The name of the tool to retrieve
|
|
388
|
+
* @returns The tool definition without handler, or undefined if not found
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* const tool = adapter.getTool('git_status')
|
|
392
|
+
* if (tool) {
|
|
393
|
+
* console.log(tool.description)
|
|
394
|
+
* }
|
|
139
395
|
*/
|
|
140
396
|
getTool(name) {
|
|
141
397
|
const tool = this.tools.get(name);
|
|
@@ -148,7 +404,18 @@ export class MCPAdapter {
|
|
|
148
404
|
};
|
|
149
405
|
}
|
|
150
406
|
/**
|
|
151
|
-
* Register all git tools
|
|
407
|
+
* Register all git tools.
|
|
408
|
+
*
|
|
409
|
+
* @description
|
|
410
|
+
* Convenience method that registers all built-in git tools from the
|
|
411
|
+
* tools module. Skips any tools that are already registered.
|
|
412
|
+
*
|
|
413
|
+
* @returns void
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* const adapter = new MCPAdapter()
|
|
417
|
+
* adapter.registerGitTools()
|
|
418
|
+
* // All 18 git tools are now registered
|
|
152
419
|
*/
|
|
153
420
|
registerGitTools() {
|
|
154
421
|
for (const tool of gitTools) {
|
|
@@ -163,19 +430,62 @@ export class MCPAdapter {
|
|
|
163
430
|
}
|
|
164
431
|
}
|
|
165
432
|
/**
|
|
166
|
-
* Register a resource
|
|
433
|
+
* Register a resource.
|
|
434
|
+
*
|
|
435
|
+
* @description
|
|
436
|
+
* Adds a resource to the adapter's registry. The resource will be
|
|
437
|
+
* available for listing and reading via the resources/* methods.
|
|
438
|
+
*
|
|
439
|
+
* @param resourceInfo - The resource definition to register
|
|
440
|
+
* @returns void
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* adapter.registerResource({
|
|
444
|
+
* uri: 'git://repo/config',
|
|
445
|
+
* name: 'Repository Config',
|
|
446
|
+
* mimeType: 'application/json',
|
|
447
|
+
* handler: async () => ({ content: JSON.stringify(config) })
|
|
448
|
+
* })
|
|
167
449
|
*/
|
|
168
450
|
registerResource(resourceInfo) {
|
|
169
451
|
this.resources.set(resourceInfo.uri, resourceInfo);
|
|
170
452
|
}
|
|
171
453
|
/**
|
|
172
|
-
* Register a prompt
|
|
454
|
+
* Register a prompt.
|
|
455
|
+
*
|
|
456
|
+
* @description
|
|
457
|
+
* Adds a prompt template to the adapter's registry. The prompt will
|
|
458
|
+
* be available for listing and retrieval via the prompts/* methods.
|
|
459
|
+
*
|
|
460
|
+
* @param promptInfo - The prompt definition to register
|
|
461
|
+
* @returns void
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* adapter.registerPrompt({
|
|
465
|
+
* name: 'review-code',
|
|
466
|
+
* description: 'Review code changes',
|
|
467
|
+
* handler: async () => ({
|
|
468
|
+
* messages: [{ role: 'user', content: { type: 'text', text: '...' } }]
|
|
469
|
+
* })
|
|
470
|
+
* })
|
|
173
471
|
*/
|
|
174
472
|
registerPrompt(promptInfo) {
|
|
175
473
|
this.prompts.set(promptInfo.name, promptInfo);
|
|
176
474
|
}
|
|
177
475
|
/**
|
|
178
|
-
* Handle a raw JSON string request
|
|
476
|
+
* Handle a raw JSON string request.
|
|
477
|
+
*
|
|
478
|
+
* @description
|
|
479
|
+
* Parses a raw JSON string as an MCP request and processes it.
|
|
480
|
+
* Returns a parse error response if the JSON is invalid.
|
|
481
|
+
*
|
|
482
|
+
* @param rawRequest - Raw JSON string containing the request
|
|
483
|
+
* @returns Promise resolving to the MCP response
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* const response = await adapter.handleRawRequest(
|
|
487
|
+
* '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
|
|
488
|
+
* )
|
|
179
489
|
*/
|
|
180
490
|
async handleRawRequest(rawRequest) {
|
|
181
491
|
let request;
|
|
@@ -201,7 +511,20 @@ export class MCPAdapter {
|
|
|
201
511
|
};
|
|
202
512
|
}
|
|
203
513
|
/**
|
|
204
|
-
* Handle a batch of requests
|
|
514
|
+
* Handle a batch of requests.
|
|
515
|
+
*
|
|
516
|
+
* @description
|
|
517
|
+
* Processes multiple MCP requests sequentially. Notifications (requests
|
|
518
|
+
* without an id) are processed but do not produce responses.
|
|
519
|
+
*
|
|
520
|
+
* @param requests - Array of MCP requests to process
|
|
521
|
+
* @returns Promise resolving to array of responses (excluding notifications)
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* const responses = await adapter.handleBatchRequest([
|
|
525
|
+
* { jsonrpc: '2.0', id: 1, method: 'tools/list' },
|
|
526
|
+
* { jsonrpc: '2.0', id: 2, method: 'initialize', params: {} }
|
|
527
|
+
* ])
|
|
205
528
|
*/
|
|
206
529
|
async handleBatchRequest(requests) {
|
|
207
530
|
const responses = [];
|
|
@@ -215,7 +538,23 @@ export class MCPAdapter {
|
|
|
215
538
|
return responses;
|
|
216
539
|
}
|
|
217
540
|
/**
|
|
218
|
-
* Handle a single MCP request
|
|
541
|
+
* Handle a single MCP request.
|
|
542
|
+
*
|
|
543
|
+
* @description
|
|
544
|
+
* Main request handler that routes MCP requests to the appropriate
|
|
545
|
+
* method handler. Supports initialize, tools/*, resources/*, and prompts/*
|
|
546
|
+
* methods. Returns undefined for notifications (requests without id).
|
|
547
|
+
*
|
|
548
|
+
* @param request - The MCP request to handle
|
|
549
|
+
* @returns Promise resolving to response, or undefined for notifications
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* const response = await adapter.handleRequest({
|
|
553
|
+
* jsonrpc: '2.0',
|
|
554
|
+
* id: 1,
|
|
555
|
+
* method: 'tools/call',
|
|
556
|
+
* params: { name: 'git_status', arguments: {} }
|
|
557
|
+
* })
|
|
219
558
|
*/
|
|
220
559
|
async handleRequest(request) {
|
|
221
560
|
// Handle notifications (no id) - they don't expect a response
|
|
@@ -256,7 +595,15 @@ export class MCPAdapter {
|
|
|
256
595
|
}
|
|
257
596
|
}
|
|
258
597
|
/**
|
|
259
|
-
* Handle initialize request
|
|
598
|
+
* Handle initialize request.
|
|
599
|
+
*
|
|
600
|
+
* @description
|
|
601
|
+
* Processes the MCP initialize request and returns server information
|
|
602
|
+
* and capabilities. This is the first request a client should send.
|
|
603
|
+
*
|
|
604
|
+
* @param request - The initialize request
|
|
605
|
+
* @returns Response with server info and capabilities
|
|
606
|
+
* @internal
|
|
260
607
|
*/
|
|
261
608
|
handleInitialize(request) {
|
|
262
609
|
const params = request.params || {};
|
|
@@ -285,7 +632,10 @@ export class MCPAdapter {
|
|
|
285
632
|
};
|
|
286
633
|
}
|
|
287
634
|
/**
|
|
288
|
-
* Handle tools/list request
|
|
635
|
+
* Handle tools/list request.
|
|
636
|
+
* @param request - The tools/list request
|
|
637
|
+
* @returns Response with list of registered tools
|
|
638
|
+
* @internal
|
|
289
639
|
*/
|
|
290
640
|
handleToolsList(request) {
|
|
291
641
|
if (!this.hasCapability('tools')) {
|
|
@@ -300,7 +650,10 @@ export class MCPAdapter {
|
|
|
300
650
|
};
|
|
301
651
|
}
|
|
302
652
|
/**
|
|
303
|
-
* Handle tools/call request
|
|
653
|
+
* Handle tools/call request.
|
|
654
|
+
* @param request - The tools/call request with tool name and arguments
|
|
655
|
+
* @returns Response with tool execution result
|
|
656
|
+
* @internal
|
|
304
657
|
*/
|
|
305
658
|
async handleToolsCall(request) {
|
|
306
659
|
if (!this.hasCapability('tools')) {
|
|
@@ -346,7 +699,11 @@ export class MCPAdapter {
|
|
|
346
699
|
}
|
|
347
700
|
}
|
|
348
701
|
/**
|
|
349
|
-
* Validate tool parameters against schema
|
|
702
|
+
* Validate tool parameters against schema.
|
|
703
|
+
* @param tool - The tool to validate parameters for
|
|
704
|
+
* @param params - The parameters to validate
|
|
705
|
+
* @returns Validation result with errors array
|
|
706
|
+
* @internal
|
|
350
707
|
*/
|
|
351
708
|
validateToolParams(tool, params) {
|
|
352
709
|
const errors = [];
|
|
@@ -385,7 +742,10 @@ export class MCPAdapter {
|
|
|
385
742
|
return { valid: errors.length === 0, errors };
|
|
386
743
|
}
|
|
387
744
|
/**
|
|
388
|
-
* Handle resources/list request
|
|
745
|
+
* Handle resources/list request.
|
|
746
|
+
* @param request - The resources/list request
|
|
747
|
+
* @returns Response with list of registered resources
|
|
748
|
+
* @internal
|
|
389
749
|
*/
|
|
390
750
|
handleResourcesList(request) {
|
|
391
751
|
if (!this.hasCapability('resources')) {
|
|
@@ -404,7 +764,10 @@ export class MCPAdapter {
|
|
|
404
764
|
};
|
|
405
765
|
}
|
|
406
766
|
/**
|
|
407
|
-
* Handle resources/read request
|
|
767
|
+
* Handle resources/read request.
|
|
768
|
+
* @param request - The resources/read request with URI
|
|
769
|
+
* @returns Response with resource content
|
|
770
|
+
* @internal
|
|
408
771
|
*/
|
|
409
772
|
async handleResourcesRead(request) {
|
|
410
773
|
if (!this.hasCapability('resources')) {
|
|
@@ -436,7 +799,10 @@ export class MCPAdapter {
|
|
|
436
799
|
};
|
|
437
800
|
}
|
|
438
801
|
/**
|
|
439
|
-
* Handle prompts/list request
|
|
802
|
+
* Handle prompts/list request.
|
|
803
|
+
* @param request - The prompts/list request
|
|
804
|
+
* @returns Response with list of registered prompts
|
|
805
|
+
* @internal
|
|
440
806
|
*/
|
|
441
807
|
handlePromptsList(request) {
|
|
442
808
|
if (!this.hasCapability('prompts')) {
|
|
@@ -454,7 +820,10 @@ export class MCPAdapter {
|
|
|
454
820
|
};
|
|
455
821
|
}
|
|
456
822
|
/**
|
|
457
|
-
* Handle prompts/get request
|
|
823
|
+
* Handle prompts/get request.
|
|
824
|
+
* @param request - The prompts/get request with name and arguments
|
|
825
|
+
* @returns Response with generated prompt messages
|
|
826
|
+
* @internal
|
|
458
827
|
*/
|
|
459
828
|
async handlePromptsGet(request) {
|
|
460
829
|
if (!this.hasCapability('prompts')) {
|
|
@@ -479,7 +848,13 @@ export class MCPAdapter {
|
|
|
479
848
|
};
|
|
480
849
|
}
|
|
481
850
|
/**
|
|
482
|
-
* Create an error response
|
|
851
|
+
* Create an error response.
|
|
852
|
+
* @param id - Request ID
|
|
853
|
+
* @param code - Error code
|
|
854
|
+
* @param message - Error message
|
|
855
|
+
* @param data - Optional additional error data
|
|
856
|
+
* @returns Formatted error response
|
|
857
|
+
* @internal
|
|
483
858
|
*/
|
|
484
859
|
errorResponse(id, code, message, data) {
|
|
485
860
|
const response = {
|
|
@@ -494,7 +869,25 @@ export class MCPAdapter {
|
|
|
494
869
|
}
|
|
495
870
|
}
|
|
496
871
|
/**
|
|
497
|
-
* Factory function to create an MCP adapter
|
|
872
|
+
* Factory function to create an MCP adapter.
|
|
873
|
+
*
|
|
874
|
+
* @description
|
|
875
|
+
* Convenience function for creating a new MCP adapter instance.
|
|
876
|
+
* Equivalent to using `new MCPAdapter(config)`.
|
|
877
|
+
*
|
|
878
|
+
* @param config - Optional server configuration
|
|
879
|
+
* @returns A new MCPAdapter instance
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* import { createMCPAdapter } from './adapter'
|
|
883
|
+
*
|
|
884
|
+
* const adapter = createMCPAdapter({
|
|
885
|
+
* name: 'my-git-server',
|
|
886
|
+
* capabilities: ['tools', 'resources']
|
|
887
|
+
* })
|
|
888
|
+
*
|
|
889
|
+
* adapter.registerGitTools()
|
|
890
|
+
* await adapter.start()
|
|
498
891
|
*/
|
|
499
892
|
export function createMCPAdapter(config) {
|
|
500
893
|
return new MCPAdapter(config);
|