mcp-filter 0.5.0 → 0.6.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.0] - 2025-12-02
9
+
10
+ ### Added
11
+ - **Consola Logging**: Modern CLI output with colors, icons, and semantic log levels
12
+ - `info` for startup information
13
+ - `success` for connection and ready states
14
+ - `error` for errors with actionable messages
15
+ - `fatal` for unrecoverable errors
16
+ - **Argument Validation**: Detects common JSON configuration mistakes
17
+ - Catches combined flag+pattern in single string (e.g., `"--include pattern"`)
18
+ - Catches multiple flags in single string (e.g., `"--include pattern --"`)
19
+ - LLM-friendly error messages with WRONG/CORRECT examples
20
+
21
+ ### Changed
22
+ - **README restructured** for better onboarding (490 → 189 lines)
23
+ - Replaced all `console.*` calls with `consola` logger
24
+
8
25
  ## [0.5.0] - 2025-11-22
9
26
 
10
27
  ### Added
package/README.md CHANGED
@@ -3,406 +3,185 @@
3
3
  [![npm version](https://badge.fury.io/js/mcp-filter.svg)](https://www.npmjs.com/package/mcp-filter)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- MCP server proxy to filter tools, resources, and prompts from upstream MCP servers.
6
+ Filter tools, resources, and prompts from MCP servers. Control what AI agents can access.
7
7
 
8
- ## Installation
9
-
10
- ```bash
11
- npm install -g mcp-filter
12
- # or use with npx
13
- npx mcp-filter [options] -- <upstream-command>
14
- ```
15
-
16
- ## Usage
17
-
18
- ### Local MCP Servers (Stdio Transport)
19
-
20
- ```bash
21
- # Exclude mode: filter out specific tools
22
- npx mcp-filter --exclude "playwright*" -- npx @playwright/mcp
23
-
24
- # Include mode: only allow specific tools
25
- npx mcp-filter --include "browser_navigate" --include "browser_screenshot" -- npx @playwright/mcp
26
-
27
- # Combination: include with exceptions (order matters!)
28
- npx mcp-filter --exclude "browser_close" --include "browser_*" -- npx @playwright/mcp
29
-
30
- # Multiple patterns
31
- npx mcp-filter --exclude "playwright*" --exclude "unsafe_*" -- npx @playwright/mcp
8
+ ## Quick Start
32
9
 
33
- # Use with any local MCP server
34
- npx mcp-filter --exclude "debug*" -- node my-mcp-server.js
35
- ```
36
-
37
- ### Remote MCP Servers (HTTP/SSE Transport)
38
-
39
- ```bash
40
- # Filter remote HTTP server (e.g., Notion, Stripe, Linear)
41
- npx mcp-filter --exclude "delete_*" --upstream-url https://mcp.notion.com/mcp
10
+ Add to your MCP client config (Claude Desktop, Cursor, etc.):
42
11
 
43
- # Filter with custom headers (authentication, etc.)
44
- npx mcp-filter --exclude "admin_*" \
45
- --upstream-url https://api.example.com/mcp \
46
- --header "Authorization: Bearer your-token-here"
47
-
48
- # SSE transport (deprecated, for legacy servers)
49
- npx mcp-filter --transport sse \
50
- --upstream-url https://mcp.asana.com/sse \
51
- --exclude "dangerous_*"
52
-
53
- # Complex filtering with remote servers
54
- npx mcp-filter \
55
- --exclude "delete_*" \
56
- --exclude "update_*" \
57
- --include "read_*" \
58
- --upstream-url https://mcp.example.com/mcp
12
+ ```json
13
+ {
14
+ "mcpServers": {
15
+ "playwright-safe": {
16
+ "command": "npx",
17
+ "args": [
18
+ "mcp-filter",
19
+ "--exclude", "browser_close",
20
+ "--exclude", "browser_evaluate",
21
+ "--include", "browser_*",
22
+ "--",
23
+ "npx", "@playwright/mcp@latest"
24
+ ]
25
+ }
26
+ }
27
+ }
59
28
  ```
60
29
 
61
- ## Options
62
-
63
- ### Filtering Options
64
- - `--exclude <pattern>` - Exclude tools/resources/prompts matching this pattern
65
- - `--include <pattern>` - Include ONLY tools/resources/prompts matching this pattern (whitelist mode)
66
-
67
- ### Transport Options
68
- - `--upstream-url <url>` - Connect to remote HTTP/SSE server (instead of local command)
69
- - `--transport <type>` - Transport type: `stdio`, `http`, `sse` (auto-detected if omitted)
70
- - `--header <header>` - Add HTTP header (format: `"Key: Value"`, HTTP/SSE only, can be repeated)
71
- - `--` - Separates options from local server command (stdio mode only)
30
+ This allows all `browser_*` tools **except** `browser_close` and `browser_evaluate`.
72
31
 
73
- **Note**: `--upstream-url` and `--` are mutually exclusive. Use `--upstream-url` for remote servers, or `-- <command>` for local servers.
32
+ ## Why?
74
33
 
75
- All options can be specified multiple times and combined together.
34
+ - **Security** - Block dangerous tools (eval, delete, admin operations)
35
+ - **Control** - Whitelist only the tools your agent needs
36
+ - **Works everywhere** - Proxy any MCP server (local or remote)
76
37
 
77
- **Filtering style:** rsync-style evaluation where patterns are evaluated in the order specified, and first match wins.
78
-
79
- ## Filtering Modes
80
-
81
- ### Exclude Mode (--exclude only)
82
-
83
- Blocks specific items, allows everything else:
38
+ ## Installation
84
39
 
85
40
  ```bash
86
- # Block browser_close and browser_evaluate tools
87
- npx mcp-filter --exclude "browser_close" --exclude "browser_evaluate" -- npx @playwright/mcp
41
+ npx mcp-filter [options] -- <server-command>
42
+ # or install globally
43
+ npm install -g mcp-filter
88
44
  ```
89
45
 
90
- ### Include Mode (--include only)
46
+ ## How Patterns Work
91
47
 
92
- Allows ONLY specified items, blocks everything else:
48
+ Use `--include` and `--exclude` with glob patterns:
93
49
 
94
50
  ```bash
95
- # Only allow safe, read-only browser tools
96
- npx mcp-filter --include "browser_navigate" --include "browser_screenshot" -- npx @playwright/mcp
51
+ --include "browser_*" # Allow all browser_* tools
52
+ --exclude "browser_close" # Block browser_close
53
+ --exclude "delete_*" # Block all delete_* tools
97
54
  ```
98
55
 
99
- ### Combination Mode (--include + --exclude)
100
-
101
- **Rsync-style filtering**: patterns evaluated in order, first match wins.
102
-
103
- ⚠️ **Common mistake**: Putting `--include` before `--exclude` means the exclude never applies!
56
+ **Order matters!** Patterns are evaluated in order, first match wins:
104
57
 
105
58
  ```bash
106
- # Example 1: Include first, then exclude (DOES NOT WORK AS EXPECTED!)
107
- npx mcp-filter --include "browser_*" --exclude "browser_close" -- npx @playwright/mcp
108
- # Result: All browser_* tools are INCLUDED (browser_* matched first)
109
- # browser_close is also included because it matches browser_* first
110
- # The --exclude "browser_close" is never evaluated!
111
-
112
- # Example 2: Exclude first, then include (CORRECT way to exclude exceptions!)
113
- npx mcp-filter --exclude "browser_close" --include "browser_*" -- npx @playwright/mcp
114
- # Result: browser_close is EXCLUDED (matched exclude first)
115
- # Other browser_* tools are included
116
-
117
- # Example 3: Multiple exclusions, then broad include (recommended pattern)
118
- npx mcp-filter --exclude "browser_close" --exclude "browser_evaluate" --include "browser_*" -- npx @playwright/mcp
119
- # Result: browser_close and browser_evaluate excluded (matched first)
120
- # All other browser_* tools included
121
- ```
122
-
123
- **Key principle**: Order matters! The first pattern that matches determines if the item is included or excluded.
124
-
125
- ## Pattern Examples
126
-
127
- Patterns use glob syntax (via minimatch):
128
-
129
- - `playwright*` - Match all items starting with "playwright"
130
- - `*_admin` - Match all items ending with "\_admin"
131
- - `test_*_debug` - Match items with pattern in middle
132
- - `exact_name` - Match exact name
133
- - `browser_*` - Match all browser-related tools
134
- - `*` - Match everything
135
-
136
- ## Rsync-Style Filtering
137
-
138
- mcp-filter uses rsync-style pattern evaluation:
139
-
140
- 1. **Order matters**: Patterns are evaluated in the order you specify them
141
- 2. **First match wins**: Once a pattern matches, that determines the outcome
142
- 3. **Default behavior**:
143
- - If no patterns specified: allow everything (passthrough)
144
- - If only `--include`: items not matching any include are excluded (whitelist mode)
145
- - If only `--exclude`: items not matching any exclude are included
146
- - If mixed: items not matching any pattern use whitelist mode if includes exist
147
-
148
- **Example workflow**:
59
+ # CORRECT: exclude first, then include
60
+ --exclude "browser_close" --include "browser_*"
61
+ # Result: browser_close blocked, other browser_* allowed
149
62
 
150
- ```bash
151
- # Put more specific patterns first
152
- npx mcp-filter \
153
- --exclude "browser_close" \
154
- --exclude "browser_evaluate" \
155
- --include "browser_*" \
156
- -- npx @playwright/mcp
157
-
158
- # This works because:
159
- # 1. browser_close matches --exclude "browser_close" first → excluded
160
- # 2. browser_evaluate matches --exclude "browser_evaluate" first → excluded
161
- # 3. browser_navigate matches --include "browser_*" → included
162
- # 4. other_tool doesn't match any pattern, but --include exists → excluded (whitelist mode)
63
+ # WRONG: include first (exclude never matches!)
64
+ --include "browser_*" --exclude "browser_close"
65
+ # Result: ALL browser_* allowed (browser_* matches first)
163
66
  ```
164
67
 
165
- ## Using with Claude Code
68
+ ## Configuration
166
69
 
167
- ### Adding Filtered MCP Servers
70
+ ### JSON Config (Claude Desktop, Cursor, VS Code)
168
71
 
169
- Add filtered MCP servers to Claude Code using the `claude mcp add` command:
72
+ Each argument must be a **separate string** in the array:
170
73
 
171
- ```bash
172
- # Basic syntax
173
- claude mcp add <name> -- npx mcp-filter [filter-options] -- <upstream-command>
174
-
175
- # Example: Safe Playwright with read-only browser access
176
- claude mcp add playwright-safe -- \
177
- npx mcp-filter \
178
- --include "browser_navigate" \
179
- --include "browser_screenshot" \
180
- --include "browser_snapshot" \
181
- -- npx @playwright/mcp@latest
182
-
183
- # Example: Block dangerous operations
184
- claude mcp add playwright-filtered -- \
185
- npx mcp-filter \
186
- --exclude "browser_close" \
187
- --exclude "browser_evaluate" \
188
- -- npx @playwright/mcp@latest
189
-
190
- # Example: Include category with exceptions (rsync-style)
191
- claude mcp add playwright -- \
192
- npx mcp-filter \
193
- --exclude "browser_close" \
194
- --exclude "browser_evaluate" \
195
- --include "browser_*" \
196
- -- npx @playwright/mcp@latest
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "my-server": {
78
+ "command": "npx",
79
+ "args": [
80
+ "mcp-filter",
81
+ "--exclude", "dangerous_*",
82
+ "--include", "safe_*",
83
+ "--",
84
+ "npx", "your-mcp-server"
85
+ ]
86
+ }
87
+ }
88
+ }
197
89
  ```
198
90
 
199
- **Understanding the command structure:**
200
-
201
- - First `--` separates Claude's options from the mcp-filter command
202
- - Second `--` separates mcp-filter options from the upstream MCP server command
203
-
204
- ### Scope Options
91
+ **Config file locations:**
92
+ - Claude Desktop: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
93
+ - Cursor: `.cursor/mcp.json` or `~/.cursor/mcp.json`
205
94
 
206
- Choose where to store the configuration:
95
+ ### CLI Usage
207
96
 
208
97
  ```bash
