{"record":{"id":"91905038dadf332b","repo":"mastra-ai/mastra","slug":"mcp-server-resources-not-configured","errorCode":"MCP_SERVER_RESOURCES_NOT_CONFIGURED","errorMessage":"MCP_SERVER_RESOURCES_NOT_CONFIGURED","messagePattern":"MCP_SERVER_RESOURCES_NOT_CONFIGURED","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/server/server.ts","lineNumber":3052,"sourceCode":"        },\n        error,\n      );\n      this.logger.trackException(mastraError);\n      throw mastraError;\n    }\n  }\n\n  /**\n   * Reads the content of a resource by URI.\n   *\n   * Used by the Studio API to proxy `ui://` resource reads for MCP Apps rendering.\n   *\n   * @param uri - The resource URI to read (e.g. `ui://weather/dashboard`)\n   * @returns Promise resolving to the resource content\n   */\n  public async readResource(uri: string): Promise<{ contents: Array<{ uri: string; text?: string; blob?: string }> }> {\n    if (!this.resourceOptions?.getResourceContent) {\n      throw new MastraError({\n        id: 'MCP_SERVER_RESOURCES_NOT_CONFIGURED',\n        domain: ErrorDomain.MCP,\n        category: ErrorCategory.USER,\n        details: { uri },\n      });\n    }\n\n    const extra = {} as any;\n    const result = await this.resourceOptions.getResourceContent({ uri, extra });\n    const contents = Array.isArray(result) ? result : [result];\n\n    return {\n      contents: contents.map(c => ({\n        uri,\n        ...('text' in c && c.text !== undefined ? { text: c.text } : {}),\n        ...('blob' in c && c.blob !== undefined ? { blob: c.blob } : {}),\n      })),\n    };","sourceCodeStart":3034,"sourceCodeEnd":3070,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/server/server.ts#L3034-L3070","documentation":"readResource() on MCPServer requires a `getResourceContent` handler supplied via resourceOptions at construction. If none was configured, the server cannot resolve any resource URI and throws MCP_SERVER_RESOURCES_NOT_CONFIGURED (ErrorCategory.USER) with the requested uri in details. It signals a server configuration gap, not a bad URI.","triggerScenarios":"Calling `server.readResource(uri)` (e.g. readResource('ui://weather/dashboard')) on an MCPServer instance constructed without `resourceOptions.getResourceContent`.","commonSituations":"Creating an MCPServer with tools/prompts only, then later adding resource reads without updating the constructor options; copying server bootstrap code that omits resourceOptions; a framework/deployment path instantiating the server without resource support.","solutions":["Pass `resourceOptions: { getResourceContent: async (uri) => ... }` when constructing the MCPServer","Implement getResourceContent to return `{ contents: [{ uri, text }] }` for the URIs you serve","If resources are not intended to be supported, remove/guard the readResource call on the client side"],"exampleFix":"// before\nconst server = new MCPServer({ name: 'my-server', version: '1.0.0', tools });\nawait server.readResource('ui://weather/dashboard'); // throws\n// after\nconst server = new MCPServer({\n  name: 'my-server',\n  version: '1.0.0',\n  tools,\n  resourceOptions: {\n    getResourceContent: async (uri: string) => ({\n      contents: [{ uri, text: JSON.stringify({ dashboard: 'data' }) }],\n    }),\n  },\n});","handlingStrategy":"validation","validationCode":"if (typeof server.readResource === 'function' && serverHasResourceOptions(server)) {\n  await server.readResource(uri);\n} else {\n  console.warn('This MCPServer has no resource support configured');\n}","typeGuard":"function supportsResources(server: any): server is { readResource: (uri: string) => Promise<any> } & { resourceOptions: { getResourceContent: Function } } {\n  return !!server?.resourceOptions?.getResourceContent;\n}","tryCatchPattern":"try {\n  const res = await server.readResource(uri);\n} catch (e) {\n  if ((e as any).id === 'MCP_SERVER_RESOURCES_NOT_CONFIGURED') {\n    console.error(`Resource support not configured on this server (uri: ${e.details.uri})`);\n  } else throw e;\n}","preventionTips":["Configure resourceOptions.getResourceContent at server construction if you plan to serve resources","List resources only when a getResourceContent handler exists","Add a startup self-check that readResource works for a known URI"],"tags":["mcp","resources","configuration","missing-handler"],"backgroundTag":"resource-handler-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}