distill-mcp 0.6.0-beta → 0.6.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +227 -0
- package/bin/cli.js +17 -17
- package/dist/cli/doctor.js +12 -12
- package/dist/cli/hooks.d.ts +1 -1
- package/dist/cli/hooks.js +13 -13
- package/dist/cli/setup.js +10 -10
- package/dist/cli/utils.d.ts +1 -1
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/middleware/chain.js +1 -1
- package/dist/sandbox/executor.d.ts +1 -1
- package/dist/sandbox/executor.js +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +1 -1
- package/dist/server.js +4 -4
- package/dist/tools/analyze-context.js +1 -1
- package/dist/tools/code-execute.d.ts +1 -1
- package/dist/tools/code-execute.js +2 -2
- package/dist/tools/context-budget.js +1 -1
- package/dist/tools/dynamic-loader.js +1 -1
- package/dist/tools/lazy-mcp.js +2 -2
- package/dist/tools/lazy-mcp.test.js +2 -2
- package/dist/tools/optimization-tips.js +2 -2
- package/dist/utils/token-counter.js +1 -1
- package/package.json +3 -3
- package/scripts/install.ps1 +19 -19
- package/scripts/install.sh +19 -19
- package/scripts/pre-commit-hook.sh +9 -9
package/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Distill
|
|
2
|
+
|
|
3
|
+
> Extract the essence. Compress the context. Save tokens.
|
|
4
|
+
|
|
5
|
+
**Distill** is an open-source MCP server that optimizes LLM token usage through intelligent context compression. Works with Claude Code, Cursor, and Windsurf.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/distill-mcp)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
## Why Distill?
|
|
11
|
+
|
|
12
|
+
| Problem | Distill Solution | Savings |
|
|
13
|
+
|---------|------------------|---------|
|
|
14
|
+
| Large build outputs | Auto-compress errors | 80-95% |
|
|
15
|
+
| Reading entire files | AST-based extraction | 50-70% |
|
|
16
|
+
| Multiple tool calls | TypeScript SDK execution | **98%** |
|
|
17
|
+
| Verbose logs | Smart summarization | 80-90% |
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Run directly with npx
|
|
23
|
+
npx distill-mcp
|
|
24
|
+
|
|
25
|
+
# Or install globally
|
|
26
|
+
npm install -g distill-mcp
|
|
27
|
+
|
|
28
|
+
# Configure your IDE
|
|
29
|
+
distill-mcp setup
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Add to Claude Code
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
claude mcp add distill -- npx distill-mcp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- **Smart File Reading** - Extract functions, classes, or signatures without loading entire files
|
|
41
|
+
- **Auto Compression** - Detects content type and applies optimal compression
|
|
42
|
+
- **Code Execution SDK** - Write TypeScript instead of chaining tool calls
|
|
43
|
+
- **Lazy Loading** - Only loads tools when needed (85% token overhead reduction)
|
|
44
|
+
- **7 Languages** - TypeScript, JavaScript, Python, Go, Rust, PHP, Swift
|
|
45
|
+
|
|
46
|
+
## MCP Tools
|
|
47
|
+
|
|
48
|
+
### Core Tools (Always Loaded)
|
|
49
|
+
|
|
50
|
+
| Tool | Purpose | Savings |
|
|
51
|
+
|------|---------|---------|
|
|
52
|
+
| `auto_optimize` | Auto-detect and compress content | 40-95% |
|
|
53
|
+
| `smart_file_read` | Read code with AST extraction | 50-70% |
|
|
54
|
+
| `code_execute` | Execute TypeScript with SDK | **98%** |
|
|
55
|
+
| `discover_tools` | Browse/load additional tools | - |
|
|
56
|
+
|
|
57
|
+
### On-Demand Tools
|
|
58
|
+
|
|
59
|
+
| Tool | Purpose | Savings |
|
|
60
|
+
|------|---------|---------|
|
|
61
|
+
| `semantic_compress` | TF-IDF based compression | 40-60% |
|
|
62
|
+
| `summarize_logs` | Summarize server/test/build logs | 80-90% |
|
|
63
|
+
| `analyze_build_output` | Parse build errors | 95%+ |
|
|
64
|
+
| `deduplicate_errors` | Group repeated errors | 80-95% |
|
|
65
|
+
| `diff_compress` | Compress git diffs | 50-80% |
|
|
66
|
+
| `context_budget` | Pre-flight token estimation | - |
|
|
67
|
+
| `session_stats` | Usage analytics | - |
|
|
68
|
+
|
|
69
|
+
## Usage Examples
|
|
70
|
+
|
|
71
|
+
### Smart File Reading
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Get file structure overview
|
|
75
|
+
mcp__distill__smart_file_read filePath="src/server.ts"
|
|
76
|
+
|
|
77
|
+
# Extract specific function
|
|
78
|
+
mcp__distill__smart_file_read filePath="src/server.ts" target={"type":"function","name":"createServer"}
|
|
79
|
+
|
|
80
|
+
# Get skeleton (signatures only)
|
|
81
|
+
mcp__distill__smart_file_read filePath="src/server.ts" skeleton=true
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Compress Build Output
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# After a failed build, compress the output
|
|
88
|
+
mcp__distill__auto_optimize content="<paste npm/tsc/webpack output>"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Code Execution SDK
|
|
92
|
+
|
|
93
|
+
The `code_execute` tool provides **98% token savings** by letting LLMs write TypeScript:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
mcp__distill__code_execute code="return ctx.compress.auto(ctx.files.read('logs.txt'))"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**SDK API:**
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// File operations
|
|
103
|
+
ctx.files.read(path)
|
|
104
|
+
ctx.files.glob(pattern)
|
|
105
|
+
ctx.files.exists(path)
|
|
106
|
+
|
|
107
|
+
// Code analysis
|
|
108
|
+
ctx.code.skeleton(content, lang)
|
|
109
|
+
ctx.code.extract(content, lang, {type, name})
|
|
110
|
+
ctx.code.parse(content, lang)
|
|
111
|
+
|
|
112
|
+
// Compression
|
|
113
|
+
ctx.compress.auto(content, hint?)
|
|
114
|
+
ctx.compress.logs(logs)
|
|
115
|
+
ctx.compress.diff(diff)
|
|
116
|
+
ctx.compress.semantic(content, ratio?)
|
|
117
|
+
|
|
118
|
+
// Git operations
|
|
119
|
+
ctx.git.diff(ref?)
|
|
120
|
+
ctx.git.log(limit?)
|
|
121
|
+
ctx.git.blame(file, line?)
|
|
122
|
+
|
|
123
|
+
// Search
|
|
124
|
+
ctx.search.grep(pattern, glob?)
|
|
125
|
+
ctx.search.symbols(query)
|
|
126
|
+
|
|
127
|
+
// Analysis
|
|
128
|
+
ctx.analyze.dependencies(file)
|
|
129
|
+
ctx.analyze.callGraph(fn)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Discover Tools
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Browse available tools (metadata only)
|
|
136
|
+
mcp__distill__discover_tools category="compress"
|
|
137
|
+
|
|
138
|
+
# Load tools when needed
|
|
139
|
+
mcp__distill__discover_tools category="compress" load=true
|
|
140
|
+
|
|
141
|
+
# TOON format for compact output
|
|
142
|
+
mcp__distill__discover_tools format="toon"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## CLI Commands
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
distill-mcp setup # Auto-configure detected IDEs
|
|
149
|
+
distill-mcp setup --claude # Configure Claude Code only
|
|
150
|
+
distill-mcp setup --cursor # Configure Cursor only
|
|
151
|
+
distill-mcp doctor # Verify installation
|
|
152
|
+
distill-mcp serve # Start MCP server
|
|
153
|
+
distill-mcp analyze # Analyze codebase token usage
|
|
154
|
+
distill-mcp --help # Show help
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## IDE Configuration
|
|
158
|
+
|
|
159
|
+
### Claude Code
|
|
160
|
+
|
|
161
|
+
After running `distill-mcp setup`, your config will include:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"mcpServers": {
|
|
166
|
+
"distill": {
|
|
167
|
+
"command": "npx",
|
|
168
|
+
"args": ["distill-mcp", "serve"]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Cursor / Windsurf
|
|
175
|
+
|
|
176
|
+
Configuration is automatically added to the appropriate settings file.
|
|
177
|
+
|
|
178
|
+
## Token Overhead
|
|
179
|
+
|
|
180
|
+
Distill uses **lazy loading** to minimize overhead:
|
|
181
|
+
|
|
182
|
+
| Mode | Tokens | Description |
|
|
183
|
+
|------|--------|-------------|
|
|
184
|
+
| Core only | 264 | Default (4 tools) |
|
|
185
|
+
| All tools | 1,108 | Full suite (21 tools) |
|
|
186
|
+
| **Savings** | **76%** | Lazy vs eager loading |
|
|
187
|
+
|
|
188
|
+
## Security
|
|
189
|
+
|
|
190
|
+
Code execution runs in a sandboxed environment:
|
|
191
|
+
- Blocked: `eval`, `require`, `import()`, `process`, `global`
|
|
192
|
+
- File access restricted to working directory
|
|
193
|
+
- Sensitive files blocked (`.env`, credentials, keys)
|
|
194
|
+
- Memory limit: 128MB, Timeout: 30s
|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Install dependencies
|
|
200
|
+
bun install
|
|
201
|
+
|
|
202
|
+
# Run tests
|
|
203
|
+
bun run test
|
|
204
|
+
|
|
205
|
+
# Build
|
|
206
|
+
bun run build
|
|
207
|
+
|
|
208
|
+
# Start dev server
|
|
209
|
+
bun run dev
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
Contributions welcome! See [CONTRIBUTING.md](https://github.com/ArthurDEV44/distill/blob/main/CONTRIBUTING.md) for guidelines.
|
|
215
|
+
|
|
216
|
+
**Priority areas:**
|
|
217
|
+
- New language parsers (Java, C#, Kotlin)
|
|
218
|
+
- SDK extensions
|
|
219
|
+
- Documentation
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
MIT
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
**[npm](https://www.npmjs.com/package/distill-mcp)** · **[GitHub](https://github.com/ArthurDEV44/distill)** · **[Documentation](https://github.com/ArthurDEV44/distill/tree/main/docs)**
|
package/bin/cli.js
CHANGED
|
@@ -12,15 +12,15 @@ const command = args[0];
|
|
|
12
12
|
function showHelp() {
|
|
13
13
|
const version = getPackageVersion();
|
|
14
14
|
console.log(`
|
|
15
|
-
${COLORS.bright}${COLORS.cyan}
|
|
16
|
-
|
|
15
|
+
${COLORS.bright}${COLORS.cyan}Distill MCP Server${COLORS.reset} v${version}
|
|
16
|
+
Extract the essence. Compress the context. Save tokens.
|
|
17
17
|
|
|
18
18
|
${COLORS.bright}Usage:${COLORS.reset}
|
|
19
|
-
|
|
19
|
+
distill-mcp <command> [options]
|
|
20
20
|
|
|
21
21
|
${COLORS.bright}Commands:${COLORS.reset}
|
|
22
22
|
serve Start the MCP server (stdio mode)
|
|
23
|
-
setup Configure IDEs to use
|
|
23
|
+
setup Configure IDEs to use Distill
|
|
24
24
|
doctor Check installation and configuration
|
|
25
25
|
analyze Analyze files for token usage
|
|
26
26
|
|
|
@@ -47,20 +47,20 @@ ${COLORS.bright}Other Options:${COLORS.reset}
|
|
|
47
47
|
--help, -h Show this help message
|
|
48
48
|
|
|
49
49
|
${COLORS.bright}Examples:${COLORS.reset}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
distill-mcp setup Auto-detect and configure all IDEs
|
|
51
|
+
distill-mcp setup --claude Configure Claude Code only
|
|
52
|
+
distill-mcp setup --claude --hooks Configure Claude Code + install hooks
|
|
53
|
+
distill-mcp setup --hooks Install hooks only (current project)
|
|
54
|
+
distill-mcp setup --force Overwrite existing configurations
|
|
55
|
+
distill-mcp doctor Verify installation
|
|
56
|
+
distill-mcp serve Start MCP server (used by IDE)
|
|
57
|
+
distill-mcp serve --lazy Start with lazy mode (95% savings)
|
|
58
|
+
distill-mcp serve --verbose Start with verbose logging
|
|
59
|
+
distill-mcp analyze Analyze token usage in codebase
|
|
60
|
+
distill-mcp analyze -t 5000 --json Custom threshold, JSON output
|
|
61
61
|
|
|
62
62
|
${COLORS.bright}Documentation:${COLORS.reset}
|
|
63
|
-
https://
|
|
63
|
+
https://distill.dev/docs
|
|
64
64
|
`);
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -121,7 +121,7 @@ async function main() {
|
|
|
121
121
|
|
|
122
122
|
default: {
|
|
123
123
|
console.error(`Unknown command: ${command}`);
|
|
124
|
-
console.error('Run "
|
|
124
|
+
console.error('Run "distill-mcp --help" for usage information.');
|
|
125
125
|
process.exit(1);
|
|
126
126
|
}
|
|
127
127
|
}
|
package/dist/cli/doctor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execSync } from "child_process";
|
|
2
2
|
import { existsSync } from "fs";
|
|
3
|
-
import { detectInstalledIDEs, readJSONFile,
|
|
3
|
+
import { detectInstalledIDEs, readJSONFile, isDistillConfigured, success, warn, error, log, COLORS, getPackageVersion, } from "./utils.js";
|
|
4
4
|
function checkNodeVersion() {
|
|
5
5
|
try {
|
|
6
6
|
const version = process.version;
|
|
@@ -30,20 +30,20 @@ function checkNodeVersion() {
|
|
|
30
30
|
}
|
|
31
31
|
function checkPackageInstallation() {
|
|
32
32
|
try {
|
|
33
|
-
// Check if
|
|
33
|
+
// Check if distill-mcp is in PATH
|
|
34
34
|
const which = process.platform === "win32" ? "where" : "which";
|
|
35
|
-
execSync(`${which}
|
|
35
|
+
execSync(`${which} distill-mcp`, { stdio: "pipe" });
|
|
36
36
|
return {
|
|
37
37
|
name: "Package installation",
|
|
38
38
|
status: "pass",
|
|
39
|
-
message:
|
|
39
|
+
message: `distill-mcp v${getPackageVersion()} installed globally`,
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
catch {
|
|
43
43
|
return {
|
|
44
44
|
name: "Package installation",
|
|
45
45
|
status: "warn",
|
|
46
|
-
message: "
|
|
46
|
+
message: "distill-mcp not found in PATH (may be running via npx)",
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -68,25 +68,25 @@ function checkIDEConfigurations() {
|
|
|
68
68
|
});
|
|
69
69
|
continue;
|
|
70
70
|
}
|
|
71
|
-
if (
|
|
71
|
+
if (isDistillConfigured(configFile)) {
|
|
72
72
|
results.push({
|
|
73
73
|
name: `${config.name} configuration`,
|
|
74
74
|
status: "pass",
|
|
75
|
-
message: `
|
|
75
|
+
message: `Distill configured in ${config.configPath}`,
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
79
|
results.push({
|
|
80
80
|
name: `${config.name} configuration`,
|
|
81
81
|
status: "fail",
|
|
82
|
-
message: `
|
|
82
|
+
message: `Distill not configured. Run 'distill-mcp setup --${ide}'`,
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
return results;
|
|
87
87
|
}
|
|
88
88
|
export async function doctor() {
|
|
89
|
-
log(`\n${COLORS.bright}${COLORS.cyan}
|
|
89
|
+
log(`\n${COLORS.bright}${COLORS.cyan}Distill MCP Server Doctor${COLORS.reset}\n`);
|
|
90
90
|
log(`Running diagnostic checks...\n`);
|
|
91
91
|
const checks = [
|
|
92
92
|
checkNodeVersion(),
|
|
@@ -114,14 +114,14 @@ export async function doctor() {
|
|
|
114
114
|
}
|
|
115
115
|
log("\n" + "─".repeat(50));
|
|
116
116
|
if (failCount === 0 && warnCount === 0) {
|
|
117
|
-
success(`All ${passCount} checks passed!
|
|
117
|
+
success(`All ${passCount} checks passed! Distill is ready to use.`);
|
|
118
118
|
}
|
|
119
119
|
else if (failCount === 0) {
|
|
120
|
-
warn(`${passCount} passed, ${warnCount} warnings.
|
|
120
|
+
warn(`${passCount} passed, ${warnCount} warnings. Distill should work but may have limited functionality.`);
|
|
121
121
|
}
|
|
122
122
|
else {
|
|
123
123
|
error(`${passCount} passed, ${warnCount} warnings, ${failCount} failed.`);
|
|
124
|
-
log(`\nRun ${COLORS.cyan}
|
|
124
|
+
log(`\nRun ${COLORS.cyan}distill-mcp setup${COLORS.reset} to fix configuration issues.`);
|
|
125
125
|
}
|
|
126
126
|
log("");
|
|
127
127
|
}
|
package/dist/cli/hooks.d.ts
CHANGED
package/dist/cli/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Distill Hooks Installation Module
|
|
3
3
|
*
|
|
4
4
|
* Installs Claude Code hooks that suggest MCP tool usage:
|
|
5
5
|
* - PreToolUse: Suggests smart_file_read for code files (non-blocking for Edit compatibility)
|
|
@@ -13,7 +13,7 @@ import { success, warn, info, error, log, COLORS, readJSONFile, writeJSONFile }
|
|
|
13
13
|
// Hook Script Templates
|
|
14
14
|
// ============================================================================
|
|
15
15
|
const PRE_READ_CHECK_SCRIPT = `#!/bin/bash
|
|
16
|
-
#
|
|
16
|
+
# Distill - PreToolUse Hook for Read
|
|
17
17
|
# Suggests smart_file_read for code files (non-blocking to allow Edit to work)
|
|
18
18
|
|
|
19
19
|
INPUT=$(cat)
|
|
@@ -35,7 +35,7 @@ fi
|
|
|
35
35
|
if echo "$FILE_PATH" | grep -qE "\\.(ts|tsx|js|jsx|py|go|rs|java|cpp|c|h|hpp)$"; then
|
|
36
36
|
# Use systemMessage to suggest without blocking (allows Edit to work)
|
|
37
37
|
cat << EOF
|
|
38
|
-
{"systemMessage": "TIP: Consider using
|
|
38
|
+
{"systemMessage": "TIP: Consider using mcp__distill__smart_file_read for '\$BASENAME' to save 50-70% tokens. Example: mcp__distill__smart_file_read filePath=\\"\$FILE_PATH\\" target={\\"type\\":\\"function\\",\\"name\\":\\"myFunc\\"}"}
|
|
39
39
|
EOF
|
|
40
40
|
exit 0
|
|
41
41
|
fi
|
|
@@ -44,7 +44,7 @@ fi
|
|
|
44
44
|
exit 0
|
|
45
45
|
`;
|
|
46
46
|
const POST_BASH_REMIND_SCRIPT = `#!/bin/bash
|
|
47
|
-
#
|
|
47
|
+
# Distill - PostToolUse Hook for Bash
|
|
48
48
|
# Reminds to use MCP tools for large outputs
|
|
49
49
|
|
|
50
50
|
INPUT=$(cat)
|
|
@@ -61,29 +61,29 @@ fi
|
|
|
61
61
|
|
|
62
62
|
# Detect content type and suggest appropriate tool
|
|
63
63
|
if echo "$TOOL_RESPONSE" | grep -qiE "(error TS|warning TS|error\\[E|npm ERR|ERROR in|failed|FAILED)"; then
|
|
64
|
-
echo '{"systemMessage": "TIP: Large build output detected. Use
|
|
64
|
+
echo '{"systemMessage": "TIP: Large build output detected. Use mcp__distill__auto_optimize to compress errors (95%+ reduction)."}'
|
|
65
65
|
exit 0
|
|
66
66
|
fi
|
|
67
67
|
|
|
68
68
|
if echo "$TOOL_RESPONSE" | grep -qiE "(\\[INFO\\]|\\[ERROR\\]|\\[WARN\\]|\\[DEBUG\\]|[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2})"; then
|
|
69
|
-
echo '{"systemMessage": "TIP: Large log output detected. Use
|
|
69
|
+
echo '{"systemMessage": "TIP: Large log output detected. Use mcp__distill__summarize_logs to compress (80-90% reduction)."}'
|
|
70
70
|
exit 0
|
|
71
71
|
fi
|
|
72
72
|
|
|
73
73
|
# Generic large output
|
|
74
|
-
echo '{"systemMessage": "TIP: Large output ('$RESPONSE_SIZE' chars). Consider using
|
|
74
|
+
echo '{"systemMessage": "TIP: Large output ('$RESPONSE_SIZE' chars). Consider using mcp__distill__auto_optimize for compression (40-60% reduction)."}'
|
|
75
75
|
exit 0
|
|
76
76
|
`;
|
|
77
77
|
const PROMPT_INJECT_SCRIPT = `#!/bin/bash
|
|
78
|
-
#
|
|
78
|
+
# Distill - UserPromptSubmit Hook
|
|
79
79
|
# Injects MCP tool reminders at the start of each prompt
|
|
80
80
|
|
|
81
81
|
cat << 'EOF'
|
|
82
82
|
<user-prompt-submit-hook>
|
|
83
|
-
|
|
84
|
-
- Code files:
|
|
85
|
-
- Build/test output:
|
|
86
|
-
- Session stats:
|
|
83
|
+
DISTILL REMINDER: Use MCP tools for token optimization:
|
|
84
|
+
- Code files: mcp__distill__smart_file_read (50-70% savings vs Read)
|
|
85
|
+
- Build/test output: mcp__distill__auto_optimize
|
|
86
|
+
- Session stats: mcp__distill__session_stats
|
|
87
87
|
</user-prompt-submit-hook>
|
|
88
88
|
EOF
|
|
89
89
|
exit 0
|
|
@@ -133,7 +133,7 @@ function createHooksConfig() {
|
|
|
133
133
|
export async function installHooks(options = {}) {
|
|
134
134
|
const projectDir = options.projectDir || process.cwd();
|
|
135
135
|
const force = options.force || false;
|
|
136
|
-
log(`\n${COLORS.bright}Installing
|
|
136
|
+
log(`\n${COLORS.bright}Installing Distill hooks...${COLORS.reset}\n`);
|
|
137
137
|
// Check for jq dependency
|
|
138
138
|
info("Checking dependencies...");
|
|
139
139
|
const jqCheck = checkJqInstalled();
|
package/dist/cli/setup.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { detectInstalledIDEs, readJSONFile, writeJSONFile, getMCPServerConfig,
|
|
1
|
+
import { detectInstalledIDEs, readJSONFile, writeJSONFile, getMCPServerConfig, isDistillConfigured, success, warn, error, info, log, COLORS, } from "./utils.js";
|
|
2
2
|
import { installHooks } from "./hooks.js";
|
|
3
3
|
function configureIDE(ide, config, force) {
|
|
4
4
|
log(`\nConfiguring ${COLORS.bright}${config.name}${COLORS.reset}...`);
|
|
5
5
|
const existingConfig = readJSONFile(config.configPath) || {};
|
|
6
|
-
if (
|
|
7
|
-
warn(`
|
|
6
|
+
if (isDistillConfigured(existingConfig) && !force) {
|
|
7
|
+
warn(`Distill already configured in ${config.name}. Use --force to overwrite.`);
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
10
|
const mcpServers = existingConfig.mcpServers || {};
|
|
11
|
-
mcpServers.
|
|
11
|
+
mcpServers.distill = getMCPServerConfig();
|
|
12
12
|
existingConfig.mcpServers = mcpServers;
|
|
13
13
|
if (writeJSONFile(config.configPath, existingConfig)) {
|
|
14
14
|
success(`Configured ${config.name} at ${config.configPath}`);
|
|
@@ -20,7 +20,7 @@ function configureIDE(ide, config, force) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
export async function setup(options = {}) {
|
|
23
|
-
log(`\n${COLORS.bright}${COLORS.cyan}
|
|
23
|
+
log(`\n${COLORS.bright}${COLORS.cyan}Distill MCP Server Setup${COLORS.reset}\n`);
|
|
24
24
|
const ideConfigs = detectInstalledIDEs();
|
|
25
25
|
const specificIDEs = options.claude || options.cursor || options.windsurf;
|
|
26
26
|
const hooksOnly = options.hooks && !specificIDEs;
|
|
@@ -53,9 +53,9 @@ export async function setup(options = {}) {
|
|
|
53
53
|
log(" • Cursor");
|
|
54
54
|
log(" • Windsurf");
|
|
55
55
|
log("\nYou can manually configure by running:");
|
|
56
|
-
log("
|
|
57
|
-
log("
|
|
58
|
-
log("
|
|
56
|
+
log(" distill-mcp setup --claude");
|
|
57
|
+
log(" distill-mcp setup --cursor");
|
|
58
|
+
log(" distill-mcp setup --windsurf");
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
if (idesToConfigure.length > 0) {
|
|
@@ -88,8 +88,8 @@ export async function setup(options = {}) {
|
|
|
88
88
|
}
|
|
89
89
|
log(`\n${COLORS.dim}Next steps:${COLORS.reset}`);
|
|
90
90
|
log(" 1. Restart your IDE to load the MCP server");
|
|
91
|
-
log(" 2. Run '
|
|
92
|
-
log(` 3. Visit ${COLORS.cyan}https://
|
|
91
|
+
log(" 2. Run 'distill-mcp doctor' to verify the installation");
|
|
92
|
+
log(` 3. Visit ${COLORS.cyan}https://distill.dev/docs${COLORS.reset} for documentation\n`);
|
|
93
93
|
}
|
|
94
94
|
export function parseSetupArgs(args) {
|
|
95
95
|
const options = {};
|
package/dist/cli/utils.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ export declare function detectInstalledIDEs(): Record<IDE, IDEConfig>;
|
|
|
25
25
|
export declare function readJSONFile(path: string): Record<string, unknown> | null;
|
|
26
26
|
export declare function writeJSONFile(path: string, data: Record<string, unknown>): boolean;
|
|
27
27
|
export declare function getMCPServerConfig(): Record<string, unknown>;
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function isDistillConfigured(config: Record<string, unknown> | null): boolean;
|
|
29
29
|
export declare function getPackageVersion(): string;
|
|
30
30
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/cli/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,MAAM;;;;;;;;;CASlB,CAAC;AAEF,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzC;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAgC1D;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAS5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUzE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAWlF;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM5D;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,MAAM;;;;;;;;;CASlB,CAAC;AAEF,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzC;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAgC1D;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAS5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUzE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAWlF;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM5D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAInF;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C"}
|
package/dist/cli/utils.js
CHANGED
|
@@ -93,16 +93,16 @@ export function writeJSONFile(path, data) {
|
|
|
93
93
|
}
|
|
94
94
|
export function getMCPServerConfig() {
|
|
95
95
|
return {
|
|
96
|
-
command: "
|
|
96
|
+
command: "distill-mcp",
|
|
97
97
|
args: ["serve"],
|
|
98
98
|
env: {},
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
export function
|
|
101
|
+
export function isDistillConfigured(config) {
|
|
102
102
|
if (!config)
|
|
103
103
|
return false;
|
|
104
104
|
const mcpServers = config.mcpServers;
|
|
105
|
-
return mcpServers?.
|
|
105
|
+
return mcpServers?.distill !== undefined;
|
|
106
106
|
}
|
|
107
107
|
export function getPackageVersion() {
|
|
108
108
|
try {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/middleware/chain.js
CHANGED
|
@@ -44,7 +44,7 @@ export class MiddlewareChain {
|
|
|
44
44
|
timestamp: Date.now(),
|
|
45
45
|
});
|
|
46
46
|
// Also log for debugging
|
|
47
|
-
console.error(`[
|
|
47
|
+
console.error(`[distill] Middleware ${middlewareName} ${phase} error:`, err.message);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Execute beforeTool hooks for all middlewares
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sandbox Executor
|
|
3
3
|
*
|
|
4
|
-
* Executes user code in a sandboxed environment with
|
|
4
|
+
* Executes user code in a sandboxed environment with Distill SDK.
|
|
5
5
|
* Uses Function constructor with restricted scope for isolation.
|
|
6
6
|
*/
|
|
7
7
|
import type { ExecutionContext, ExecutionResult } from "./types.js";
|
package/dist/sandbox/executor.js
CHANGED
package/dist/sandbox/index.d.ts
CHANGED
package/dist/sandbox/index.js
CHANGED
package/dist/server.js
CHANGED
|
@@ -45,7 +45,7 @@ export async function createServer(config = {}) {
|
|
|
45
45
|
});
|
|
46
46
|
if (config.verbose) {
|
|
47
47
|
const savings = calculateLazySavings();
|
|
48
|
-
console.error(`[
|
|
48
|
+
console.error(`[distill] Lazy mode: ${savings.savingsPercent}% token savings`);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
else if (mode === "all") {
|
|
@@ -75,7 +75,7 @@ export async function createServer(config = {}) {
|
|
|
75
75
|
});
|
|
76
76
|
// Create MCP server
|
|
77
77
|
const server = new Server({
|
|
78
|
-
name: "
|
|
78
|
+
name: "distill-mcp",
|
|
79
79
|
version: "0.1.0",
|
|
80
80
|
}, {
|
|
81
81
|
capabilities: {
|
|
@@ -124,10 +124,10 @@ export async function runServer(config = {}) {
|
|
|
124
124
|
// Handle server close event
|
|
125
125
|
server.onclose = async () => {
|
|
126
126
|
if (config.verbose) {
|
|
127
|
-
console.error("[
|
|
127
|
+
console.error("[distill] Server connection closed");
|
|
128
128
|
}
|
|
129
129
|
process.exit(0);
|
|
130
130
|
};
|
|
131
131
|
await server.connect(transport);
|
|
132
|
-
console.error("
|
|
132
|
+
console.error("Distill MCP Server running on stdio");
|
|
133
133
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { encodingForModel } from "js-tiktoken";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { ANTHROPIC_MODELS, calculateCost, formatCost, calculateContextUsage, } from "@
|
|
3
|
+
import { ANTHROPIC_MODELS, calculateCost, formatCost, calculateContextUsage, } from "@distill/shared";
|
|
4
4
|
export const analyzeContextSchema = {
|
|
5
5
|
type: "object",
|
|
6
6
|
properties: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code Execute Tool
|
|
3
3
|
*
|
|
4
|
-
* Executes TypeScript code with
|
|
4
|
+
* Executes TypeScript code with Distill SDK in a sandboxed environment.
|
|
5
5
|
* Reduces MCP token overhead by ~98% compared to individual tool calls.
|
|
6
6
|
*/
|
|
7
7
|
import type { ToolDefinition } from "./registry.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code Execute Tool
|
|
3
3
|
*
|
|
4
|
-
* Executes TypeScript code with
|
|
4
|
+
* Executes TypeScript code with Distill SDK in a sandboxed environment.
|
|
5
5
|
* Reduces MCP token overhead by ~98% compared to individual tool calls.
|
|
6
6
|
*/
|
|
7
7
|
import { executeSandbox, DEFAULT_LIMITS } from "../sandbox/index.js";
|
|
@@ -67,7 +67,7 @@ async function executeCodeExecute(args) {
|
|
|
67
67
|
/**
|
|
68
68
|
* Tool description with SDK reference
|
|
69
69
|
*/
|
|
70
|
-
const DESCRIPTION = `Execute TypeScript with
|
|
70
|
+
const DESCRIPTION = `Execute TypeScript with Distill SDK. 98% fewer tokens than tool calls.
|
|
71
71
|
|
|
72
72
|
SDK (ctx):
|
|
73
73
|
compress: auto(content,hint?) logs(logs) diff(diff) semantic(content,ratio?)
|
|
@@ -8,7 +8,7 @@ import { z } from "zod";
|
|
|
8
8
|
import { countTokens } from "../utils/token-counter.js";
|
|
9
9
|
import { detectContentType } from "../utils/content-detector.js";
|
|
10
10
|
import { estimateOutputTokens } from "../utils/output-estimator.js";
|
|
11
|
-
import { ANTHROPIC_MODELS, DEFAULT_MODEL, calculateCost, formatCost, calculateContextUsage, } from "@
|
|
11
|
+
import { ANTHROPIC_MODELS, DEFAULT_MODEL, calculateCost, formatCost, calculateContextUsage, } from "@distill/shared";
|
|
12
12
|
/**
|
|
13
13
|
* JSON Schema for MCP tool registration
|
|
14
14
|
*/
|
|
@@ -30,7 +30,7 @@ export const TOOL_CATALOG = [
|
|
|
30
30
|
name: "code_execute",
|
|
31
31
|
category: "core",
|
|
32
32
|
keywords: ["execute", "code", "sdk", "typescript", "script", "sandbox"],
|
|
33
|
-
description: "Execute TypeScript with
|
|
33
|
+
description: "Execute TypeScript with Distill SDK (98% token savings)",
|
|
34
34
|
loader: async () => (await import("./code-execute.js")).codeExecuteTool,
|
|
35
35
|
},
|
|
36
36
|
// Compress category
|
package/dist/tools/lazy-mcp.js
CHANGED
|
@@ -33,7 +33,7 @@ async function executeBrowseTools(args) {
|
|
|
33
33
|
categories.set(tool.category, (categories.get(tool.category) || 0) + 1);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const lines = ["
|
|
36
|
+
const lines = ["distill/", ""];
|
|
37
37
|
for (const [cat, count] of categories) {
|
|
38
38
|
lines.push(` ${cat}/ (${count} tools)`);
|
|
39
39
|
}
|
|
@@ -48,7 +48,7 @@ async function executeBrowseTools(args) {
|
|
|
48
48
|
content: [{ type: "text", text: `No tools in category: ${category}` }],
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
const lines = [`
|
|
51
|
+
const lines = [`distill/${category}/`, ""];
|
|
52
52
|
for (const tool of tools) {
|
|
53
53
|
lines.push(` ${tool.name}: ${tool.description}`);
|
|
54
54
|
}
|
|
@@ -18,7 +18,7 @@ describe("Lazy MCP Pattern", () => {
|
|
|
18
18
|
it("should list categories when no category specified", async () => {
|
|
19
19
|
const result = await browseToolsTool.execute({});
|
|
20
20
|
const text = result.content[0]?.text ?? "";
|
|
21
|
-
expect(text).toContain("
|
|
21
|
+
expect(text).toContain("distill/");
|
|
22
22
|
expect(text).toContain("compress/");
|
|
23
23
|
expect(text).toContain("analyze/");
|
|
24
24
|
expect(text).toContain("logs/");
|
|
@@ -28,7 +28,7 @@ describe("Lazy MCP Pattern", () => {
|
|
|
28
28
|
it("should list tools in a specific category", async () => {
|
|
29
29
|
const result = await browseToolsTool.execute({ category: "compress" });
|
|
30
30
|
const text = result.content[0]?.text ?? "";
|
|
31
|
-
expect(text).toContain("
|
|
31
|
+
expect(text).toContain("distill/compress/");
|
|
32
32
|
expect(text).toContain("compress_context");
|
|
33
33
|
expect(text).toContain("semantic_compress");
|
|
34
34
|
});
|
|
@@ -125,8 +125,8 @@ export async function optimizationTips(args, _config) {
|
|
|
125
125
|
const result = `${tips}
|
|
126
126
|
|
|
127
127
|
---
|
|
128
|
-
*Tips from
|
|
129
|
-
*Learn more at https://
|
|
128
|
+
*Tips from Distill - LLM Token Optimization*
|
|
129
|
+
*Learn more at https://distill.dev*`;
|
|
130
130
|
return {
|
|
131
131
|
content: [{ type: "text", text: result }],
|
|
132
132
|
};
|
|
@@ -16,7 +16,7 @@ function getEncoder() {
|
|
|
16
16
|
encoder = encodingForModel("gpt-4");
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
|
-
console.error("[
|
|
19
|
+
console.error("[distill] Failed to initialize tiktoken encoder:", error);
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "distill-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1-beta",
|
|
4
4
|
"description": "Distill - MCP Server for LLM token optimization and context compression",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test:coverage": "vitest run --coverage"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@
|
|
32
|
+
"@distill/shared": "workspace:*",
|
|
33
33
|
"@huggingface/transformers": "^3.8.1",
|
|
34
34
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
35
35
|
"js-tiktoken": "^1.0.15",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"repository": {
|
|
58
58
|
"type": "git",
|
|
59
|
-
"url": "https://github.com/ArthurDEV44/
|
|
59
|
+
"url": "https://github.com/ArthurDEV44/distill.git",
|
|
60
60
|
"directory": "packages/mcp-server"
|
|
61
61
|
},
|
|
62
62
|
"license": "MIT"
|
package/scripts/install.ps1
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#
|
|
2
|
-
# https://
|
|
1
|
+
# Distill MCP Server Installation Script for Windows
|
|
2
|
+
# https://distill.dev
|
|
3
3
|
#
|
|
4
4
|
# Usage:
|
|
5
|
-
# irm https://
|
|
5
|
+
# irm https://distill.dev/install.ps1 | iex
|
|
6
6
|
#
|
|
7
7
|
# This script will:
|
|
8
8
|
# 1. Detect your package manager
|
|
9
|
-
# 2. Install
|
|
9
|
+
# 2. Install distill-mcp globally
|
|
10
10
|
# 3. Auto-configure detected IDEs (Claude Code, Cursor, Windsurf)
|
|
11
11
|
# 4. Verify the installation
|
|
12
12
|
|
|
@@ -50,13 +50,13 @@ function Test-NodeVersion {
|
|
|
50
50
|
function Install-Package {
|
|
51
51
|
param([string]$PackageManager)
|
|
52
52
|
|
|
53
|
-
Write-Info "Installing
|
|
53
|
+
Write-Info "Installing distill-mcp using $PackageManager..."
|
|
54
54
|
|
|
55
55
|
switch ($PackageManager) {
|
|
56
|
-
"bun" { bun install -g
|
|
57
|
-
"npm" { npm install -g
|
|
58
|
-
"yarn" { yarn global add
|
|
59
|
-
"pnpm" { pnpm add -g
|
|
56
|
+
"bun" { bun install -g distill-mcp }
|
|
57
|
+
"npm" { npm install -g distill-mcp }
|
|
58
|
+
"yarn" { yarn global add distill-mcp }
|
|
59
|
+
"pnpm" { pnpm add -g distill-mcp }
|
|
60
60
|
default {
|
|
61
61
|
Write-Error "No supported package manager found."
|
|
62
62
|
Write-Host ""
|
|
@@ -74,7 +74,7 @@ function Install-Package {
|
|
|
74
74
|
function Main {
|
|
75
75
|
Write-Host ""
|
|
76
76
|
Write-Host "================================================" -ForegroundColor Cyan
|
|
77
|
-
Write-Host "
|
|
77
|
+
Write-Host " Distill MCP Server Installation" -ForegroundColor Cyan
|
|
78
78
|
Write-Host "================================================" -ForegroundColor Cyan
|
|
79
79
|
Write-Host ""
|
|
80
80
|
|
|
@@ -96,12 +96,12 @@ function Main {
|
|
|
96
96
|
|
|
97
97
|
# Verify installation
|
|
98
98
|
Write-Host ""
|
|
99
|
-
if (Get-Command
|
|
100
|
-
$version =
|
|
99
|
+
if (Get-Command distill-mcp -ErrorAction SilentlyContinue) {
|
|
100
|
+
$version = distill-mcp --version 2>$null
|
|
101
101
|
if (-not $version) { $version = "unknown" }
|
|
102
|
-
Write-Success "
|
|
102
|
+
Write-Success "distill-mcp v$version is now available"
|
|
103
103
|
} else {
|
|
104
|
-
Write-Warning "
|
|
104
|
+
Write-Warning "distill-mcp not found in PATH. You may need to restart your terminal."
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
# Run setup
|
|
@@ -109,11 +109,11 @@ function Main {
|
|
|
109
109
|
Write-Info "Configuring IDEs..."
|
|
110
110
|
Write-Host ""
|
|
111
111
|
|
|
112
|
-
if (Get-Command
|
|
113
|
-
|
|
112
|
+
if (Get-Command distill-mcp -ErrorAction SilentlyContinue) {
|
|
113
|
+
distill-mcp setup
|
|
114
114
|
} else {
|
|
115
115
|
# Fallback to npx if global install didn't add to PATH yet
|
|
116
|
-
npx
|
|
116
|
+
npx distill-mcp setup
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
# Final message
|
|
@@ -122,10 +122,10 @@ function Main {
|
|
|
122
122
|
Write-Host ""
|
|
123
123
|
Write-Host "Next steps:"
|
|
124
124
|
Write-Host " 1. Restart your IDE to load the MCP server"
|
|
125
|
-
Write-Host " 2. Run '
|
|
125
|
+
Write-Host " 2. Run 'distill-mcp doctor' to verify everything is working"
|
|
126
126
|
Write-Host ""
|
|
127
127
|
Write-Host "Documentation: " -NoNewline
|
|
128
|
-
Write-Host "https://
|
|
128
|
+
Write-Host "https://distill.dev/docs" -ForegroundColor Cyan
|
|
129
129
|
Write-Host ""
|
|
130
130
|
}
|
|
131
131
|
|
package/scripts/install.sh
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
# https://
|
|
3
|
+
# Distill MCP Server Installation Script
|
|
4
|
+
# https://distill.dev
|
|
5
5
|
#
|
|
6
6
|
# Usage:
|
|
7
|
-
# curl -fsSL https://
|
|
7
|
+
# curl -fsSL https://distill.dev/install.sh | bash
|
|
8
8
|
#
|
|
9
9
|
# This script will:
|
|
10
10
|
# 1. Detect your OS and package manager
|
|
11
|
-
# 2. Install
|
|
11
|
+
# 2. Install distill-mcp globally
|
|
12
12
|
# 3. Auto-configure detected IDEs (Claude Code, Cursor, Windsurf)
|
|
13
13
|
# 4. Verify the installation
|
|
14
14
|
|
|
@@ -92,20 +92,20 @@ check_node() {
|
|
|
92
92
|
install_package() {
|
|
93
93
|
local pm=$1
|
|
94
94
|
|
|
95
|
-
log "Installing
|
|
95
|
+
log "Installing distill-mcp using $pm..."
|
|
96
96
|
|
|
97
97
|
case "$pm" in
|
|
98
98
|
bun)
|
|
99
|
-
bun install -g
|
|
99
|
+
bun install -g distill-mcp
|
|
100
100
|
;;
|
|
101
101
|
npm)
|
|
102
|
-
npm install -g
|
|
102
|
+
npm install -g distill-mcp
|
|
103
103
|
;;
|
|
104
104
|
yarn)
|
|
105
|
-
yarn global add
|
|
105
|
+
yarn global add distill-mcp
|
|
106
106
|
;;
|
|
107
107
|
pnpm)
|
|
108
|
-
pnpm add -g
|
|
108
|
+
pnpm add -g distill-mcp
|
|
109
109
|
;;
|
|
110
110
|
*)
|
|
111
111
|
error "No supported package manager found."
|
|
@@ -125,7 +125,7 @@ install_package() {
|
|
|
125
125
|
main() {
|
|
126
126
|
echo ""
|
|
127
127
|
echo -e "${BOLD}${CYAN}╔══════════════════════════════════════════╗${NC}"
|
|
128
|
-
echo -e "${BOLD}${CYAN}║
|
|
128
|
+
echo -e "${BOLD}${CYAN}║ Distill MCP Server Installation ║${NC}"
|
|
129
129
|
echo -e "${BOLD}${CYAN}╚══════════════════════════════════════════╝${NC}"
|
|
130
130
|
echo ""
|
|
131
131
|
|
|
@@ -148,11 +148,11 @@ main() {
|
|
|
148
148
|
|
|
149
149
|
# Verify installation
|
|
150
150
|
echo ""
|
|
151
|
-
if command -v
|
|
152
|
-
VERSION=$(
|
|
153
|
-
success "
|
|
151
|
+
if command -v distill-mcp &> /dev/null; then
|
|
152
|
+
VERSION=$(distill-mcp --version 2>/dev/null || echo "unknown")
|
|
153
|
+
success "distill-mcp v$VERSION is now available"
|
|
154
154
|
else
|
|
155
|
-
warn "
|
|
155
|
+
warn "distill-mcp not found in PATH. You may need to restart your terminal."
|
|
156
156
|
fi
|
|
157
157
|
|
|
158
158
|
# Run setup
|
|
@@ -160,11 +160,11 @@ main() {
|
|
|
160
160
|
log "Configuring IDEs..."
|
|
161
161
|
echo ""
|
|
162
162
|
|
|
163
|
-
if command -v
|
|
164
|
-
|
|
163
|
+
if command -v distill-mcp &> /dev/null; then
|
|
164
|
+
distill-mcp setup
|
|
165
165
|
else
|
|
166
166
|
# Fallback to npx if global install didn't add to PATH yet
|
|
167
|
-
npx
|
|
167
|
+
npx distill-mcp setup
|
|
168
168
|
fi
|
|
169
169
|
|
|
170
170
|
# Final message
|
|
@@ -173,9 +173,9 @@ main() {
|
|
|
173
173
|
echo ""
|
|
174
174
|
echo "Next steps:"
|
|
175
175
|
echo " 1. Restart your IDE to load the MCP server"
|
|
176
|
-
echo " 2. Run '
|
|
176
|
+
echo " 2. Run 'distill-mcp doctor' to verify everything is working"
|
|
177
177
|
echo ""
|
|
178
|
-
echo -e "Documentation: ${CYAN}https://
|
|
178
|
+
echo -e "Documentation: ${CYAN}https://distill.dev/docs${NC}"
|
|
179
179
|
echo ""
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
#
|
|
3
|
-
#
|
|
3
|
+
# Distill Pre-commit Hook
|
|
4
4
|
#
|
|
5
5
|
# Warns about files with high token counts that may cause issues
|
|
6
6
|
# with AI coding assistants.
|
|
7
7
|
#
|
|
8
8
|
# Installation:
|
|
9
|
-
#
|
|
9
|
+
# distill-mcp setup --hooks
|
|
10
10
|
# OR
|
|
11
11
|
# cp scripts/pre-commit-hook.sh .git/hooks/pre-commit
|
|
12
12
|
# chmod +x .git/hooks/pre-commit
|
|
@@ -24,17 +24,17 @@ GREEN='\033[0;32m'
|
|
|
24
24
|
CYAN='\033[0;36m'
|
|
25
25
|
NC='\033[0m' # No Color
|
|
26
26
|
|
|
27
|
-
# Check if
|
|
28
|
-
if ! command -v
|
|
27
|
+
# Check if distill-mcp is installed
|
|
28
|
+
if ! command -v distill-mcp &> /dev/null; then
|
|
29
29
|
# Try npx as fallback
|
|
30
30
|
if command -v npx &> /dev/null; then
|
|
31
|
-
CTXOPT_CMD="npx @anthropic-ai/
|
|
31
|
+
CTXOPT_CMD="npx @anthropic-ai/distill-mcp"
|
|
32
32
|
else
|
|
33
|
-
echo -e "${YELLOW}Warning:
|
|
33
|
+
echo -e "${YELLOW}Warning: distill-mcp not found. Skipping token analysis.${NC}"
|
|
34
34
|
exit 0
|
|
35
35
|
fi
|
|
36
36
|
else
|
|
37
|
-
CTXOPT_CMD="
|
|
37
|
+
CTXOPT_CMD="distill-mcp"
|
|
38
38
|
fi
|
|
39
39
|
|
|
40
40
|
# Get staged files (only source code files)
|
|
@@ -54,7 +54,7 @@ for file in $STAGED_FILES; do
|
|
|
54
54
|
fi
|
|
55
55
|
|
|
56
56
|
# Get token count using a simple wc-based estimate
|
|
57
|
-
# More accurate counting requires the full
|
|
57
|
+
# More accurate counting requires the full distill-mcp analyze
|
|
58
58
|
LINES=$(wc -l < "$file" 2>/dev/null || echo "0")
|
|
59
59
|
WORDS=$(wc -w < "$file" 2>/dev/null || echo "0")
|
|
60
60
|
|
|
@@ -72,7 +72,7 @@ done
|
|
|
72
72
|
if [ "$WARNINGS" -gt 0 ]; then
|
|
73
73
|
echo ""
|
|
74
74
|
echo -e "${YELLOW}$WARNINGS file(s) may have high token counts.${NC}"
|
|
75
|
-
echo -e "Consider using
|
|
75
|
+
echo -e "Consider using Distill tools when working with these files:"
|
|
76
76
|
echo -e " - ${CYAN}smart_file_read${NC}: Extract specific functions/classes"
|
|
77
77
|
echo -e " - ${CYAN}code_skeleton${NC}: Get signatures only"
|
|
78
78
|
echo ""
|