@botuyo/mcp 0.2.12 → 0.2.13
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.
|
@@ -1,21 +1,59 @@
|
|
|
1
|
+
import { writeFileSync, mkdirSync } from 'fs';
|
|
2
|
+
import { join, resolve } from 'path';
|
|
1
3
|
export const EXPORT_AGENT_JSON_TOOL = {
|
|
2
4
|
name: 'export_agent_json',
|
|
3
5
|
description: `Export the full agent configuration as clean, editable JSON.
|
|
4
6
|
|
|
5
7
|
Returns the complete agentConfig including identity, stages, connections (graph edges),
|
|
6
|
-
channelFlows, enabledTools, channels, and all other settings.
|
|
8
|
+
channelFlows, enabledTools, channels, widgetConfig, voice, and all other settings.
|
|
9
|
+
Also includes apiKey (read-only) for external integrations.
|
|
10
|
+
|
|
11
|
+
The exported JSON is automatically saved to a local file for easy editing:
|
|
12
|
+
- Default: saves to ./agents/{agent-name}.json in the current working directory
|
|
13
|
+
- Custom: use savePath to specify a different directory
|
|
7
14
|
|
|
8
15
|
Use import_agent_json to re-import after editing.`,
|
|
9
16
|
inputSchema: {
|
|
10
17
|
type: 'object',
|
|
11
18
|
properties: {
|
|
12
|
-
agentId: { type: 'string', description: 'The MongoDB ID of the agent to export' }
|
|
19
|
+
agentId: { type: 'string', description: 'The MongoDB ID of the agent to export' },
|
|
20
|
+
savePath: { type: 'string', description: 'Optional. Directory path where the JSON file will be saved. Default: ./agents/' }
|
|
13
21
|
},
|
|
14
22
|
required: ['agentId']
|
|
15
23
|
}
|
|
16
24
|
};
|
|
17
25
|
export async function exportAgentJsonHandler(client, args) {
|
|
18
26
|
const agentId = args.agentId;
|
|
19
|
-
|
|
27
|
+
const savePath = args.savePath || './agents';
|
|
28
|
+
const result = await client.get(`/api/v1/mcp/agents/${agentId}/export`);
|
|
29
|
+
// Auto-save to local file
|
|
30
|
+
if (result?.success && result?.data?.agentConfig) {
|
|
31
|
+
try {
|
|
32
|
+
const agentName = result.data.agentConfig.name || agentId;
|
|
33
|
+
// Sanitize filename: replace special chars, lowercase
|
|
34
|
+
const sanitizedName = agentName
|
|
35
|
+
.replace(/[^\w\s-]/g, '')
|
|
36
|
+
.replace(/\s+/g, '_')
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.substring(0, 50);
|
|
39
|
+
const fileName = `${sanitizedName}.json`;
|
|
40
|
+
const dir = resolve(savePath);
|
|
41
|
+
mkdirSync(dir, { recursive: true });
|
|
42
|
+
const filePath = join(dir, fileName);
|
|
43
|
+
const exportPayload = {
|
|
44
|
+
_exportedAt: new Date().toISOString(),
|
|
45
|
+
_agentId: result.data.agentId,
|
|
46
|
+
_apiKey: result.data.apiKey,
|
|
47
|
+
...result.data.agentConfig
|
|
48
|
+
};
|
|
49
|
+
writeFileSync(filePath, JSON.stringify(exportPayload, null, 2), 'utf-8');
|
|
50
|
+
result.savedTo = filePath;
|
|
51
|
+
result.message = `${result.message || ''} File saved to: ${filePath}`;
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
result.fileSaveError = `Could not save file: ${err.message}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
20
58
|
}
|
|
21
59
|
//# sourceMappingURL=export_agent_json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export_agent_json.js","sourceRoot":"","sources":["../../src/tools/export_agent_json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"export_agent_json.js","sourceRoot":"","sources":["../../src/tools/export_agent_json.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEpC,MAAM,CAAC,MAAM,sBAAsB,GAAS;IAC1C,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE;;;;;;;;;;kDAUmC;IAChD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,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