protect-mcp 0.4.3 → 0.4.5
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 +1 -1
- package/dist/{bundle-TXOTFJIJ.mjs → bundle-XTR3YMPO.mjs} +1 -0
- package/dist/chunk-PQJP2ZCI.mjs +8 -0
- package/dist/chunk-SU2FZH7U.mjs +35167 -0
- package/dist/cli.mjs +8 -7
- package/dist/demo-server.d.mts +21 -0
- package/dist/demo-server.d.ts +21 -0
- package/dist/demo-server.js +35054 -0
- package/dist/demo-server.mjs +7 -135
- package/dist/{ed25519-EDO4K4EP.mjs → ed25519-V7HDL2WC.mjs} +1 -0
- package/dist/{http-transport-VLIPOPIC.mjs → http-transport-XCHIKTYG.mjs} +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +35176 -11
- package/dist/index.mjs +5 -0
- package/dist/{report-ENQ3KUI2.mjs → report-5XCNW6FB.mjs} +1 -0
- package/dist/{utils-IDWBSHJU.mjs → utils-6AYZFE5A.mjs} +1 -0
- package/package.json +2 -1
package/dist/demo-server.mjs
CHANGED
|
@@ -1,136 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
inputSchema: {
|
|
10
|
-
type: "object",
|
|
11
|
-
properties: { path: { type: "string", description: "File path to read" } },
|
|
12
|
-
required: ["path"]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: "write_file",
|
|
17
|
-
description: "Write content to a file",
|
|
18
|
-
inputSchema: {
|
|
19
|
-
type: "object",
|
|
20
|
-
properties: {
|
|
21
|
-
path: { type: "string", description: "File path to write" },
|
|
22
|
-
content: { type: "string", description: "Content to write" }
|
|
23
|
-
},
|
|
24
|
-
required: ["path", "content"]
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "delete_file",
|
|
29
|
-
description: "Delete a file from the filesystem",
|
|
30
|
-
inputSchema: {
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: { path: { type: "string", description: "File path to delete" } },
|
|
33
|
-
required: ["path"]
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: "web_search",
|
|
38
|
-
description: "Search the web for information",
|
|
39
|
-
inputSchema: {
|
|
40
|
-
type: "object",
|
|
41
|
-
properties: { query: { type: "string", description: "Search query" } },
|
|
42
|
-
required: ["query"]
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "deploy",
|
|
47
|
-
description: "Deploy the application to production",
|
|
48
|
-
inputSchema: {
|
|
49
|
-
type: "object",
|
|
50
|
-
properties: {
|
|
51
|
-
environment: { type: "string", description: "Target environment", enum: ["staging", "production"] },
|
|
52
|
-
reason: { type: "string", description: "Deployment reason" }
|
|
53
|
-
},
|
|
54
|
-
required: ["environment"]
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
];
|
|
58
|
-
function handleRequest(request) {
|
|
59
|
-
if (request.method === "initialize") {
|
|
60
|
-
return JSON.stringify({
|
|
61
|
-
jsonrpc: "2.0",
|
|
62
|
-
id: request.id,
|
|
63
|
-
result: {
|
|
64
|
-
protocolVersion: "2024-11-05",
|
|
65
|
-
serverInfo: { name: "protect-mcp-demo", version: "0.2.0" },
|
|
66
|
-
capabilities: { tools: {} }
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (request.method === "notifications/initialized") {
|
|
71
|
-
return "";
|
|
72
|
-
}
|
|
73
|
-
if (request.method === "tools/list") {
|
|
74
|
-
return JSON.stringify({
|
|
75
|
-
jsonrpc: "2.0",
|
|
76
|
-
id: request.id,
|
|
77
|
-
result: { tools: TOOLS }
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
if (request.method === "tools/call") {
|
|
81
|
-
const toolName = request.params?.name || "unknown";
|
|
82
|
-
const args = request.params?.arguments || {};
|
|
83
|
-
let resultText;
|
|
84
|
-
switch (toolName) {
|
|
85
|
-
case "read_file":
|
|
86
|
-
resultText = `[demo] Read file: ${args.path || "/example.txt"}
|
|
87
|
-
Contents: Hello from protect-mcp demo server!`;
|
|
88
|
-
break;
|
|
89
|
-
case "write_file":
|
|
90
|
-
resultText = `[demo] Wrote ${String(args.content || "").length} bytes to ${args.path || "/example.txt"}`;
|
|
91
|
-
break;
|
|
92
|
-
case "delete_file":
|
|
93
|
-
resultText = `[demo] Deleted file: ${args.path || "/example.txt"}`;
|
|
94
|
-
break;
|
|
95
|
-
case "web_search":
|
|
96
|
-
resultText = `[demo] Search results for "${args.query || "test"}":
|
|
97
|
-
1. Example result \u2014 scopeblind.com
|
|
98
|
-
2. MCP security \u2014 modelcontextprotocol.io`;
|
|
99
|
-
break;
|
|
100
|
-
case "deploy":
|
|
101
|
-
resultText = `[demo] Deployed to ${args.environment || "staging"}${args.reason ? ` (reason: ${args.reason})` : ""}`;
|
|
102
|
-
break;
|
|
103
|
-
default:
|
|
104
|
-
resultText = `[demo] Unknown tool: ${toolName}`;
|
|
105
|
-
}
|
|
106
|
-
return JSON.stringify({
|
|
107
|
-
jsonrpc: "2.0",
|
|
108
|
-
id: request.id,
|
|
109
|
-
result: {
|
|
110
|
-
content: [{ type: "text", text: resultText }]
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (request.id !== void 0) {
|
|
115
|
-
return JSON.stringify({
|
|
116
|
-
jsonrpc: "2.0",
|
|
117
|
-
id: request.id,
|
|
118
|
-
error: { code: -32601, message: `Method not found: ${request.method}` }
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return "";
|
|
122
|
-
}
|
|
123
|
-
var rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
124
|
-
rl.on("line", (line) => {
|
|
125
|
-
const trimmed = line.trim();
|
|
126
|
-
if (!trimmed) return;
|
|
127
|
-
try {
|
|
128
|
-
const request = JSON.parse(trimmed);
|
|
129
|
-
const response = handleRequest(request);
|
|
130
|
-
if (response) {
|
|
131
|
-
process.stdout.write(response + "\n");
|
|
132
|
-
}
|
|
133
|
-
} catch {
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
process.stderr.write("[DEMO_SERVER] protect-mcp demo server started \u2014 5 tools registered\n");
|
|
2
|
+
import {
|
|
3
|
+
createSandboxServer
|
|
4
|
+
} from "./chunk-SU2FZH7U.mjs";
|
|
5
|
+
import "./chunk-PQJP2ZCI.mjs";
|
|
6
|
+
export {
|
|
7
|
+
createSandboxServer
|
|
8
|
+
};
|
package/dist/index.d.mts
CHANGED