Skip to content

Comments

fix(mcp): review fixes, multi-platform docs, remove Smithery#93

Merged
GiggleLiu merged 10 commits intomainfrom
fix/mcp-review-fixes
Feb 22, 2026
Merged

fix(mcp): review fixes, multi-platform docs, remove Smithery#93
GiggleLiu merged 10 commits intomainfrom
fix/mcp-review-fixes

Conversation

@GiggleLiu
Copy link
Contributor

@GiggleLiu GiggleLiu commented Feb 22, 2026

Summary

Review and cleanup of the MCP server implementation (commits 2b2e112..3ddc415 pushed directly to main).

Code Fixes

  • Fix Box::leak memory leak in find_path_inner — replaced with CustomCost closure
  • Remove redundant double-serialization (to_value then to_string_pretty) at 3 call sites
  • Extract shared helpers in tools.rsser_vertex_weight_problem, ser_edge_weight_problem, ser_kcoloring
  • Refactor integration tests — extract shared spawn_mcp/send/read_response/initialize/shutdown helpers; fix stdin ownership deadlock

Documentation

  • Multi-platform MCP configs — add Cursor, Windsurf, OpenCode setup instructions to CLI help, README, and mdBook docs
  • Remove Smithery artifactssmithery.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 cleanup
  • problemreductions-cli/tests/mcp_integration.rs — refactored test helpers, deadlock fix
  • problemreductions-cli/src/cli.rs — updated MCP help text
  • README.md — updated MCP section
  • docs/src/mcp.md — removed Smithery, kept multi-platform configs
  • .claude/CLAUDE.md — added make mcp-test
  • Deleted: smithery.yaml, Dockerfile

Test plan

🤖 Generated with Claude Code

GiggleLiu and others added 2 commits February 22, 2026 20:32
- 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
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.36%. Comparing base (3ddc415) to head (8e971cf).
⚠️ Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 for find_path with a CustomCost closure 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 rustfmt across 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 cost is minimize:<field>, the code still chooses best_path by comparing p.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., sum cost_fn.edge_cost over graph.path_overheads(p) while updating ProblemSize through each overhead), or changing find_cheapest_path to 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_response loops until it can parse a JSON-RPC line, with no timeout or max-iteration guard. If pred mcp hangs 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 and recv_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.

GiggleLiu and others added 4 commits February 22, 2026 22:00
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>
@GiggleLiu GiggleLiu changed the title fix(mcp): address review findings from MCP server implementation fix(mcp): review fixes, multi-platform docs, remove Smithery Feb 22, 2026
GiggleLiu and others added 4 commits February 22, 2026 23:08
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>
@GiggleLiu GiggleLiu merged commit de6757f into main Feb 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant