shrike-mcp 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 +201 -0
- package/README.md +279 -0
- package/dist/auth.d.ts +25 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +80 -0
- package/dist/auth.js.map +1 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +53 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +264 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/rateLimiter.d.ts +40 -0
- package/dist/middleware/rateLimiter.d.ts.map +1 -0
- package/dist/middleware/rateLimiter.js +100 -0
- package/dist/middleware/rateLimiter.js.map +1 -0
- package/dist/tools/fileWrite.d.ts +71 -0
- package/dist/tools/fileWrite.d.ts.map +1 -0
- package/dist/tools/fileWrite.js +282 -0
- package/dist/tools/fileWrite.js.map +1 -0
- package/dist/tools/reportBypass.d.ts +71 -0
- package/dist/tools/reportBypass.d.ts.map +1 -0
- package/dist/tools/reportBypass.js +174 -0
- package/dist/tools/reportBypass.js.map +1 -0
- package/dist/tools/scan.d.ts +195 -0
- package/dist/tools/scan.d.ts.map +1 -0
- package/dist/tools/scan.js +367 -0
- package/dist/tools/scan.js.map +1 -0
- package/dist/tools/scanResponse.d.ts +83 -0
- package/dist/tools/scanResponse.d.ts.map +1 -0
- package/dist/tools/scanResponse.js +355 -0
- package/dist/tools/scanResponse.js.map +1 -0
- package/dist/tools/sqlQuery.d.ts +69 -0
- package/dist/tools/sqlQuery.d.ts.map +1 -0
- package/dist/tools/sqlQuery.js +214 -0
- package/dist/tools/sqlQuery.js.map +1 -0
- package/dist/tools/threatIntel.d.ts +50 -0
- package/dist/tools/threatIntel.d.ts.map +1 -0
- package/dist/tools/threatIntel.js +77 -0
- package/dist/tools/threatIntel.js.map +1 -0
- package/dist/tools/webSearch.d.ts +66 -0
- package/dist/tools/webSearch.d.ts.map +1 -0
- package/dist/tools/webSearch.js +254 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/utils/piiRedactor.d.ts +48 -0
- package/dist/utils/piiRedactor.d.ts.map +1 -0
- package/dist/utils/piiRedactor.js +187 -0
- package/dist/utils/piiRedactor.js.map +1 -0
- package/dist/utils/responseFormatter.d.ts +183 -0
- package/dist/utils/responseFormatter.d.ts.map +1 -0
- package/dist/utils/responseFormatter.js +371 -0
- package/dist/utils/responseFormatter.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 Shrike Security
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# shrike-mcp
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for Shrike Security — protect AI agents from prompt injection, jailbreaks, SQL injection, data exfiltration, and malicious file operations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g shrike-mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use with npx:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx shrike-mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### With Claude Desktop
|
|
20
|
+
|
|
21
|
+
Add to your Claude Desktop configuration (`~/.claude/claude_desktop_config.json`):
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"mcpServers": {
|
|
26
|
+
"shrike-security": {
|
|
27
|
+
"command": "npx",
|
|
28
|
+
"args": ["shrike-mcp"],
|
|
29
|
+
"env": {
|
|
30
|
+
"SHRIKE_API_KEY": "your-api-key-here"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Without an API key, scans run on the free tier (regex-only layers L1–L4). With an API key, you get the full 9-layer scan pipeline including LLM semantic analysis.
|
|
38
|
+
|
|
39
|
+
### Environment Variables
|
|
40
|
+
|
|
41
|
+
| Variable | Description | Default |
|
|
42
|
+
|----------|-------------|---------|
|
|
43
|
+
| `SHRIKE_API_KEY` | API key for authenticated scans (enables L7/L8 LLM layers) | *none* (free tier) |
|
|
44
|
+
| `SHRIKE_BACKEND_URL` | URL of the Shrike backend API | `https://api.shrikesecurity.com/agent` |
|
|
45
|
+
| `MCP_SCAN_TIMEOUT_MS` | Timeout for scan requests (ms) | `15000` |
|
|
46
|
+
| `MCP_RATE_LIMIT_PER_MINUTE` | Max requests per minute per customer | `100` |
|
|
47
|
+
| `MCP_DEBUG` | Enable debug logging (`true`/`false`) | `false` |
|
|
48
|
+
|
|
49
|
+
## Available Tools
|
|
50
|
+
|
|
51
|
+
### `scan_prompt`
|
|
52
|
+
|
|
53
|
+
Scans user prompts for prompt injection, jailbreak attempts, and malicious content. Supports PII redaction with token-based rehydration.
|
|
54
|
+
|
|
55
|
+
**Parameters:**
|
|
56
|
+
|
|
57
|
+
| Parameter | Type | Required | Description |
|
|
58
|
+
|-----------|------|----------|-------------|
|
|
59
|
+
| `content` | string | Yes | The prompt text to scan |
|
|
60
|
+
| `context` | string | No | Conversation history for context-aware scanning |
|
|
61
|
+
| `redact_pii` | boolean | No | When true, PII is redacted before scanning. Response includes tokens for rehydration. |
|
|
62
|
+
|
|
63
|
+
**Example:**
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const result = await mcp.callTool('scan_prompt', {
|
|
67
|
+
content: userInput,
|
|
68
|
+
context: conversationHistory,
|
|
69
|
+
redact_pii: true,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (result.blocked) {
|
|
73
|
+
console.log('Threat detected:', result.threat_type);
|
|
74
|
+
} else if (result.pii_redaction) {
|
|
75
|
+
// Use redacted content for LLM processing
|
|
76
|
+
const safePrompt = result.pii_redaction.redacted_content;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `scan_response`
|
|
81
|
+
|
|
82
|
+
Scans LLM-generated responses before showing them to users. Detects system prompt leaks, unexpected PII, toxic language, and topic drift. Rehydrates PII tokens when provided.
|
|
83
|
+
|
|
84
|
+
**Parameters:**
|
|
85
|
+
|
|
86
|
+
| Parameter | Type | Required | Description |
|
|
87
|
+
|-----------|------|----------|-------------|
|
|
88
|
+
| `response` | string | Yes | The LLM-generated response to scan |
|
|
89
|
+
| `original_prompt` | string | No | The original prompt (enables PII diff and topic mismatch detection) |
|
|
90
|
+
| `pii_tokens` | array | No | PII token map from `scan_prompt(redact_pii=true)` for rehydration |
|
|
91
|
+
|
|
92
|
+
**Example:**
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const result = await mcp.callTool('scan_response', {
|
|
96
|
+
response: llmOutput,
|
|
97
|
+
original_prompt: userInput,
|
|
98
|
+
pii_tokens: scanPromptResult.pii_redaction?.tokens,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (result.blocked) {
|
|
102
|
+
console.log('Response blocked:', result.threat_type);
|
|
103
|
+
} else if (result.rehydrated_response) {
|
|
104
|
+
// PII tokens replaced with original values
|
|
105
|
+
showToUser(result.rehydrated_response);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `scan_sql_query`
|
|
110
|
+
|
|
111
|
+
Scans SQL queries for injection attacks and dangerous operations before execution.
|
|
112
|
+
|
|
113
|
+
**Parameters:**
|
|
114
|
+
|
|
115
|
+
| Parameter | Type | Required | Description |
|
|
116
|
+
|-----------|------|----------|-------------|
|
|
117
|
+
| `query` | string | Yes | The SQL query to scan |
|
|
118
|
+
| `database` | string | No | Target database name for context |
|
|
119
|
+
| `allowDestructive` | boolean | No | Allow DROP/TRUNCATE for migrations (default: false) |
|
|
120
|
+
|
|
121
|
+
**Example:**
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const result = await mcp.callTool('scan_sql_query', {
|
|
125
|
+
query: sqlQuery,
|
|
126
|
+
database: 'postgresql',
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
if (result.blocked) {
|
|
130
|
+
throw new Error(`SQL injection detected: ${result.guidance}`);
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### `scan_file_write`
|
|
135
|
+
|
|
136
|
+
Validates file paths and content before write operations. Checks for path traversal, secrets in content, and sensitive file access.
|
|
137
|
+
|
|
138
|
+
**Parameters:**
|
|
139
|
+
|
|
140
|
+
| Parameter | Type | Required | Description |
|
|
141
|
+
|-----------|------|----------|-------------|
|
|
142
|
+
| `path` | string | Yes | The target file path |
|
|
143
|
+
| `content` | string | Yes | The content to write |
|
|
144
|
+
| `mode` | string | No | Write mode: `create`, `overwrite`, or `append` |
|
|
145
|
+
|
|
146
|
+
**Example:**
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const result = await mcp.callTool('scan_file_write', {
|
|
150
|
+
path: filePath,
|
|
151
|
+
content: fileContent,
|
|
152
|
+
mode: 'create',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (result.blocked) {
|
|
156
|
+
throw new Error(`File write blocked: ${result.guidance}`);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `scan_web_search`
|
|
161
|
+
|
|
162
|
+
Scans web search queries for PII exposure, data exfiltration patterns, and blocked domains.
|
|
163
|
+
|
|
164
|
+
**Parameters:**
|
|
165
|
+
|
|
166
|
+
| Parameter | Type | Required | Description |
|
|
167
|
+
|-----------|------|----------|-------------|
|
|
168
|
+
| `query` | string | Yes | The search query to scan |
|
|
169
|
+
| `targetDomains` | string[] | No | List of target domains to validate |
|
|
170
|
+
|
|
171
|
+
**Example:**
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const result = await mcp.callTool('scan_web_search', {
|
|
175
|
+
query: searchQuery,
|
|
176
|
+
targetDomains: ['example.com'],
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
if (result.blocked) {
|
|
180
|
+
console.log('Search blocked:', result.guidance);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `report_bypass`
|
|
185
|
+
|
|
186
|
+
Reports content that bypassed security checks to improve detection via ThreatSense pattern learning.
|
|
187
|
+
|
|
188
|
+
**Parameters:**
|
|
189
|
+
|
|
190
|
+
| Parameter | Type | Required | Description |
|
|
191
|
+
|-----------|------|----------|-------------|
|
|
192
|
+
| `prompt` | string | No | The prompt that bypassed detection |
|
|
193
|
+
| `filePath` | string | No | File path for file_write bypasses |
|
|
194
|
+
| `fileContent` | string | No | File content that should have been blocked |
|
|
195
|
+
| `sqlQuery` | string | No | SQL query that bypassed injection detection |
|
|
196
|
+
| `searchQuery` | string | No | Web search query with undetected PII |
|
|
197
|
+
| `mutationType` | string | No | Type of mutation used (e.g., `semantic_rewrite`, `encoding_exploit`) |
|
|
198
|
+
| `category` | string | No | Threat category (auto-inferred if not provided) |
|
|
199
|
+
| `notes` | string | No | Additional notes about the bypass |
|
|
200
|
+
|
|
201
|
+
### `get_threat_intel`
|
|
202
|
+
|
|
203
|
+
Retrieves current threat intelligence including active detection patterns, threat categories, and statistics.
|
|
204
|
+
|
|
205
|
+
**Parameters:**
|
|
206
|
+
|
|
207
|
+
| Parameter | Type | Required | Description |
|
|
208
|
+
|-----------|------|----------|-------------|
|
|
209
|
+
| `category` | string | No | Filter by threat category |
|
|
210
|
+
| `limit` | number | No | Max patterns to return (default: 50) |
|
|
211
|
+
|
|
212
|
+
## Response Format
|
|
213
|
+
|
|
214
|
+
All scan tools return a sanitized response:
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"blocked": true,
|
|
219
|
+
"threat_type": "prompt_injection",
|
|
220
|
+
"severity": "high",
|
|
221
|
+
"confidence": "high",
|
|
222
|
+
"guidance": "This prompt contains patterns consistent with instruction override attempts.",
|
|
223
|
+
"request_id": "req_lxyz123_a8f3k2m9"
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Safe results return:
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"blocked": false,
|
|
232
|
+
"request_id": "req_lxyz123_a8f3k2m9"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Security Model
|
|
237
|
+
|
|
238
|
+
This MCP server implements a **fail-closed** security model:
|
|
239
|
+
|
|
240
|
+
- Network timeouts result in **BLOCK** (not allow)
|
|
241
|
+
- Backend errors result in **BLOCK** (not allow)
|
|
242
|
+
- Unknown content types result in **BLOCK** (not allow)
|
|
243
|
+
|
|
244
|
+
This prevents bypass attacks via service disruption.
|
|
245
|
+
|
|
246
|
+
## Self-Hosting
|
|
247
|
+
|
|
248
|
+
To run your own Shrike backend:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
git clone https://github.com/shrike-security/shrike-security-agent.git
|
|
252
|
+
cd shrike-security-agent/backend
|
|
253
|
+
go run ./cmd/refactored-agent
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Then point the MCP server to your local backend:
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"mcpServers": {
|
|
261
|
+
"shrike-security": {
|
|
262
|
+
"command": "npx",
|
|
263
|
+
"args": ["shrike-mcp"],
|
|
264
|
+
"env": {
|
|
265
|
+
"SHRIKE_BACKEND_URL": "http://localhost:8080"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
Apache License 2.0 — See [LICENSE](LICENSE) for details.
|
|
275
|
+
|
|
276
|
+
## Links
|
|
277
|
+
|
|
278
|
+
- [GitHub Repository](https://github.com/shrike-security/shrike-security-agent)
|
|
279
|
+
- [Issue Tracker](https://github.com/shrike-security/shrike-security-agent/issues)
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Authentication
|
|
3
|
+
* Validates API keys against the backend and resolves to customer_id
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthResult {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
customerId?: string;
|
|
8
|
+
tier?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validates an API key against the backend
|
|
13
|
+
* Returns customer_id and tier for rate limiting
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateApiKey(apiKey: string): Promise<AuthResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Extracts API key from Authorization header
|
|
18
|
+
* Supports: "Bearer <key>" or raw key
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractApiKey(authHeader: string | undefined): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Clears the key cache (useful for testing)
|
|
23
|
+
*/
|
|
24
|
+
export declare function clearKeyCache(): void;
|
|
25
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA0DxE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAS3E;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Authentication
|
|
3
|
+
* Validates API keys against the backend and resolves to customer_id
|
|
4
|
+
*/
|
|
5
|
+
import { config } from './config.js';
|
|
6
|
+
// Cache validated keys for 5 minutes to reduce backend calls
|
|
7
|
+
const keyCache = new Map();
|
|
8
|
+
const CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
9
|
+
/**
|
|
10
|
+
* Validates an API key against the backend
|
|
11
|
+
* Returns customer_id and tier for rate limiting
|
|
12
|
+
*/
|
|
13
|
+
export async function validateApiKey(apiKey) {
|
|
14
|
+
if (!apiKey) {
|
|
15
|
+
return { valid: false, error: 'API key is required' };
|
|
16
|
+
}
|
|
17
|
+
// Check cache first
|
|
18
|
+
const cached = keyCache.get(apiKey);
|
|
19
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
20
|
+
return cached.result;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const response = await fetch(`${config.backendUrl}/api/internal/validate-key`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({ api_key: apiKey }),
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
const result = {
|
|
32
|
+
valid: false,
|
|
33
|
+
error: `Backend returned ${response.status}`,
|
|
34
|
+
};
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
const data = await response.json();
|
|
38
|
+
const result = {
|
|
39
|
+
valid: data.valid,
|
|
40
|
+
customerId: data.customer_id,
|
|
41
|
+
tier: data.tier,
|
|
42
|
+
error: data.error,
|
|
43
|
+
};
|
|
44
|
+
// Cache successful validations
|
|
45
|
+
if (result.valid) {
|
|
46
|
+
keyCache.set(apiKey, {
|
|
47
|
+
result,
|
|
48
|
+
expiresAt: Date.now() + CACHE_TTL_MS,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error('API key validation failed:', error);
|
|
55
|
+
return {
|
|
56
|
+
valid: false,
|
|
57
|
+
error: error instanceof Error ? error.message : 'Validation failed',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Extracts API key from Authorization header
|
|
63
|
+
* Supports: "Bearer <key>" or raw key
|
|
64
|
+
*/
|
|
65
|
+
export function extractApiKey(authHeader) {
|
|
66
|
+
if (!authHeader)
|
|
67
|
+
return null;
|
|
68
|
+
if (authHeader.startsWith('Bearer ')) {
|
|
69
|
+
return authHeader.slice(7).trim();
|
|
70
|
+
}
|
|
71
|
+
// Allow raw key for simplicity
|
|
72
|
+
return authHeader.trim();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Clears the key cache (useful for testing)
|
|
76
|
+
*/
|
|
77
|
+
export function clearKeyCache() {
|
|
78
|
+
keyCache.clear();
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,6DAA6D;AAC7D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAqD,CAAC;AAC9E,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAEhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc;IACjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;IACxD,CAAC;IAED,oBAAoB;IACpB,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,UAAU,4BAA4B,EAAE;YAC7E,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SAC1C,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,MAAM,GAAe;gBACzB,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,oBAAoB,QAAQ,CAAC,MAAM,EAAE;aAC7C,CAAC;YACF,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAK/B,CAAC;QAEF,MAAM,MAAM,GAAe;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;QAEF,+BAA+B;QAC/B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE;gBACnB,MAAM;gBACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY;aACrC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;SACpE,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,UAA8B;IAC1D,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7B,IAAI,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACrC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IAED,+BAA+B;IAC/B,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Configuration
|
|
3
|
+
* Loads settings from environment variables with sensible defaults
|
|
4
|
+
*/
|
|
5
|
+
export interface Config {
|
|
6
|
+
/** MCP server port */
|
|
7
|
+
port: number;
|
|
8
|
+
/** Backend API URL for scan requests */
|
|
9
|
+
backendUrl: string;
|
|
10
|
+
/** Shrike API key for authenticated (paid tier) scans */
|
|
11
|
+
apiKey: string | null;
|
|
12
|
+
/** Timeout for scan requests in milliseconds */
|
|
13
|
+
scanTimeoutMs: number;
|
|
14
|
+
/** Rate limit: requests per minute per API key */
|
|
15
|
+
rateLimitPerMinute: number;
|
|
16
|
+
/** Heartbeat interval in milliseconds */
|
|
17
|
+
heartbeatIntervalMs: number;
|
|
18
|
+
/** Enable debug logging */
|
|
19
|
+
debug: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const config: Config;
|
|
22
|
+
export declare function logConfig(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Returns authorization headers if API key is configured
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAuthHeaders(): Record<string, string>;
|
|
27
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,MAAM;IACrB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,yCAAyC;IACzC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2BAA2B;IAC3B,KAAK,EAAE,OAAO,CAAC;CAChB;AAaD,eAAO,MAAM,MAAM,EAAE,MAcpB,CAAC;AAEF,wBAAgB,SAAS,IAAI,IAAI,CAUhC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQvD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Configuration
|
|
3
|
+
* Loads settings from environment variables with sensible defaults
|
|
4
|
+
*/
|
|
5
|
+
function getEnvOrDefault(key, defaultValue) {
|
|
6
|
+
return process.env[key] || defaultValue;
|
|
7
|
+
}
|
|
8
|
+
function getEnvNumber(key, defaultValue) {
|
|
9
|
+
const value = process.env[key];
|
|
10
|
+
if (!value)
|
|
11
|
+
return defaultValue;
|
|
12
|
+
const parsed = parseInt(value, 10);
|
|
13
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
14
|
+
}
|
|
15
|
+
export const config = {
|
|
16
|
+
port: getEnvNumber('MCP_PORT', 3000),
|
|
17
|
+
// Default uses load balancer for scalability. Override with SHRIKE_BACKEND_URL for VPC deployments.
|
|
18
|
+
backendUrl: getEnvOrDefault('SHRIKE_BACKEND_URL', 'https://api.shrikesecurity.com/agent'),
|
|
19
|
+
// API key for authenticated scans (enables LLM layer L7-L8)
|
|
20
|
+
// Without API key, scans are free tier (L1-L4 regex only)
|
|
21
|
+
// Get your API key at: https://console.shrikesecurity.com/api-keys
|
|
22
|
+
apiKey: process.env.SHRIKE_API_KEY || null,
|
|
23
|
+
// SECURITY: 15000ms allows for full 8-layer scan pipeline with LLM analysis
|
|
24
|
+
// Backend takes ~10s for comprehensive scans including vector embeddings + LLM
|
|
25
|
+
scanTimeoutMs: getEnvNumber('MCP_SCAN_TIMEOUT_MS', 15000),
|
|
26
|
+
rateLimitPerMinute: getEnvNumber('MCP_RATE_LIMIT_PER_MINUTE', 100),
|
|
27
|
+
heartbeatIntervalMs: getEnvNumber('MCP_HEARTBEAT_INTERVAL_MS', 30000),
|
|
28
|
+
debug: getEnvOrDefault('MCP_DEBUG', 'false') === 'true',
|
|
29
|
+
};
|
|
30
|
+
export function logConfig() {
|
|
31
|
+
// Use stderr to avoid interfering with MCP JSON-RPC protocol on stdout
|
|
32
|
+
console.error('MCP Server Configuration:');
|
|
33
|
+
console.error(` Port: ${config.port}`);
|
|
34
|
+
console.error(` Backend URL: ${config.backendUrl}`);
|
|
35
|
+
console.error(` API Key: ${config.apiKey ? '***' + config.apiKey.slice(-4) + ' (authenticated - L1-L8 full scan)' : 'NOT SET (free tier - L1-L4 regex only)'}`);
|
|
36
|
+
console.error(` Scan Timeout: ${config.scanTimeoutMs}ms`);
|
|
37
|
+
console.error(` Rate Limit: ${config.rateLimitPerMinute} req/min`);
|
|
38
|
+
console.error(` Heartbeat Interval: ${config.heartbeatIntervalMs}ms`);
|
|
39
|
+
console.error(` Debug: ${config.debug}`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns authorization headers if API key is configured
|
|
43
|
+
*/
|
|
44
|
+
export function getAuthHeaders() {
|
|
45
|
+
const headers = {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
};
|
|
48
|
+
if (config.apiKey) {
|
|
49
|
+
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
50
|
+
}
|
|
51
|
+
return headers;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=config.js.map
|