Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(pi): refuse redirects in the Pi MCP bridge

João Matheusba9336299c4d
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rs
index d0da3391..0f61069e 100644
--- a/crates/ai-memory-cli/src/commands/install_hooks.rs
+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs
@@ -5794,8 +5794,11 @@ function mcpHeaders(ctx?: any): Record<string, string> {
async function mcpRpc(method: string, params?: unknown, ctx?: any, signal?: AbortSignal): Promise<any> {
const id = ++mcpRequestId;
+ // Like the hook client, the bridge never follows a redirect: a 307 or 308
+ // would replay the request body and session headers to the redirect target.
const response = await fetch(MCP_SERVER, {
proxy: false,
+ redirect: "error",
method: "POST",
headers: mcpHeaders(ctx),
body: JSON.stringify({ jsonrpc: "2.0", id, method, params: params ?? {} }),
@@ -5811,6 +5814,7 @@ async function mcpRpc(method: string, params?: unknown, ctx?: any, signal?: Abor
async function mcpNotify(method: string, params?: unknown, ctx?: any, signal?: AbortSignal): Promise<void> {
const response = await fetch(MCP_SERVER, {
proxy: false,
+ redirect: "error",
method: "POST",
headers: mcpHeaders(ctx),
body: JSON.stringify({ jsonrpc: "2.0", method, params: params ?? {} }),