agent2agent-cli 0.3.4 → 0.3.6
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/a2a-mcp.js +16 -6
- package/package.json +1 -1
package/a2a-mcp.js
CHANGED
|
@@ -24,7 +24,7 @@ const fs = require('fs');
|
|
|
24
24
|
const path = require('path');
|
|
25
25
|
const readline = require('readline');
|
|
26
26
|
|
|
27
|
-
const VERSION = '0.3.
|
|
27
|
+
const VERSION = '0.3.6';
|
|
28
28
|
const PROTOCOL_VERSION = '2024-11-05'; // MCP 当前稳定协议版本
|
|
29
29
|
|
|
30
30
|
/* ------------------------------------------------------------------ *
|
|
@@ -360,18 +360,26 @@ async function apiText(config, pathName) {
|
|
|
360
360
|
// 兼容的 MCP 协议版本(Cursor 可能请求较新版本,回显客户端请求值)
|
|
361
361
|
const KNOWN_PROTOCOLS = ['2024-11-05', '2025-03-26', '2025-06-18'];
|
|
362
362
|
|
|
363
|
+
/* 崩溃兜底:任何未捕获异常/拒绝都打印真实堆栈到 stderr(Cursor 会显示出来),便于定位 */
|
|
364
|
+
process.on('uncaughtException', (err) => {
|
|
365
|
+
console.error('[a2a-mcp] uncaughtException:', err && err.stack ? err.stack : err);
|
|
366
|
+
process.exit(1);
|
|
367
|
+
});
|
|
368
|
+
process.on('unhandledRejection', (err) => {
|
|
369
|
+
console.error('[a2a-mcp] unhandledRejection:', err && err.stack ? err.stack : err);
|
|
370
|
+
process.exit(1);
|
|
371
|
+
});
|
|
372
|
+
|
|
363
373
|
function main() {
|
|
364
374
|
// 找不到配置不再退出:server 照常启动(tools 可用),调用工具时才给出明确指引
|
|
365
375
|
const config = resolveConfig();
|
|
366
376
|
const cfgMissing = !config.url;
|
|
377
|
+
// 握手完成前不打 stderr(避免客户端将 stderr 视为错误干扰握手);仅配置缺失时提示
|
|
367
378
|
if (cfgMissing) {
|
|
368
|
-
console.error(`[a2a-mcp v${VERSION}]
|
|
369
|
-
console.error('[a2a-mcp] 未找到平台配置(.a2a.json):请在含 .a2a.json 的项目目录使用;');
|
|
370
|
-
console.error('[a2a-mcp] 或设置 A2A_URL / A2A_TOKEN / A2A_ACCOUNT 环境变量;首次接入:a2a init');
|
|
371
|
-
} else {
|
|
372
|
-
console.error(`[a2a-mcp v${VERSION}] 已加载配置: ${config.url}(账号: ${config.accountId || '?'})`);
|
|
379
|
+
console.error(`[a2a-mcp v${VERSION}] 未找到平台配置(cwd=${process.cwd()})。请在含 .a2a.json 的项目目录使用,或设置 A2A_URL/A2A_TOKEN/A2A_ACCOUNT。首次接入:a2a init`);
|
|
373
380
|
}
|
|
374
381
|
|
|
382
|
+
let warnedCfg = false;
|
|
375
383
|
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
376
384
|
let serverReady = false;
|
|
377
385
|
|
|
@@ -420,6 +428,8 @@ function main() {
|
|
|
420
428
|
finish({});
|
|
421
429
|
break;
|
|
422
430
|
case 'tools/list':
|
|
431
|
+
// 握手已完成,此时 stderr 不再影响握手——打印配置状态便于排查
|
|
432
|
+
if (!cfgMissing && !warnedCfg) { warnedCfg = true; console.error(`[a2a-mcp v${VERSION}] 已加载配置: ${config.url}(账号: ${config.accountId || '?'})`); }
|
|
423
433
|
finish({ tools: TOOLS });
|
|
424
434
|
break;
|
|
425
435
|
case 'tools/call': {
|