Skip to content

Commit de6757f

Browse files
GiggleLiuclaude
andauthored
fix(mcp): review fixes, multi-platform docs, remove Smithery (#93)
* update review skill * fix(mcp): address review findings from MCP server implementation - 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> * docs(mcp): add configuration examples for Cursor, Windsurf, and OpenCode 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> * feat(mcp): add Smithery registry support for one-command install 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> * docs: update README, CLAUDE.md, and mcp.md with Smithery and multi-platform 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> * chore: remove Smithery registry and Docker artifacts 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> * docs: add MCP prompts redesign design 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> * docs: add MCP prompts redesign implementation plan 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> * refactor(mcp): replace 3 tool-centric prompts with 7 task-oriented prompts 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> * chore: update Makefile cli target to use cargo install, gitignore mcp.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3ddc415 commit de6757f

21 files changed

Lines changed: 1200 additions & 535 deletions

.claude/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ make compare # Generate and compare Rust mapping exports
3333
make jl-testdata # Regenerate Julia parity test data (requires julia)
3434
make cli # Build the pred CLI tool (release mode)
3535
make cli-demo # Run closed-loop CLI demo (exercises all commands)
36+
make mcp-test # Run MCP server tests (unit + integration)
3637
make run-plan # Execute a plan with Claude autorun
3738
make release V=x.y.z # Tag and push a new release (CI publishes to crates.io)
3839
```

.claude/skills/review-implementation/SKILL.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ Read the implementation files and assess:
9797
3. **Example quality** -- Is it tutorial-style? Does it use the instance from the issue? Does the JSON export include both source and target data?
9898
4. **Paper quality** -- Is the reduction-rule statement precise? Is the proof sketch sound? Is the example figure clear?
9999

100+
### Code Quality Principles (applies to both Models and Rules):
101+
1. **DRY (Don't Repeat Yourself)** -- Is there duplicated logic that should be extracted into a shared helper, utility function, or common module? Check for copy-pasted code blocks across files (e.g., similar graph construction, weight handling, or solution extraction patterns). If duplication is found, suggest extracting shared logic.
102+
2. **KISS (Keep It Simple, Stupid)** -- Is the implementation unnecessarily complex? Look for: over-engineered abstractions, convoluted control flow, premature generalization, or layers of indirection that add no value. The implementation should be as simple as possible while remaining correct and maintainable.
103+
100104
## Output Format
101105

102106
Present results as:
@@ -119,7 +123,9 @@ Present results as:
119123
### Semantic Review
120124
- evaluate() correctness: OK
121125
- dims() correctness: OK
122-
- [any issues found]
126+
- DRY compliance: OK / [duplicated logic found in ...]
127+
- KISS compliance: OK / [unnecessary complexity found in ...]
128+
- [any other issues found]
123129
124130
### Summary
125131
- X/Y structural checks passed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Cargo.lock
66

77
# Developer-specific Claude Code settings
88
.claude/settings.local.json
9+
.claude/mcp.json
910

1011
# IDE
1112
.idea/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ endif
144144
git push origin main --tags
145145
@echo "v$(V) pushed — CI will publish to crates.io"
146146

147-
# Build the pred CLI tool
147+
# Build and install the pred CLI tool
148148
cli:
149-
cargo build -p problemreductions-cli --release
149+
cargo install --path problemreductions-cli
150150

151151
# Generate Rust mapping JSON exports for all graphs and modes
152152
GRAPHS := diamond bull house petersen

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ See the [Getting Started](https://codingthrust.github.io/problem-reductions/gett
4444

4545
## MCP Server (AI Integration)
4646

47-
The `pred` CLI includes a built-in [MCP](https://modelcontextprotocol.io/) server for AI assistant integration:
47+
The `pred` CLI includes a built-in [MCP](https://modelcontextprotocol.io/) server for AI assistant integration (Claude Code, Cursor, Windsurf, OpenCode, etc.).
48+
49+
Add to your client's MCP config file:
4850

4951
```json
5052
{"mcpServers": {"problemreductions": {"command": "pred", "args": ["mcp"]}}}
5153
```
5254

53-
See the [MCP documentation](https://codingthrust.github.io/problem-reductions/mcp.html) for available tools, prompts, and configuration details.
55+
| Client | Config file |
56+
|--------|------------|
57+
| Claude Code / Desktop | `.mcp.json` or `~/.claude/mcp.json` |
58+
| Cursor | `.cursor/mcp.json` |
59+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` |
60+
| OpenCode | `opencode.json` (use `{"mcp": {"problemreductions": {"type": "local", "command": ["pred", "mcp"]}}}`) |
61+
62+
See the [MCP documentation](https://codingthrust.github.io/problem-reductions/mcp.html) for available tools, prompts, and full configuration details.
5463

5564
## Contributing
5665

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# MCP Prompts Redesign: Task-Oriented Prompts
2+
3+
## Problem
4+
5+
The current 3 MCP prompts (`analyze_problem`, `reduction_walkthrough`, `explore_graph`) are tool-centric — they list which tools to call rather than expressing what the user wants to accomplish. This makes them disconnected from how researchers, students, and LLM agents actually think about reductions.
6+
7+
## Design
8+
9+
Replace the 3 existing prompts with 7 task-oriented prompts. All prompt text frames requests as user questions. No tool names appear in prompt text — the LLM decides which tools to call.
10+
11+
### Prompt Inventory
12+
13+
| # | Name | Arguments | User question it answers |
14+
|---|------|-----------|--------------------------|
15+
| 1 | `what_is` | `problem` (req) | "What is MaxCut?" |
16+
| 2 | `model_my_problem` | `description` (req) | "I have a scheduling problem — what maps to it?" |
17+
| 3 | `compare` | `problem_a` (req), `problem_b` (req) | "How do MIS and Vertex Cover relate?" |
18+
| 4 | `reduce` | `source` (req), `target` (req) | "Walk me through reducing MIS to QUBO" |
19+
| 5 | `solve` | `problem_type` (req), `instance` (req) | "Solve this graph for maximum independent set" |
20+
| 6 | `find_reduction` | `source` (req), `target` (req) | "What's the cheapest path from SAT to QUBO?" |
21+
| 7 | `overview` | *(none)* | "Show me the full problem landscape" |
22+
23+
### Prompt Texts
24+
25+
#### 1. `what_is`
26+
27+
**Description:** Explain a problem type: what it models, its variants, and how it connects to other problems
28+
29+
```
30+
Explain the "{problem}" problem to me.
31+
32+
What does it model in the real world? What are its variants (graph types,
33+
weight types)? What other problems can it reduce to, and which problems
34+
reduce to it?
35+
36+
Give me a concise summary suitable for someone encountering this problem
37+
for the first time, then show the technical details.
38+
```
39+
40+
#### 2. `model_my_problem`
41+
42+
**Description:** Map a real-world problem to the closest NP-hard problem type in the reduction graph
43+
44+
```
45+
I have a real-world problem and I need help identifying which NP-hard
46+
problem type it maps to.
47+
48+
Here's my problem: "{description}"
49+
50+
Look through the available problem types in the reduction graph and
51+
identify which one(s) best model my problem. Explain why it's a good fit,
52+
what the variables and constraints map to, and suggest how I could encode
53+
my specific instance.
54+
```
55+
56+
#### 3. `compare`
57+
58+
**Description:** Compare two problem types: their relationship, differences, and reduction path between them
59+
60+
```
61+
Compare "{problem_a}" and "{problem_b}".
62+
63+
How are they related? Is there a direct reduction between them, or do they
64+
connect through intermediate problems? What are the key differences in
65+
what they model? If one can be reduced to the other, what is the overhead?
66+
```
67+
68+
#### 4. `reduce`
69+
70+
**Description:** Step-by-step reduction walkthrough: create an instance, reduce it, solve it, and map the solution back
71+
72+
```
73+
Walk me through reducing a "{source}" instance to "{target}", step by step.
74+
75+
1. Find the reduction path and explain the overhead.
76+
2. Create a small, concrete example instance of "{source}".
77+
3. Reduce it to "{target}" and show what the transformed instance looks like.
78+
4. Solve the reduced instance.
79+
5. Explain how the solution maps back to the original problem.
80+
81+
Use a small example so I can follow each transformation by hand.
82+
```
83+
84+
#### 5. `solve`
85+
86+
**Description:** Create and solve a problem instance, showing the optimal solution
87+
88+
```
89+
Create a {problem_type} instance with these parameters: {instance}
90+
91+
Solve it and show me:
92+
- The problem instance details (size, structure)
93+
- The optimal solution and its objective value
94+
- Why this solution is optimal (briefly)
95+
```
96+
97+
#### 6. `find_reduction`
98+
99+
**Description:** Find the best reduction path between two problems, with cost analysis
100+
101+
```
102+
Find the best way to reduce "{source}" to "{target}".
103+
104+
Show me the cheapest reduction path and explain the cost at each step.
105+
Are there alternative paths? If so, compare them — which is better for
106+
small instances vs. large instances?
107+
```
108+
109+
#### 7. `overview`
110+
111+
**Description:** Explore the full landscape of NP-hard problems and reductions in the graph
112+
113+
```
114+
Give me an overview of the NP-hard problem reduction landscape.
115+
116+
How many problem types are registered? What are the major categories
117+
(graph, SAT, optimization)? Which problems are the most connected hubs?
118+
Which problems can reach the most targets through reductions?
119+
120+
Summarize the structure so I understand what's available and where to
121+
start exploring.
122+
```
123+
124+
## Scope
125+
126+
- **Changed:** `problemreductions-cli/src/mcp/prompts.rs` (prompt definitions)
127+
- **Changed:** `problemreductions-cli/src/mcp/tests.rs` (prompt tests)
128+
- **Unchanged:** All 10 MCP tools, tool handlers, server infrastructure
129+
130+
## Testing
131+
132+
- Unit tests: verify `list_prompts` returns 7 prompts with correct names/arguments
133+
- Unit tests: verify `get_prompt` returns correct message text for each prompt
134+
- Integration test: call each prompt via JSON-RPC and verify response structure

0 commit comments

Comments
 (0)