Content
# Copilot Leecher
**English** |
> Squeeze every drop out of your GitHub Copilot premium requests — turn follow-up prompts into free MCP tool calls.
## Why This Exists
GitHub Copilot charges by **premium requests** (300/month on Pro; each Claude Opus 4.6 call costs 3 requests), *not* by tokens. Through experimentation, we discovered:
| Action | Costs a Premium Request? |
|---|---|
| New user prompt | ✅ Yes |
| Follow-up in the same session | ✅ Yes |
| Tool calls / MCP calls | ❌ **No** |
So the most cost-effective way to use Copilot is: **pack as much work as possible into a single premium request**.
The problem? Humans rarely express everything perfectly in one shot. Follow-up questions ("wait, also do X…") are inevitable — and each one burns another request.
**Copilot Leecher** solves this by providing a `request_review` MCP tool. When the agent finishes a task, it calls this tool and *blocks* — waiting for your feedback via a local web UI. Your feedback is returned as a **tool calls result** (free!), not a new user prompt. The agent then acts on your feedback within the *same* request.
One prompt → review → refine → review → approve. **All for the price of a single premium request.**
## How It Works
```
You (1 prompt) Copilot Agent
│ │
├─── "Implement feature X" ────────► (works on it…)
│ │
│ request_review() │ ← MCP tool call (FREE)
│ │
│ ┌──────────────────────────────┤
│ │ Web UI (localhost:3456) │
│ │ "Also handle edge case Y" │ ← your feedback
│ └──────────────────────────────┤
│ │
│ (improves work…) │
│ │
│ request_review() │ ← still FREE
│ ┌──────────────────────────────┤
│ │ "ok" │ ← approved
│ └──────────────────────────────┤
│ │
│ ✅ Done ◄──────────────┤
│ │
Total premium requests used: 1
```
## Quick Start
### 1. Install & Build
```bash
git clone https://github.com/user/copilot-leecher.git
cd copilot-leecher
npm install
npm run build
```
### 2. Configure VS Code
Add to your VS Code `settings.json`:
```json
{
"github.copilot.chat.mcp.servers": {
"copilot-leecher": {
"command": "node",
"args": ["/absolute/path/to/copilot-leecher/dist/index.js"]
}
}
}
```
> Replace the path with your actual absolute path.
### 3. Restart VS Code & Open Dashboard
Restart VS Code. The MCP server auto-starts an HTTP dashboard at **http://127.0.0.1:3456**.
### 4. Use It
In your Copilot Chat prompt or Agent Contract, instruct the agent:
```
After completing your work, call the request_review tool with a taskId and summary.
Wait for feedback. If approved, finish. Otherwise, improve and request review again.
```
Then open http://127.0.0.1:3456 to review and provide feedback.
## Architecture
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ VS Code #1 │ │ VS Code #2 │ │ Browser │
│ Copilot Agent │ │ Copilot Agent │ │ 127.0.0.1:3456 │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ MCP │ MCP │ HTTP
┌────▼────┐ ┌────▼────┐ │
│MCP+HTTP │ │MCP only │ │
│Server #1│ │Server #2│ │
│(:3456) │ │(skipped)│ │
└────┬────┘ └────┬────┘ │
└────────┬────────────┘ │
▼ │
┌──────────────────────────────────┐ │
│ /tmp/copilot-reviewer-sessions/ │◄─────────────┘
│ (file-system persistence) │
└──────────────────────────────────┘
```
- The first MCP process binds port 3456 for the web dashboard.
- Subsequent instances skip the HTTP server but share session data via the filesystem.
## MCP Tool: `request_review`
| Parameter | Type | Required | Description |
|---|---|---|---|
| `taskId` | string | ✅ | Unique task identifier (e.g. `task-20260217-001`) |
| `summary` | string | ✅ | Brief summary of work done (2-3 sentences) |
**Returns**: `{ status, feedback, sessionId, reviewerUrl }`
- `status`: `"approved"` or `"needs_revision"`
- `feedback`: The reviewer's text
## HTTP API
| Method | Endpoint | Description |
|---|---|---|
| GET | `/api/sessions` | List all sessions |
| GET | `/api/sessions/pending` | List pending sessions |
| GET | `/api/sessions/:id` | Get session details |
| POST | `/api/sessions/:id/feedback` | Submit feedback `{ "feedback": "..." }` |
| GET | `/api/health` | Health check |
## Agent Contract Template
Add this to your prompt / system instructions:
```markdown
After completing all tasks, you MUST call the `request_review` tool.
- taskId: a unique identifier for the task
- summary: 2-3 sentences describing what you did
Then wait for expert feedback:
- "ok" / "approved" / "lgtm" → task complete, stop working
- anything else → improve your work based on the feedback, then call request_review again
NEVER finish without an approved review.
```
<details>
<summary><strong>Full Agent Contract Example (click to expand)</strong></summary>
```markdown
# Agent Contract
## Review Requirements
### When to Request Review
After completing all task steps, you MUST call `request_review`.
### How to Call
- **taskId**: Use format `[type]-[date]-[seq]` (e.g. `feature-20260217-001`)
- **summary**: 2-3 sentences summarizing your work
### Handling Feedback
1. **Approved** ("ok" / "approved" / "lgtm"): Stop working, confirm completion
2. **Needs revision**: Read feedback, improve, call request_review again
3. **Timeout**: Inform user, offer to retry
### Rules
- ❌ NEVER finish without approved review
- ❌ NEVER skip the review step
- ✅ Always request review after completing work
- ✅ Keep improving until approved
```
</details>
## Project Structure
```
src/
├── index.ts # MCP server entry (auto-starts HTTP server)
├── reviewer-server.ts # Express HTTP server + Web UI
├── types.ts # TypeScript type definitions
└── shared-state.ts # File-system-based session persistence
```
## Development
```bash
npm run watch # watch mode
npm run dev # build + run MCP server
```
## Troubleshooting
**MCP Server won't connect?**
Ensure an absolute path in `settings.json` and that `dist/index.js` exists. Check VS Code Output panel → "MCP Server" logs.
**Port 3456 in use?**
A second MCP instance auto-skips HTTP startup. Sessions are shared via `/tmp/copilot-reviewer-sessions/` — one dashboard shows all.
**Agent doesn't call request_review?**
Make sure your Agent Contract / prompt explicitly requires it.
## License
MIT
### 2. Configure VS Code
Add the following to `settings.json`:
```json
{
"github.copilot.chat.mcp.servers": {
"copilot-leecher": {
"command": "node",
"args": ["/your/absolute/path/copilot-leecher/dist/index.js"]
}
}
}
```
### 3. Restart VS Code & Open Dashboard
After restarting VS Code, MCP Server will automatically start the Web review interface at **http://127.0.0.1:3456**.
### 4. Usage
In Copilot Chat prompts or Agent Contract, instruct the Agent:
```
After completing all tasks, call the request_review tool with taskId and a brief summary of the work.
Wait for review feedback: if the feedback is "ok" / "approved", end the task; otherwise, improve based on the feedback and re-request review.
Do not end the task if it does not pass the review.
```
Then open http://127.0.0.1:3456 to review and submit feedback.
## Agent Contract Template
```markdown
After completing all tasks, you **must** call the `request_review` tool:
- taskId: Unique task identifier (e.g., feature-20260217-001)
- summary: Briefly describe what was completed in 2-3 sentences
Then wait for expert feedback:
- "ok" / "approved" / "lgtm" / "通过" → End the task
- Other content → Improve based on feedback, then call request_review again
**Important: Do not end the task if it does not pass the review!**
```
<details>
<summary><strong>Complete Agent Contract Example (click to expand)</strong></summary>
```markdown
# Agent Contract
## Review Requirements
### When to Request Review
After completing all task steps, **must** call `request_review`.
### Calling Method
- **taskId**: Format `[type]-[date]-[sequence number]` (e.g., `feature-20260217-001`)
- **summary**: Describe the completed work in 2-3 sentences
### Feedback Handling
1. **Approved** ("ok" / "approved" / "lgtm" / "通过"): Stop work, confirm completion
2. **Needs Improvement**: Read feedback, improve work, and call request_review again
3. **Timeout**: Inform the user, ask if they want to re-request
### Rules
- ❌ Do not end the task without passing the review
- ❌ Do not skip the review step
- ✅ Request review immediately after completing the work
- ✅ Continuously improve until approved
```
</details>
## Frequently Asked Questions
**Q: MCP Server cannot connect?**
Ensure that the absolute path is used in `settings.json`, and `dist/index.js` exists. Check the VS Code output panel → "MCP Server" logs.
**Q: Port 3456 is occupied?**
The second MCP instance will automatically skip HTTP startup. Sessions are shared through `/tmp/copilot-reviewer-sessions/` files, and a single dashboard can see all instances' sessions.
**Q: Agent does not call request_review?**
Check if the Agent Contract prompt explicitly requires it.
## License
MIT