209
- # Local scope (default): Only you, only this project
210
- claude mcp add playwright-safe -- npx mcp-filter --include "browser_*" -- npx @playwright/mcp@latest
98
+ # Local server (stdio)
99
+ npx mcp-filter --exclude "admin_*" -- npx @playwright/mcp
211
100
 
212
- # User scope: Available across all your projects
213
- claude mcp add --scope user playwright-safe -- \
214
- npx mcp-filter --include "browser_*" -- npx @playwright/mcp@latest
101
+ # Remote server (HTTP)
102
+ npx mcp-filter --exclude "delete_*" --upstream-url https://mcp.example.com/mcp
215
103
 
216
- # Project scope: Share with team via .mcp.json (checked into git)
217
- claude mcp add --scope project playwright-safe -- \
218
- npx mcp-filter --include "browser_*" -- npx @playwright/mcp@latest
104
+ # With authentication header
105
+ npx mcp-filter --exclude "admin_*" \
106
+ --upstream-url https://api.example.com/mcp \
107
+ --header "Authorization: Bearer token"
219
108
  ```
220
109
 
221
- **Security Note**: Claude Code prompts for approval before using project-scoped servers from `.mcp.json` files. To reset approval choices, use `claude mcp reset-project-choices`.
222
-
223
- ### Managing Filtered Servers
224
-
225
- ```bash
226
- # List all configured servers
227
- claude mcp list
228
-
229
- # Get details for a specific server
230
- claude mcp get playwright-safe
110
+ ## Common Mistakes
231
111
 
