moeru-ai/airi · error · Error

mcp server is not running: ${serverName}

Error message

mcp server is not running: ${serverName}

What it means

Thrown by the MCP (Model Context Protocol) server manager's callTool when parseQualifiedToolName extracts a serverName that has no entry in the live sessions map. The sessions map is populated when an MCP server is started and removed when it stops or crashes, so the error means the referenced server is not currently connected.

Source

Thrown at apps/stage-tamagotchi/src/main/services/airi/mcp-servers/index.ts:281

          toolName: item.name,
          description: item.description,
          inputSchema: item.inputSchema,
        }))
      }
      catch (error) {
        log.withFields({ serverName }).withError(error).warn('failed to list tools from mcp server')
        return []
      }
    }))

    return listResult.flat()
  }

  const callTool = async (payload: ElectronMcpCallToolPayload): Promise<ElectronMcpCallToolResult> => {
    const { serverName, toolName } = parseQualifiedToolName(payload.name)
    const session = sessions.get(serverName)
    if (!session) {
      throw new Error(`mcp server is not running: ${serverName}`)
    }

    let result
    try {
      result = await session.client.callTool({
        name: toolName,
        arguments: payload.arguments ?? {},
      }, undefined, {
        timeout: mcpRequestTimeoutMsec,
        maxTotalTimeout: mcpRequestMaxTotalTimeoutMsec,
      })
    }
    catch (error) {
      const fallbackToolName = resolveFallbackToolName(toolName)
      if (!fallbackToolName || fallbackToolName === toolName) {
        throw error
      }

View on GitHub (pinned to 27111382b4)

Solutions

  1. Check whether the server is in the running state by inspecting the MCP servers status list before issuing the call.
  2. Restart or re-enable the MCP server named in the error, then retry the tool call.
  3. Verify the payload.name uses the correct qualified format 'serverName<separator>toolName' matching the configured toolNameSeparator.
  4. If the server crashes repeatedly, inspect lastError in the server status to find the root cause of the process exit.

Example fix

// before
const result = await callTool({ name: 'myServer.search', arguments: { q } })

// after
const status = await listServers()
if (!status.some(s => s.name === 'myServer' && s.status === 'running')) {
  await startServer('myServer')
}
const result = await callTool({ name: 'myServer.search', arguments: { q } })
Defensive patterns

Strategy: validation

Validate before calling

// Check the server is running before calling a tool
const servers = await listMcpServers()
const running = servers.some(s => s.name === serverName && s.status === 'running')
if (!running) {
  await startMcpServer(serverName)
}

Type guard

function isRunningServer(s: { status?: string }): boolean {
  return s.status === 'running'
}

Try / catch

try {
  return await callTool(payload)
} catch (e) {
  if (/mcp server is not running/.test(errorMessageFrom(e) ?? '')) {
    await startMcpServer(serverName)
    return await callTool(payload)
  }
  throw e
}

Prevention

When it happens

Trigger: Calling ElectronMcpCallToolPayload with a qualified tool name like 'myServer.someTool' when 'myServer' was never started, was started and then stopped, or crashed silently. Also triggered if the serverName is misspelled or uses the wrong separator (parseQualifiedToolName splits on toolNameSeparator).

Common situations: The MCP server process exited or was restarted between tool listing and tool call; the user disabled a server in config but the renderer still holds a cached tool list; a server failed health checks and was evicted from the sessions map; the separator in the qualified name doesn't match toolNameSeparator.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/cae2d44bb2e62a03. Report an issue: GitHub.