Extract MCP transport handler#329
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR extracts JSON-RPC request handling logic from the ChangesMCP Handler Module Extraction
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ayskobtw-lil
left a comment
There was a problem hiding this comment.
No blockers from my review on current head 7cba74e30fe03446f1be6e56eef4df2782650a80.
Evidence checked:
- Inspected
app/mcp.pyand the delegated/mcproute inapp/main.py. - Compared the extracted
tools/list,tools/call, malformed request, parse-error, invalid params, invalid tool-arguments, structuredContent, and text-result paths against the previous inline implementation. - Verified
_call_mcp_tool()remains the business dispatch boundary and the new handler only owns JSON-RPC transport/error shaping. - Confirmed CodeRabbit reports no actionable comments and hosted CI is green.
Validation run locally:
python -m pytest tests/test_api_mcp.py -q-> 68 passed.python -m ruff check app/main.py app/mcp.py tests/test_api_mcp.py-> passed.python -m ruff format --check app/main.py app/mcp.py tests/test_api_mcp.py-> passed.python -m mypy app/main.py app/mcp.py-> success.git diff --check origin/main...HEAD-> clean.
Residual risk is limited to future drift between MCP_TOOLS metadata and _call_mcp_tool() behavior, but this PR preserves the current advertised tool set and response shape.
artylobos
left a comment
There was a problem hiding this comment.
Reviewed the MCP transport extraction in PR #329.
Evidence checked:
- Inspected
app/mcp.pyand the delegated/mcproute inapp/main.py, and compared the extracted handler against the prior inline JSON-RPC handling fromorigin/main. - Verified parse-error, non-object request, unknown method, invalid params/arguments, missing tool name, invalid tool argument,
tools/list, string tool result, and dictstructuredContentbehavior are still covered by the MCP tests. - Confirmed
app/main.pynow only wires the route to_call_mcp_tool, while protocol-level request validation and result shaping live inapp/mcp.py.
Validation run locally on the PR head:
git diff --check origin/main...HEAD-> clean.uv run --extra dev python -m pytest tests/test_api_mcp.py -q-> 68 passed.uv run --extra dev ruff check app/main.py app/mcp.py tests/test_api_mcp.py-> passed.uv run --extra dev ruff format --check app/main.py app/mcp.py tests/test_api_mcp.py-> 3 files already formatted.uv run --extra dev python -m mypy app/main.py app/mcp.py-> success.
No blockers found. Residual risk is limited to the tool catalog now being a module-level mutable list, but this is equivalent for the current tools/list response path and not a merge blocker.
Refs #320
Summary
/mcpJSON-RPC transport handling fromapp/main.pyintoapp/mcp.py._call_mcp_tool()implementation, so public MCP behavior stays unchanged.handle_mcp_request().Complexity reduced
app/main.pyno longer carries the MCP transport parser and response boilerplate inline with route/page/admin wiring. The MCP boundary is now easier to review independently:app/mcp.pyowns protocol-level JSON-RPC handling, whileapp/main.pyonly wires the route to the existing business dispatch function.Evidence
uv run --extra dev python -m pytest tests/test_api_mcp.py -q-> 68 passed.uv run --extra dev ruff check app/main.py app/mcp.py tests/test_api_mcp.py-> passed.uv run --extra dev ruff format --check app/main.py app/mcp.py tests/test_api_mcp.py-> passed.uv run --extra dev python -m mypy app/main.py app/mcp.py-> success.git diff --check-> clean.Safety
Summary by CodeRabbit
Refactor
Improvements