natureco-cli 2.11.0 → 2.11.2
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/package.json
CHANGED
|
@@ -211,7 +211,7 @@ body::before{
|
|
|
211
211
|
<div class="header-bot-name" id="header-bot-name">Nature Bot</div>
|
|
212
212
|
<div class="header-bot-model" id="header-bot-model">NatureCo</div>
|
|
213
213
|
</div>
|
|
214
|
-
<div class="version-badge" id="version-badge">v2.11.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.11.2</div>
|
|
215
215
|
</div>
|
|
216
216
|
<div class="messages" id="messages"></div>
|
|
217
217
|
<div class="input-area">
|
|
@@ -341,7 +341,7 @@ function dashboard(action) {
|
|
|
341
341
|
apiKey: cfg.apiKey,
|
|
342
342
|
defaultBot: cfg.defaultBot,
|
|
343
343
|
defaultBotId: cfg.defaultBotId,
|
|
344
|
-
version: 'v2.11.
|
|
344
|
+
version: 'v2.11.2',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
|
@@ -138,7 +138,7 @@ async function startGateway() {
|
|
|
138
138
|
|
|
139
139
|
async function runGatewayWorker() {
|
|
140
140
|
// This runs in the background
|
|
141
|
-
log('gateway', 'Starting NatureCo Gateway v2.11.
|
|
141
|
+
log('gateway', 'Starting NatureCo Gateway v2.11.2...', 'green');
|
|
142
142
|
|
|
143
143
|
// Load config
|
|
144
144
|
const { getConfig } = require('../utils/config');
|
package/src/utils/api.js
CHANGED
|
@@ -136,6 +136,41 @@ function getMcpTools() {
|
|
|
136
136
|
return allTools;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Coerce MCP tool parameters to match schema types
|
|
141
|
+
*/
|
|
142
|
+
function coerceMcpParams(tool, params) {
|
|
143
|
+
const schema = tool.inputSchema?.properties || tool.input_schema?.properties || {};
|
|
144
|
+
const coerced = { ...params };
|
|
145
|
+
|
|
146
|
+
for (const [key, def] of Object.entries(schema)) {
|
|
147
|
+
if (coerced[key] === undefined || coerced[key] === null) continue;
|
|
148
|
+
|
|
149
|
+
// Coerce number
|
|
150
|
+
if (def.type === 'number' && typeof coerced[key] === 'string') {
|
|
151
|
+
const num = Number(coerced[key]);
|
|
152
|
+
if (!isNaN(num)) {
|
|
153
|
+
coerced[key] = num;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Coerce boolean
|
|
158
|
+
if (def.type === 'boolean' && typeof coerced[key] === 'string') {
|
|
159
|
+
coerced[key] = coerced[key] === 'true' || coerced[key] === '1';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Coerce integer
|
|
163
|
+
if (def.type === 'integer' && typeof coerced[key] === 'string') {
|
|
164
|
+
const num = parseInt(coerced[key], 10);
|
|
165
|
+
if (!isNaN(num)) {
|
|
166
|
+
coerced[key] = num;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return coerced;
|
|
172
|
+
}
|
|
173
|
+
|
|
139
174
|
/**
|
|
140
175
|
* Execute MCP tool call
|
|
141
176
|
*/
|
|
@@ -150,7 +185,11 @@ async function executeMcpTool(toolName, toolArgs) {
|
|
|
150
185
|
debugLog(`[MCP] Calling tool ${toolName} on server ${serverName}`);
|
|
151
186
|
|
|
152
187
|
try {
|
|
153
|
-
|
|
188
|
+
// Coerce parameters to match schema types
|
|
189
|
+
const coercedArgs = coerceMcpParams(tool, toolArgs);
|
|
190
|
+
console.log('[DEBUG] MCP COERCED ARGS:', JSON.stringify(coercedArgs).slice(0, 100));
|
|
191
|
+
|
|
192
|
+
const result = await client.callTool(toolName, coercedArgs);
|
|
154
193
|
|
|
155
194
|
console.log('[DEBUG] MCP RAW RESULT:', JSON.stringify(result).slice(0, 200));
|
|
156
195
|
|
|
@@ -162,7 +201,14 @@ async function executeMcpTool(toolName, toolArgs) {
|
|
|
162
201
|
.map(c => c.text);
|
|
163
202
|
|
|
164
203
|
if (textContents.length > 0) {
|
|
165
|
-
|
|
204
|
+
let output = textContents.join('\n');
|
|
205
|
+
|
|
206
|
+
// Truncate MCP result to max 1500 characters
|
|
207
|
+
if (output.length > 1500) {
|
|
208
|
+
output = output.slice(0, 1500) + '... (truncated)';
|
|
209
|
+
console.log('[DEBUG] MCP OUTPUT TRUNCATED from', textContents.join('\n').length, 'to 1500 chars');
|
|
210
|
+
}
|
|
211
|
+
|
|
166
212
|
console.log('[DEBUG] MCP FORMATTED OUTPUT:', output.slice(0, 100));
|
|
167
213
|
return {
|
|
168
214
|
success: true,
|
|
@@ -172,7 +218,14 @@ async function executeMcpTool(toolName, toolArgs) {
|
|
|
172
218
|
}
|
|
173
219
|
|
|
174
220
|
// Fallback: return entire result as JSON
|
|
175
|
-
|
|
221
|
+
let fallbackOutput = JSON.stringify(result, null, 2);
|
|
222
|
+
|
|
223
|
+
// Truncate fallback output too
|
|
224
|
+
if (fallbackOutput.length > 1500) {
|
|
225
|
+
fallbackOutput = fallbackOutput.slice(0, 1500) + '... (truncated)';
|
|
226
|
+
console.log('[DEBUG] MCP FALLBACK OUTPUT TRUNCATED');
|
|
227
|
+
}
|
|
228
|
+
|
|
176
229
|
console.log('[DEBUG] MCP FALLBACK OUTPUT:', fallbackOutput.slice(0, 100));
|
|
177
230
|
return {
|
|
178
231
|
success: true,
|