contextguard 0.1.7 → 0.2.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/LICENSE +23 -17
- package/README.md +157 -109
- package/dist/agent.d.ts +24 -0
- package/dist/agent.js +369 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +266 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.js +56 -0
- package/dist/database.d.ts +116 -0
- package/dist/database.js +291 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +18 -0
- package/dist/init.d.ts +7 -0
- package/dist/init.js +173 -0
- package/dist/lib/supabase-client.d.ts +27 -0
- package/dist/lib/supabase-client.js +97 -0
- package/dist/logger.d.ts +36 -0
- package/dist/logger.js +145 -0
- package/dist/mcp-security-wrapper.d.ts +84 -0
- package/dist/mcp-security-wrapper.js +394 -120
- package/dist/mcp-traceability-integration.d.ts +118 -0
- package/dist/mcp-traceability-integration.js +302 -0
- package/dist/policy.d.ts +30 -0
- package/dist/policy.js +273 -0
- package/dist/premium-features.d.ts +364 -0
- package/dist/premium-features.js +950 -0
- package/dist/security-logger.d.ts +45 -0
- package/dist/security-logger.js +125 -0
- package/dist/security-policy.d.ts +55 -0
- package/dist/security-policy.js +140 -0
- package/dist/semantic-detector.d.ts +21 -0
- package/dist/semantic-detector.js +49 -0
- package/dist/sse-proxy.d.ts +21 -0
- package/dist/sse-proxy.js +276 -0
- package/dist/supabase-client.d.ts +27 -0
- package/dist/supabase-client.js +89 -0
- package/dist/types/database.types.d.ts +220 -0
- package/dist/types/database.types.js +8 -0
- package/dist/types/mcp.d.ts +27 -0
- package/dist/types/mcp.js +15 -0
- package/dist/types/types.d.ts +65 -0
- package/dist/types/types.js +8 -0
- package/dist/types.d.ts +84 -0
- package/dist/types.js +8 -0
- package/dist/wrapper.d.ts +115 -0
- package/dist/wrapper.js +417 -0
- package/package.json +35 -10
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -57
- package/CONTRIBUTING.md +0 -532
- package/SECURITY.md +0 -254
- package/assets/demo.mp4 +0 -0
- package/eslint.config.mts +0 -23
- package/examples/config/config.json +0 -19
- package/examples/mcp-server/demo.js +0 -228
- package/examples/mcp-server/package-lock.json +0 -978
- package/examples/mcp-server/package.json +0 -16
- package/examples/mcp-server/pnpm-lock.yaml +0 -745
- package/src/mcp-security-wrapper.ts +0 -529
- package/test/test-server.ts +0 -295
- package/tsconfig.json +0 -16
package/SECURITY.md
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Our Commitment
|
|
4
|
-
|
|
5
|
-
ContextGuard is a security tool designed to protect MCP servers from various attack vectors. We take the security of ContextGuard itself very seriously. If you discover a security vulnerability, we appreciate your help in disclosing it to us responsibly.
|
|
6
|
-
|
|
7
|
-
## Supported Versions
|
|
8
|
-
|
|
9
|
-
We release patches for security vulnerabilities for the following versions:
|
|
10
|
-
|
|
11
|
-
| Version | Supported |
|
|
12
|
-
| ------- | ------------------ |
|
|
13
|
-
| 0.1.x | :white_check_mark: |
|
|
14
|
-
| < 0.1 | :x: |
|
|
15
|
-
|
|
16
|
-
## What We Protect Against
|
|
17
|
-
|
|
18
|
-
ContextGuard currently detects and prevents:
|
|
19
|
-
|
|
20
|
-
### High Severity Threats
|
|
21
|
-
|
|
22
|
-
- **Prompt Injection Attacks**: 8+ patterns including instruction hijacking, role manipulation, and context escape attempts
|
|
23
|
-
- **Sensitive Data Leakage**: API keys, passwords, private keys, SSH keys, database credentials, social security numbers
|
|
24
|
-
- **Path Traversal Attacks**: Unauthorized file system access attempts using relative paths or escape sequences
|
|
25
|
-
|
|
26
|
-
### Medium Severity Threats
|
|
27
|
-
|
|
28
|
-
- **Rate Limit Violations**: Prevents abuse through excessive requests
|
|
29
|
-
- **Suspicious Input Patterns**: Anomalous request structures that may indicate reconnaissance
|
|
30
|
-
|
|
31
|
-
### Logging & Monitoring
|
|
32
|
-
|
|
33
|
-
- **Comprehensive Event Logging**: All security events logged with timestamps and severity levels
|
|
34
|
-
- **Forensic Analysis**: Detailed logs for post-incident investigation
|
|
35
|
-
|
|
36
|
-
## Known Limitations
|
|
37
|
-
|
|
38
|
-
ContextGuard is a defense-in-depth tool and should not be your only security measure:
|
|
39
|
-
|
|
40
|
-
### Current Limitations
|
|
41
|
-
|
|
42
|
-
- **Evasion Techniques**: Sophisticated attackers may use encoding, obfuscation, or novel patterns to bypass detection
|
|
43
|
-
- **False Positives**: Some legitimate requests may be flagged as suspicious
|
|
44
|
-
- **Performance**: While overhead is <1%, extremely high-throughput scenarios should be tested
|
|
45
|
-
- **Transport Support**: Currently only stdio transport is fully supported (SSE/HTTP in development)
|
|
46
|
-
|
|
47
|
-
### Not Protected Against
|
|
48
|
-
|
|
49
|
-
- **Zero-day MCP vulnerabilities**: Unknown vulnerabilities in the MCP protocol itself
|
|
50
|
-
- **Server-side vulnerabilities**: Bugs in your MCP server implementation
|
|
51
|
-
- **Network-level attacks**: DDoS, man-in-the-middle (requires network-level protection)
|
|
52
|
-
- **Compromised dependencies**: Supply chain attacks in your MCP server's dependencies
|
|
53
|
-
|
|
54
|
-
## Reporting a Vulnerability
|
|
55
|
-
|
|
56
|
-
**Please DO NOT report security vulnerabilities through public GitHub issues.**
|
|
57
|
-
|
|
58
|
-
### How to Report
|
|
59
|
-
|
|
60
|
-
1. **Email**: Send details to [amir@mironi.co.il](mailto:amir@mironi.co.il)
|
|
61
|
-
- Subject: "SECURITY: [Brief Description]"
|
|
62
|
-
2. **Include**:
|
|
63
|
-
|
|
64
|
-
- Type of vulnerability
|
|
65
|
-
- Full paths of source file(s) related to the vulnerability
|
|
66
|
-
- Location of affected source code (tag/branch/commit or direct URL)
|
|
67
|
-
- Step-by-step instructions to reproduce
|
|
68
|
-
- Proof-of-concept or exploit code (if available)
|
|
69
|
-
- Impact assessment
|
|
70
|
-
- Any potential fixes you've considered
|
|
71
|
-
|
|
72
|
-
3. **Response Time**:
|
|
73
|
-
- Initial response: Within 48 hours
|
|
74
|
-
- Status update: Within 7 days
|
|
75
|
-
- Fix timeline: Depends on severity
|
|
76
|
-
|
|
77
|
-
### What to Expect
|
|
78
|
-
|
|
79
|
-
After you submit a report:
|
|
80
|
-
|
|
81
|
-
1. **Acknowledgment**: We'll confirm receipt within 48 hours
|
|
82
|
-
2. **Assessment**: We'll investigate and determine severity
|
|
83
|
-
3. **Communication**: We'll keep you updated on progress
|
|
84
|
-
4. **Fix Development**: We'll work on a patch
|
|
85
|
-
5. **Disclosure**: We'll coordinate public disclosure with you
|
|
86
|
-
6. **Credit**: We'll credit you (unless you prefer anonymity)
|
|
87
|
-
|
|
88
|
-
### Severity Levels
|
|
89
|
-
|
|
90
|
-
We use the following severity scale:
|
|
91
|
-
|
|
92
|
-
| Severity | Description | Response Time |
|
|
93
|
-
| ------------ | -------------------------------------------------- | --------------- |
|
|
94
|
-
| **Critical** | Remote code execution, complete bypass of security | Immediate (24h) |
|
|
95
|
-
| **High** | Unauthorized data access, privilege escalation | 3-7 days |
|
|
96
|
-
| **Medium** | Denial of service, partial bypass | 7-14 days |
|
|
97
|
-
| **Low** | Minor information disclosure, edge cases | 14-30 days |
|
|
98
|
-
|
|
99
|
-
## Security Best Practices
|
|
100
|
-
|
|
101
|
-
When using ContextGuard:
|
|
102
|
-
|
|
103
|
-
### Deployment Recommendations
|
|
104
|
-
|
|
105
|
-
1. **Defense in Depth**
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
# Use ContextGuard as ONE layer of security
|
|
109
|
-
# Also implement:
|
|
110
|
-
# - Network firewalls
|
|
111
|
-
# - Rate limiting at API gateway
|
|
112
|
-
# - Authentication/authorization
|
|
113
|
-
# - Input validation in your MCP server
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
2. **Configuration Security**
|
|
117
|
-
|
|
118
|
-
```json
|
|
119
|
-
{
|
|
120
|
-
"maxToolCallsPerMinute": 30,
|
|
121
|
-
"enablePromptInjectionDetection": true,
|
|
122
|
-
"enableSensitiveDataDetection": true,
|
|
123
|
-
"allowedFilePaths": ["/safe/directory/only"],
|
|
124
|
-
"logLevel": "info"
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
3. **Least Privilege**
|
|
129
|
-
|
|
130
|
-
- Run ContextGuard with minimal required permissions
|
|
131
|
-
- Restrict file system access to only necessary directories
|
|
132
|
-
- Use environment variables for secrets, never hardcode
|
|
133
|
-
|
|
134
|
-
4. **Regular Updates**
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
# Check for updates regularly
|
|
138
|
-
npm update -g contextguard
|
|
139
|
-
|
|
140
|
-
# Subscribe to security advisories
|
|
141
|
-
npm audit
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
5. **Monitor Logs**
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
# Review security logs regularly
|
|
148
|
-
tail -f mcp_security.log | grep "SECURITY_VIOLATION"
|
|
149
|
-
|
|
150
|
-
# Set up alerts for HIGH severity events
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Testing Security
|
|
154
|
-
|
|
155
|
-
Before production deployment:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
# 1. Test with known attack patterns
|
|
159
|
-
contextguard --server "node test-server.js" --config test-security.json
|
|
160
|
-
|
|
161
|
-
# 2. Review logs for false positives
|
|
162
|
-
cat mcp_security.log | jq 'select(.severity == "HIGH")'
|
|
163
|
-
|
|
164
|
-
# 3. Performance testing
|
|
165
|
-
# Ensure <1% overhead in your specific environment
|
|
166
|
-
|
|
167
|
-
# 4. Backup and recovery
|
|
168
|
-
# Test your incident response plan
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Security Audit History
|
|
172
|
-
|
|
173
|
-
| Date | Auditor | Scope | Status |
|
|
174
|
-
| ---- | ------- | ------------- | ------- |
|
|
175
|
-
| TBD | TBD | Full codebase | Planned |
|
|
176
|
-
|
|
177
|
-
We plan to conduct regular security audits as the project matures.
|
|
178
|
-
|
|
179
|
-
## Security-Related Configuration
|
|
180
|
-
|
|
181
|
-
### Example Production Configuration
|
|
182
|
-
|
|
183
|
-
```json
|
|
184
|
-
{
|
|
185
|
-
"maxToolCallsPerMinute": 30,
|
|
186
|
-
"enablePromptInjectionDetection": true,
|
|
187
|
-
"enableSensitiveDataDetection": true,
|
|
188
|
-
"enablePathTraversalPrevention": true,
|
|
189
|
-
"allowedFilePaths": ["/var/app/data", "/home/user/safe-directory"],
|
|
190
|
-
"blockedPatterns": [
|
|
191
|
-
"ignore previous instructions",
|
|
192
|
-
"system prompt",
|
|
193
|
-
"confidential"
|
|
194
|
-
],
|
|
195
|
-
"logLevel": "info",
|
|
196
|
-
"logFile": "/tmp/mcp_security.log",
|
|
197
|
-
"alertWebhook": "https://your-monitoring-service.com/webhook"
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Environment Variables
|
|
202
|
-
|
|
203
|
-
Never store secrets in configuration files:
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
# Good
|
|
207
|
-
export MCP_API_KEY="your-key-here"
|
|
208
|
-
contextguard --server "node server.js"
|
|
209
|
-
|
|
210
|
-
# Bad
|
|
211
|
-
# Don't hardcode secrets in config files or code
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
## Vulnerability Disclosure Policy
|
|
215
|
-
|
|
216
|
-
### Our Commitment
|
|
217
|
-
|
|
218
|
-
- We will respond to your report within 48 hours
|
|
219
|
-
- We will keep you informed of our progress
|
|
220
|
-
- We will not take legal action against security researchers who:
|
|
221
|
-
- Act in good faith
|
|
222
|
-
- Avoid privacy violations and service disruption
|
|
223
|
-
- Give us reasonable time to fix issues before disclosure
|
|
224
|
-
|
|
225
|
-
### Public Disclosure
|
|
226
|
-
|
|
227
|
-
- **Coordinated Disclosure**: We prefer to fix vulnerabilities before public disclosure
|
|
228
|
-
- **Timeline**: We aim to release fixes within 90 days of initial report
|
|
229
|
-
- **Credit**: We will publicly thank reporters (unless they prefer anonymity)
|
|
230
|
-
- **CVE Assignment**: Critical vulnerabilities will receive CVE identifiers
|
|
231
|
-
|
|
232
|
-
## Contact
|
|
233
|
-
|
|
234
|
-
- **Security Issues**: [amir@mironi.co.il](mailto:amir@mironi.co.il)
|
|
235
|
-
- **General Questions**: [GitHub Issues](https://github.com/amironi/contextguard/issues)
|
|
236
|
-
- **PGP Key**: Coming soon
|
|
237
|
-
|
|
238
|
-
## Attribution
|
|
239
|
-
|
|
240
|
-
We appreciate the security research community. Past contributors:
|
|
241
|
-
|
|
242
|
-
- _Your name could be here!_
|
|
243
|
-
|
|
244
|
-
## Resources
|
|
245
|
-
|
|
246
|
-
- [OWASP Top 10 for LLMs](https://owasp.org/www-project-top-10-for-large-language-model-applications/)
|
|
247
|
-
- [MCP Security Best Practices](https://modelcontextprotocol.io/docs/security)
|
|
248
|
-
- [Prompt Injection Defense](https://simonwillison.net/2023/Apr/14/worst-that-can-happen/)
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
**Last Updated**: October 2025
|
|
253
|
-
|
|
254
|
-
Thank you for helping keep ContextGuard and its users safe!
|
package/assets/demo.mp4
DELETED
|
File without changes
|
package/eslint.config.mts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import tseslint from "typescript-eslint";
|
|
4
|
-
import { defineConfig } from "eslint/config";
|
|
5
|
-
|
|
6
|
-
export default defineConfig([
|
|
7
|
-
{
|
|
8
|
-
ignores: ["dist/**", "node_modules/**"],
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
|
|
12
|
-
plugins: { js },
|
|
13
|
-
extends: ["js/recommended"],
|
|
14
|
-
languageOptions: { globals: globals.browser },
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
rules: {
|
|
18
|
-
// "no-unused-vars": "warn",
|
|
19
|
-
// "no-explicit-any": "info",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
tseslint.configs.recommended,
|
|
23
|
-
]);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"maxToolCallsPerMinute": 30,
|
|
3
|
-
"blockedPatterns": [
|
|
4
|
-
"ignore previous instructions",
|
|
5
|
-
"system prompt",
|
|
6
|
-
"confidential"
|
|
7
|
-
],
|
|
8
|
-
"allowedFilePaths": [
|
|
9
|
-
"/var/app/data",
|
|
10
|
-
"/home/user/safe-directory"
|
|
11
|
-
],
|
|
12
|
-
"alertThreshold": 5,
|
|
13
|
-
"enablePromptInjectionDetection": true,
|
|
14
|
-
"enableSensitiveDataDetection": true,
|
|
15
|
-
"enablePathTraversalPrevention": true,
|
|
16
|
-
"enableRateLimiting": true,
|
|
17
|
-
"logLevel": "debug",
|
|
18
|
-
"logPath": "/tmp/mcp_security.log"
|
|
19
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Simple MCP Test Server
|
|
5
|
-
* This is a basic MCP server for testing ContextGuard
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
10
|
-
import {
|
|
11
|
-
CallToolRequestSchema,
|
|
12
|
-
ListToolsRequestSchema,
|
|
13
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
14
|
-
import fs from "fs/promises";
|
|
15
|
-
|
|
16
|
-
// Create server instance
|
|
17
|
-
const server = new Server(
|
|
18
|
-
{
|
|
19
|
-
name: "test-mcp-server",
|
|
20
|
-
version: "1.0.0",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
capabilities: {
|
|
24
|
-
tools: {},
|
|
25
|
-
},
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// Tool 1: Echo - Simple text echo (safe)
|
|
30
|
-
// Tool 2: Read File - Reads files (vulnerable to path traversal)
|
|
31
|
-
// Tool 3: Get Secret - Returns API key (vulnerable to data leakage)
|
|
32
|
-
// Tool 4: Execute Command - Runs commands (vulnerable to prompt injection)
|
|
33
|
-
|
|
34
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
35
|
-
return {
|
|
36
|
-
tools: [
|
|
37
|
-
{
|
|
38
|
-
name: "echo",
|
|
39
|
-
description: "Echoes back the input text",
|
|
40
|
-
inputSchema: {
|
|
41
|
-
type: "object",
|
|
42
|
-
properties: {
|
|
43
|
-
message: {
|
|
44
|
-
type: "string",
|
|
45
|
-
description: "The message to echo back",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
required: ["message"],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "read_file",
|
|
53
|
-
description: "Reads a file from the filesystem",
|
|
54
|
-
inputSchema: {
|
|
55
|
-
type: "object",
|
|
56
|
-
properties: {
|
|
57
|
-
filepath: {
|
|
58
|
-
type: "string",
|
|
59
|
-
description: "Path to the file to read",
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
required: ["filepath"],
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "get_config",
|
|
67
|
-
description: "Gets application configuration (contains API keys)",
|
|
68
|
-
inputSchema: {
|
|
69
|
-
type: "object",
|
|
70
|
-
properties: {
|
|
71
|
-
key: {
|
|
72
|
-
type: "string",
|
|
73
|
-
description: "Configuration key to retrieve",
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
required: ["key"],
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: "search_database",
|
|
81
|
-
description: "Searches the user database",
|
|
82
|
-
inputSchema: {
|
|
83
|
-
type: "object",
|
|
84
|
-
properties: {
|
|
85
|
-
query: {
|
|
86
|
-
type: "string",
|
|
87
|
-
description: "Search query",
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
required: ["query"],
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
98
|
-
const { name, arguments: args } = request.params;
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
switch (name) {
|
|
102
|
-
case "echo": {
|
|
103
|
-
return {
|
|
104
|
-
content: [
|
|
105
|
-
{
|
|
106
|
-
type: "text",
|
|
107
|
-
text: `Echo: ${args.message}`,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
case "read_file": {
|
|
114
|
-
// VULNERABLE: No path validation!
|
|
115
|
-
// An attacker could use: ../../../../etc/passwd
|
|
116
|
-
const filepath = args.filepath;
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const content = await fs.readFile(filepath, "utf-8");
|
|
120
|
-
return {
|
|
121
|
-
content: [
|
|
122
|
-
{
|
|
123
|
-
type: "text",
|
|
124
|
-
text: `File content:\n${content}`,
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
};
|
|
128
|
-
} catch (error) {
|
|
129
|
-
return {
|
|
130
|
-
content: [
|
|
131
|
-
{
|
|
132
|
-
type: "text",
|
|
133
|
-
text: `Error reading file: ${error.message}`,
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
isError: true,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
case "get_config": {
|
|
142
|
-
// VULNERABLE: Returns sensitive data!
|
|
143
|
-
const configs = {
|
|
144
|
-
api_key: "sk-1234567890abcdefghijklmnop",
|
|
145
|
-
database_password: "super_secret_password_123",
|
|
146
|
-
aws_secret: "AKIAIOSFODNN7EXAMPLE",
|
|
147
|
-
stripe_key: "sk_live_51234567890",
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
content: [
|
|
152
|
-
{
|
|
153
|
-
type: "text",
|
|
154
|
-
text: `Config value: ${configs[args.key] || "Not found"}`,
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
case "search_database": {
|
|
161
|
-
// VULNERABLE: Could be manipulated via prompt injection
|
|
162
|
-
const query = args.query;
|
|
163
|
-
|
|
164
|
-
// Simulated database with sensitive info
|
|
165
|
-
const users = [
|
|
166
|
-
{
|
|
167
|
-
id: 1,
|
|
168
|
-
name: "John Doe",
|
|
169
|
-
ssn: "123-45-6789",
|
|
170
|
-
email: "john@example.com",
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
id: 2,
|
|
174
|
-
name: "Jane Smith",
|
|
175
|
-
ssn: "987-65-4321",
|
|
176
|
-
email: "jane@example.com",
|
|
177
|
-
},
|
|
178
|
-
];
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
content: [
|
|
182
|
-
{
|
|
183
|
-
type: "text",
|
|
184
|
-
text: `Search results for "${query}":\n${JSON.stringify(
|
|
185
|
-
users,
|
|
186
|
-
null,
|
|
187
|
-
2
|
|
188
|
-
)}`,
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
default:
|
|
195
|
-
return {
|
|
196
|
-
content: [
|
|
197
|
-
{
|
|
198
|
-
type: "text",
|
|
199
|
-
text: `Unknown tool: ${name}`,
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
isError: true,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
} catch (error) {
|
|
206
|
-
return {
|
|
207
|
-
content: [
|
|
208
|
-
{
|
|
209
|
-
type: "text",
|
|
210
|
-
text: `Error: ${error.message}`,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
isError: true,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
// Start the server
|
|
219
|
-
async function main() {
|
|
220
|
-
const transport = new StdioServerTransport();
|
|
221
|
-
await server.connect(transport);
|
|
222
|
-
console.error("Test MCP Server running on stdio");
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
main().catch((error) => {
|
|
226
|
-
console.error("Fatal error:", error);
|
|
227
|
-
process.exit(1);
|
|
228
|
-
});
|