contextguard 0.1.3 → 0.1.4
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 +2 -17
- package/{security.json → config.json} +3 -3
- package/dist/mcp-security-wrapper.js +6 -2
- package/mcp-server-demo/package-lock.json +978 -0
- package/mcp-server-demo/package.json +16 -0
- package/mcp-server-demo/pnpm-lock.yaml +745 -0
- package/mcp-server-demo/test-server.js +228 -0
- package/mcp-server-demo/test.md +393 -0
- package/mcp_security.log +7 -2
- package/package.json +2 -2
- package/src/mcp-security-wrapper.ts +9 -2
package/README.md
CHANGED
|
@@ -55,20 +55,6 @@ Zero code changes needed. Less than 1% overhead.
|
|
|
55
55
|
✅ **Rate limiting** - Prevents abuse
|
|
56
56
|
✅ **Comprehensive logging** - JSON format with severity levels
|
|
57
57
|
|
|
58
|
-
## Quick Start
|
|
59
|
-
|
|
60
|
-
### Installation
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
npm install -g ContextGuard
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Basic Usage
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
ContextGuard --server "node /path/to/mcp-server.js"
|
|
70
|
-
```
|
|
71
|
-
|
|
72
58
|
### Claude Desktop Integration
|
|
73
59
|
|
|
74
60
|
Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
@@ -78,7 +64,7 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
78
64
|
"mcpServers": {
|
|
79
65
|
"secure-server": {
|
|
80
66
|
"command": "npx",
|
|
81
|
-
"args": ["-y", "
|
|
67
|
+
"args": ["-y", "contextguard", "--server", "node /path/to/your-server.js"]
|
|
82
68
|
}
|
|
83
69
|
}
|
|
84
70
|
}
|
|
@@ -100,7 +86,7 @@ Create `security.json`:
|
|
|
100
86
|
Then run:
|
|
101
87
|
|
|
102
88
|
```bash
|
|
103
|
-
|
|
89
|
+
contextguard --server "node server.js" --config security.json
|
|
104
90
|
```
|
|
105
91
|
|
|
106
92
|
## Security Events
|
|
@@ -154,7 +140,6 @@ npm test
|
|
|
154
140
|
|
|
155
141
|
- **Issues**: [GitHub Issues](https://github.com/amironi/contextguard/issues)
|
|
156
142
|
- **Email**: amir@mironi.co.il
|
|
157
|
-
<!-- - **Twitter**: [@yourusername](https://twitter.com/yourusername) -->
|
|
158
143
|
|
|
159
144
|
---
|
|
160
145
|
|
|
@@ -266,7 +266,7 @@ class MCPSecurityWrapper {
|
|
|
266
266
|
message.params?.arguments?.directory,
|
|
267
267
|
message.params?.path,
|
|
268
268
|
message.params?.filePath,
|
|
269
|
-
].filter((path) => typeof path ===
|
|
269
|
+
].filter((path) => typeof path === "string");
|
|
270
270
|
for (const filePath of filePathParams) {
|
|
271
271
|
const fileViolations = this.policy.checkFileAccess(filePath);
|
|
272
272
|
violations.push(...fileViolations);
|
|
@@ -360,6 +360,9 @@ Options:
|
|
|
360
360
|
--config <file> Path to security config JSON file (optional)
|
|
361
361
|
--help Show this help message
|
|
362
362
|
|
|
363
|
+
Config file options:
|
|
364
|
+
logPath: Custom path for security log file (default: ./mcp_security.log)
|
|
365
|
+
|
|
363
366
|
Example:
|
|
364
367
|
npx ts-node mcp-security-wrapper.ts --server "node server.js" --config security.json
|
|
365
368
|
`);
|
|
@@ -386,8 +389,9 @@ Example:
|
|
|
386
389
|
config = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
387
390
|
}
|
|
388
391
|
const policy = new SecurityPolicy(config);
|
|
389
|
-
const logger = new SecurityLogger();
|
|
392
|
+
const logger = new SecurityLogger(config.logPath);
|
|
390
393
|
const wrapper = new MCPSecurityWrapper(serverCommand.split(" "), policy, logger);
|
|
394
|
+
console.log("ContextGuard is running");
|
|
391
395
|
await wrapper.start();
|
|
392
396
|
}
|
|
393
397
|
if (require.main === module) {
|