Skip to content

Commit d95f87b

Browse files
GiggleLiuclaude
andcommitted
docs(mcp): rewrite for end users with conversational walkthrough
- Add walkthrough showing a complete MIS → QUBO session as natural dialogue - Use `claude mcp add` command for Claude Code configuration - Merge Cursor/Windsurf into single section (same JSON config) - Update prompts table from 3 to current 7 task-oriented prompts - Remove developer-only sections (MCP Inspector, make mcp-test) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1883011 commit d95f87b

File tree

1 file changed

+62
-99
lines changed

1 file changed

+62
-99
lines changed

docs/src/mcp.md

Lines changed: 62 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,93 @@
22

33
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is an open standard that allows AI assistants to interact with external tools and data sources. The `pred` CLI includes a built-in MCP server that exposes the full reduction graph, problem creation, solving, and reduction capabilities to any MCP-compatible AI assistant (such as Claude Code, Cursor, Windsurf, or OpenCode).
44

5+
## Walkthrough
6+
7+
A complete session showing how an AI assistant uses MCP tools behind the scenes to answer your questions.
8+
9+
**You:** Create a weighted MIS problem on a 4-vertex graph with edges 0-1, 1-2, 2-3, 3-0, 0-2 and weights [1, 2, 3, 4], explain the result.
10+
11+
> **Assistant:** I created a Maximum Independent Set instance on a SimpleGraph with 4 vertices, 5 edges, and integer weights [1, 2, 3, 4]. Each vertex has a weight, and the goal is to find a subset of non-adjacent vertices that maximizes total weight.
12+
13+
**You:** What can I do with this problem? Explain the result.
14+
15+
> **Assistant:** This instance has 4 binary variables (one per vertex). It can be reduced to 5 other problem types: ILP, MaximumSetPacking, MinimumVertexCover, QUBO, and other MIS variants. You can solve it directly using either an ILP solver or brute-force search.
16+
17+
**You:** Check if selecting vertices 1 and 3 is a valid solution, explain the result.
18+
19+
> **Assistant:** Yes! Selecting vertices 1 and 3 (configuration [0,1,0,1]) is a valid independent set — these two vertices are not adjacent. The total weight is 2 + 4 = 6.
20+
21+
**You:** Reduce this to QUBO, explain the result.
22+
23+
> **Assistant:** Done. The MIS instance was transformed into a 4x4 QUBO matrix:
24+
>
25+
> ```
26+
> [-1.0, 11.0, 11.0, 11.0]
27+
> [ 0.0, -2.0, 11.0, 0.0]
28+
> [ 0.0, 0.0, -3.0, 11.0]
29+
> [ 0.0, 0.0, 0.0, -4.0]
30+
> ```
31+
>
32+
> The diagonal entries (-1, -2, -3, -4) encode vertex weights negated for minimization. The off-diagonal entries (11.0) are large penalties on edges — selecting two adjacent vertices would incur a penalty that outweighs any benefit. The reduction path is: MaximumIndependentSet → QUBO.
33+
34+
**You:** Now solve it through the reduction, explain the result.
35+
36+
> **Assistant:** The brute-force solver found the optimal solution by solving the QUBO, then mapping the result back to the original MIS:
37+
>
38+
> - **QUBO solution:** [0,1,0,1] with objective -6.0 (minimization)
39+
> - **MIS solution:** vertices {1, 3} with weight **6** (maximization)
40+
>
41+
> The QUBO objective of -6.0 corresponds to the MIS maximum of 6 — the reduction correctly inverts the sign. This confirms that {1, 3} is the optimal independent set.
42+
543
## Installation
644
7-
### Via cargo
45+
Install via cargo:
846
947
```bash
1048
cargo install problemreductions-cli
1149
```
1250
13-
### From source
51+
Or build from source:
1452

1553
```bash
1654
git clone https://github.com/CodingThrust/problem-reductions
1755
cd problem-reductions
18-
make cli # builds target/release/pred
56+
make cli # builds and installs target/release/pred
1957
```
2058

2159
## Configuration
2260

23-
### Claude Code / Claude Desktop
61+
### Claude Code
2462

25-
Add to your project's `.mcp.json` (or `~/.claude/mcp.json` for global):
63+
```bash
64+
# Project-scoped (current project only)
65+
claude mcp add --scope project problemreductions -- pred mcp
2666

27-
```json
28-
{
29-
"mcpServers": {
30-
"problemreductions": {
31-
"command": "pred",
32-
"args": ["mcp"]
33-
}
34-
}
35-
}
67+
# User-scoped (all projects)
68+
claude mcp add --scope user problemreductions -- pred mcp
3669
```
3770

38-
### Cursor
71+
### Cursor / Windsurf
3972

40-
Add to `.cursor/mcp.json` in your project root (or `~/.cursor/mcp.json` for global):
73+
Add to the appropriate config file:
74+
- **Cursor:** `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global)
75+
- **Windsurf:** `~/.codeium/windsurf/mcp_config.json`
4176

