@botuyo/mcp 0.2.12 → 0.2.14
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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AAM,CAAC,IAAI,CAAC,OAAO;gBAC7B,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM;gBAC3B,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW;aAC3B,CAAA;YAED,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;YAExE,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAA;YACzB,MAAM,CAAC,OAAO,GAAG,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,mBAAmB,QAAQ,EAAE,CAAA;QACvE,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,aAAa,GAAG,wBAAwB,GAAG,CAAC,OAAO,EAAE,CAAA;QAC9D,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { resolve } from 'path';
|
|
1
3
|
export const IMPORT_AGENT_JSON_TOOL = {
|
|
2
4
|
name: 'import_agent_json',
|
|
3
|
-
description: `Import/replace an agent's full configuration from a JSON object.
|
|
5
|
+
description: `Import/replace an agent's full configuration from a local JSON file or from a JSON object.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
**Preferred workflow:**
|
|
8
|
+
1. Use export_agent_json to save the agent config to a local file (auto-saved to ./agents/)
|
|
9
|
+
2. Edit the local file as needed
|
|
10
|
+
3. Use this tool with filePath pointing to that file to apply the changes
|
|
7
11
|
|
|
12
|
+
You can provide the config either via:
|
|
13
|
+
- filePath: path to a local JSON file (preferred — reads the file from disk)
|
|
14
|
+
- agentConfig: inline JSON object (fallback if no file)
|
|
15
|
+
|
|
16
|
+
If both are provided, filePath takes priority.
|
|
17
|
+
|
|
18
|
+
The file can contain the metadata fields from export (_exportedAt, _agentId, _apiKey) — they are stripped automatically.
|
|
8
19
|
The agentConfig must include at least 'name' and 'identity'.
|
|
9
|
-
All fields (stages, connections, channelFlows, enabledTools, widgetConfig, etc.) will be overwritten.
|
|
10
20
|
Internal fields (model, temperature, summaryThreshold, voice.liveModel) are preserved from existing config.
|
|
11
21
|
|
|
12
22
|
Requires role: owner, admin, or developer.`,
|
|
13
23
|
inputSchema: {
|
|
14
24
|
type: 'object',
|
|
15
25
|
properties: {
|
|
16
|
-
agentId: { type: 'string', description: 'The MongoDB ID of the agent to update' },
|
|
26
|
+
agentId: { type: 'string', description: 'The MongoDB ID of the agent to update. If not provided and filePath contains _agentId, that will be used.' },
|
|
27
|
+
filePath: { type: 'string', description: 'Path to a local JSON file with the agent config (e.g. ./agents/mar.json). Preferred over inline agentConfig.' },
|
|
17
28
|
agentConfig: {
|
|
18
29
|
type: 'object',
|
|
19
|
-
description: 'The full agentConfig object
|
|
30
|
+
description: 'The full agentConfig object (fallback if filePath is not provided). Must include name and identity.',
|
|
20
31
|
properties: {
|
|
21
32
|
name: { type: 'string', description: 'Agent display name' },
|
|
22
33
|
identity: {
|
|
@@ -61,11 +72,58 @@ Requires role: owner, admin, or developer.`,
|
|
|
61
72
|
required: ['name', 'identity']
|
|
62
73
|
}
|
|
63
74
|
},
|
|
64
|
-
required: ['agentId'
|
|
75
|
+
required: ['agentId']
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
78
|
export async function importAgentJsonHandler(client, args) {
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
let agentId = args.agentId;
|
|
80
|
+
let agentConfig = args.agentConfig;
|
|
81
|
+
// If filePath is provided, read the JSON from local filesystem
|
|
82
|
+
const filePath = args.filePath;
|
|
83
|
+
if (filePath) {
|
|
84
|
+
const resolvedPath = resolve(filePath);
|
|
85
|
+
if (!existsSync(resolvedPath)) {
|
|
86
|
+
return {
|
|
87
|
+
success: false,
|
|
88
|
+
error: `File not found: ${resolvedPath}`,
|
|
89
|
+
hint: 'Use export_agent_json first to create a local file, or check the path.'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const raw = readFileSync(resolvedPath, 'utf-8');
|
|
94
|
+
const parsed = JSON.parse(raw);
|
|
95
|
+
// Strip export metadata fields — they're informational only
|
|
96
|
+
const { _exportedAt, _agentId, _apiKey, ...config } = parsed;
|
|
97
|
+
// Use _agentId from file if not explicitly provided
|
|
98
|
+
if (!agentId && _agentId) {
|
|
99
|
+
agentId = _agentId;
|
|
100
|
+
}
|
|
101
|
+
agentConfig = config;
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
error: `Failed to read/parse file: ${err.message}`,
|
|
107
|
+
path: resolvedPath
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!agentId) {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
error: 'agentId is required. Provide it explicitly or use a file exported with export_agent_json (contains _agentId).'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (!agentConfig) {
|
|
118
|
+
return {
|
|
119
|
+
success: false,
|
|
120
|
+
error: 'No agent config provided. Use filePath to point to a local JSON file, or provide agentConfig inline.'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const result = await client.put(`/api/v1/mcp/agents/${agentId}/import`, { agentConfig });
|
|
124
|
+
return {
|
|
125
|
+
...result,
|
|
126
|
+
importedFrom: filePath ? resolve(filePath) : 'inline',
|
|
127
|
+
};
|
|
70
128
|
}
|
|
71
129
|
//# sourceMappingURL=import_agent_json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import_agent_json.js","sourceRoot":"","sources":["../../src/tools/import_agent_json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import_agent_json.js","sourceRoot":"","sources":["../../src/tools/import_agent_json.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAA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