232
- # Remove a server
233
- claude mcp remove playwright-safe
112
+ ### JSON args must be separate strings
234
113
 
235
- # Check server status in Claude Code
236
- /mcp
114
+ **WRONG:**
115
+ ```json
116
+ "args": ["mcp-filter", "--include browser_* --", "npx", "server"]
237
117
  ```
238
118
 
239
- ### Practical Examples
240
-
241
- **Monitoring agent (read-only)**
242
-
243
- ```bash
244
- claude mcp add browser-monitor -- \
245
- npx mcp-filter \
246
- --include "browser_navigate" \
247
- --include "browser_snapshot" \
248
- --include "browser_console_messages" \
249
- --include "browser_network_requests" \
250
- --include "browser_take_screenshot" \
251
- -- npx @playwright/mcp@latest
119
+ **CORRECT:**
120
+ ```json
121
+ "args": ["mcp-filter", "--include", "browser_*", "--", "npx", "server"]
252
122
  ```
253
123
 
254
- **Testing agent (no destructive actions)**
124
+ The shell splits arguments for you. JSON doesn't - you must split them manually.
255
125
 
256
- ```bash
257
- claude mcp add browser-test -- \
258
- npx mcp-filter \
259
- --exclude "browser_close" \
260
- --exclude "browser_tabs" \
261
- --exclude "browser_evaluate" \
262
- --include "browser_*" \
263
- -- npx @playwright/mcp@latest
264
- ```
126
+ mcp-filter detects this and shows a helpful error:
265
127
 
266
- Note: Exclude patterns must come BEFORE the include pattern to match first.
128
+ ```
129
+ Malformed argument: "--include browser_* --"
267
130
 
