CherryHQ/cherry-studio · error · Error

Failed to get resource ${uri} from server: ${server.name}: $

Error message

Failed to get resource ${uri} from server: ${server.name}: ${error.message}

What it means

Thrown when reading a resource from an MCP server fails. The `getResourceImpl` method calls `client.readResource()` and catches any error, wrapping it with the URI and server name for context. The error is also logged via getServerLogger before being thrown.

Source

Thrown at src/main/ai/mcp/McpRuntimeService.ts:1467

    const client = await this.getOrCreateClient(server)
    try {
      const result = await client.readResource({ uri: uri })
      const contents: McpResource[] = []
      if (result.contents && result.contents.length > 0) {
        result.contents.forEach((content: any) => {
          contents.push({
            ...content,
            serverId: server.id,
            serverName: server.name
          })
        })
      }
      return {
        contents: contents
      }
    } catch (error: any) {
      getServerLogger(server, { uri }).error(`Failed to get resource`, error as Error)
      throw new Error(`Failed to get resource ${uri} from server: ${server.name}: ${error.message}`)
    }
  }

  /**
   * Get a specific resource from an MCP server with caching
   */
  @TraceMethod({ spanName: 'getResource', tag: 'mcp' })
  public async getResource({ serverId, uri }: { serverId: string; uri: string }): Promise<GetResourceResponse> {
    const server = this.getServerById(serverId)
    const cachedGetResource = withCache<[McpServer, string], GetResourceResponse>(
      this.getResourceImpl.bind(this),
      (server, uri) => {
        const serverKey = this.getServerKey(server)
        return `mcp:get_resource:${serverKey}:${uri}`
      },
      30 * 60 * 1000, // 30 minutes TTL
      `[MCP] Resource ${uri} from ${server.name}`
    )

View on GitHub (pinned to 726446b54c)

Solutions

  1. Check the detailed server logs (emitted before the throw) for the original error.message
  2. Verify the URI is valid and was obtained from a prior `listResources` call
  3. Confirm the server is still connected — a stale client may need reconnection
  4. If the resource is server-specific, consult the server's documentation for supported URI schemes
  5. Wrap the call in try-catch and fall back gracefully if the resource is optional
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const result = await runtime.getResource({ serverId, uri })
  return result
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Failed to get resource')) {
    logger.warn(`Resource ${uri} unavailable on ${server.name}`)
    return { contents: [] }  // graceful degradation
  }
  throw e
}

Prevention

When it happens

Trigger: Calling `getResource({ serverId, uri })` where the server's readResource handler fails — invalid URI format, resource doesn't exist on the server, server-side processing error, or the client connection dropped mid-request.

Common situations: The URI is malformed or references a non-existent resource; the MCP server has a bug in its resource handler; the server disconnected between the resource list call and the resource read; permissions issue on the server side; the resource is temporarily unavailable.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/51571b6164b91733. Report an issue: GitHub.