microsoft/autogen · error · ValueError

uri is required for read_resource

Error message

uri is required for read_resource

What it means

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.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/tools/mcp/_actor.py:117

        if not self._active:
            raise RuntimeError("MCP Actor not running, call initialize() first")
        if self._actor_task and self._actor_task.done():
            raise RuntimeError("MCP actor task crashed", self._actor_task.exception())
        fut: asyncio.Future[McpFuture] = asyncio.Future()
        if type in {"list_tools", "list_prompts", "list_resources", "list_resource_templates", "shutdown"}:
            await self._command_queue.put({"type": type, "future": fut})
            res = await fut
        elif type in {"call_tool", "read_resource", "get_prompt"}:
            if args is None:
                raise ValueError(f"args is required for {type}")
            name = args.get("name", None)
            kwargs = args.get("kargs", {})
            if type == "call_tool" and name is None:
                raise ValueError("name is required for call_tool")
            elif type == "read_resource":
                uri = kwargs.get("uri", None)
                if uri is None:
                    raise ValueError("uri is required for read_resource")
                await self._command_queue.put({"type": type, "uri": uri, "future": fut})
            elif type == "get_prompt":
                if name is None:
                    raise ValueError("name is required for get_prompt")
                prompt_args = kwargs.get("arguments", None)
                await self._command_queue.put({"type": type, "name": name, "args": prompt_args, "future": fut})
            else:  # call_tool
                await self._command_queue.put({"type": type, "name": name, "args": kwargs, "future": fut})
            res = await fut
        else:
            raise ValueError(f"Unknown command type: {type}")
        return res

    async def close(self) -> None:
        if not self._active or self._actor_task is None:
            return
        self._shutdown_future = asyncio.Future()
        await self._command_queue.put({"type": "shutdown", "future": self._shutdown_future})

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Put the uri inside kargs: args={'kargs': {'uri': resource.uri}}.
  2. Take the uri from a prior list_resources response rather than hand-typing it.
  3. Double-check the exact key name 'uri' (lowercase).

Example fix

# before
await actor.call("read_resource", args={"name": "config", "kargs": {}})

# after
await actor.call("read_resource", args={"kargs": {"uri": "config://app/settings"}})
Defensive patterns

Strategy: validation

Validate before calling

uri = (args.get("kargs") or {}).get("uri")
if cmd == "read_resource" and not uri:
    raise ValueError("read_resource requires args['kargs']['uri']")

Prevention

When it happens

Trigger: 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'.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/b20659c03552e2d2. Report an issue: GitHub.