4277
```json
43-
{
44-
"mcpServers": {
45-
"problemreductions": {
46-
"command": "pred",
47-
"args": ["mcp"]
48-
}
49-
}
50-
}
51-
```
52-
53-
### Windsurf
54-
55-
Add to `~/.codeium/windsurf/mcp_config.json`:
56-
57-
```json
58-
{
59-
"mcpServers": {
60-
"problemreductions": {
61-
"command": "pred",
62-
"args": ["mcp"]
63-
}
64-
}
65-
}
78+
{ "mcpServers": { "problemreductions": { "command": "pred", "args": ["mcp"] } } }
6679
```
6780

6881
### OpenCode
6982

7083
Add to `opencode.json` in your project root:
7184

7285
```json
73-
{
74-
"mcp": {
75-
"problemreductions": {
76-
"type": "local",
77-
"command": ["pred", "mcp"]
78-
}
79-
}
80-
}
86+
{ "mcp": { "problemreductions": { "type": "local", "command": ["pred", "mcp"] } } }
8187
```
8288

8389
### Generic MCP Client
8490

85-
Any MCP client that supports the stdio transport can connect to the server by running:
86-
87-
```bash
88-
pred mcp
89-
```
90-
91-
The server communicates over stdin/stdout using the MCP JSON-RPC protocol.
91+
Any MCP client that supports the stdio transport can connect by running `pred mcp`. The server communicates over stdin/stdout using the MCP JSON-RPC protocol.
9292

9393
## Available Tools
9494

@@ -116,51 +116,14 @@ The MCP server provides 10 tools organized into two categories: **graph query to
116116

117117
## Available Prompts
118118

119-
The server provides 3 prompt templates that guide the AI assistant through common workflows:
119+
The server provides 7 task-oriented prompt templates:
120120

121121
| Prompt | Arguments | Description |
122122
|--------|-----------|-------------|
123-
| `analyze_problem` | `problem_type` (required) | Analyze a problem type: show its definition, variants, size fields, and reduction edges |
124-
| `reduction_walkthrough` | `source` (required), `target` (required) | End-to-end reduction walkthrough: find a path, create an instance, reduce it, and solve the result |
125-
| `explore_graph` | *(none)* | Explore the reduction graph: list all problems, export the graph, and analyze its structure |
126-
127-
## Example Usage
128-
129-
Once configured, you can interact with the reduction graph naturally through your AI assistant:
130-
131-
```
132-
> What problems can MaximumIndependentSet reduce to?
133-
134-
> Walk me through reducing a 5-vertex MIS instance to QUBO
135-
136-
> Create a random graph with 8 vertices and solve the MaxCut problem on it
137-
138-
> Find all reduction paths from Satisfiability to SpinGlass
139-
```
140-
141-
The AI assistant will automatically call the appropriate MCP tools to answer your questions, create problem instances, perform reductions, and solve problems.
142-
143-
## Testing with MCP Inspector
144-
145-
You can test the MCP server using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
146-
147-
```bash
148-
npx @modelcontextprotocol/inspector pred mcp
149-
```
150-
151-
This opens a web UI where you can:
152-
153-
1. Browse the list of available tools and their schemas
154-
2. Call tools with custom parameters and inspect the JSON responses
155-
3. Browse and invoke prompt templates
156-
4. Verify the server is working correctly before configuring your AI assistant
157-
158-
## Running MCP Tests
159-
160-
To run the MCP server test suite:
161-
162-
```bash
163-
make mcp-test
164-
```
165-
166-
This runs both unit tests (tool logic) and integration tests (MCP protocol-level tool calls).
123+
| `what_is` | `problem_type` (required) | Explain a problem type |
124+
| `model_my_problem` | `description` (required) | Map a real-world problem to an NP-hard type |
125+
| `compare` | `problem_a` (required), `problem_b` (required) | Compare two problem types |
126+
| `reduce` | `source` (required), `target` (required) | Step-by-step reduction walkthrough |
127+
| `solve` | `problem_type` (required), `params` (required) | Create and solve a problem instance |
128+
| `find_reduction` | `source` (required), `target` (required) | Find the best reduction path between two problems |
129+
| `overview` | *(none)* | Explore the full landscape of NP-hard problems |

0 commit comments

Comments
 (0)