protect-mcp 0.4.3 → 0.4.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 +1 -1
- package/dist/chunk-U76JZVH6.mjs +144 -0
- package/dist/demo-server.d.mts +106 -0
- package/dist/demo-server.d.ts +106 -0
- package/dist/demo-server.js +32 -0
- package/dist/demo-server.mjs +6 -135
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +143 -0
- package/dist/index.mjs +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -254,4 +254,4 @@ Supports OPA, Cerbos, Cedar (AWS AgentCore), and generic HTTP endpoints:
|
|
|
254
254
|
|
|
255
255
|
MIT — free to use, modify, distribute, and build upon without restriction.
|
|
256
256
|
|
|
257
|
-
[scopeblind.com](https://scopeblind.com) · [npm](https://www.npmjs.com/package/protect-mcp) · [GitHub](https://github.com/scopeblind/
|
|
257
|
+
[scopeblind.com](https://scopeblind.com) · [npm](https://www.npmjs.com/package/protect-mcp) · [GitHub](https://github.com/scopeblind/scopeblind-gateway) · [IETF Draft](https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/)
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// src/demo-server.ts
|
|
2
|
+
import { createInterface } from "readline";
|
|
3
|
+
var TOOLS = [
|
|
4
|
+
{
|
|
5
|
+
name: "read_file",
|
|
6
|
+
description: "Read the contents of a file",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: { path: { type: "string", description: "File path to read" } },
|
|
10
|
+
required: ["path"]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "write_file",
|
|
15
|
+
description: "Write content to a file",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
path: { type: "string", description: "File path to write" },
|
|
20
|
+
content: { type: "string", description: "Content to write" }
|
|
21
|
+
},
|
|
22
|
+
required: ["path", "content"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "delete_file",
|
|
27
|
+
description: "Delete a file from the filesystem",
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: "object",
|
|
30
|
+
properties: { path: { type: "string", description: "File path to delete" } },
|
|
31
|
+
required: ["path"]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "web_search",
|
|
36
|
+
description: "Search the web for information",
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: { query: { type: "string", description: "Search query" } },
|
|
40
|
+
required: ["query"]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "deploy",
|
|
45
|
+
description: "Deploy the application to production",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
environment: { type: "string", description: "Target environment", enum: ["staging", "production"] },
|
|
50
|
+
reason: { type: "string", description: "Deployment reason" }
|
|
51
|
+
},
|
|
52
|
+
required: ["environment"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
function handleRequest(request) {
|
|
57
|
+
if (request.method === "initialize") {
|
|
58
|
+
return JSON.stringify({
|
|
59
|
+
jsonrpc: "2.0",
|
|
60
|
+
id: request.id,
|
|
61
|
+
result: {
|
|
62
|
+
protocolVersion: "2024-11-05",
|
|
63
|
+
serverInfo: { name: "protect-mcp-demo", version: "0.2.0" },
|
|
64
|
+
capabilities: { tools: {} }
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (request.method === "notifications/initialized") {
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
if (request.method === "tools/list") {
|
|
72
|
+
return JSON.stringify({
|
|
73
|
+
jsonrpc: "2.0",
|
|
74
|
+
id: request.id,
|
|
75
|
+
result: { tools: TOOLS }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (request.method === "tools/call") {
|
|
79
|
+
const toolName = request.params?.name || "unknown";
|
|
80
|
+
const args = request.params?.arguments || {};
|
|
81
|
+
let resultText;
|
|
82
|
+
switch (toolName) {
|
|
83
|
+
case "read_file":
|
|
84
|
+
resultText = `[demo] Read file: ${args.path || "/example.txt"}
|
|
85
|
+
Contents: Hello from protect-mcp demo server!`;
|
|
86
|
+
break;
|
|
87
|
+
case "write_file":
|
|
88
|
+
resultText = `[demo] Wrote ${String(args.content || "").length} bytes to ${args.path || "/example.txt"}`;
|
|
89
|
+
break;
|
|
90
|
+
case "delete_file":
|
|
91
|
+
resultText = `[demo] Deleted file: ${args.path || "/example.txt"}`;
|
|
92
|
+
break;
|
|
93
|
+
case "web_search":
|
|
94
|
+
resultText = `[demo] Search results for "${args.query || "test"}":
|
|
95
|
+
1. Example result \u2014 scopeblind.com
|
|
96
|
+
2. MCP security \u2014 modelcontextprotocol.io`;
|
|
97
|
+
break;
|
|
98
|
+
case "deploy":
|
|
99
|
+
resultText = `[demo] Deployed to ${args.environment || "staging"}${args.reason ? ` (reason: ${args.reason})` : ""}`;
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
resultText = `[demo] Unknown tool: ${toolName}`;
|
|
103
|
+
}
|
|
104
|
+
return JSON.stringify({
|
|
105
|
+
jsonrpc: "2.0",
|
|
106
|
+
id: request.id,
|
|
107
|
+
result: {
|
|
108
|
+
content: [{ type: "text", text: resultText }]
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (request.id !== void 0) {
|
|
113
|
+
return JSON.stringify({
|
|
114
|
+
jsonrpc: "2.0",
|
|
115
|
+
id: request.id,
|
|
116
|
+
error: { code: -32601, message: `Method not found: ${request.method}` }
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return "";
|
|
120
|
+
}
|
|
121
|
+
var rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
122
|
+
rl.on("line", (line) => {
|
|
123
|
+
const trimmed = line.trim();
|
|
124
|
+
if (!trimmed) return;
|
|
125
|
+
try {
|
|
126
|
+
const request = JSON.parse(trimmed);
|
|
127
|
+
const response = handleRequest(request);
|
|
128
|
+
if (response) {
|
|
129
|
+
process.stdout.write(response + "\n");
|
|
130
|
+
}
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
process.stderr.write("[DEMO_SERVER] protect-mcp demo server started \u2014 5 tools registered\n");
|
|
135
|
+
function createSandboxServer() {
|
|
136
|
+
return {
|
|
137
|
+
tools: TOOLS,
|
|
138
|
+
handleRequest
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export {
|
|
143
|
+
createSandboxServer
|
|
144
|
+
};
|
package/dist/demo-server.d.mts
CHANGED
|
@@ -1 +1,107 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @scopeblind/protect-mcp — Built-in Demo MCP Server
|
|
4
|
+
*
|
|
5
|
+
* A minimal MCP server (JSON-RPC over stdio) that registers 5 demo tools.
|
|
6
|
+
* Used by `protect-mcp demo` to let users see receipts flowing
|
|
7
|
+
* without having their own MCP server.
|
|
8
|
+
*
|
|
9
|
+
* Tools:
|
|
10
|
+
* - read_file (safe, high-frequency)
|
|
11
|
+
* - write_file (medium risk)
|
|
12
|
+
* - delete_file (destructive, blocked by default policy)
|
|
13
|
+
* - web_search (rate-limited)
|
|
14
|
+
* - deploy (high-privilege)
|
|
15
|
+
*/
|
|
16
|
+
interface JsonRpcRequest {
|
|
17
|
+
jsonrpc: '2.0';
|
|
18
|
+
id?: string | number;
|
|
19
|
+
method: string;
|
|
20
|
+
params?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
declare function handleRequest(request: JsonRpcRequest): string;
|
|
23
|
+
/**
|
|
24
|
+
* Smithery sandbox server — returns a minimal MCP server instance
|
|
25
|
+
* that Smithery can scan for tool/resource capabilities.
|
|
26
|
+
*/
|
|
27
|
+
declare function createSandboxServer(): {
|
|
28
|
+
tools: ({
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: string;
|
|
33
|
+
properties: {
|
|
34
|
+
path: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
content?: undefined;
|
|
39
|
+
query?: undefined;
|
|
40
|
+
environment?: undefined;
|
|
41
|
+
reason?: undefined;
|
|
42
|
+
};
|
|
43
|
+
required: string[];
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: string;
|
|
50
|
+
properties: {
|
|
51
|
+
path: {
|
|
52
|
+
type: string;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
content: {
|
|
56
|
+
type: string;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
query?: undefined;
|
|
60
|
+
environment?: undefined;
|
|
61
|
+
reason?: undefined;
|
|
62
|
+
};
|
|
63
|
+
required: string[];
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: string;
|
|
70
|
+
properties: {
|
|
71
|
+
query: {
|
|
72
|
+
type: string;
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
path?: undefined;
|
|
76
|
+
content?: undefined;
|
|
77
|
+
environment?: undefined;
|
|
78
|
+
reason?: undefined;
|
|
79
|
+
};
|
|
80
|
+
required: string[];
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: string;
|
|
87
|
+
properties: {
|
|
88
|
+
environment: {
|
|
89
|
+
type: string;
|
|
90
|
+
description: string;
|
|
91
|
+
enum: string[];
|
|
92
|
+
};
|
|
93
|
+
reason: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
path?: undefined;
|
|
98
|
+
content?: undefined;
|
|
99
|
+
query?: undefined;
|
|
100
|
+
};
|
|
101
|
+
required: string[];
|
|
102
|
+
};
|
|
103
|
+
})[];
|
|
104
|
+
handleRequest: typeof handleRequest;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { createSandboxServer };
|
package/dist/demo-server.d.ts
CHANGED
|
@@ -1 +1,107 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @scopeblind/protect-mcp — Built-in Demo MCP Server
|
|
4
|
+
*
|
|
5
|
+
* A minimal MCP server (JSON-RPC over stdio) that registers 5 demo tools.
|
|
6
|
+
* Used by `protect-mcp demo` to let users see receipts flowing
|
|
7
|
+
* without having their own MCP server.
|
|
8
|
+
*
|
|
9
|
+
* Tools:
|
|
10
|
+
* - read_file (safe, high-frequency)
|
|
11
|
+
* - write_file (medium risk)
|
|
12
|
+
* - delete_file (destructive, blocked by default policy)
|
|
13
|
+
* - web_search (rate-limited)
|
|
14
|
+
* - deploy (high-privilege)
|
|
15
|
+
*/
|
|
16
|
+
interface JsonRpcRequest {
|
|
17
|
+
jsonrpc: '2.0';
|
|
18
|
+
id?: string | number;
|
|
19
|
+
method: string;
|
|
20
|
+
params?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
declare function handleRequest(request: JsonRpcRequest): string;
|
|
23
|
+
/**
|
|
24
|
+
* Smithery sandbox server — returns a minimal MCP server instance
|
|
25
|
+
* that Smithery can scan for tool/resource capabilities.
|
|
26
|
+
*/
|
|
27
|
+
declare function createSandboxServer(): {
|
|
28
|
+
tools: ({
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: string;
|
|
33
|
+
properties: {
|
|
34
|
+
path: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
content?: undefined;
|
|
39
|
+
query?: undefined;
|
|
40
|
+
environment?: undefined;
|
|
41
|
+
reason?: undefined;
|
|
42
|
+
};
|
|
43
|
+
required: string[];
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: string;
|
|
50
|
+
properties: {
|
|
51
|
+
path: {
|
|
52
|
+
type: string;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
content: {
|
|
56
|
+
type: string;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
query?: undefined;
|
|
60
|
+
environment?: undefined;
|
|
61
|
+
reason?: undefined;
|
|
62
|
+
};
|
|
63
|
+
required: string[];
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: string;
|
|
70
|
+
properties: {
|
|
71
|
+
query: {
|
|
72
|
+
type: string;
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
path?: undefined;
|
|
76
|
+
content?: undefined;
|
|
77
|
+
environment?: undefined;
|
|
78
|
+
reason?: undefined;
|
|
79
|
+
};
|
|
80
|
+
required: string[];
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: string;
|
|
87
|
+
properties: {
|
|
88
|
+
environment: {
|
|
89
|
+
type: string;
|
|
90
|
+
description: string;
|
|
91
|
+
enum: string[];
|
|
92
|
+
};
|
|
93
|
+
reason: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
path?: undefined;
|
|
98
|
+
content?: undefined;
|
|
99
|
+
query?: undefined;
|
|
100
|
+
};
|
|
101
|
+
required: string[];
|
|
102
|
+
};
|
|
103
|
+
})[];
|
|
104
|
+
handleRequest: typeof handleRequest;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { createSandboxServer };
|
package/dist/demo-server.js
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
3
20
|
|
|
4
21
|
// src/demo-server.ts
|
|
22
|
+
var demo_server_exports = {};
|
|
23
|
+
__export(demo_server_exports, {
|
|
24
|
+
createSandboxServer: () => createSandboxServer
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(demo_server_exports);
|
|
5
27
|
var import_node_readline = require("readline");
|
|
6
28
|
var TOOLS = [
|
|
7
29
|
{
|
|
@@ -135,3 +157,13 @@ rl.on("line", (line) => {
|
|
|
135
157
|
}
|
|
136
158
|
});
|
|
137
159
|
process.stderr.write("[DEMO_SERVER] protect-mcp demo server started \u2014 5 tools registered\n");
|
|
160
|
+
function createSandboxServer() {
|
|
161
|
+
return {
|
|
162
|
+
tools: TOOLS,
|
|
163
|
+
handleRequest
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
createSandboxServer
|
|
169
|
+
});
|
package/dist/demo-server.mjs
CHANGED
|
@@ -1,136 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
description: "Read the contents of a file",
|
|
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-U76JZVH6.mjs";
|
|
5
|
+
export {
|
|
6
|
+
createSandboxServer
|
|
7
|
+
};
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
createLogAnchorField: () => createLogAnchorField,
|
|
50
50
|
createReceiptChannel: () => createReceiptChannel,
|
|
51
51
|
createSandbox: () => createSandbox,
|
|
52
|
+
createSandboxServer: () => createSandboxServer,
|
|
52
53
|
destroySandbox: () => destroySandbox,
|
|
53
54
|
ed25519ToDIDKey: () => ed25519ToDIDKey,
|
|
54
55
|
evaluateTier: () => evaluateTier,
|
|
@@ -3464,6 +3465,147 @@ async function confidentialInference(_prompt, _config) {
|
|
|
3464
3465
|
"Confidential inference requires a TEE/HE provider SDK. See docs at scopeblind.com/docs/confidential for setup instructions. Supported providers: Gramine (local_tee), Zama Concrete ML (homomorphic), NVIDIA Confidential Computing (secure_enclave)."
|
|
3465
3466
|
);
|
|
3466
3467
|
}
|
|
3468
|
+
|
|
3469
|
+
// src/demo-server.ts
|
|
3470
|
+
var import_node_readline2 = require("readline");
|
|
3471
|
+
var TOOLS = [
|
|
3472
|
+
{
|
|
3473
|
+
name: "read_file",
|
|
3474
|
+
description: "Read the contents of a file",
|
|
3475
|
+
inputSchema: {
|
|
3476
|
+
type: "object",
|
|
3477
|
+
properties: { path: { type: "string", description: "File path to read" } },
|
|
3478
|
+
required: ["path"]
|
|
3479
|
+
}
|
|
3480
|
+
},
|
|
3481
|
+
{
|
|
3482
|
+
name: "write_file",
|
|
3483
|
+
description: "Write content to a file",
|
|
3484
|
+
inputSchema: {
|
|
3485
|
+
type: "object",
|
|
3486
|
+
properties: {
|
|
3487
|
+
path: { type: "string", description: "File path to write" },
|
|
3488
|
+
content: { type: "string", description: "Content to write" }
|
|
3489
|
+
},
|
|
3490
|
+
required: ["path", "content"]
|
|
3491
|
+
}
|
|
3492
|
+
},
|
|
3493
|
+
{
|
|
3494
|
+
name: "delete_file",
|
|
3495
|
+
description: "Delete a file from the filesystem",
|
|
3496
|
+
inputSchema: {
|
|
3497
|
+
type: "object",
|
|
3498
|
+
properties: { path: { type: "string", description: "File path to delete" } },
|
|
3499
|
+
required: ["path"]
|
|
3500
|
+
}
|
|
3501
|
+
},
|
|
3502
|
+
{
|
|
3503
|
+
name: "web_search",
|
|
3504
|
+
description: "Search the web for information",
|
|
3505
|
+
inputSchema: {
|
|
3506
|
+
type: "object",
|
|
3507
|
+
properties: { query: { type: "string", description: "Search query" } },
|
|
3508
|
+
required: ["query"]
|
|
3509
|
+
}
|
|
3510
|
+
},
|
|
3511
|
+
{
|
|
3512
|
+
name: "deploy",
|
|
3513
|
+
description: "Deploy the application to production",
|
|
3514
|
+
inputSchema: {
|
|
3515
|
+
type: "object",
|
|
3516
|
+
properties: {
|
|
3517
|
+
environment: { type: "string", description: "Target environment", enum: ["staging", "production"] },
|
|
3518
|
+
reason: { type: "string", description: "Deployment reason" }
|
|
3519
|
+
},
|
|
3520
|
+
required: ["environment"]
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
];
|
|
3524
|
+
function handleRequest(request) {
|
|
3525
|
+
if (request.method === "initialize") {
|
|
3526
|
+
return JSON.stringify({
|
|
3527
|
+
jsonrpc: "2.0",
|
|
3528
|
+
id: request.id,
|
|
3529
|
+
result: {
|
|
3530
|
+
protocolVersion: "2024-11-05",
|
|
3531
|
+
serverInfo: { name: "protect-mcp-demo", version: "0.2.0" },
|
|
3532
|
+
capabilities: { tools: {} }
|
|
3533
|
+
}
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
if (request.method === "notifications/initialized") {
|
|
3537
|
+
return "";
|
|
3538
|
+
}
|
|
3539
|
+
if (request.method === "tools/list") {
|
|
3540
|
+
return JSON.stringify({
|
|
3541
|
+
jsonrpc: "2.0",
|
|
3542
|
+
id: request.id,
|
|
3543
|
+
result: { tools: TOOLS }
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
if (request.method === "tools/call") {
|
|
3547
|
+
const toolName = request.params?.name || "unknown";
|
|
3548
|
+
const args = request.params?.arguments || {};
|
|
3549
|
+
let resultText;
|
|
3550
|
+
switch (toolName) {
|
|
3551
|
+
case "read_file":
|
|
3552
|
+
resultText = `[demo] Read file: ${args.path || "/example.txt"}
|
|
3553
|
+
Contents: Hello from protect-mcp demo server!`;
|
|
3554
|
+
break;
|
|
3555
|
+
case "write_file":
|
|
3556
|
+
resultText = `[demo] Wrote ${String(args.content || "").length} bytes to ${args.path || "/example.txt"}`;
|
|
3557
|
+
break;
|
|
3558
|
+
case "delete_file":
|
|
3559
|
+
resultText = `[demo] Deleted file: ${args.path || "/example.txt"}`;
|
|
3560
|
+
break;
|
|
3561
|
+
case "web_search":
|
|
3562
|
+
resultText = `[demo] Search results for "${args.query || "test"}":
|
|
3563
|
+
1. Example result \u2014 scopeblind.com
|
|
3564
|
+
2. MCP security \u2014 modelcontextprotocol.io`;
|
|
3565
|
+
break;
|
|
3566
|
+
case "deploy":
|
|
3567
|
+
resultText = `[demo] Deployed to ${args.environment || "staging"}${args.reason ? ` (reason: ${args.reason})` : ""}`;
|
|
3568
|
+
break;
|
|
3569
|
+
default:
|
|
3570
|
+
resultText = `[demo] Unknown tool: ${toolName}`;
|
|
3571
|
+
}
|
|
3572
|
+
return JSON.stringify({
|
|
3573
|
+
jsonrpc: "2.0",
|
|
3574
|
+
id: request.id,
|
|
3575
|
+
result: {
|
|
3576
|
+
content: [{ type: "text", text: resultText }]
|
|
3577
|
+
}
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
if (request.id !== void 0) {
|
|
3581
|
+
return JSON.stringify({
|
|
3582
|
+
jsonrpc: "2.0",
|
|
3583
|
+
id: request.id,
|
|
3584
|
+
error: { code: -32601, message: `Method not found: ${request.method}` }
|
|
3585
|
+
});
|
|
3586
|
+
}
|
|
3587
|
+
return "";
|
|
3588
|
+
}
|
|
3589
|
+
var rl = (0, import_node_readline2.createInterface)({ input: process.stdin, crlfDelay: Infinity });
|
|
3590
|
+
rl.on("line", (line) => {
|
|
3591
|
+
const trimmed = line.trim();
|
|
3592
|
+
if (!trimmed) return;
|
|
3593
|
+
try {
|
|
3594
|
+
const request = JSON.parse(trimmed);
|
|
3595
|
+
const response = handleRequest(request);
|
|
3596
|
+
if (response) {
|
|
3597
|
+
process.stdout.write(response + "\n");
|
|
3598
|
+
}
|
|
3599
|
+
} catch {
|
|
3600
|
+
}
|
|
3601
|
+
});
|
|
3602
|
+
process.stderr.write("[DEMO_SERVER] protect-mcp demo server started \u2014 5 tools registered\n");
|
|
3603
|
+
function createSandboxServer() {
|
|
3604
|
+
return {
|
|
3605
|
+
tools: TOOLS,
|
|
3606
|
+
handleRequest
|
|
3607
|
+
};
|
|
3608
|
+
}
|
|
3467
3609
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3468
3610
|
0 && (module.exports = {
|
|
3469
3611
|
ConfidentialGate,
|
|
@@ -3485,6 +3627,7 @@ async function confidentialInference(_prompt, _config) {
|
|
|
3485
3627
|
createLogAnchorField,
|
|
3486
3628
|
createReceiptChannel,
|
|
3487
3629
|
createSandbox,
|
|
3630
|
+
createSandboxServer,
|
|
3488
3631
|
destroySandbox,
|
|
3489
3632
|
ed25519ToDIDKey,
|
|
3490
3633
|
evaluateTier,
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,9 @@ import {
|
|
|
3
3
|
parseLogFile,
|
|
4
4
|
simulate
|
|
5
5
|
} from "./chunk-VIA2B65K.mjs";
|
|
6
|
+
import {
|
|
7
|
+
createSandboxServer
|
|
8
|
+
} from "./chunk-U76JZVH6.mjs";
|
|
6
9
|
import {
|
|
7
10
|
collectSignedReceipts,
|
|
8
11
|
createAuditBundle
|
|
@@ -1433,6 +1436,7 @@ export {
|
|
|
1433
1436
|
createLogAnchorField,
|
|
1434
1437
|
createReceiptChannel,
|
|
1435
1438
|
createSandbox,
|
|
1439
|
+
createSandboxServer,
|
|
1436
1440
|
destroySandbox,
|
|
1437
1441
|
ed25519ToDIDKey,
|
|
1438
1442
|
evaluateTier,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "protect-mcp",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"mcpName": "io.github.tomjwxf/protect-mcp",
|
|
5
5
|
"description": "Security gateway for MCP servers. Shadow-mode logs, per-tool policies, optional local Ed25519-signed receipts. Programmatic hooks for trust tiers, credential config, and external policy engines.",
|
|
6
6
|
"main": "dist/index.js",
|