@crowdstrike/aidr-mcp-proxy 1.0.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.txt +21 -0
- package/README.md +102 -0
- package/dist/proxy.mjs +184 -0
- package/package.json +47 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CrowdStrike
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# CrowdStrike AIDR MCP proxy
|
|
2
|
+
|
|
3
|
+
Protect communications between a client and any MCP server. Now with 99% less
|
|
4
|
+
prompt injection! The CrowdStrike AIDR MCP proxy allows any MCP client to secure
|
|
5
|
+
the messages it sends and receives to/from an MCP server, using the CrowdStrike
|
|
6
|
+
AIDR service to guard tools' inputs and outputs.
|
|
7
|
+
|
|
8
|
+
What it does: protect users from common threat vectors by running all MCP I/O
|
|
9
|
+
through CrowdStrike AIDR, which blocks:
|
|
10
|
+
|
|
11
|
+
- Prompt injections (yes, even the ones wrapped in a riddle)
|
|
12
|
+
- Malicious links, IPs, domains
|
|
13
|
+
- 50 types of confidential information and PII
|
|
14
|
+
- 10 content filters, including toxicity, self harm, violence, and filtering by topic
|
|
15
|
+
- Support for 104 spoken languages
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
- Node.js v22.15.0 or greater.
|
|
20
|
+
- A CrowdStrike AIDR API token.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
In an existing stdio-based MCP server configuration like the following:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"qrcode": {
|
|
30
|
+
"command": "npx",
|
|
31
|
+
"args": ["-y", "@jwalsh/mcp-server-qrcode"]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Wrap the original command with `npx -y @crowdstrike/aidr-mcp-proxy` and add
|
|
38
|
+
environment variables:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"qrcode": {
|
|
44
|
+
"command": "npx",
|
|
45
|
+
"args": [
|
|
46
|
+
"-y",
|
|
47
|
+
"@crowdstrike/aidr-mcp-proxy",
|
|
48
|
+
"--",
|
|
49
|
+
"npx",
|
|
50
|
+
"-y",
|
|
51
|
+
"@jwalsh/mcp-server-qrcode"
|
|
52
|
+
],
|
|
53
|
+
"env": {
|
|
54
|
+
"CS_AIDR_TOKEN": "cs_00000000000000000000000000000000",
|
|
55
|
+
"CS_AIDR_BASE_URL_TEMPLATE": "https://api.falcon.crowdstrike.com/aidr/{SERVICE_NAME}"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
1. Update the `CS_AIDR_TOKEN` value to the CrowdStrike AIDR API token.
|
|
63
|
+
1. Update the `CS_AIDR_BASE_URL_TEMPLATE` value to the CrowdStrike AIDR base URL
|
|
64
|
+
template.
|
|
65
|
+
|
|
66
|
+
For remote servers using HTTP or SSE, use [mcp-remote][] to turn them into stdio
|
|
67
|
+
servers:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"mcpServers": {
|
|
72
|
+
"proxied": {
|
|
73
|
+
"command": "npx",
|
|
74
|
+
"args": [
|
|
75
|
+
"-y",
|
|
76
|
+
"@crowdstrike/aidr-mcp-proxy",
|
|
77
|
+
"--",
|
|
78
|
+
"npx",
|
|
79
|
+
"-y",
|
|
80
|
+
"mcp-remote",
|
|
81
|
+
"https://remote.mcp.server/sse"
|
|
82
|
+
],
|
|
83
|
+
"env": {
|
|
84
|
+
"CS_AIDR_TOKEN": "cs_00000000000000000000000000000000",
|
|
85
|
+
"CS_AIDR_BASE_URL_TEMPLATE": "https://api.falcon.crowdstrike.com/aidr/{SERVICE_NAME}"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### App ID
|
|
93
|
+
|
|
94
|
+
To identify the calling app by ID in CrowdStrike AIDR, set the `APP_ID`
|
|
95
|
+
environment variable.
|
|
96
|
+
|
|
97
|
+
### App name
|
|
98
|
+
|
|
99
|
+
To identify the calling app by name in CrowdStrike AIDR, set the `APP_NAME`
|
|
100
|
+
environment variable.
|
|
101
|
+
|
|
102
|
+
[mcp-remote]: https://github.com/geelen/mcp-remote
|
package/dist/proxy.mjs
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AIGuard } from "@crowdstrike/aidr";
|
|
3
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
5
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import { CallToolRequestSchema, CompleteRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourceTemplatesRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, LoggingMessageNotificationSchema, ReadResourceRequestSchema, ResourceUpdatedNotificationSchema, SubscribeRequestSchema, UnsubscribeRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
import { defineCommand, runMain } from "citty";
|
|
9
|
+
import { consola } from "consola";
|
|
10
|
+
|
|
11
|
+
//#region src/proxy.ts
|
|
12
|
+
runMain(defineCommand({
|
|
13
|
+
args: {},
|
|
14
|
+
async run({ args }) {
|
|
15
|
+
if (!process.env.CS_AIDR_TOKEN) throw new Error("Missing environment variable: CS_AIDR_TOKEN");
|
|
16
|
+
if (!process.env.CS_AIDR_BASE_URL_TEMPLATE) throw new Error("Missing environment variable: CS_AIDR_BASE_URL_TEMPLATE");
|
|
17
|
+
if (args._.length < 1) {
|
|
18
|
+
consola.error("No command provided.");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const clientTransport = new StdioClientTransport({
|
|
22
|
+
command: args._[0],
|
|
23
|
+
args: args._.slice(1),
|
|
24
|
+
env: process.env,
|
|
25
|
+
stderr: "pipe"
|
|
26
|
+
});
|
|
27
|
+
const client = new Client({
|
|
28
|
+
name: "cs-aidr-mcp-proxy-client",
|
|
29
|
+
version: "1.0.0"
|
|
30
|
+
}, { capabilities: {} });
|
|
31
|
+
await client.connect(clientTransport);
|
|
32
|
+
const serverTransport = new StdioServerTransport();
|
|
33
|
+
const serverCapabilities = client.getServerCapabilities();
|
|
34
|
+
const serverVersion = client.getServerVersion();
|
|
35
|
+
const server = new Server(serverVersion, { capabilities: serverCapabilities });
|
|
36
|
+
if (serverCapabilities?.logging) server.setNotificationHandler(LoggingMessageNotificationSchema, (args$1) => client.notification(args$1));
|
|
37
|
+
if (serverCapabilities?.prompts) {
|
|
38
|
+
server.setRequestHandler(GetPromptRequestSchema, (args$1) => client.getPrompt(args$1.params));
|
|
39
|
+
server.setRequestHandler(ListPromptsRequestSchema, (args$1) => client.listPrompts(args$1.params));
|
|
40
|
+
}
|
|
41
|
+
if (serverCapabilities?.resources) {
|
|
42
|
+
server.setRequestHandler(ListResourcesRequestSchema, (args$1) => client.listResources(args$1.params));
|
|
43
|
+
server.setRequestHandler(ListResourceTemplatesRequestSchema, (args$1) => client.listResourceTemplates(args$1.params));
|
|
44
|
+
server.setRequestHandler(ReadResourceRequestSchema, (args$1) => client.readResource(args$1.params));
|
|
45
|
+
if (serverCapabilities?.resources.subscribe) {
|
|
46
|
+
server.setNotificationHandler(ResourceUpdatedNotificationSchema, (args$1) => client.notification(args$1));
|
|
47
|
+
server.setRequestHandler(SubscribeRequestSchema, (args$1) => client.subscribeResource(args$1.params));
|
|
48
|
+
server.setRequestHandler(UnsubscribeRequestSchema, (args$1) => client.unsubscribeResource(args$1.params));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (serverCapabilities?.tools) {
|
|
52
|
+
const aiGuard = new AIGuard({
|
|
53
|
+
token: process.env.CS_AIDR_TOKEN,
|
|
54
|
+
baseURLTemplate: process.env.CS_AIDR_BASE_URL_TEMPLATE
|
|
55
|
+
});
|
|
56
|
+
server.setRequestHandler(ListToolsRequestSchema, async (args$1) => {
|
|
57
|
+
const response = await client.listTools(args$1.params);
|
|
58
|
+
const { tools } = response;
|
|
59
|
+
const guardedToolsList = await aiGuard.guardChatCompletions({
|
|
60
|
+
guard_input: {
|
|
61
|
+
messages: [],
|
|
62
|
+
tools
|
|
63
|
+
},
|
|
64
|
+
app_id: process.env.APP_ID,
|
|
65
|
+
event_type: "tool_listing",
|
|
66
|
+
extra_info: {
|
|
67
|
+
app_name: process.env.APP_NAME,
|
|
68
|
+
mcp_server_name: serverVersion.name
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (guardedToolsList.status !== "Success") throw new Error(`Failed to guard tools list. ${JSON.stringify(guardedToolsList, null, 2)}`);
|
|
72
|
+
return guardedToolsList.result?.blocked ? {
|
|
73
|
+
...response,
|
|
74
|
+
tools: []
|
|
75
|
+
} : response;
|
|
76
|
+
});
|
|
77
|
+
server.setRequestHandler(CallToolRequestSchema, async (args$1) => {
|
|
78
|
+
const guardedInput = await aiGuard.guardChatCompletions({
|
|
79
|
+
guard_input: { messages: [{
|
|
80
|
+
role: "user",
|
|
81
|
+
content: JSON.stringify(args$1.params.arguments) ?? ""
|
|
82
|
+
}] },
|
|
83
|
+
app_id: process.env.APP_ID,
|
|
84
|
+
event_type: "tool_input",
|
|
85
|
+
extra_info: {
|
|
86
|
+
app_name: process.env.APP_NAME,
|
|
87
|
+
mcp_server_name: serverVersion.name,
|
|
88
|
+
tool_name: args$1.params.name
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (guardedInput.status !== "Success") throw new Error("Failed to guard input.");
|
|
92
|
+
if (guardedInput.result?.blocked) {
|
|
93
|
+
const { guard_output, ...rest } = guardedInput.result;
|
|
94
|
+
return {
|
|
95
|
+
content: [{
|
|
96
|
+
type: "text",
|
|
97
|
+
text: `Input has been blocked by CrowdStrike AIDR.\n\n${JSON.stringify(rest, null, 2)}`
|
|
98
|
+
}],
|
|
99
|
+
isError: true
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const newArgs = guardedInput.result?.transformed ? JSON.parse((guardedInput.result?.guard_output?.messages)[0].content ?? "{}") : args$1.params.arguments;
|
|
103
|
+
const response = await client.callTool({
|
|
104
|
+
...args$1.params,
|
|
105
|
+
arguments: newArgs
|
|
106
|
+
});
|
|
107
|
+
const { content, structuredContent } = response;
|
|
108
|
+
if (structuredContent) {
|
|
109
|
+
const guardedOutput = await aiGuard.guardChatCompletions({
|
|
110
|
+
guard_input: { messages: [{
|
|
111
|
+
role: "tool",
|
|
112
|
+
content: JSON.stringify(structuredContent)
|
|
113
|
+
}] },
|
|
114
|
+
app_id: process.env.APP_ID,
|
|
115
|
+
event_type: "tool_output",
|
|
116
|
+
extra_info: {
|
|
117
|
+
app_name: process.env.APP_NAME,
|
|
118
|
+
mcp_server_name: serverVersion.name,
|
|
119
|
+
tool_name: args$1.params.name
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
if (guardedOutput.status !== "Success") throw new Error("Failed to guard output.");
|
|
123
|
+
if (guardedOutput.result?.blocked) {
|
|
124
|
+
const { guard_output, ...rest } = guardedOutput.result;
|
|
125
|
+
return {
|
|
126
|
+
content: [{
|
|
127
|
+
type: "text",
|
|
128
|
+
text: `Output has been blocked by CrowdStrike AIDR.\n\n${JSON.stringify(rest, null, 2)}`
|
|
129
|
+
}],
|
|
130
|
+
isError: true
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (guardedOutput.result?.transformed) {
|
|
134
|
+
const contentText = (guardedOutput.result.guard_output?.messages)[0].content;
|
|
135
|
+
try {
|
|
136
|
+
response.structuredContent = JSON.parse(contentText);
|
|
137
|
+
response.content = [{
|
|
138
|
+
type: "text",
|
|
139
|
+
text: JSON.stringify(response.structuredContent)
|
|
140
|
+
}];
|
|
141
|
+
} catch {
|
|
142
|
+
response.content = [{
|
|
143
|
+
type: "text",
|
|
144
|
+
text: contentText
|
|
145
|
+
}];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
} else for (const contentItem of content.filter((c) => c.type === "text")) {
|
|
149
|
+
const guardedOutput = await aiGuard.guardChatCompletions({
|
|
150
|
+
guard_input: { messages: [{
|
|
151
|
+
role: "tool",
|
|
152
|
+
content: contentItem.text
|
|
153
|
+
}] },
|
|
154
|
+
app_id: process.env.APP_ID,
|
|
155
|
+
event_type: "tool_output",
|
|
156
|
+
extra_info: {
|
|
157
|
+
app_name: process.env.APP_NAME,
|
|
158
|
+
mcp_server_name: serverVersion.name,
|
|
159
|
+
tool_name: args$1.params.name
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
if (guardedOutput.status !== "Success") throw new Error("Failed to guard output.");
|
|
163
|
+
if (guardedOutput.result?.blocked) {
|
|
164
|
+
const { guard_output, ...rest } = guardedOutput.result;
|
|
165
|
+
return {
|
|
166
|
+
content: [{
|
|
167
|
+
type: "text",
|
|
168
|
+
text: `Output has been blocked by CrowdStrike AIDR.\n\n${JSON.stringify(rest, null, 2)}`
|
|
169
|
+
}],
|
|
170
|
+
isError: true
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (guardedOutput.result?.transformed) contentItem.text = (guardedOutput.result.guard_output?.messages)[0].content;
|
|
174
|
+
}
|
|
175
|
+
return response;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (serverCapabilities?.completions) server.setRequestHandler(CompleteRequestSchema, (args$1) => client.complete(args$1.params));
|
|
179
|
+
await server.connect(serverTransport);
|
|
180
|
+
}
|
|
181
|
+
}));
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
export { };
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crowdstrike/aidr-mcp-proxy",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Protect any MCP server from malicious entities and confidential PII.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/CrowdStrike/aidr-mcp-proxy.git"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"LICENSE.txt",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"main": "dist/proxy.mjs",
|
|
20
|
+
"bin": {
|
|
21
|
+
"mcp-proxy": "dist/proxy.mjs"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@crowdstrike/aidr": "^1.0.2",
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
26
|
+
"citty": "^0.1.6",
|
|
27
|
+
"consola": "^3.4.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@biomejs/biome": "2.3.8",
|
|
31
|
+
"@containerbase/semantic-release-pnpm": "1.3.5",
|
|
32
|
+
"@kenan/biome-config": "1.0.6",
|
|
33
|
+
"@tsconfig/node22": "22.0.5",
|
|
34
|
+
"@types/node": "22.19.1",
|
|
35
|
+
"conventional-changelog-conventionalcommits": "9.1.0",
|
|
36
|
+
"lefthook": "2.0.4",
|
|
37
|
+
"semantic-release": "25.0.2",
|
|
38
|
+
"tsdown": "0.17.2",
|
|
39
|
+
"typescript": "5.9.3"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsdown && pnpm typecheck",
|
|
43
|
+
"lint": "biome check .",
|
|
44
|
+
"lint:fix": "biome check --write .",
|
|
45
|
+
"typecheck": "tsc --noEmit"
|
|
46
|
+
}
|
|
47
|
+
}
|