fix(mcp): review fixes, multi-platform docs, remove Smithery#93
fix(mcp): review fixes, multi-platform docs, remove Smithery#93
Conversation
- Fix memory leak: replace Box::leak with CustomCost closure in find_path_inner (safe for long-running MCP server) - Fix redundant double-serialization (to_value then to_string_pretty) - DRY: extract shared graph problem serialization helpers (ser_vertex_weight_problem, ser_edge_weight_problem, ser_kcoloring) - DRY: extract shared integration test helpers (spawn_mcp, send, read_response, initialize, shutdown) - Fix integration test deadlock from ChildStdin ownership - Apply rustfmt formatting fixes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
=======================================
Coverage 96.36% 96.36%
=======================================
Files 197 197
Lines 27210 27214 +4
=======================================
+ Hits 26220 26224 +4
Misses 990 990 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refines the MCP server implementation in problemreductions-cli to address prior review findings, focusing on correctness for long-running operation and reducing duplicated serialization/test logic.
Changes:
- Replaced
Box::leak-based cost selection forfind_pathwith aCustomCostclosure to avoid per-request memory leaks. - Removed redundant JSON double-serialization patterns and extracted shared problem-serialization helpers for MCP instance creation.
- Refactored MCP integration tests with reusable helpers and adjusted subprocess I/O ownership to avoid deadlocks; ran
rustfmtacross touched files.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/rules/graph.rs | Pure formatting adjustment in neighbor tree construction. |
| problemreductions-cli/tests/mcp_integration.rs | Extracted MCP subprocess/test helpers; improved shutdown behavior by taking ownership of ChildStdin. |
| problemreductions-cli/tests/cli_tests.rs | Formatting-only changes to CLI tests. |
| problemreductions-cli/src/mcp/tools.rs | Core MCP server fixes/refactors: CustomCost for path costs, DRY serialization helpers, removed double-serialization. |
| problemreductions-cli/src/mcp/prompts.rs | Formatting-only import consolidation. |
| problemreductions-cli/src/main.rs | Formatting-only change in command dispatch. |
| problemreductions-cli/src/commands/solve.rs | Minor formatting/closure style change. |
| problemreductions-cli/src/commands/graph.rs | Formatting-only change to color_fns initialization. |
| problemreductions-cli/src/commands/create.rs | Formatting-only change to argument extraction. |
| examples/reduction_satisfiability_to_circuitsat.rs | Formatting-only example output tweaks. |
| examples/reduction_maximumsetpacking_to_maximumindependentset.rs | Formatting-only example output tweaks. |
| examples/reduction_ksatisfiability_to_satisfiability.rs | Formatting-only example output tweaks. |
| .claude/skills/review-implementation/SKILL.md | Documentation update: adds DRY/KISS review checklist items. |
Comments suppressed due to low confidence (2)
problemreductions-cli/src/mcp/tools.rs:350
- When
costisminimize:<field>, the code still choosesbest_pathby comparingp.len()(step count). That ignores the requested cost function across different source/target variant combinations, so the returned path may not be globally cheapest for the selected field. Consider tracking and comparing the total path cost (e.g., sumcost_fn.edge_costovergraph.path_overheads(p)while updatingProblemSizethrough each overhead), or changingfind_cheapest_pathto also return the final cost so the caller can pick the true minimum.
if let Some(p) = found {
let is_better = best_path.as_ref().is_none_or(|bp| p.len() < bp.len());
if is_better {
best_path = Some(p);
}
problemreductions-cli/tests/mcp_integration.rs:45
read_responseloops until it can parse a JSON-RPC line, with no timeout or max-iteration guard. Ifpred mcphangs or stops producing valid JSON (e.g., crashes after spawning, or writes unexpected output), this test will block indefinitely in CI. Consider adding a time limit (e.g., read in a separate thread andrecv_timeout, or cap the number of lines / elapsed time before failing with a helpful panic message).
fn read_response(reader: &mut BufReader<std::process::ChildStdout>) -> serde_json::Value {
loop {
let mut line = String::new();
let bytes = reader.read_line(&mut line).expect("Failed to read line");
if bytes == 0 {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update CLI help text and mdBook documentation to cover all major MCP-compatible platforms: Claude Code/Desktop, Cursor, Windsurf, and OpenCode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add smithery.yaml and Dockerfile so the MCP server can be registered on the Smithery registry, enabling one-command install: npx -y @smithery/cli install problemreductions --client claude Update CLI help and docs to show Smithery as the primary quick-setup method, with manual config as fallback for all platforms. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…atform info - README: add Smithery one-command install, platform config table - CLAUDE.md: add mcp-test make target - mcp.md: mention OpenCode in intro Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Smithery requires a running server URL for registration, which doesn't work for our stdio-based MCP server. Remove smithery.yaml, Dockerfile, and all Smithery references from docs and CLI help. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace 3 tool-centric prompts with 7 task-oriented prompts that map to real user journeys (what_is, model_my_problem, compare, reduce, solve, find_reduction, overview). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4-task plan: rewrite list_prompts, rewrite get_prompt, update integration tests, rebuild and verify. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ompts New prompts: what_is, model_my_problem, compare, reduce, solve, find_reduction, overview. Prompt text frames user questions instead of listing tool calls. Integration test updated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
….json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Review and cleanup of the MCP server implementation (commits
2b2e112..3ddc415pushed directly to main).Code Fixes
Box::leakmemory leak infind_path_inner— replaced withCustomCostclosureto_valuethento_string_pretty) at 3 call sitestools.rs—ser_vertex_weight_problem,ser_edge_weight_problem,ser_kcoloringspawn_mcp/send/read_response/initialize/shutdownhelpers; fix stdin ownership deadlockDocumentation
smithery.yaml,Dockerfile, and all Smithery references (Smithery requires a running server URL, incompatible with our stdio-based server)Files Changed
problemreductions-cli/src/mcp/tools.rs— memory leak fix, DRY helpers, serialization cleanupproblemreductions-cli/tests/mcp_integration.rs— refactored test helpers, deadlock fixproblemreductions-cli/src/cli.rs— updated MCP help textREADME.md— updated MCP sectiondocs/src/mcp.md— removed Smithery, kept multi-platform configs.claude/CLAUDE.md— addedmake mcp-testsmithery.yaml,DockerfileTest plan
make mcp-testpasses (unit + integration)make clippypassescargo build -p problemreductions-cli --releasesucceeds🤖 Generated with Claude Code