@crowdstrike/aidr-mcp-proxy 1.2.2 → 1.4.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 +5 -0
- package/dist/proxy.mjs +39 -26
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -99,4 +99,9 @@ environment variable.
|
|
|
99
99
|
To identify the calling app by name in CrowdStrike AIDR, set the `APP_NAME`
|
|
100
100
|
environment variable.
|
|
101
101
|
|
|
102
|
+
### User ID
|
|
103
|
+
|
|
104
|
+
To identify the calling user by ID in CrowdStrike AIDR, set the
|
|
105
|
+
`CS_AIDR_USER_ID` environment variable.
|
|
106
|
+
|
|
102
107
|
[mcp-remote]: https://github.com/geelen/mcp-remote
|
package/dist/proxy.mjs
CHANGED
|
@@ -7,8 +7,13 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
7
7
|
import { CallToolRequestSchema, CompleteRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourceTemplatesRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, LoggingMessageNotificationSchema, ReadResourceRequestSchema, ResourceUpdatedNotificationSchema, SubscribeRequestSchema, UnsubscribeRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
8
8
|
import { defineCommand, runMain } from "citty";
|
|
9
9
|
import { consola } from "consola";
|
|
10
|
-
|
|
11
10
|
//#region src/proxy.ts
|
|
11
|
+
function isTextContent(x) {
|
|
12
|
+
return x.type === "text";
|
|
13
|
+
}
|
|
14
|
+
function isImageContent(x) {
|
|
15
|
+
return x.type === "image";
|
|
16
|
+
}
|
|
12
17
|
runMain(defineCommand({
|
|
13
18
|
args: {},
|
|
14
19
|
async run({ args }) {
|
|
@@ -23,7 +28,8 @@ runMain(defineCommand({
|
|
|
23
28
|
args: args._.slice(1),
|
|
24
29
|
env: {
|
|
25
30
|
...process.env,
|
|
26
|
-
CS_AIDR_TOKEN: void 0
|
|
31
|
+
CS_AIDR_TOKEN: void 0,
|
|
32
|
+
CS_AIDR_USER_ID: void 0
|
|
27
33
|
}
|
|
28
34
|
});
|
|
29
35
|
const client = new Client({
|
|
@@ -38,19 +44,19 @@ runMain(defineCommand({
|
|
|
38
44
|
capabilities: serverCapabilities,
|
|
39
45
|
instructions: client.getInstructions()
|
|
40
46
|
});
|
|
41
|
-
if (serverCapabilities?.logging) server.setNotificationHandler(LoggingMessageNotificationSchema, (args
|
|
47
|
+
if (serverCapabilities?.logging) server.setNotificationHandler(LoggingMessageNotificationSchema, (args) => client.notification(args));
|
|
42
48
|
if (serverCapabilities?.prompts) {
|
|
43
|
-
server.setRequestHandler(GetPromptRequestSchema, (args
|
|
44
|
-
server.setRequestHandler(ListPromptsRequestSchema, (args
|
|
49
|
+
server.setRequestHandler(GetPromptRequestSchema, (args) => client.getPrompt(args.params));
|
|
50
|
+
server.setRequestHandler(ListPromptsRequestSchema, (args) => client.listPrompts(args.params));
|
|
45
51
|
}
|
|
46
52
|
if (serverCapabilities?.resources) {
|
|
47
|
-
server.setRequestHandler(ListResourcesRequestSchema, (args
|
|
48
|
-
server.setRequestHandler(ListResourceTemplatesRequestSchema, (args
|
|
49
|
-
server.setRequestHandler(ReadResourceRequestSchema, (args
|
|
53
|
+
server.setRequestHandler(ListResourcesRequestSchema, (args) => client.listResources(args.params));
|
|
54
|
+
server.setRequestHandler(ListResourceTemplatesRequestSchema, (args) => client.listResourceTemplates(args.params));
|
|
55
|
+
server.setRequestHandler(ReadResourceRequestSchema, (args) => client.readResource(args.params));
|
|
50
56
|
if (serverCapabilities?.resources.subscribe) {
|
|
51
|
-
server.setNotificationHandler(ResourceUpdatedNotificationSchema, (args
|
|
52
|
-
server.setRequestHandler(SubscribeRequestSchema, (args
|
|
53
|
-
server.setRequestHandler(UnsubscribeRequestSchema, (args
|
|
57
|
+
server.setNotificationHandler(ResourceUpdatedNotificationSchema, (args) => client.notification(args));
|
|
58
|
+
server.setRequestHandler(SubscribeRequestSchema, (args) => client.subscribeResource(args.params));
|
|
59
|
+
server.setRequestHandler(UnsubscribeRequestSchema, (args) => client.unsubscribeResource(args.params));
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
if (serverCapabilities?.tools) {
|
|
@@ -58,8 +64,8 @@ runMain(defineCommand({
|
|
|
58
64
|
token: process.env.CS_AIDR_TOKEN,
|
|
59
65
|
baseURLTemplate: process.env.CS_AIDR_BASE_URL_TEMPLATE
|
|
60
66
|
});
|
|
61
|
-
server.setRequestHandler(ListToolsRequestSchema, async (args
|
|
62
|
-
const response = await client.listTools(args
|
|
67
|
+
server.setRequestHandler(ListToolsRequestSchema, async (args) => {
|
|
68
|
+
const response = await client.listTools(args.params);
|
|
63
69
|
const { tools } = response;
|
|
64
70
|
const guardedToolsList = await aiGuard.guardChatCompletions({
|
|
65
71
|
guard_input: {
|
|
@@ -68,6 +74,7 @@ runMain(defineCommand({
|
|
|
68
74
|
},
|
|
69
75
|
app_id: process.env.APP_ID,
|
|
70
76
|
event_type: "tool_listing",
|
|
77
|
+
user_id: process.env.CS_AIDR_USER_ID,
|
|
71
78
|
extra_info: {
|
|
72
79
|
app_name: process.env.APP_NAME,
|
|
73
80
|
mcp_server_name: serverVersion.name
|
|
@@ -79,18 +86,19 @@ runMain(defineCommand({
|
|
|
79
86
|
tools: []
|
|
80
87
|
} : response;
|
|
81
88
|
});
|
|
82
|
-
server.setRequestHandler(CallToolRequestSchema, async (args
|
|
89
|
+
server.setRequestHandler(CallToolRequestSchema, async (args) => {
|
|
83
90
|
const guardedInput = await aiGuard.guardChatCompletions({
|
|
84
91
|
guard_input: { messages: [{
|
|
85
92
|
role: "user",
|
|
86
|
-
content: JSON.stringify(args
|
|
93
|
+
content: JSON.stringify(args.params.arguments) ?? ""
|
|
87
94
|
}] },
|
|
88
95
|
app_id: process.env.APP_ID,
|
|
89
96
|
event_type: "tool_input",
|
|
97
|
+
user_id: process.env.CS_AIDR_USER_ID,
|
|
90
98
|
extra_info: {
|
|
91
99
|
app_name: process.env.APP_NAME,
|
|
92
100
|
mcp_server_name: serverVersion.name,
|
|
93
|
-
tool_name: args
|
|
101
|
+
tool_name: args.params.name
|
|
94
102
|
}
|
|
95
103
|
});
|
|
96
104
|
if (guardedInput.status !== "Success") throw new Error("Failed to guard input.");
|
|
@@ -104,9 +112,9 @@ runMain(defineCommand({
|
|
|
104
112
|
isError: true
|
|
105
113
|
};
|
|
106
114
|
}
|
|
107
|
-
const newArgs = guardedInput.result?.transformed ? JSON.parse((guardedInput.result?.guard_output?.messages)[0].content ?? "{}") : args
|
|
115
|
+
const newArgs = guardedInput.result?.transformed ? JSON.parse((guardedInput.result?.guard_output?.messages)[0].content ?? "{}") : args.params.arguments;
|
|
108
116
|
const response = await client.callTool({
|
|
109
|
-
...args
|
|
117
|
+
...args.params,
|
|
110
118
|
arguments: newArgs
|
|
111
119
|
});
|
|
112
120
|
const { content, structuredContent } = response;
|
|
@@ -118,10 +126,11 @@ runMain(defineCommand({
|
|
|
118
126
|
}] },
|
|
119
127
|
app_id: process.env.APP_ID,
|
|
120
128
|
event_type: "tool_output",
|
|
129
|
+
user_id: process.env.CS_AIDR_USER_ID,
|
|
121
130
|
extra_info: {
|
|
122
131
|
app_name: process.env.APP_NAME,
|
|
123
132
|
mcp_server_name: serverVersion.name,
|
|
124
|
-
tool_name: args
|
|
133
|
+
tool_name: args.params.name
|
|
125
134
|
}
|
|
126
135
|
});
|
|
127
136
|
if (guardedOutput.status !== "Success") throw new Error("Failed to guard output.");
|
|
@@ -150,18 +159,23 @@ runMain(defineCommand({
|
|
|
150
159
|
}];
|
|
151
160
|
}
|
|
152
161
|
}
|
|
153
|
-
} else for (const contentItem of content.filter((c) => c
|
|
162
|
+
} else for (const contentItem of content.filter((c) => isTextContent(c) || isImageContent(c))) {
|
|
163
|
+
const content = isTextContent(contentItem) ? contentItem.text : [{
|
|
164
|
+
type: "image_url",
|
|
165
|
+
image_url: { url: `data:${contentItem.mimeType};base64,${contentItem.data}` }
|
|
166
|
+
}];
|
|
154
167
|
const guardedOutput = await aiGuard.guardChatCompletions({
|
|
155
168
|
guard_input: { messages: [{
|
|
156
169
|
role: "tool",
|
|
157
|
-
content
|
|
170
|
+
content
|
|
158
171
|
}] },
|
|
159
172
|
app_id: process.env.APP_ID,
|
|
160
173
|
event_type: "tool_output",
|
|
174
|
+
user_id: process.env.CS_AIDR_USER_ID,
|
|
161
175
|
extra_info: {
|
|
162
176
|
app_name: process.env.APP_NAME,
|
|
163
177
|
mcp_server_name: serverVersion.name,
|
|
164
|
-
tool_name: args
|
|
178
|
+
tool_name: args.params.name
|
|
165
179
|
}
|
|
166
180
|
});
|
|
167
181
|
if (guardedOutput.status !== "Success") throw new Error("Failed to guard output.");
|
|
@@ -175,15 +189,14 @@ runMain(defineCommand({
|
|
|
175
189
|
isError: true
|
|
176
190
|
};
|
|
177
191
|
}
|
|
178
|
-
if (guardedOutput.result?.transformed) contentItem.text = (guardedOutput.result.guard_output?.messages)[0].content;
|
|
192
|
+
if (isTextContent(contentItem) && guardedOutput.result?.transformed) contentItem.text = (guardedOutput.result.guard_output?.messages)[0].content;
|
|
179
193
|
}
|
|
180
194
|
return response;
|
|
181
195
|
});
|
|
182
196
|
}
|
|
183
|
-
if (serverCapabilities?.completions) server.setRequestHandler(CompleteRequestSchema, (args
|
|
197
|
+
if (serverCapabilities?.completions) server.setRequestHandler(CompleteRequestSchema, (args) => client.complete(args.params));
|
|
184
198
|
await server.connect(serverTransport);
|
|
185
199
|
}
|
|
186
200
|
}));
|
|
187
|
-
|
|
188
201
|
//#endregion
|
|
189
|
-
export {
|
|
202
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdstrike/aidr-mcp-proxy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Protect any MCP server from malicious entities and confidential PII.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@biomejs/biome": "2.3.11",
|
|
31
|
-
"@containerbase/semantic-release-pnpm": "1.3.
|
|
31
|
+
"@containerbase/semantic-release-pnpm": "1.3.28",
|
|
32
32
|
"@tsconfig/node22": "22.0.5",
|
|
33
33
|
"@types/node": "22.19.1",
|
|
34
|
-
"conventional-changelog-conventionalcommits": "9.
|
|
34
|
+
"conventional-changelog-conventionalcommits": "9.3.0",
|
|
35
35
|
"lefthook": "2.0.15",
|
|
36
36
|
"semantic-release": "25.0.3",
|
|
37
|
-
"tsdown": "0.
|
|
37
|
+
"tsdown": "0.21.4",
|
|
38
38
|
"typescript": "5.9.3"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|