@toolsdk.ai/registry 1.0.114 → 1.0.115
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 +66 -11
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +23 -25
- package/dist/domains/config/config-route.d.ts +2 -0
- package/dist/domains/config/config-route.js +31 -0
- package/dist/domains/config/config-schema.d.ts +57 -0
- package/dist/domains/config/config-schema.js +10 -0
- package/dist/domains/config/config-types.d.ts +3 -0
- package/dist/domains/executor/executor-factory.d.ts +9 -0
- package/dist/domains/executor/executor-factory.js +17 -0
- package/dist/domains/executor/executor-types.d.ts +15 -0
- package/dist/domains/executor/local-executor.d.ts +12 -0
- package/dist/domains/executor/local-executor.js +48 -0
- package/dist/domains/executor/sandbox-executor.d.ts +16 -0
- package/dist/domains/executor/sandbox-executor.js +83 -0
- package/dist/domains/package/package-handler.d.ts +17 -0
- package/dist/domains/package/package-handler.js +58 -0
- package/dist/domains/package/package-repository.d.ts +9 -0
- package/dist/domains/package/package-repository.js +26 -0
- package/dist/domains/package/package-route.d.ts +2 -0
- package/dist/{api → domains/package}/package-route.js +38 -52
- package/dist/domains/package/package-schema.d.ts +244 -0
- package/dist/domains/package/package-schema.js +52 -0
- package/dist/domains/package/package-so.d.ts +78 -0
- package/dist/domains/package/package-so.js +61 -0
- package/dist/domains/package/package-so.test.js +378 -0
- package/dist/domains/package/package-types.d.ts +9 -0
- package/dist/domains/sandbox/clients/daytona-client.d.ts +17 -0
- package/dist/domains/sandbox/clients/daytona-client.js +112 -0
- package/dist/domains/sandbox/clients/sandock-client.d.ts +19 -0
- package/dist/domains/sandbox/clients/sandock-client.js +178 -0
- package/dist/domains/sandbox/sandbox-factory.d.ts +8 -0
- package/dist/domains/sandbox/sandbox-factory.js +23 -0
- package/dist/domains/sandbox/sandbox-pool-so.d.ts +25 -0
- package/dist/domains/sandbox/sandbox-pool-so.js +123 -0
- package/dist/domains/sandbox/sandbox-types.d.ts +25 -0
- package/dist/domains/sandbox/sandbox-types.js +1 -0
- package/dist/domains/sandbox/sandbox-utils.d.ts +3 -0
- package/dist/domains/sandbox/sandbox-utils.js +109 -0
- package/dist/domains/search/search-handler.d.ts +47 -0
- package/dist/domains/search/search-handler.js +113 -0
- package/dist/domains/search/search-route.d.ts +2 -0
- package/dist/domains/search/search-route.js +101 -0
- package/dist/domains/search/search-schema.d.ts +384 -0
- package/dist/domains/search/search-schema.js +99 -0
- package/dist/domains/search/search-so.d.ts +55 -0
- package/dist/{search/search-service.js → domains/search/search-so.js} +200 -297
- package/dist/shared/config/environment.d.ts +16 -0
- package/dist/shared/config/environment.js +41 -0
- package/dist/shared/schemas/common-schema.d.ts +249 -0
- package/dist/{schema.js → shared/schemas/common-schema.js} +37 -80
- package/dist/shared/schemas/index.d.ts +1 -0
- package/dist/shared/schemas/index.js +1 -0
- package/dist/shared/scripts-helpers/index.d.ts +60 -0
- package/dist/shared/scripts-helpers/index.js +61 -0
- package/dist/shared/utils/file-util.d.ts +1 -0
- package/dist/shared/utils/file-util.js +5 -0
- package/dist/shared/utils/index.d.ts +5 -0
- package/dist/shared/utils/index.js +5 -0
- package/dist/shared/utils/mcp-client-util.d.ts +31 -0
- package/dist/shared/utils/mcp-client-util.js +79 -0
- package/dist/shared/utils/package-util.d.ts +6 -0
- package/dist/shared/utils/package-util.js +53 -0
- package/dist/shared/utils/promise-util.d.ts +1 -0
- package/dist/shared/utils/promise-util.js +14 -0
- package/dist/{utils.d.ts → shared/utils/response-util.d.ts} +6 -2
- package/dist/{utils.js → shared/utils/response-util.js} +1 -6
- package/dist/shared/utils/string-util.d.ts +1 -0
- package/dist/shared/utils/string-util.js +25 -0
- package/dist/shared/utils/validation-util.d.ts +12 -0
- package/dist/shared/utils/validation-util.js +99 -0
- package/indexes/categories-list.json +1 -0
- package/indexes/packages-list.json +6 -0
- package/package.json +8 -2
- package/packages/developer-tools/neurolink.json +23 -0
- package/README.dev.md +0 -195
- package/dist/api/package-handler.d.ts +0 -18
- package/dist/api/package-handler.js +0 -73
- package/dist/api/package-route.d.ts +0 -2
- package/dist/api/package-so.d.ts +0 -19
- package/dist/api/package-so.js +0 -223
- package/dist/api/package.test.js +0 -19
- package/dist/helper.d.ts +0 -74
- package/dist/helper.js +0 -312
- package/dist/sandbox/mcp-sandbox-client.d.ts +0 -16
- package/dist/sandbox/mcp-sandbox-client.js +0 -229
- package/dist/sandbox/mcp-sandbox-client.test.js +0 -491
- package/dist/schema.d.ts +0 -806
- package/dist/search/search-route.d.ts +0 -3
- package/dist/search/search-route.js +0 -305
- package/dist/search/search-service.d.ts +0 -120
- package/dist/search/search.test.js +0 -100
- package/dist/types.d.ts +0 -28
- /package/dist/{api/package.test.d.ts → domains/config/config-types.js} +0 -0
- /package/dist/{sandbox/mcp-sandbox-client.test.d.ts → domains/executor/executor-types.js} +0 -0
- /package/dist/{search/search.test.d.ts → domains/package/package-so.test.d.ts} +0 -0
- /package/dist/{types.js → domains/package/package-types.js} +0 -0
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { Daytona, Image } from "@daytonaio/sdk";
|
|
2
|
-
import { extractLastOuterJSON, getPackageConfigByKey } from "../helper";
|
|
3
|
-
export class MCPSandboxClient {
|
|
4
|
-
constructor(runtime = "node", provider = "DAYTONA") {
|
|
5
|
-
this.sandbox = null;
|
|
6
|
-
this.initializing = null;
|
|
7
|
-
this.runtime = "node";
|
|
8
|
-
this.apiKey = process.env.DAYTONA_API_KEY || "daytona-api-key-placeholder";
|
|
9
|
-
this.runtime = runtime;
|
|
10
|
-
this.provider = provider;
|
|
11
|
-
}
|
|
12
|
-
// Safe initialize: ensures concurrent calls don't create duplicate sandboxes
|
|
13
|
-
async initialize() {
|
|
14
|
-
if (this.sandbox) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (this.initializing) {
|
|
18
|
-
// Wait for existing initialization to complete
|
|
19
|
-
await this.initializing;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this.initializing = (async () => {
|
|
23
|
-
try {
|
|
24
|
-
const daytonaConfig = {
|
|
25
|
-
apiKey: this.apiKey,
|
|
26
|
-
};
|
|
27
|
-
if (this.provider === "SANDOCK") {
|
|
28
|
-
daytonaConfig.apiUrl = process.env.SANDOCK_DAYTONA_API_URL || process.env.DAYTONA_API_URL;
|
|
29
|
-
if (!daytonaConfig.apiUrl) {
|
|
30
|
-
console.warn("[MCPSandboxClient] SANDOCK provider selected but SANDOCK_DAYTONA_API_URL is not set. Falling back to default Daytona API URL.");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const daytona = new Daytona(daytonaConfig);
|
|
34
|
-
// Create image with required dependencies
|
|
35
|
-
const declarativeImage = Image.base("node:20")
|
|
36
|
-
.runCommands("npm install -g pnpm", "mkdir -p /workspace", "cd /workspace && npm init -y", "cd /workspace && pnpm add @modelcontextprotocol/sdk")
|
|
37
|
-
.workdir("/workspace");
|
|
38
|
-
// const pnpmStoreVolume = await daytona.volume.get("pnpm-store-shared", true);
|
|
39
|
-
this.sandbox = await daytona.create({
|
|
40
|
-
language: "javascript",
|
|
41
|
-
image: declarativeImage,
|
|
42
|
-
// volumes: [
|
|
43
|
-
// {
|
|
44
|
-
// volumeId: pnpmStoreVolume.id,
|
|
45
|
-
// mountPath: "/pnpm-store",
|
|
46
|
-
// },
|
|
47
|
-
// ],
|
|
48
|
-
});
|
|
49
|
-
console.log("[MCPSandboxClient] Daytona Sandbox created successfully");
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
this.initializing = null;
|
|
53
|
-
}
|
|
54
|
-
})();
|
|
55
|
-
await this.initializing;
|
|
56
|
-
}
|
|
57
|
-
// Force close and cleanup
|
|
58
|
-
async kill() {
|
|
59
|
-
try {
|
|
60
|
-
if (this.sandbox) {
|
|
61
|
-
await this.sandbox.delete();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
console.log(err.message);
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
this.sandbox = null;
|
|
69
|
-
// clear cache
|
|
70
|
-
// this.toolCache.clear();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
async listTools(packageKey) {
|
|
74
|
-
if (!this.sandbox) {
|
|
75
|
-
throw new Error("Sandbox not initialized. Call initialize() first.");
|
|
76
|
-
}
|
|
77
|
-
const mcpServerConfig = await getPackageConfigByKey(packageKey);
|
|
78
|
-
const testCode = this.generateMCPTestCode(mcpServerConfig, "listTools");
|
|
79
|
-
try {
|
|
80
|
-
const response = await this.sandbox.process.codeRun(testCode);
|
|
81
|
-
if (response.exitCode !== 0) {
|
|
82
|
-
throw new Error(`Failed to list tools: ${response.result}`);
|
|
83
|
-
}
|
|
84
|
-
const parsedResultStr = extractLastOuterJSON(response.result);
|
|
85
|
-
const result = JSON.parse(parsedResultStr);
|
|
86
|
-
return result.tools;
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
console.error("[MCPSandboxClient] Error listing tools:", err);
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
async executeTool(packageKey, toolName, argumentsObj, envs) {
|
|
94
|
-
if (!this.sandbox) {
|
|
95
|
-
throw new Error("Sandbox not initialized. Call initialize() first.");
|
|
96
|
-
}
|
|
97
|
-
const mcpServerConfig = await getPackageConfigByKey(packageKey);
|
|
98
|
-
const testCode = this.generateMCPTestCode(mcpServerConfig, "executeTool", toolName, argumentsObj, envs);
|
|
99
|
-
try {
|
|
100
|
-
const response = await this.sandbox.process.codeRun(testCode);
|
|
101
|
-
if (response.exitCode !== 0) {
|
|
102
|
-
throw new Error(`Failed to execute tool: ${response.result}`);
|
|
103
|
-
}
|
|
104
|
-
const parsedResultStr = extractLastOuterJSON(response.result);
|
|
105
|
-
const result = JSON.parse(parsedResultStr);
|
|
106
|
-
if (result.isError) {
|
|
107
|
-
console.error("[MCPSandboxClient] Tool execution error:", result.errorMessage);
|
|
108
|
-
throw new Error(result.errorMessage);
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
console.error("[MCPSandboxClient] Error executing tool:", err);
|
|
114
|
-
throw err;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
generateMCPTestCode(mcpServerConfig, operation, toolName, argumentsObj, envs) {
|
|
118
|
-
const commonCode = `
|
|
119
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
120
|
-
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
121
|
-
|
|
122
|
-
async function runMCP() {
|
|
123
|
-
let client;
|
|
124
|
-
try {
|
|
125
|
-
const packageName = "${mcpServerConfig.packageName}";
|
|
126
|
-
|
|
127
|
-
const transport = new StdioClientTransport({
|
|
128
|
-
command: "pnpx",
|
|
129
|
-
args: ["--silent", packageName],
|
|
130
|
-
env: {
|
|
131
|
-
...Object.fromEntries(
|
|
132
|
-
Object.entries(process.env).filter(([_, v]) => v !== undefined)
|
|
133
|
-
),
|
|
134
|
-
PNPM_HOME: "/root/.local/share/pnpm",
|
|
135
|
-
PNPM_STORE_PATH: "/pnpm-store",
|
|
136
|
-
${this.generateEnvVariables(mcpServerConfig.env, envs)}
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
client = new Client(
|
|
141
|
-
{
|
|
142
|
-
name: "mcp-server-${mcpServerConfig.packageName}-client",
|
|
143
|
-
version: "1.0.0",
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
capabilities: {
|
|
147
|
-
tools: {},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
await client.connect(transport);
|
|
153
|
-
`;
|
|
154
|
-
if (operation === "listTools") {
|
|
155
|
-
const toolsCode = `${commonCode}
|
|
156
|
-
const toolsObj = await client.listTools();
|
|
157
|
-
|
|
158
|
-
const result = {
|
|
159
|
-
toolCount: toolsObj.tools.length,
|
|
160
|
-
tools: toolsObj.tools
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
process.stdout.write(JSON.stringify(result));
|
|
164
|
-
} catch (error) {
|
|
165
|
-
console.error("Error in MCP test:", error);
|
|
166
|
-
process.exitCode = 1;
|
|
167
|
-
process.stdout.write(JSON.stringify({ error: error.message || "Unknown error occurred" }));
|
|
168
|
-
} finally {
|
|
169
|
-
if (client) {
|
|
170
|
-
try {
|
|
171
|
-
await client.close();
|
|
172
|
-
} catch (closeError) {
|
|
173
|
-
console.error("Error closing MCP client:", closeError);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
runMCP();
|
|
180
|
-
`;
|
|
181
|
-
return toolsCode;
|
|
182
|
-
// } else if (operation === "executeTool" && toolName) {
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
const toolExecuteCode = `${commonCode}
|
|
186
|
-
|
|
187
|
-
const result = await client.callTool({
|
|
188
|
-
name: "${toolName}",
|
|
189
|
-
arguments: ${JSON.stringify(argumentsObj)}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
process.stdout.write(JSON.stringify(result));
|
|
193
|
-
} catch (error) {
|
|
194
|
-
console.error("Error in MCP test:", error);
|
|
195
|
-
process.exitCode = 1;
|
|
196
|
-
process.stdout.write(JSON.stringify({
|
|
197
|
-
result: null,
|
|
198
|
-
isError: true,
|
|
199
|
-
errorMessage: error.message
|
|
200
|
-
}));
|
|
201
|
-
} finally {
|
|
202
|
-
if (client) {
|
|
203
|
-
try {
|
|
204
|
-
await client.close();
|
|
205
|
-
} catch (closeError) {
|
|
206
|
-
console.error("Error closing MCP client:", closeError);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
runMCP();
|
|
213
|
-
`;
|
|
214
|
-
return toolExecuteCode;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
generateEnvVariables(env, realEnvs) {
|
|
218
|
-
if (!env) {
|
|
219
|
-
return "";
|
|
220
|
-
}
|
|
221
|
-
const envEntries = Object.entries(env).map(([key, _]) => {
|
|
222
|
-
if (realEnvs === null || realEnvs === void 0 ? void 0 : realEnvs[key]) {
|
|
223
|
-
return `${JSON.stringify(key)}: ${JSON.stringify(realEnvs[key])}`;
|
|
224
|
-
}
|
|
225
|
-
return `${JSON.stringify(key)}: "mock_value"`;
|
|
226
|
-
});
|
|
227
|
-
return envEntries.join(",\n ");
|
|
228
|
-
}
|
|
229
|
-
}
|