Fix MCP regex to handle SSE connection failures

Update regex patterns to recognize SSE servers (case-insensitive) with failed connection status (✗).
Previously only matched successful (✓) or warning (⚠) states, causing failed SSE connections to be ignored.
This commit is contained in:
Amrit Subramanian 2025-10-09 12:15:03 -04:00
parent d6f853a497
commit b0ab86ba9a

View file

@ -144,8 +144,8 @@ function spawnMcpPoller(sessionId: string, projectDir: string) {
// Parse output whenever we have MCP server entries
// Match lines like: "servername: url (type) - ✓ Connected" or "servername: command (stdio) - ✓ Connected"
// Pattern handles SSE, stdio, and HTTP types
const mcpServerLineRegex = /^[\w-]+:.+\((?:SSE|stdio|HTTP)\)\s+-\s+[✓⚠]/m;
// Pattern handles SSE, stdio, and HTTP types (case-insensitive) with success (✓), warning (⚠), or failure (✗) status
const mcpServerLineRegex = /^[\w-]+:.+\((?:SSE|sse|stdio|HTTP)\)\s+-\s+[✓⚠]/mi;
if (mcpServerLineRegex.test(data) || data.includes("No MCP servers configured")) {
try {
@ -217,7 +217,7 @@ function parseMcpOutput(output: string): any[] {
// Only parse lines that match the MCP server format
// Must have: "name: something (SSE|stdio|HTTP) - status"
const serverMatch = line.match(/^([\w-]+):.+\((?:SSE|stdio|HTTP)\)\s+-\s+[✓⚠]/);
const serverMatch = line.match(/^([\w-]+):.+\((?:SSE|sse|stdio|HTTP)\)\s+-\s+[✓⚠]/i);
if (serverMatch) {
const serverName = serverMatch[1];
const isConnected = line.includes("✓") || line.includes("Connected");