@botuyo/mcp 0.2.13 → 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,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,IAAI,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,MAAM,CAAC,MAAM,sBAAsB,GAAS;IAC1C,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE;;;;;;;;;;;;;;;;;2CAiB4B;IACzC,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2GAA2G,EAAE;YACrJ,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8GAA8G,EAAE;YACzJ,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qGAA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