modelcontextprotocol / modelcontextprotocol/python-sdk

tests/client/test_client.py: 14 failures on Windows — AttributeError: '...Result' object has no attribute '_meta'

未關閉
#3,544 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
24.3k
分支
4k
平均合併
1 天 1 小時
30 天內合併 PR
31

描述

Initial Checks
Release line

2.x (current stable)

Description

On a clean checkout of main, tests/client/test_client.py fails with 14 errors of the form AttributeError: 'CallToolResult' object has no attribute '_meta'. Did you mean: 'meta'?

The snapshots pass the wire name (snapshot(CallToolResult(_meta={...}))), but inline_snapshot's generic_call_adapter.argument() does a plain getattr(value, '_meta') and the pydantic model exposes the field as meta. The data is there — the repr shows meta={'io.modelcontextprotocol/serverInfo': ...}.

I'd expect the test suite to pass on a fresh clone with locked dependencies.

Ruled out: unlocked dependency resolution (reproduced with --frozen and --no-sync), Python version (3.12.14 and 3.14.2 both fail), and a non-ASCII checkout path (reproduces under a plain ASCII path too).

I only have Windows to test on, so I don't know whether this reproduces on Linux or macOS. If CI is green, the difference is presumably platform-specific and I'm happy to run whatever would help narrow it down.

┃ File ┃ Function ┃ Function Line ┃ Error Line ┃ Error ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
│ tests\client\test_client.py │ test_client_with_simple_server │ 133 │ │ │
│ tests\client\test_client.py │ test_client_list_tools │ 151 │ │ │
│ tests\client\test_client.py │ test_client_call_tool │ 179 │ │ │
│ tests\client\test_client.py │ test_read_resource │ 191 │ │ │
│ tests\client\test_client.py │ test_get_prompt │ 272 │ │ │
│ tests\client\test_client.py │ test_client_list_resources_wi… │ 339 │ │ │
│ tests\client\test_client.py │ test_client_list_resource_tem… │ 358 │ │ │
│ tests\client\test_client.py │ test_list_prompts │ 369 │ │ │
│ tests\client\test_client.py │ test_complete_with_prompt_ref… │ 387 │ │ │
│ tests\client\test_client.py │ test_call_tool_auto_loop_disp… │ 768 │ 797 │ AttributeError │
│ tests\client\test_client.py │ test_call_tool_auto_loop_disp… │ 810 │ 846 │ AttributeError │
│ tests\client\test_client.py │ test_call_tool_auto_loop_disp… │ 857 │ 881 │ AttributeError │
│ tests\client\test_client.py │ test_get_prompt_auto_loop_res… │ 945 │ 968 │ AttributeError │
│ tests\client\test_client.py │ test_read_resource_auto_loop_… │ 976 │ 999 │ AttributeError

Example Code
┃  File                         ┃  Function                        ┃  Function Line  ┃  Error Line  ┃  Error           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
│  tests\client\test_client.py  │  test_client_with_simple_server  │  133            │              │                  │
│  tests\client\test_client.py  │  test_client_list_tools          │  151            │              │                  │
│  tests\client\test_client.py  │  test_client_call_tool           │  179            │              │                  │
│  tests\client\test_client.py  │  test_read_resource              │  191            │              │                  │
│  tests\client\test_client.py  │  test_get_prompt                 │  272            │              │                  │
│  tests\client\test_client.py  │  test_client_list_resources_wi…  │  339            │              │                  │
│  tests\client\test_client.py  │  test_client_list_resource_tem…  │  358            │              │                  │
│  tests\client\test_client.py  │  test_list_prompts               │  369            │              │                  │
│  tests\client\test_client.py  │  test_complete_with_prompt_ref…  │  387            │              │                  │
│  tests\client\test_client.py  │  test_call_tool_auto_loop_disp…  │  768            │  797         │  AttributeError  │
│  tests\client\test_client.py  │  test_call_tool_auto_loop_disp…  │  810            │  846         │  AttributeError  │
│  tests\client\test_client.py  │  test_call_tool_auto_loop_disp…  │  857            │  881         │  AttributeError  │
│  tests\client\test_client.py  │  test_get_prompt_auto_loop_res…  │  945            │  968         │  AttributeError  │
│  tests\client\test_client.py  │  test_read_resource_auto_loop_…  │  976            │  999         │  AttributeError

git clone https://github.com/modelcontextprotocol/python-sdk.git
cd python-sdk
uv sync --frozen --all-extras --dev
uv run --no-sync pytest tests/client/test_client.py -q

# → 14 failed, 33 passed
Python & MCP Python SDK
Python 3.12.14 (also reproduced on 3.14.2)
mcp 2.2.1.dev1+6affe5c0 (source checkout of main, commit 6affe5c0)
inline_snapshot 0.28.0, pydantic 2.12.5 (both from uv.lock)
uv 0.12.16
Windows 11, PowerShell

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先,在 Windows 上使用已鎖定的相依套件執行 uv run --no-sync pytest tests/client/test_client.py -q。閱讀 tests/client/test_client.py 中失敗的案例,並將其 CallToolResult snapshot 引數與回報的 meta/_meta 行為進行比較。當 14 個失敗都已解決,且用戶端測試檔案在不弱化其預期結果的情況下通過時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
testing
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
活躍
描述清晰度
描述清楚
新手友好度
75/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。