268
- **Production debugging (safe operations only)**
131
+ WRONG:
132
+ "args": ["--include browser_* --", ...]
269
133
 
270
- ```bash
271
- # Add as user-scoped for use across projects
272
- claude mcp add --scope user prod-debugger -- \
273
- npx mcp-filter \
274
- --exclude "browser_click" \
275
- --exclude "browser_type" \
276
- --exclude "browser_evaluate" \
277
- --exclude "browser_fill_form" \
278
- --include "browser_*" \
279
- -- npx @playwright/mcp@latest
134
+ CORRECT:
135
+ "args": ["--include", "browser_*", "--", ...]
280
136
  ```
281
137
 
282
- ### Updating Server Configuration
138
+ ### Pattern order matters
283
139
 
284
- To update filter rules, remove and re-add the server:
140
+ Put `--exclude` patterns **before** `--include` to create exceptions:
285
141
 
286
142
  ```bash
287
- # Remove existing configuration
288
- claude mcp remove playwright-safe
289
-
290
- # Add with new filter rules
291
- claude mcp add playwright-safe -- \
292
- npx mcp-filter \
293
- --include "browser_navigate" \
294
- --include "browser_screenshot" \
295
- -- npx @playwright/mcp@latest
143
+ # Block browser_close, allow other browser_* tools
144
+ --exclude "browser_close" --include "browser_*"
296
145
  ```
