fix(wren): align MCP handlers with ServeContext and query limits#2500
fix(wren): align MCP handlers with ServeContext and query limits#2500ttw225 wants to merge 2 commits into
Conversation
Use ServeContext as the source of truth for MCP memory paths and workflow capabilities. This keeps explicit project selection and registered tools aligned throughout the server. Embed the cube N+1 probe in generated SQL so truncation detection works without applying a second connector limit. Preserve the requested limit in SQL-only output and reject negative limits for MCP query tools. Add handler-level MCP tests and a dedicated CI job that installs the mcp extra.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe MCP server now uses project-scoped memory paths, context-dependent workflow prompts, validated query limits, and SQL-level cube-query probing. Dedicated CI execution covers the MCP server tests. ChangesMCP server behavior
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant MCPClient
participant query_cube
participant SQLBuilder
participant Connector
MCPClient->>query_cube: Submit cube query with limit and offset
query_cube->>SQLBuilder: Build SQL with probe limit
query_cube->>Connector: Execute SQL with limit=None
Connector-->>query_cube: Return probe rows
query_cube-->>MCPClient: Return rows and truncation metadata
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/wren-ci.yml (1)
221-221: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueConsider disabling credential persistence in checkout.
To prevent the
GITHUB_TOKENfrom being persisted in the local git config, it's a security best practice to setpersist-credentials: falsewhen checking out the repository, especially if the.gitdirectory could ever be uploaded as an artifact or accessed by third-party tools.🛠️ Proposed fix
- - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + persist-credentials: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/wren-ci.yml at line 221, Update the actions/checkout@v4 step to disable credential persistence by setting persist-credentials to false, ensuring the checkout does not retain the GITHUB_TOKEN in local git configuration.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/wren-ci.yml:
- Line 221: Update the actions/checkout@v4 step to disable credential
persistence by setting persist-credentials to false, ensuring the checkout does
not retain the GITHUB_TOKEN in local git configuration.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c8904e73-4679-470b-990d-5d68a04efac2
📒 Files selected for processing (3)
.github/workflows/wren-ci.ymlcore/wren/src/wren/mcp_server.pycore/wren/tests/unit/test_mcp_server.py
Summary
#2438 introduced
wren serve mcpand centralized the selected project,engine, and capability flags in
ServeContext.This follow-up builds on that foundation by using the startup context
consistently across memory tools and workflow guidance, refining cube query
limit handling, and adding dedicated MCP test coverage.
Changes
ServeContext.projectas the source of truth for all MCP memory paths,keeping memory access aligned with the project selected through
--project.wren_workflowprompt from the active capabilities.applying a second connector limit:
individual connectors implement their
limitargumentLIMIT/OFFSETordering for MySQL and Dorisrun_sqlandquery_cube.test-mcpCI job with theoptional
mcpdependency.Workflow capabilities
store_querydry_run→run_sql, withquery_cubefor metrics--allow-writedry_run→run_sql, withquery_cubefor metrics--no-connectdry_plan--no-connect --allow-writedry_planThe generated workflow only references tools registered for the active
server configuration, with contiguous step numbering in every mode.
Test plan
uv lock --checkuv run --no-sync ruff format --check src/wren/mcp_server.py tests/unit/test_mcp_server.pyuv run --no-sync ruff check src/wren/mcp_server.py tests/unit/test_mcp_server.pyuv run --no-sync pytest tests/unit/test_mcp_server.py -quv run --no-sync pytest tests/unit -qSummary by CodeRabbit
Bug Fixes
.wren/memorydirectory.limitvalues for SQL and cube queries.LIMIT/OFFSEThandling) and consistenttruncated/row_countreporting, including SQL-only output.Tests
Chores