opencode-toolbox 0.10.0 → 0.10.4
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/index.js +34 -17
- package/package.json +5 -1
- package/toolbox.schema.json +2 -0
package/dist/index.js
CHANGED
|
@@ -36280,21 +36280,21 @@ class LocalMCPClient {
|
|
|
36280
36280
|
toolsCache;
|
|
36281
36281
|
name;
|
|
36282
36282
|
config;
|
|
36283
|
-
|
|
36283
|
+
transportFactory;
|
|
36284
|
+
constructor(config3, options) {
|
|
36284
36285
|
this.transport = null;
|
|
36285
36286
|
this.toolsCache = null;
|
|
36286
36287
|
this.name = config3.name;
|
|
36287
36288
|
this.config = config3;
|
|
36288
|
-
|
|
36289
|
-
|
|
36290
|
-
|
|
36291
|
-
}, {});
|
|
36289
|
+
const clientFactory = options?.clientFactory ?? ((name) => new Client({ name: `opencode-toolbox-client-${name}`, version: "0.1.0" }, {}));
|
|
36290
|
+
this.transportFactory = options?.transportFactory ?? ((opts) => new StdioClientTransport(opts));
|
|
36291
|
+
this.client = clientFactory(this.name);
|
|
36292
36292
|
}
|
|
36293
36293
|
async connect() {
|
|
36294
36294
|
if (!this.config.command || this.config.command.length === 0) {
|
|
36295
36295
|
throw new Error(`Local MCP server ${this.name} has no command`);
|
|
36296
36296
|
}
|
|
36297
|
-
this.transport =
|
|
36297
|
+
this.transport = this.transportFactory({
|
|
36298
36298
|
command: this.config.command[0],
|
|
36299
36299
|
args: this.config.command.slice(1),
|
|
36300
36300
|
env: {
|
|
@@ -38028,20 +38028,45 @@ class RemoteMCPClient {
|
|
|
38028
38028
|
name;
|
|
38029
38029
|
config;
|
|
38030
38030
|
transportType;
|
|
38031
|
-
|
|
38031
|
+
options;
|
|
38032
|
+
constructor(config3, options) {
|
|
38032
38033
|
this.transport = null;
|
|
38033
38034
|
this.toolsCache = null;
|
|
38034
38035
|
this.name = config3.name;
|
|
38035
38036
|
this.config = config3;
|
|
38036
38037
|
this.transportType = null;
|
|
38038
|
+
this.options = options ?? {};
|
|
38037
38039
|
this.client = this.createClient();
|
|
38038
38040
|
}
|
|
38039
38041
|
createClient() {
|
|
38042
|
+
if (this.options.clientFactory) {
|
|
38043
|
+
return this.options.clientFactory(this.name);
|
|
38044
|
+
}
|
|
38040
38045
|
return new Client({
|
|
38041
38046
|
name: `opencode-toolbox-client-${this.name}`,
|
|
38042
38047
|
version: "0.1.0"
|
|
38043
38048
|
}, {});
|
|
38044
38049
|
}
|
|
38050
|
+
createStreamableTransport(url3) {
|
|
38051
|
+
if (this.options.streamableTransportFactory) {
|
|
38052
|
+
return this.options.streamableTransportFactory(url3, this.config.headers);
|
|
38053
|
+
}
|
|
38054
|
+
return new StreamableHTTPClientTransport(url3, {
|
|
38055
|
+
requestInit: {
|
|
38056
|
+
headers: this.config.headers
|
|
38057
|
+
}
|
|
38058
|
+
});
|
|
38059
|
+
}
|
|
38060
|
+
createSSETransport(url3, headers) {
|
|
38061
|
+
if (this.options.sseTransportFactory) {
|
|
38062
|
+
return this.options.sseTransportFactory(url3, headers);
|
|
38063
|
+
}
|
|
38064
|
+
return new SSEClientTransport(url3, {
|
|
38065
|
+
requestInit: {
|
|
38066
|
+
headers
|
|
38067
|
+
}
|
|
38068
|
+
});
|
|
38069
|
+
}
|
|
38045
38070
|
async connect() {
|
|
38046
38071
|
if (!this.config.url) {
|
|
38047
38072
|
throw new Error(`Remote MCP server ${this.name} has no URL`);
|
|
@@ -38050,11 +38075,7 @@ class RemoteMCPClient {
|
|
|
38050
38075
|
this.transportType = null;
|
|
38051
38076
|
let streamableTransport = null;
|
|
38052
38077
|
try {
|
|
38053
|
-
streamableTransport =
|
|
38054
|
-
requestInit: {
|
|
38055
|
-
headers: this.config.headers
|
|
38056
|
-
}
|
|
38057
|
-
});
|
|
38078
|
+
streamableTransport = this.createStreamableTransport(url3);
|
|
38058
38079
|
await this.client.connect(streamableTransport);
|
|
38059
38080
|
this.transport = streamableTransport;
|
|
38060
38081
|
this.transportType = "streamable-http";
|
|
@@ -38071,11 +38092,7 @@ class RemoteMCPClient {
|
|
|
38071
38092
|
Accept: "text/event-stream",
|
|
38072
38093
|
...this.config.headers
|
|
38073
38094
|
};
|
|
38074
|
-
sseTransport =
|
|
38075
|
-
requestInit: {
|
|
38076
|
-
headers: sseHeaders
|
|
38077
|
-
}
|
|
38078
|
-
});
|
|
38095
|
+
sseTransport = this.createSSETransport(url3, sseHeaders);
|
|
38079
38096
|
await this.client.connect(sseTransport);
|
|
38080
38097
|
this.transport = sseTransport;
|
|
38081
38098
|
this.transportType = "sse";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-toolbox",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Tool Search Tool Plugin for OpenCode - search and execute tools from MCP servers on-demand",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"mcp"
|
|
35
35
|
],
|
|
36
36
|
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/assagman/opencode-toolbox"
|
|
40
|
+
},
|
|
37
41
|
"devDependencies": {
|
|
38
42
|
"@types/bun": "latest",
|
|
39
43
|
"typescript": "^5.9.3"
|
package/toolbox.schema.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://unpkg.com/opencode-toolbox@latest/toolbox.schema.json",
|
|
4
|
+
"allowTrailingCommas": true,
|
|
5
|
+
"allowComments": true,
|
|
4
6
|
"title": "OpenCode Toolbox Configuration",
|
|
5
7
|
"description": "Configuration schema for opencode-toolbox plugin",
|
|
6
8
|
"type": "object",
|