297
146
 
298
- ## Using with Cursor IDE
147
+ ## Options Reference
299
148
 
300
- Add to your `.cursor/mcp.json` or `~/.cursor/mcp.json`:
149
+ | Option | Description |
150
+ |--------|-------------|
151
+ | `--include <pattern>` | Include items matching pattern (whitelist) |
152
+ | `--exclude <pattern>` | Exclude items matching pattern (blocklist) |
153
+ | `--upstream-url <url>` | Connect to remote HTTP/SSE server |
154
+ | `--transport <type>` | Transport: `stdio`, `http`, `sse` (auto-detected) |
155
+ | `--header <header>` | HTTP header (format: `"Key: Value"`) |
156
+ | `--help` | Show help |
301
157
 
302
- ### Example 1: Exclude specific dangerous tools
158
+ Options can be repeated. Patterns use glob syntax via [minimatch](https://github.com/isaacs/minimatch).
303
159
 
304
- ```json
305
- {
306
- "mcpServers": {
307
- "playwright": {
308
- "command": "npx",
309
- "args": [
310
- "mcp-filter",
311
- "--exclude",
312
- "browser_close",
313
- "--exclude",
314
- "browser_evaluate",
315
- "--",
316
- "npx",
317
- "@playwright/mcp@latest"
318
- ]
319
- }
320
- }
321
- }
322
- ```
323
-
324
- ### Example 2: Include safe tools only
160
+ ## How It Works
325
161
 
326
- ```json
327
- {
328
- "mcpServers": {
329
- "playwright-safe": {
330
- "command": "npx",
331
- "args": [
332
- "mcp-filter",
333
- "--include",
334
- "browser_navigate",
335
- "--include",
336
- "browser_screenshot",
337
- "--include",
338
- "browser_snapshot",
339
- "--",
340
- "npx",
341
- "@playwright/mcp@latest"
342
- ]
343
- }
344
- }
345
- }
346
162
  ```
347
-
348
- ### Example 3: Include category with exceptions (rsync-style)
349
-
350
- ```json
351
- {
352
- "mcpServers": {
353
- "playwright-filtered": {
354
- "command": "npx",
355
- "args": [
356
- "mcp-filter",
357
- "--exclude",
358
- "browser_close",
359
- "--exclude",
360
- "browser_evaluate",
361
- "--include",
362
- "browser_*",
363
- "--",
364
- "npx",
365
- "@playwright/mcp@latest"
366
- ]
367
- }
368
- }
369
- }
163
+ MCP Client → mcp-filter → Upstream MCP Server
164
+
165
+ Filters tools/list
166
+ Blocks excluded calls
370
167
  ```
371
168
 
372
- Note: Exclude patterns come first to match before the broader include pattern.
373
-
374
- After adding the configuration, restart Cursor completely to apply the changes.
375
-
376
- ## How It Works
377
-
378
- mcp-filter acts as a proxy between an MCP client and an upstream MCP server:
379
-
380
- 1. Spawns the upstream MCP server as a subprocess
381
- 2. Connects to it as an MCP client
382
- 3. Exposes a filtered MCP server interface
383
- 4. Filters `tools/list`, `resources/list`, and `prompts/list` responses
384
- 5. Blocks calls to filtered items with error responses
169
+ 1. Proxies requests between your MCP client and upstream server
170
+ 2. Filters `tools/list`, `resources/list`, `prompts/list` responses
171
+ 3. Blocks calls to filtered items with error responses
385
172
 
386
173
  ## Development
387
174
 
388
175
  ```bash
389
- # Install dependencies
390
176
  pnpm install
391
-
392
- # Build
393
177
  pnpm run build
394
-
395
- # Run tests
396
178
  pnpm test
397
-
398
- # Test locally
399
- ./dist/index.js --exclude "playwright*" -- npx tsx test-server.ts
400
179
  ```
401
180
 
402
181
  ## Links
403
182
 
404
183
  - [npm package](https://www.npmjs.com/package/mcp-filter)
405
- - [GitHub repository](https://github.com/baranovxyz/mcp-filter)
184
+ - [GitHub](https://github.com/baranovxyz/mcp-filter)
406
185
 
407
186
  ## License
408
187
 
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAGb,MAAM,YAAY,CAAC;AAEpB,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,YAAY,CAkKtD"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAGb,MAAM,YAAY,CAAC;AAwCpB,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,YAAY,CAoKtD"}
package/dist/cli.js CHANGED
@@ -1,4 +1,38 @@
1
+ /**
2
+ * Validates arguments for common JSON configuration mistakes.
3
+ * In JSON configs, each argument must be a separate array element.
4
+ * This catches cases like ["--include pattern"] instead of ["--include", "pattern"].
5
+ */
6
+ function validateArgs(args) {
7
+ for (const arg of args) {
8
+ // Detect combined flag+value: "--include pattern" or "--exclude pattern"
9
+ if (/^--(include|exclude)\s+/.test(arg)) {
10
+ const parts = arg.split(/\s+/);
11
+ const flag = parts[0];
12
+ const pattern = parts.slice(1).join(" ");
13
+ throw new Error(`Malformed argument: "${arg}"\n\n` +
14
+ `In JSON config, each argument must be a separate string.\n\n` +
15
+ `WRONG:\n` +
16
+ ` "args": ["${arg}", ...]\n\n` +
17
+ `CORRECT:\n` +
18
+ ` "args": ["${flag}", "${pattern}", ...]\n\n` +
19
+ `Split the argument into separate array elements.`);
20
+ }
21
+ // Detect multiple flags in one string: "--include pattern --" or "--exclude foo --include bar"
22
+ if (arg.startsWith("--") && / --/.test(arg)) {
23
+ throw new Error(`Malformed argument: "${arg}"\n\n` +
24
+ `Multiple flags found in single argument. In JSON config, each must be separate.\n\n` +
25
+ `WRONG:\n` +
26
+ ` "args": ["${arg}", ...]\n\n` +
27
+ `CORRECT:\n` +
28
+ ` "args": ["--include", "pattern", "--", ...]\n\n` +
29
+ `Split into separate array elements.`);
30
+ }
31
+ }
32
+ }
1
33
  export function parseArgs(args) {
34
+ // Validate for common JSON config mistakes before parsing
35
+ validateArgs(args);
2
36
  const patterns = [];
3
37
  const upstreamCommand = [];
4
38
  let upstreamUrl;
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,IAAI,WAA+B,CAAC;IACpC,IAAI,iBAA4C,CAAC;IACjD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAE9B,KAAK,IAAI,CAAC,G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,CAAC;IAED,OAAO;QACL,QAAQ;QACR,eAAe;KAChB,CAAC;AACJ,CAAC"}
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { parseArgs } from "./cli.js";
4
4
  import { Filter } from "./filter.js";
5
+ import { logger } from "./logger.js";
5
6
  import { ProxyServer } from "./proxy.js";
6
7
  import { createClientTransport } from "./transport.js";
7
8
  async function main() {
@@ -12,88 +13,69 @@ async function main() {
12
13
  config = parseArgs(args);
13
14
  }
14
15
  catch (error) {
16
+ const helpText = `Usage:
17
+ mcp-filter [options] -- <command> [args...] # stdio transport
18
+ mcp-filter [options] --upstream-url <url> # HTTP transport
19
+
20
+ Options:
21
+ --exclude <pattern> Exclude items matching pattern
22
+ --include <pattern> Include items matching pattern
23
+ --upstream-url <url> Connect to HTTP/SSE server (mutually exclusive with --)
24
+ --transport <type> Transport type: stdio, http, sse (auto-detected if omitted)
25
+ --header <header> Add HTTP header (format: 'Key: Value', HTTP/SSE only)
26
+ --help, -h Show this help message
27
+
28
+ Examples:
29
+ # Stdio transport (local servers)
30
+ mcp-filter --exclude "test*" -- npx tsx test-server.ts
31
+
32
+ # HTTP transport (remote servers)
33
+ mcp-filter --exclude "dangerous_*" --upstream-url https://mcp.notion.com/mcp
34
+
35
+ # SSE transport (deprecated, legacy servers)
36
+ mcp-filter --transport sse --upstream-url https://mcp.asana.com/sse`;
15
37
  if (error.message === "help") {
16
- console.log("Usage:");
17
- console.log(" mcp-filter [options] -- <command> [args...] # stdio transport");
18
- console.log(" mcp-filter [options] --upstream-url <url> # HTTP transport");
19
- console.log("");
20
- console.log("Options:");
21
- console.log(" --exclude <pattern> Exclude items matching pattern");
22
- console.log(" --include <pattern> Include items matching pattern");
23
- console.log(" --upstream-url <url> Connect to HTTP/SSE server (mutually exclusive with --)");
24
- console.log(" --transport <type> Transport type: stdio, http, sse (auto-detected if omitted)");
25
- console.log(" --header <header> Add HTTP header (format: 'Key: Value', HTTP/SSE only)");
26
- console.log(" --help, -h Show this help message");
27
- console.log("");
28
- console.log("Examples:");
29
- console.log(" # Stdio transport (local servers)");
30
- console.log(' mcp-filter --exclude "test*" -- npx tsx test-server.ts');
31
- console.log("");
32
- console.log(" # HTTP transport (remote servers)");
33
- console.log(' mcp-filter --exclude "dangerous_*" --upstream-url https://mcp.notion.com/mcp');
34
- console.log("");
35
- console.log(" # SSE transport (deprecated, legacy servers)");
36
- console.log(' mcp-filter --transport sse --upstream-url https://mcp.asana.com/sse');
38
+ logger.log(helpText);
37
39
  process.exit(0);
38
40
  }
39
- console.error(`Error: ${error.message}`);
40
- console.error("");
41
- console.error("Usage:");
42
- console.error(" mcp-filter [options] -- <command> [args...] # stdio transport");
43
- console.error(" mcp-filter [options] --upstream-url <url> # HTTP transport");
44
- console.error("");
45
- console.error("Options:");
46
- console.error(" --exclude <pattern> Exclude items matching pattern");
47
- console.error(" --include <pattern> Include items matching pattern");
48
- console.error(" --upstream-url <url> Connect to HTTP/SSE server (mutually exclusive with --)");
49
- console.error(" --transport <type> Transport type: stdio, http, sse (auto-detected if omitted)");
50
- console.error(" --header <header> Add HTTP header (format: 'Key: Value', HTTP/SSE only)");
51
- console.error("");
52
- console.error("Examples:");
53
- console.error(" # Stdio transport (local servers)");
54
- console.error(' mcp-filter --exclude "test*" -- npx tsx test-server.ts');
55
- console.error("");
56
- console.error(" # HTTP transport (remote servers)");
57
- console.error(' mcp-filter --exclude "dangerous_*" --upstream-url https://mcp.notion.com/mcp');
58
- console.error("");
59
- console.error(" # SSE transport (deprecated, legacy servers)");
60
- console.error(' mcp-filter --transport sse --upstream-url https://mcp.asana.com/sse');
41
+ logger.error(error.message);
42
+ logger.log(helpText);
61
43
  process.exit(1);
62
44
  }
63
- console.error(`Starting MCP filter with ${config.patterns.length} pattern(s)`);
64
- config.patterns.forEach((p) => console.error(` ${p.type === "include" ? "Include" : "Exclude"}: ${p.pattern}`));
45
+ logger.info(`Starting MCP filter with ${config.patterns.length} pattern(s)`);
46
+ config.patterns.forEach((p) => logger.info(` ${p.type === "include" ? "Include" : "Exclude"}: ${p.pattern}`));
65
47
  const hasInclude = config.patterns.some((p) => p.type === "include");
66
48
  const hasExclude = config.patterns.some((p) => p.type === "exclude");
67
49
  if (hasInclude && hasExclude) {
68
- console.error("Note: Using rsync-style filtering - patterns evaluated in order, first match wins.");
50
+ logger.info("Note: Using rsync-style filtering - patterns evaluated in order, first match wins.");
69
51
  }
70
- console.error(`Transport: ${config.transportConfig.type}`);
52
+ logger.info(`Transport: ${config.transportConfig.type}`);
71
53
  // Create filter
72
54
  const filter = new Filter(config.patterns);
73
55
  // Create proxy server
74
56
  const proxy = new ProxyServer({
75
57
  name: "mcp-filter",
76
- version: "0.5.0",
58
+ version: "0.6.0",
77
59
  }, filter);
78
60
  // Connect client to upstream server
79
61
  // Transport factory handles creating the appropriate transport (stdio, http, sse)
80
62
  const clientTransport = createClientTransport(config.transportConfig);
81
63
  await proxy.getClient().connect(clientTransport);
82
- console.error("Connected to upstream server");
64
+ logger.success("Connected to upstream server");
83
65
  // Connect server to current process stdio (for the MCP client calling us)
84
66
  const serverTransport = new StdioServerTransport();
85
67
  await proxy.getServer().connect(serverTransport);
86
- console.error("MCP filter proxy ready");
68
+ logger.success("MCP filter proxy ready");
87
69
  // Handle cleanup
88
70
  const cleanup = () => {
89
- console.error("Shutting down...");
71
+ logger.info("Shutting down...");
90
72
  process.exit(0);
91
73
  };
92
74
  process.on("SIGINT", cleanup);
93
75
  process.on("SIGTERM", cleanup);
94
76
  }
95
77
  main().catch((error) => {
96
- console.error("Fatal error:", error);
78
+ logger.fatal(error);
97
79
  process.exit(1);
98
80
  });
99
81
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAA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CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const logger: import("consola").ConsolaInstance;
2
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,mCAEjB,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,6 @@
1
+ import { createConsola } from "consola";
2
+ // Create logger that outputs to stderr to not interfere with MCP JSON-RPC on stdout
3
+ export const logger = createConsola({
4
+ stderr: process.stderr,
5
+ });
6
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,oFAAoF;AACpF,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC;IAClC,MAAM,EAAE,OAAO,CAAC,MAAM;CACvB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-filter",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "MCP server proxy to filter tools, resources, and prompts from upstream MCP servers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,6 +37,7 @@
37
37
  "url": "https://github.com/baranovxyz/mcp-filter/issues"
38
38
  },
39
39
  "dependencies": {
40
+ "consola": "3.4.2",
40
41
  "minimatch": "10.0.1"
41
42
  },
42
43
  "peerDependencies": {