proxy_stop
Stop the MITM proxy while retaining traffic history and CA certificate.
Instructions
Stop the MITM proxy. Traffic history and CA certificate are retained.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/lifecycle.ts:62-79 (handler)The 'proxy_stop' tool handler. Defined via server.tool() with an empty input schema. Calls proxyManager.stop() to stop the MITM proxy, returning a success message.
server.tool( "proxy_stop", "Stop the MITM proxy. Traffic history and CA certificate are retained.", {}, async () => { try { await proxyManager.stop(); return { content: [{ type: "text", text: JSON.stringify({ status: "success", message: "Proxy stopped. Traffic and cert retained." }), }], }; } catch (e) { return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: String(e) }) }] }; } }, ); - src/tools/lifecycle.ts:65-65 (schema)The input schema for 'proxy_stop' — an empty object (no parameters required).
{}, - src/tools/lifecycle.ts:10-62 (registration)Registration function registerLifecycleTools() is called from src/index.ts:62, which registers the 'proxy_stop' tool among other lifecycle tools (proxy_start, proxy_status, proxy_get_ca_cert).
export function registerLifecycleTools(server: McpServer): void { server.tool( "proxy_start", "Start the HTTPS MITM proxy. Auto-generates a CA certificate. Returns port, URL, cert fingerprint, and setup instructions for the target device.", { port: z.number().optional().describe("Port to listen on (0 = random available port)"), persistence_enabled: z.boolean().optional().default(false) .describe("Enable persistent on-disk session capture (default: false)"), session_name: z.string().optional().describe("Optional name for the session when persistence is enabled"), capture_profile: z.enum(["preview", "full"]).optional().default("preview") .describe("Capture profile for persisted sessions: preview (body previews) or full (full bodies)"), storage_dir: z.string().optional().describe("Custom session storage directory"), max_disk_mb: z.number().optional().default(1024) .describe("Per-session disk cap in MB (writes are dropped once exceeded)"), }, async ({ port, persistence_enabled, session_name, capture_profile, storage_dir, max_disk_mb }) => { try { const result = await proxyManager.start(port, { persistenceEnabled: persistence_enabled ?? false, sessionName: session_name, captureProfile: capture_profile, storageDir: storage_dir, maxDiskMb: max_disk_mb, }); const localIP = getLocalIP(); return { content: [{ type: "text", text: JSON.stringify({ status: "success", port: result.port, url: result.url, certFingerprint: result.cert.fingerprint, persistence: proxyManager.getSessionStatus(), setup: { proxyHost: localIP, proxyPort: result.port, instructions: [ `1. Set device Wi-Fi proxy to ${localIP}:${result.port}`, "2. Install the CA certificate on the device (use proxy_get_ca_cert)", `3. Or use env vars: HTTP_PROXY=http://${localIP}:${result.port} HTTPS_PROXY=http://${localIP}:${result.port}`, ], }, }), }], }; } catch (e) { return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: String(e) }) }] }; } }, ); server.tool( - src/state.ts:415-439 (helper)The ProxyManager.stop() method that proxy_stop invokes. Stops the transparent proxy if running, deactivates interceptors, cleans up temp certs, stops the mockttp server, clears pending requests and TLS caches, and shuts down the TLS spoof container if active.
async stop(): Promise<void> { if (!this._running) { throw new Error("Proxy is not running."); } // Stop transparent proxy first if running if (this._transparentRunning) { await this.stopTransparent().catch(() => {}); } // Deactivate all interceptors before stopping the proxy await interceptorManager.deactivateAll().catch(() => {}); await cleanupTempCerts().catch(() => {}); if (this.server) { await this.server.stop(); this.server = null; } await this.sessionStore.stopSession().catch(() => {}); this._running = false; this.pendingRequests.clear(); this.pendingRawBodies.clear(); this.tlsMetadataCache.clear(); this.disableServerTls(); if (this._ja3SpoofConfig) { await shutdownSpoofContainer(); } }