mcp-filter 0.2.0 → 0.3.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/README.md +141 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,8 +24,8 @@ npx mcp-filter --exclude "playwright*" -- npx @playwright/mcp
|
|
|
24
24
|
# Include mode: only allow specific tools
|
|
25
25
|
npx mcp-filter --include "browser_navigate" --include "browser_screenshot" -- npx @playwright/mcp
|
|
26
26
|
|
|
27
|
-
# Combination: include with exceptions
|
|
28
|
-
npx mcp-filter --
|
|
27
|
+
# Combination: include with exceptions (order matters!)
|
|
28
|
+
npx mcp-filter --exclude "browser_close" --include "browser_*" -- npx @playwright/mcp
|
|
29
29
|
|
|
30
30
|
# Multiple patterns
|
|
31
31
|
npx mcp-filter --exclude "playwright*" --exclude "unsafe_*" -- npx @playwright/mcp
|
|
@@ -68,18 +68,21 @@ npx mcp-filter --include "browser_navigate" --include "browser_screenshot" -- np
|
|
|
68
68
|
|
|
69
69
|
**Rsync-style filtering**: patterns evaluated in order, first match wins.
|
|
70
70
|
|
|
71
|
+
⚠️ **Common mistake**: Putting `--include` before `--exclude` means the exclude never applies!
|
|
72
|
+
|
|
71
73
|
```bash
|
|
72
|
-
# Example 1: Include first, then exclude
|
|
74
|
+
# Example 1: Include first, then exclude (DOES NOT WORK AS EXPECTED!)
|
|
73
75
|
npx mcp-filter --include "browser_*" --exclude "browser_close" -- npx @playwright/mcp
|
|
74
76
|
# Result: All browser_* tools are INCLUDED (browser_* matched first)
|
|
75
77
|
# browser_close is also included because it matches browser_* first
|
|
78
|
+
# The --exclude "browser_close" is never evaluated!
|
|
76
79
|
|
|
77
|
-
# Example 2: Exclude first, then include (
|
|
80
|
+
# Example 2: Exclude first, then include (CORRECT way to exclude exceptions!)
|
|
78
81
|
npx mcp-filter --exclude "browser_close" --include "browser_*" -- npx @playwright/mcp
|
|
79
82
|
# Result: browser_close is EXCLUDED (matched exclude first)
|
|
80
83
|
# Other browser_* tools are included
|
|
81
84
|
|
|
82
|
-
# Example 3:
|
|
85
|
+
# Example 3: Multiple exclusions, then broad include (recommended pattern)
|
|
83
86
|
npx mcp-filter --exclude "browser_close" --exclude "browser_evaluate" --include "browser_*" -- npx @playwright/mcp
|
|
84
87
|
# Result: browser_close and browser_evaluate excluded (matched first)
|
|
85
88
|
# All other browser_* tools included
|
|
@@ -127,6 +130,139 @@ npx mcp-filter \
|
|
|
127
130
|
# 4. other_tool doesn't match any pattern, but --include exists → excluded (whitelist mode)
|
|
128
131
|
```
|
|
129
132
|
|
|
133
|
+
## Using with Claude Code
|
|
134
|
+
|
|
135
|
+
### Adding Filtered MCP Servers
|
|
136
|
+
|
|
137
|
+
Add filtered MCP servers to Claude Code using the `claude mcp add` command:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Basic syntax
|
|
141
|
+
claude mcp add <name> -- npx mcp-filter [filter-options] -- <upstream-command>
|
|
142
|
+
|
|
143
|
+
# Example: Safe Playwright with read-only browser access
|
|
144
|
+
claude mcp add playwright-safe -- \
|
|
145
|
+
npx mcp-filter \
|
|
146
|
+
--include "browser_navigate" \
|
|
147
|
+
--include "browser_screenshot" \
|
|
148
|
+
--include "browser_snapshot" \
|
|
149
|
+
-- npx @playwright/mcp@latest
|
|
150
|
+
|
|
151
|
+
# Example: Block dangerous operations
|
|
152
|
+
claude mcp add playwright-filtered -- \
|
|
153
|
+
npx mcp-filter \
|
|
154
|
+
--exclude "browser_close" \
|
|
155
|
+
--exclude "browser_evaluate" \
|
|
156
|
+
-- npx @playwright/mcp@latest
|
|
157
|
+
|
|
158
|
+
# Example: Include category with exceptions (rsync-style)
|
|
159
|
+
claude mcp add playwright -- \
|
|
160
|
+
npx mcp-filter \
|
|
161
|
+
--exclude "browser_close" \
|
|
162
|
+
--exclude "browser_evaluate" \
|
|
163
|
+
--include "browser_*" \
|
|
164
|
+
-- npx @playwright/mcp@latest
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Understanding the command structure:**
|
|
168
|
+
|
|
169
|
+
- First `--` separates Claude's options from the mcp-filter command
|
|
170
|
+
- Second `--` separates mcp-filter options from the upstream MCP server command
|
|
171
|
+
|
|
172
|
+
### Scope Options
|
|
173
|
+
|
|
174
|
+
Choose where to store the configuration:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Local scope (default): Only you, only this project
|
|
178
|
+
claude mcp add playwright-safe -- npx mcp-filter --include "browser_*" -- npx @playwright/mcp@latest
|
|
179
|
+
|
|
180
|
+
# User scope: Available across all your projects
|
|
181
|
+
claude mcp add --scope user playwright-safe -- \
|
|
182
|
+
npx mcp-filter --include "browser_*" -- npx @playwright/mcp@latest
|
|
183
|
+
|
|
184
|
+
# Project scope: Share with team via .mcp.json (checked into git)
|
|
185
|
+
claude mcp add --scope project playwright-safe -- \
|
|
186
|
+
npx mcp-filter --include "browser_*" -- npx @playwright/mcp@latest
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**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`.
|
|
190
|
+
|
|
191
|
+
### Managing Filtered Servers
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# List all configured servers
|
|
195
|
+
claude mcp list
|
|
196
|
+
|
|
197
|
+
# Get details for a specific server
|
|
198
|
+
claude mcp get playwright-safe
|
|
199
|
+
|
|
200
|
+
# Remove a server
|
|
201
|
+
claude mcp remove playwright-safe
|
|
202
|
+
|
|
203
|
+
# Check server status in Claude Code
|
|
204
|
+
/mcp
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Practical Examples
|
|
208
|
+
|
|
209
|
+
**Monitoring agent (read-only)**
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
claude mcp add browser-monitor -- \
|
|
213
|
+
npx mcp-filter \
|
|
214
|
+
--include "browser_navigate" \
|
|
215
|
+
--include "browser_snapshot" \
|
|
216
|
+
--include "browser_console_messages" \
|
|
217
|
+
--include "browser_network_requests" \
|
|
218
|
+
--include "browser_take_screenshot" \
|
|
219
|
+
-- npx @playwright/mcp@latest
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Testing agent (no destructive actions)**
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
claude mcp add browser-test -- \
|
|
226
|
+
npx mcp-filter \
|
|
227
|
+
--exclude "browser_close" \
|
|
228
|
+
--exclude "browser_tabs" \
|
|
229
|
+
--exclude "browser_evaluate" \
|
|
230
|
+
--include "browser_*" \
|
|
231
|
+
-- npx @playwright/mcp@latest
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Note: Exclude patterns must come BEFORE the include pattern to match first.
|
|
235
|
+
|
|
236
|
+
**Production debugging (safe operations only)**
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Add as user-scoped for use across projects
|
|
240
|
+
claude mcp add --scope user prod-debugger -- \
|
|
241
|
+
npx mcp-filter \
|
|
242
|
+
--exclude "browser_click" \
|
|
243
|
+
--exclude "browser_type" \
|
|
244
|
+
--exclude "browser_evaluate" \
|
|
245
|
+
--exclude "browser_fill_form" \
|
|
246
|
+
--include "browser_*" \
|
|
247
|
+
-- npx @playwright/mcp@latest
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Updating Server Configuration
|
|
251
|
+
|
|
252
|
+
To update filter rules, remove and re-add the server:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Remove existing configuration
|
|
256
|
+
claude mcp remove playwright-safe
|
|
257
|
+
|
|
258
|
+
# Add with new filter rules
|
|
259
|
+
claude mcp add playwright-safe -- \
|
|
260
|
+
npx mcp-filter \
|
|
261
|
+
--include "browser_navigate" \
|
|
262
|
+
--include "browser_screenshot" \
|
|
263
|
+
-- npx @playwright/mcp@latest
|
|
264
|
+
```
|
|
265
|
+
|
|
130
266
|
## Using with Cursor IDE
|
|
131
267
|
|
|
132
268
|
Add to your `.cursor/mcp.json` or `~/.cursor/mcp.json`:
|