Skip to content

Python: [Bug]: Found capabilities during initialize are not respected and is throwing exception #5360

@mrrobertsson

Description

@mrrobertsson

Description

When running agent framework with MCP servers that doesn't implement prompts will cause an exception.

I have a .NET 10 MCP Server that is only exposing tools for the agent to use.

Here is the initialize call to my MCP server:

{
  "result": {
    "protocolVersion": "2025-11-25",
    "capabilities": {
      "logging": {},
      "tools": {
        "listChanged": true
      }
    },
    "serverInfo": {
      "name": "McpServer1",
      "version": "1.0.0.0"
    }
  },
  "id": 1,
  "jsonrpc": "2.0"
}

Under MCP, prompts are optional and are negotiated during initialization. A server that supports prompts must declare the prompts capability. A client should only call prompts/list when that capability was negotiated.

Yet I get an exception that mcp.shared.exceptions.McpError: Method 'prompts/list' is not available..

Before upgrading the agent-framework library from 1.0.0b251105 to 1.0.0rc5 it was not causing any exceptions as the one above, and I couldn't see any breaking changes regarding this issue either.

It also works if I add prompts to the MCP server, but this is not feasible either.

Why is it trying to list all prompts when the server capabilities never mention that it should have any prompts?

Code Sample

Error Messages / Stack Traces

Traceback (most recent call last):
  File "/.venv/lib/python3.13/site-packages/agent_framework/_mcp.py", line 1136, in __aenter__
    await self.connect()
  File "/.venv/lib/python3.13/site-packages/agent_framework/_mcp.py", line 621, in connect
    await self._run_on_lifecycle_owner("connect", reset=reset)
  File "/.venv/lib/python3.13/site-packages/agent_framework/_mcp.py", line 596, in _run_on_lifecycle_owner
    await future
  File "/.venv/lib/python3.13/site-packages/agent_framework/_mcp.py", line 540, in _run_lifecycle_owner
    await self._connect_on_owner(reset=reset)
  File "/.venv/lib/python3.13/site-packages/agent_framework/_mcp.py", line 693, in _connect_on_owner
    await self.load_prompts()
  File "/.venv/lib/python3.13/site-packages/agent_framework/_mcp.py", line 846, in load_prompts
    prompt_list = await self.session.list_prompts(params=params)  # type: ignore[union-attr]
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.13/site-packages/mcp/client/session.py", line 457, in list_prompts
    return await self.send_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
    )
    ^
  File "/.venv/lib/python3.13/site-packages/mcp/shared/session.py", line 306, in send_request
    raise McpError(response_or_error.error)
mcp.shared.exceptions.McpError: Method 'prompts/list' is not available.

Package Versions

agent-framework: 1.0.0rc5

Python Version

Python 3.13

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions