{"record":{"id":"b20659c03552e2d2","repo":"microsoft/autogen","slug":"uri-is-required-for-read-resource","errorCode":null,"errorMessage":"uri is required for read_resource","messagePattern":"uri is required for read_resource","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/mcp/_actor.py","lineNumber":117,"sourceCode":"        if not self._active:\n            raise RuntimeError(\"MCP Actor not running, call initialize() first\")\n        if self._actor_task and self._actor_task.done():\n            raise RuntimeError(\"MCP actor task crashed\", self._actor_task.exception())\n        fut: asyncio.Future[McpFuture] = asyncio.Future()\n        if type in {\"list_tools\", \"list_prompts\", \"list_resources\", \"list_resource_templates\", \"shutdown\"}:\n            await self._command_queue.put({\"type\": type, \"future\": fut})\n            res = await fut\n        elif type in {\"call_tool\", \"read_resource\", \"get_prompt\"}:\n            if args is None:\n                raise ValueError(f\"args is required for {type}\")\n            name = args.get(\"name\", None)\n            kwargs = args.get(\"kargs\", {})\n            if type == \"call_tool\" and name is None:\n                raise ValueError(\"name is required for call_tool\")\n            elif type == \"read_resource\":\n                uri = kwargs.get(\"uri\", None)\n                if uri is None:\n                    raise ValueError(\"uri is required for read_resource\")\n                await self._command_queue.put({\"type\": type, \"uri\": uri, \"future\": fut})\n            elif type == \"get_prompt\":\n                if name is None:\n                    raise ValueError(\"name is required for get_prompt\")\n                prompt_args = kwargs.get(\"arguments\", None)\n                await self._command_queue.put({\"type\": type, \"name\": name, \"args\": prompt_args, \"future\": fut})\n            else:  # call_tool\n                await self._command_queue.put({\"type\": type, \"name\": name, \"args\": kwargs, \"future\": fut})\n            res = await fut\n        else:\n            raise ValueError(f\"Unknown command type: {type}\")\n        return res\n\n    async def close(self) -> None:\n        if not self._active or self._actor_task is None:\n            return\n        self._shutdown_future = asyncio.Future()\n        await self._command_queue.put({\"type\": \"shutdown\", \"future\": self._shutdown_future})","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/mcp/_actor.py#L99-L135","documentation":"For type == 'read_resource', McpActor.call() extracts the resource URI from args['kargs']['uri']; a missing/None URI raises ValueError('uri is required for read_resource'). The URI is the MCP resource identifier (e.g. 'file:///path', 'config://app') that resources/read requires.","triggerScenarios":"Calling actor.call('read_resource', args={'name': ...}) or args with an empty 'kargs' dict lacking 'uri'; passing the URI under 'resource' or at the top level instead of inside 'kargs'.","commonSituations":"Confusing the arg shape with the raw MCP protocol (protocol sends uri at top level, actor wants it under kargs); listing resources and forgetting to thread result[i].uri into the read call.","solutions":["Put the uri inside kargs: args={'kargs': {'uri': resource.uri}}.","Take the uri from a prior list_resources response rather than hand-typing it.","Double-check the exact key name 'uri' (lowercase)."],"exampleFix":"# before\nawait actor.call(\"read_resource\", args={\"name\": \"config\", \"kargs\": {}})\n\n# after\nawait actor.call(\"read_resource\", args={\"kargs\": {\"uri\": \"config://app/settings\"}})","handlingStrategy":"validation","validationCode":"uri = (args.get(\"kargs\") or {}).get(\"uri\")\nif cmd == \"read_resource\" and not uri:\n    raise ValueError(\"read_resource requires args['kargs']['uri']\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source uris from list_resources results rather than literals.","Centralize the read_resource call in one helper that validates the uri key."],"tags":["mcp","validation","resources","uri"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}