{"record":{"id":"e0ed7c45eee77f0f","repo":"yikart/AiToEarn","slug":"errorcode-methodnotfound-e0ed7c","errorCode":"ErrorCode.MethodNotFound","errorMessage":"Unknown resource: ${uri}","messagePattern":"Unknown resource: (.+?)","errorType":"error_code","errorClass":"McpError","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/libs/nest-mcp/src/services/handlers/mcp-resources.handler.ts","lineNumber":97,"sourceCode":"          if (resourceTemplateInfo) {\n            providerClass = resourceTemplateInfo.resourceTemplate.providerClass\n            params = {\n              ...resourceTemplateInfo.params,\n              ...request.params,\n            }\n            methodName = resourceTemplateInfo.resourceTemplate.methodName\n          }\n          else if (resourceInfo) {\n            providerClass = resourceInfo.resource.providerClass\n\n            params = {\n              ...resourceInfo.params,\n              ...request.params,\n            }\n            methodName = resourceInfo.resource.methodName\n          }\n          else {\n            throw new McpError(\n              ErrorCode.MethodNotFound,\n              `Unknown resource: ${uri}`,\n            )\n          }\n          return await this.handleRequest(\n            httpRequest,\n            providerClass,\n            uri,\n            this.createContext(mcpServer, request),\n            params,\n            methodName,\n          )\n        }\n        catch (error) {\n          this.logger.error(error)\n          const errorMessage = getErrorMessage(error)\n          return {\n            contents: [{ uri, mimeType: 'text/plain', text: errorMessage }],","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/libs/nest-mcp/src/services/handlers/mcp-resources.handler.ts#L79-L115","documentation":"The MCP resources handler in nest-mcp builds a methodName from a registered resource looked up by URI. When no resource info is found in the registry for the requested URI, it throws McpError with MethodNotFound, mirroring the JSON-RPC -32601 semantics of the MCP protocol.","triggerScenarios":"A client sends resources/read (or a resource-related request) with a URI that is not registered via @McpResource in any provider for this mcpModuleId, or the URI has a typo or wrong scheme.","commonSituations":"Client caching an old resource URI after a server rename; resource decorators not applied because the provider class was not registered; environment mismatch where the module hosting the resource is not loaded.","solutions":["Check the URI in the client request against the URIs produced by @McpResource decorators in the loaded providers","Ensure the provider class containing the resource is registered in the module for this mcpModuleId","List resources first (resources/list) and use exactly the URIs returned","Fix URI typos or scheme mismatches (e.g. file:// vs app://)"],"exampleFix":"// before\nawait client.readResource({ uri: 'docs://user-guide' });\n// after\nconst { resources } = await client.listResources();\nawait client.readResource({ uri: resources[0].uri });","handlingStrategy":"try-catch","validationCode":"const { resources } = await client.listResources();\nconst known = resources.some(r => r.uri === uri);\nif (!known) throw new Error(`URI ${uri} not offered by server`);","typeGuard":"function isKnownResource(uri: string, resources: { uri: string }[]): boolean {\n  return resources.some(r => r.uri === uri);\n}","tryCatchPattern":"try {\n  await client.readResource({ uri });\n} catch (e) {\n  if (e.code === ErrorCode.MethodNotFound) await refreshResourceList();\n  else throw e;\n}","preventionTips":["Discover resources via resources/list instead of hardcoding URIs","Re-list resources after any server redeploy","Keep URI schemes consistent between client config and @McpResource definitions","Ensure the resource provider module is enabled in the target environment"],"tags":["mcp","json-rpc","method-not-found","resources"],"backgroundTag":"mcp-method-not-found","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}