Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(pi): force direct MCP fetch for loopback URLs

DavidShenea0c3375858a
diff --git a/packages/maker-core/src/agents/pi/cindy-bridge-source.ts b/packages/maker-core/src/agents/pi/cindy-bridge-source.ts
index 00f17acd00..4759306979 100644
--- a/packages/maker-core/src/agents/pi/cindy-bridge-source.ts
+++ b/packages/maker-core/src/agents/pi/cindy-bridge-source.ts
@@ -2648,6 +2648,7 @@ class McpHttpClient {
private nextId = 1;
private sessionId: string | null = null;
private readonly requestUrl: string;
+ private readonly directLoopback: boolean;
private readonly requestTimeoutMs: number;
private startupDeadlineAt: number | null;
@@ -2668,6 +2669,7 @@ class McpHttpClient {
throw new McpBridgeError('URL outside security boundary');
}
this.requestUrl = parsed.href;
+ this.directLoopback = isLoopbackMcpHostname(parsed.hostname);
const configuredTimeout = server.remote?.requestTimeoutMs;
this.requestTimeoutMs = Number.isInteger(configuredTimeout)
&& configuredTimeout! > 0
@@ -2736,6 +2738,9 @@ class McpHttpClient {
body: JSON.stringify(body),
redirect: 'error',
signal: controller.signal,
+ // Bun can proxy IPv6 loopback despite bare ::1 in NO_PROXY. Never send
+ // local MCP authentication headers to that proxy; remote HTTPS keeps it.
+ proxy: this.directLoopback ? false : undefined,
// Bun's idle timer must not preempt the explicit request deadline while
// a local MCP tool is waiting for a user's card interaction.
timeout: false,
diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.ts
index 7fbbc55f68..b2eb226755 100644
--- a/packages/maker-core/src/agents/pi/index.ts
+++ b/packages/maker-core/src/agents/pi/index.ts
@@ -543,7 +543,8 @@ function mergeLoopbackNoProxy(env: NodeJS.ProcessEnv): void {
.flatMap((s) => s.split(','))
.map((s) => s.trim())
.filter(Boolean);
- // NO_PROXY 使用裸 IPv6 地址;URL 形式的 [::1] 会使 Python httpx 初始化失败(#7632)。
+ // NO_PROXY 使用裸 IPv6 地址,避免 [::1] 使 Python httpx 初始化失败(#7632)。
+ // Bun 对裸 ::1 的匹配不一致;MCP bridge 对已校验的回环 URL 另外显式禁用代理。
env.NO_PROXY = Array.from(new Set([...existing, '127.0.0.1', 'localhost', '::1'])).join(',');
delete env.no_proxy;
}