{"record":{"id":"6b06742920da92c9","repo":"can1357/oh-my-pi","slug":"no-mcp-server-has-resource-uri-available-re","errorCode":null,"errorMessage":"No MCP server has resource \"${uri}\".\n\nAvailable resources:\n${formatAvailableResources(mcpManager)}","messagePattern":"No MCP server has resource \"(.+?)\"\\.\n\nAvailable resources:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/mcp-protocol.ts","lineNumber":133,"sourceCode":" */\nexport class McpProtocolHandler implements ProtocolHandler {\n\treadonly scheme = \"mcp\";\n\treadonly immutable = true;\n\n\tasync resolve(url: InternalUrl): Promise<InternalResource> {\n\t\tconst mcpManager = MCPManager.instance();\n\t\tif (!mcpManager) {\n\t\t\tthrow new Error(\"No MCP manager available. MCP servers may not be configured.\");\n\t\t}\n\n\t\tconst uri = extractResourceUri(url);\n\t\tlet targetServer = resolveTargetServer(mcpManager, uri);\n\t\tif (!targetServer) {\n\t\t\tawait Promise.allSettled(mcpManager.getConnectedServers().map(name => mcpManager.ensureServerResources(name)));\n\t\t\ttargetServer = resolveTargetServer(mcpManager, uri);\n\t\t}\n\t\tif (!targetServer) {\n\t\t\tthrow new Error(\n\t\t\t\t`No MCP server has resource \"${uri}\".\\n\\nAvailable resources:\\n${formatAvailableResources(mcpManager)}`,\n\t\t\t);\n\t\t}\n\n\t\tlet result: MCPResourceReadResult | undefined;\n\t\ttry {\n\t\t\tresult = await mcpManager.readServerResource(targetServer, uri);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(`MCP resource read error: ${message}`);\n\t\t}\n\n\t\tif (!result) {\n\t\t\tthrow new Error(`Server \"${targetServer}\" returned no content for \"${uri}\".`);\n\t\t}\n\n\t\tconst textParts: string[] = [];\n\t\tfor (const item of result.contents) {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/mcp-protocol.ts#L115-L151","documentation":"After extracting the wrapped resource URI from the mcp:// URL, the handler searches all connected servers' discovered resources (literal URIs, then URI templates, refreshed once via ensureServerResources). If no server advertises a matching resource or template, it throws with the requested URI and a formatted list of every resource actually available so the caller can self-correct.","triggerScenarios":"Resolving an mcp:// URL whose inner URI does not exactly match any resource URI and does not match any server's URI template — a typo'd URI, a resource that was removed/renamed on the server, or a server that exposes the resource only after a tool call the client never made.","commonSituations":"Hard-coded mcp:// links from old session notes pointing at resources the server no longer lists; referencing a resource before the server finishes discovery; wrong server connected (URI exists on a server that isn't in config); template parameters filled incorrectly so no template matches.","solutions":["Copy a URI exactly from the 'Available resources' list embedded in the error message (match is exact string equality for literal URIs).","Reconnect/refresh the MCP server so ensureServerResources picks up newly added resources, then retry.","If the resource is server-generated, run the producing tool/flow first so it appears in the resource list.","If it should be a dynamic resource, check the server's uriTemplate and build a URI matching that template."],"exampleFix":"// before\nread(\"mcp://notes/roapmap\");            // typo — no such resource\n// after (URI taken verbatim from the error's Available resources list)\nread(\"mcp://notes/roadmap\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await handler.resolve(parseInternalUrl(input));\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"No MCP server has resource\")) {\n    const available = e.message.split(\"Available resources:\\n\")[1] ?? \"(none)\";\n    console.warn(`Unknown MCP resource; available:\\n${available}`);\n    return null;\n  }\n  throw e;\n}","preventionTips":["Only cite URIs copied verbatim from MCP resource listings — literal matching is exact string equality.","Re-list resources after reconnecting a server before referencing new resources.","Run the server tool/flow that materializes dynamic resources before reading them.","Check URI templates and fill template parameters exactly."],"tags":["mcp","resource-not-found","uri-mismatch"],"backgroundTag":"resource-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}