code-context-engine icon indicating copy to clipboard operation
code-context-engine copied to clipboard

cce serve crashes on mcp SDK 2.x: 'Server' object has no attribute 'list_tools'

Open itsandyking opened this issue 4 months ago • 3 comments

Summary

cce serve crashes on startup with the mcp Python SDK at 2.x, so a fresh install produces a non-functional MCP server. The failure is silent from the agent's perspective — Claude Code reports the server never connected and falls back to grep/read, so the tool appears installed and does nothing.

Reproduce

uv venv --python 3.12 venv
uv pip install --python ./venv/bin/python "code-context-engine[local]"
cd <a-project> && ./venv/bin/cce init --agent claude
./venv/bin/cce serve --project-dir <a-project>

Actual

CCE v0.4.25 · Starting context engine MCP server...
Traceback (most recent call last):
  ...
  File ".../context_engine/integration/mcp_server.py", line 468, in __init__
    self._register_tools()
  File ".../context_engine/integration/mcp_server.py", line 709, in _register_tools
    @self._server.list_tools()
     ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Server' object has no attribute 'list_tools'

mcp==2.0.0 resolved. python -c "import mcp.server as s; print([a for a in dir(s.Server) if 'tool' in a.lower()])" returns [] — the decorator-style Server.list_tools() registration API is gone in 2.x.

Workaround

uv pip install "mcp<2" (verified working on 1.29.0):

CCE ready · <project> · 13626 chunks indexed · live watcher active · memory hooks :56507

Suggested fix

Pin mcp<2 in the dependency spec, or support both registration APIs.

Why this matters

The failure mode is silent. In a controlled A/B run the treatment arm degraded to stock behaviour and produced a clean-looking "the agent never used CCE in 5/5 sessions" result. It took reading the session transcripts — where the agent had written "context-engine MCP never connected, so falling back to grep/read" — to find it was a server crash rather than a tool-selection finding.

Environment: macOS 27 (arm64), Python 3.12, code-context-engine 0.4.25.

itsandyking avatar Aug 02 '26 19:08 itsandyking

Fixed in #148 (merged 2026-07-15). The dependency is now pinned to mcp>=1.0,<2 in pyproject.toml, which prevents pip/uv from resolving 2.x.

Upgrading to code-context-engine>=0.4.25 picks up the fix. If you installed via uv: uv tool upgrade code-context-engine or cce upgrade.

rajkumarsakthivel avatar Aug 02 '26 20:08 rajkumarsakthivel

It still installed the wrong version for me:

% uv tool install "code-context-engine[local]"
Resolved 72 packages in 120ms
Installed 72 packages in 270ms
 + aiohappyeyeballs==2.7.1
 + aiohttp==3.14.3
 + aiosignal==1.4.0
 + annotated-doc==0.0.5
 + annotated-types==0.8.0
 + anyio==4.14.2
 + attrs==26.1.0
 + certifi==2026.7.22
 + cffi==2.1.1
 + charset-normalizer==3.4.9
 + click==8.4.2
 + code-context-engine==0.4.25
 + cryptography==50.0.0
 + fastapi==0.141.1
 + fastembed==0.8.0
 + filelock==3.32.2
 + flatbuffers==25.12.19
 + frozenlist==1.8.0
 + fsspec==2026.7.0
 + h11==0.16.0
 + hf-xet==1.6.0
 + httpcore==1.0.9
 + httpcore2==2.10.0
 + httpx==0.28.1
 + httpx2==2.10.0
 + huggingface-hub==1.27.0
 + idna==3.18
 + jsonschema==4.26.0
 + jsonschema-specifications==2025.9.1
 + loguru==0.7.3
 + mcp==2.0.0
 + mcp-types==2.0.0
 + mmh3==5.2.1
 + multidict==6.7.1
 + numpy==2.5.2
 + onnxruntime==1.28.0
 + opentelemetry-api==1.44.0
 + packaging==26.3
 + pillow==12.3.0
 + propcache==0.5.2
 + protobuf==7.35.1
 + psutil==7.2.2
 + py-rust-stemmers==0.1.8
 + pycparser==3.0
 + pydantic==2.13.4
 + pydantic-core==2.46.4
 + pyjwt==2.13.0
 + python-multipart==0.0.32
 + pyyaml==6.0.3
 + referencing==0.37.0
 + requests==2.34.2
 + rpds-py==2026.6.3
 + sqlite-vec==0.1.9
 + sse-starlette==3.4.8
 + starlette==1.6.0
 + tokenizers==0.23.1
 + tqdm==4.70.0
 + tree-sitter==0.25.2
 + tree-sitter-go==0.25.0
 + tree-sitter-java==0.23.5
 + tree-sitter-javascript==0.25.0
 + tree-sitter-php==0.24.1
 + tree-sitter-python==0.25.0
 + tree-sitter-rust==0.24.2
 + tree-sitter-typescript==0.23.2
 + truststore==0.10.4
 + typing-extensions==4.16.0
 + typing-inspection==0.4.3
 + urllib3==2.7.0
 + uvicorn==0.52.1
 + watchdog==6.0.0
 + yarl==1.24.5
Installed 3 executables: cce, cce-savings, code-context-engine

The workaround that worked for me was uv tool install "code-context-engine[local]" --with "mcp>=1,<2" --force

toumas avatar Aug 12 '26 06:08 toumas

Thanks for reporting this — you're right. The published 0.4.25 on PyPI has mcp>=1.0 without the upper bound, so uv tool install resolves to mcp==2.0.0 which breaks the server.

We've already added the mcp>=1.0,<2 pin in the repo (merged in #147), but it hasn't been released yet. Your workaround (--with "mcp>=1,<2" --force) is the right call until we cut the next release.

We'll get a patch out shortly so fresh installs resolve correctly.

rajkumarsakthivel avatar Aug 12 '26 18:08 rajkumarsakthivel