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