neoclide/coc.nvim · error · ResourceNotFoundError

Resource not found: ${uri}

Error message

Resource not found: ${uri}

What it means

The resources `read` method only handles known URI shapes: `coc://document/...` plus a fixed switch of built-in URIs (diagnostics, workspace info, etc.). Any other URI reaches the `default` branch and throws `ResourceNotFoundError`.

Source

Thrown at src/mcp/resources.ts:115

            id: stat.id,
            state: stat.state,
            languageIds: stat.languageIds,
            capabilities: init?.capabilities ?? null
          }
        })
        return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify(stats, null, 2) }] }
      }
      case 'coc://workspace': {
        let info = {
          version: workspace.version,
          cwd: workspace.cwd || process.cwd(),
          root: workspace.root || process.cwd(),
          folders: workspace.folderPaths
        }
        return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify(info, null, 2) }] }
      }
      default:
        throw new ResourceNotFoundError(`Resource not found: ${uri}`)
    }
  }

  public dispose(): void {
    // nothing to dispose
  }
}

View on GitHub (pinned to 50e974d969)

Solutions

  1. Check the exact URI string for typos in scheme or path
  2. Call resources/list to see the URIs this server actually supports
  3. Update the client to the current builtin URIs if it was written against an older version

Example fix

// before
await read('coc://diagnostic') // singular, unsupported
// after
await read('coc://diagnostics')
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN = /^coc:\/\/document\//
const BUILTINS = ['coc://diagnostics', 'coc://workspace']
function isReadable(uri: string): boolean {
  return KNOWN.test(uri) || BUILTINS.includes(uri)
}
if (!isReadable(uri)) throw new Error(`URI not supported by coc MCP: ${uri}`)

Try / catch

try {
  const res = await resources.read(uri)
} catch (e) {
  if (/Resource not found:/.test(e.message)) {
    logger.warn(`Unsupported resource '${uri}' — refresh resources/list`)
  } else throw e
}

Prevention

When it happens

Trigger: Calling `resources.read(uri)` with a URI that is not a document URI and not one of the built-in cases, e.g. a misspelled scheme ('coc://diagnostic'), an old/renamed URI, or a resource advertised by a different server.

Common situations: MCP client cached resource URIs from a previous version where a builtin was renamed; hand-typed URI with a typo; client assumes a resource exists that this coc MCP server never offered.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31). Data as JSON: /api/errors/1478b0a34200d2a4. Report an issue: GitHub.