eslint-plugin-mcp-sdk-security 0.1.0 → 0.2.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 +70 -24
- package/package.json +11 -23
- package/src/index.d.ts +17 -0
- package/src/index.js +56 -0
- package/src/oxlint.d.ts +17 -0
- package/src/oxlint.js +3 -0
- package/src/rules/no-command-injection-in-tool/index.js +173 -0
- package/src/rules/no-tool-description-injection/index.js +114 -0
- package/src/rules/no-unvalidated-tool-args/index.js +141 -0
- package/{dist/src → src}/rules/require-tool-input-schema/index.js +0 -35
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -108
- package/dist/package.json +0 -95
- package/dist/src/index.d.ts +0 -44
- package/dist/src/index.js +0 -66
- package/dist/src/oxlint.d.ts +0 -20
- package/dist/src/oxlint.js +0 -21
- package/dist/src/rules/require-tool-input-schema/index.d.ts +0 -8
- package/src/index.test.ts +0 -38
- package/src/index.ts +0 -85
- package/src/oxlint.ts +0 -23
- package/src/rules/require-tool-input-schema/index.ts +0 -150
- package/src/rules/require-tool-input-schema/require-tool-input-schema.test.ts +0 -215
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noUnvalidatedToolArgs = void 0;
|
|
4
|
+
exports.propertyKey = propertyKey;
|
|
5
|
+
exports.declaredSchemaKeys = declaredSchemaKeys;
|
|
6
|
+
exports.destructuredArgNames = destructuredArgNames;
|
|
7
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
8
|
+
const MCP_MODULE_PREFIX = '@modelcontextprotocol/sdk';
|
|
9
|
+
const REGISTER_TOOL = 'registerTool';
|
|
10
|
+
const LEGACY_TOOL = 'tool';
|
|
11
|
+
function propertyKey(prop) {
|
|
12
|
+
if (prop.type !== 'Property' || prop.computed)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (prop.key.type === 'Identifier')
|
|
15
|
+
return prop.key.name;
|
|
16
|
+
if (prop.key.type === 'Literal' && typeof prop.key.value === 'string')
|
|
17
|
+
return prop.key.value;
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
function declaredSchemaKeys(config) {
|
|
21
|
+
const index = config.properties.findIndex((prop) => propertyKey(prop) === 'inputSchema');
|
|
22
|
+
if (index === -1)
|
|
23
|
+
return undefined;
|
|
24
|
+
for (let i = index + 1; i < config.properties.length; i++) {
|
|
25
|
+
if (config.properties[i].type === 'SpreadElement')
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const value = config.properties[index].value;
|
|
29
|
+
if (value.type !== 'ObjectExpression')
|
|
30
|
+
return undefined;
|
|
31
|
+
const keys = new Set();
|
|
32
|
+
for (const entry of value.properties) {
|
|
33
|
+
if (entry.type === 'SpreadElement')
|
|
34
|
+
return undefined;
|
|
35
|
+
const key = propertyKey(entry);
|
|
36
|
+
if (key === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
keys.add(key);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function destructuredArgNames(handler) {
|
|
43
|
+
if (handler.type !== 'ArrowFunctionExpression' &&
|
|
44
|
+
handler.type !== 'FunctionExpression' &&
|
|
45
|
+
handler.type !== 'FunctionDeclaration') {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const first = handler.params[0];
|
|
49
|
+
if (first === undefined || first.type !== 'ObjectPattern')
|
|
50
|
+
return [];
|
|
51
|
+
const found = [];
|
|
52
|
+
for (const prop of first.properties) {
|
|
53
|
+
if (prop.type === 'RestElement')
|
|
54
|
+
continue;
|
|
55
|
+
const key = propertyKey(prop);
|
|
56
|
+
if (key === undefined)
|
|
57
|
+
continue;
|
|
58
|
+
found.push({ name: key, node: prop });
|
|
59
|
+
}
|
|
60
|
+
return found;
|
|
61
|
+
}
|
|
62
|
+
exports.noUnvalidatedToolArgs = (0, eslint_devkit_1.createRule)({
|
|
63
|
+
name: 'no-unvalidated-tool-args',
|
|
64
|
+
meta: {
|
|
65
|
+
type: 'problem',
|
|
66
|
+
docs: {
|
|
67
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-mcp-sdk-security/docs/rules/no-unvalidated-tool-args.md',
|
|
68
|
+
description: 'Disallow a tool handler reading an argument its declared input schema does not include',
|
|
69
|
+
cwe: 'CWE-20',
|
|
70
|
+
cvss: 7.5,
|
|
71
|
+
},
|
|
72
|
+
messages: {
|
|
73
|
+
undeclaredArg: (0, eslint_devkit_1.formatLLMMessage)({
|
|
74
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
75
|
+
issueName: 'MCP Tool Argument Outside the Declared Schema',
|
|
76
|
+
cwe: 'CWE-20',
|
|
77
|
+
owasp: 'A03:2021',
|
|
78
|
+
cvss: 7.5,
|
|
79
|
+
description: 'Tool "{{tool}}" reads `{{arg}}`, which its inputSchema does not declare — so the value either arrives unvalidated or never arrives at all',
|
|
80
|
+
severity: 'HIGH',
|
|
81
|
+
compliance: ['SOC2'],
|
|
82
|
+
fix: 'Declare `{{arg}}` in the inputSchema with the type and constraints it needs, or stop reading it. A key the schema does not mention is one nothing validated.',
|
|
83
|
+
documentationLink: 'https://modelcontextprotocol.io/docs/concepts/tools',
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
schema: [],
|
|
87
|
+
},
|
|
88
|
+
defaultOptions: [],
|
|
89
|
+
create(context) {
|
|
90
|
+
let importsMcpSdk = false;
|
|
91
|
+
const candidates = [];
|
|
92
|
+
function toolNameOf(node) {
|
|
93
|
+
const first = node.arguments[0];
|
|
94
|
+
if (first?.type === 'Literal' && typeof first.value === 'string')
|
|
95
|
+
return first.value;
|
|
96
|
+
return 'unknown';
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
ImportDeclaration(node) {
|
|
100
|
+
if (node.source.value.startsWith(MCP_MODULE_PREFIX))
|
|
101
|
+
importsMcpSdk = true;
|
|
102
|
+
},
|
|
103
|
+
CallExpression(node) {
|
|
104
|
+
if (node.callee.type === 'Identifier' &&
|
|
105
|
+
node.callee.name === 'require' &&
|
|
106
|
+
node.arguments[0]?.type === 'Literal' &&
|
|
107
|
+
typeof node.arguments[0].value === 'string' &&
|
|
108
|
+
node.arguments[0].value.startsWith(MCP_MODULE_PREFIX)) {
|
|
109
|
+
importsMcpSdk = true;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (node.callee.type !== 'MemberExpression' || node.callee.computed)
|
|
113
|
+
return;
|
|
114
|
+
if (node.callee.property.type !== 'Identifier')
|
|
115
|
+
return;
|
|
116
|
+
const method = node.callee.property.name;
|
|
117
|
+
if (method !== REGISTER_TOOL && method !== LEGACY_TOOL)
|
|
118
|
+
return;
|
|
119
|
+
const config = node.arguments[1];
|
|
120
|
+
if (config?.type !== 'ObjectExpression')
|
|
121
|
+
return;
|
|
122
|
+
const declared = declaredSchemaKeys(config);
|
|
123
|
+
if (declared === undefined)
|
|
124
|
+
return;
|
|
125
|
+
const handler = node.arguments[node.arguments.length - 1];
|
|
126
|
+
for (const read of destructuredArgNames(handler)) {
|
|
127
|
+
if (declared.has(read.name))
|
|
128
|
+
continue;
|
|
129
|
+
candidates.push({ node: read.node, tool: toolNameOf(node), arg: read.name });
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
'Program:exit'() {
|
|
133
|
+
if (!importsMcpSdk)
|
|
134
|
+
return;
|
|
135
|
+
for (const { node, tool, arg } of candidates) {
|
|
136
|
+
context.report({ node, messageId: 'undeclaredArg', data: { tool, arg } });
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
});
|
|
@@ -1,42 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
-
* MIT license that can be found in the LICENSE file.
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.requireToolInputSchema = void 0;
|
|
9
|
-
/**
|
|
10
|
-
* @fileoverview Require an input schema when registering an MCP tool
|
|
11
|
-
* @description A tool registered without an input schema receives whatever
|
|
12
|
-
* arguments the client sends. The handler then operates on unvalidated,
|
|
13
|
-
* attacker-influenced input — the entry point for the MCP tool-poisoning and
|
|
14
|
-
* argument-injection classes.
|
|
15
|
-
* @see https://modelcontextprotocol.io/docs/concepts/tools
|
|
16
|
-
*/
|
|
17
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
18
|
-
/**
|
|
19
|
-
* The rule only fires in files that actually import the MCP SDK. Gating on the
|
|
20
|
-
* SDK — rather than on a receiver name like `server` — is what keeps this rule
|
|
21
|
-
* inside its package's scope promise: it cannot fire on code that does not use
|
|
22
|
-
* `@modelcontextprotocol/sdk`.
|
|
23
|
-
*/
|
|
24
5
|
const MCP_MODULE_PREFIX = '@modelcontextprotocol/sdk';
|
|
25
6
|
const REGISTER_TOOL = 'registerTool';
|
|
26
7
|
const LEGACY_TOOL = 'tool';
|
|
27
|
-
/** Node types that stand in for a tool handler in the legacy `tool()` arity. */
|
|
28
8
|
const HANDLER_NODE_TYPES = new Set([
|
|
29
9
|
'ArrowFunctionExpression',
|
|
30
10
|
'FunctionExpression',
|
|
31
11
|
'Identifier',
|
|
32
12
|
]);
|
|
33
|
-
/**
|
|
34
|
-
* Whether the config object literal declares `inputSchema`.
|
|
35
|
-
*
|
|
36
|
-
* Returns `unreadable` for a spread: the schema may well be in the spread
|
|
37
|
-
* source, which is not visible from this node. Reporting there would flag
|
|
38
|
-
* correct code, so the rule stays silent instead.
|
|
39
|
-
*/
|
|
40
13
|
function readInputSchema(config) {
|
|
41
14
|
for (const prop of config.properties) {
|
|
42
15
|
if (prop.type === 'SpreadElement')
|
|
@@ -79,8 +52,6 @@ exports.requireToolInputSchema = (0, eslint_devkit_1.createRule)({
|
|
|
79
52
|
defaultOptions: [],
|
|
80
53
|
create(context) {
|
|
81
54
|
let importsMcpSdk = false;
|
|
82
|
-
// Registrations are collected and judged at Program:exit so the rule does
|
|
83
|
-
// not depend on the import appearing above them.
|
|
84
55
|
const candidates = [];
|
|
85
56
|
function toolNameOf(node) {
|
|
86
57
|
const first = node.arguments[0];
|
|
@@ -94,7 +65,6 @@ exports.requireToolInputSchema = (0, eslint_devkit_1.createRule)({
|
|
|
94
65
|
importsMcpSdk = true;
|
|
95
66
|
},
|
|
96
67
|
CallExpression(node) {
|
|
97
|
-
// require('@modelcontextprotocol/sdk/...')
|
|
98
68
|
if (node.callee.type === 'Identifier' &&
|
|
99
69
|
node.callee.name === 'require' &&
|
|
100
70
|
node.arguments[0]?.type === 'Literal' &&
|
|
@@ -110,8 +80,6 @@ exports.requireToolInputSchema = (0, eslint_devkit_1.createRule)({
|
|
|
110
80
|
const method = node.callee.property.name;
|
|
111
81
|
if (method === REGISTER_TOOL) {
|
|
112
82
|
const config = node.arguments[1];
|
|
113
|
-
// A config passed by reference could carry the schema — not readable
|
|
114
|
-
// here, so not reported.
|
|
115
83
|
if (config?.type !== 'ObjectExpression')
|
|
116
84
|
return;
|
|
117
85
|
if (readInputSchema(config) === 'missing') {
|
|
@@ -120,9 +88,6 @@ exports.requireToolInputSchema = (0, eslint_devkit_1.createRule)({
|
|
|
120
88
|
return;
|
|
121
89
|
}
|
|
122
90
|
if (method === LEGACY_TOOL && node.arguments.length === 2) {
|
|
123
|
-
// tool(name, handler) is the only legacy arity with no schema slot
|
|
124
|
-
// between the name and the callback. The length check above is what
|
|
125
|
-
// keeps `tool(name, schemaVariable, handler)` from being flagged.
|
|
126
91
|
const handler = node.arguments[1];
|
|
127
92
|
if (HANDLER_NODE_TYPES.has(handler.type)) {
|
|
128
93
|
candidates.push({ node, tool: toolNameOf(node) });
|
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Ofri Peretz
|
|
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/dist/README.md
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security" target="blank"><img src="https://eslint.interlace.tools/icon-light.svg" alt="Interlace" height="90" /></a>
|
|
3
|
-
|
|
4
|
-
<a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/eslint-logo.svg" alt="ESLint" height="90" /></a>
|
|
5
|
-
|
|
6
|
-
<a href="https://oxc.rs" target="_blank"><img src="https://eslint.interlace.tools/oxlint-logo.svg" alt="oxlint" height="90" /></a>
|
|
7
|
-
|
|
8
|
-
<a href="https://www.npmjs.com/package/@modelcontextprotocol/sdk" target="_blank"><img src="https://eslint.interlace.tools/mcp-logo.svg" alt="Model Context Protocol" height="90" /></a>
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<p align="center">
|
|
12
|
-
Security rules for <a href="https://www.npmjs.com/package/@modelcontextprotocol/sdk"><code>@modelcontextprotocol/sdk</code></a> — the Model Context Protocol SDK.
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<p align="center">
|
|
16
|
-
<a href="https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security" target="_blank"><img src="https://img.shields.io/npm/v/eslint-plugin-mcp-sdk-security.svg" alt="NPM Version" /></a>
|
|
17
|
-
<a href="https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security" target="_blank"><img src="https://img.shields.io/npm/dm/eslint-plugin-mcp-sdk-security.svg" alt="NPM Downloads" /></a>
|
|
18
|
-
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
> ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
|
|
22
|
-
|
|
23
|
-
## Description
|
|
24
|
-
|
|
25
|
-
Security rules for code built on [`@modelcontextprotocol/sdk`](https://www.npmjs.com/package/@modelcontextprotocol/sdk).
|
|
26
|
-
|
|
27
|
-
**Scope:** this plugin lints the MCP **SDK's API shapes** — `registerTool`, transports, handler signatures. It does not inspect MCP wire traffic, which isn't visible from source. Every rule gates on the SDK actually being imported, so it stays silent in files that don't use MCP.
|
|
28
|
-
|
|
29
|
-
## Philosophy
|
|
30
|
-
|
|
31
|
-
**Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
|
|
32
|
-
|
|
33
|
-
## Installation
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm install --save-dev eslint-plugin-mcp-sdk-security
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Usage
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
// eslint.config.js
|
|
43
|
-
import mcpSdkSecurity from 'eslint-plugin-mcp-sdk-security';
|
|
44
|
-
|
|
45
|
-
export default [
|
|
46
|
-
mcpSdkSecurity.configs.recommended,
|
|
47
|
-
];
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Or wire the rules yourself:
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
import mcpSdkSecurity from 'eslint-plugin-mcp-sdk-security';
|
|
54
|
-
|
|
55
|
-
export default [
|
|
56
|
-
{
|
|
57
|
-
plugins: { 'mcp-sdk-security': mcpSdkSecurity },
|
|
58
|
-
rules: {
|
|
59
|
-
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### oxlint
|
|
66
|
-
|
|
67
|
-
Every rule in this plugin runs on [oxlint](https://oxc.rs) as well as ESLint:
|
|
68
|
-
|
|
69
|
-
```json
|
|
70
|
-
{ "jsPlugins": ["eslint-plugin-mcp-sdk-security/oxlint"] }
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Rules
|
|
74
|
-
|
|
75
|
-
| Rule | Description | CWE | Recommended |
|
|
76
|
-
| --- | --- | --- | --- |
|
|
77
|
-
| [require-tool-input-schema](./docs/rules/require-tool-input-schema.md) | Require an input schema when registering an MCP tool | CWE-20 | ✅ error |
|
|
78
|
-
|
|
79
|
-
## What it catches
|
|
80
|
-
|
|
81
|
-
```ts
|
|
82
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
83
|
-
|
|
84
|
-
// ❌ handler receives whatever the client sends
|
|
85
|
-
server.registerTool('read_file', { description: 'Read a file' }, async (args) => {
|
|
86
|
-
return readFileSync(args.path, 'utf8');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// ✅ arguments are constrained before the handler runs
|
|
90
|
-
server.registerTool('read_file', {
|
|
91
|
-
description: 'Read a file',
|
|
92
|
-
inputSchema: { path: z.string() },
|
|
93
|
-
}, async (args) => {
|
|
94
|
-
return readFileSync(args.path, 'utf8');
|
|
95
|
-
});
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Roadmap
|
|
99
|
-
|
|
100
|
-
`0.1.x` covers the tool-registration surface — the entry point for tool poisoning and argument injection. Next: transport authentication on streamable HTTP, resource path traversal, and tool-output handling.
|
|
101
|
-
|
|
102
|
-
## 📄 License
|
|
103
|
-
|
|
104
|
-
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
105
|
-
|
|
106
|
-
<p align="center">
|
|
107
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security" target="blank"><img src="https://eslint.interlace.tools/icon-light.svg" alt="Interlace" height="70" /></a>
|
|
108
|
-
</p>
|
package/dist/package.json
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "eslint-plugin-mcp-sdk-security",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "ESLint plugin for Model Context Protocol (MCP) SDK security — catches tools registered without an input schema, so handlers never run on unvalidated client-supplied arguments.",
|
|
5
|
-
"type": "commonjs",
|
|
6
|
-
"main": "./src/index.js",
|
|
7
|
-
"types": "./src/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./src/index.d.ts",
|
|
11
|
-
"default": "./src/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./oxlint": {
|
|
14
|
-
"types": "./src/oxlint.d.ts",
|
|
15
|
-
"default": "./src/oxlint.js"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"author": "Ofri Peretz <ofriperetzdev@gmail.com>",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"homepage": "https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security",
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "https://github.com/ofri-peretz/eslint",
|
|
24
|
-
"directory": "packages/eslint-plugin-mcp-sdk-security"
|
|
25
|
-
},
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/ofri-peretz/eslint/issues"
|
|
28
|
-
},
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
},
|
|
32
|
-
"files": [
|
|
33
|
-
"src/",
|
|
34
|
-
"dist/",
|
|
35
|
-
"README.md",
|
|
36
|
-
"LICENSE",
|
|
37
|
-
"CHANGELOG.md"
|
|
38
|
-
],
|
|
39
|
-
"keywords": [
|
|
40
|
-
"eslint",
|
|
41
|
-
"eslintplugin",
|
|
42
|
-
"eslint-plugin",
|
|
43
|
-
"static-analysis",
|
|
44
|
-
"linting",
|
|
45
|
-
"code-quality",
|
|
46
|
-
"security",
|
|
47
|
-
"sast",
|
|
48
|
-
"appsec",
|
|
49
|
-
"vulnerability",
|
|
50
|
-
"owasp",
|
|
51
|
-
"cwe",
|
|
52
|
-
"interlace-security",
|
|
53
|
-
"mcp",
|
|
54
|
-
"mcp-security",
|
|
55
|
-
"mcp-server",
|
|
56
|
-
"model-context-protocol",
|
|
57
|
-
"modelcontextprotocol",
|
|
58
|
-
"tool-calling",
|
|
59
|
-
"tool-poisoning",
|
|
60
|
-
"ai-security",
|
|
61
|
-
"llm",
|
|
62
|
-
"llm-security",
|
|
63
|
-
"agentic",
|
|
64
|
-
"typescript"
|
|
65
|
-
],
|
|
66
|
-
"engines": {
|
|
67
|
-
"node": ">=18.0.0"
|
|
68
|
-
},
|
|
69
|
-
"peerDependencies": {
|
|
70
|
-
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
71
|
-
},
|
|
72
|
-
"peerDependenciesMeta": {
|
|
73
|
-
"@modelcontextprotocol/sdk": {
|
|
74
|
-
"optional": true
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
"dependencies": {
|
|
78
|
-
"tslib": "^2.3.0",
|
|
79
|
-
"@interlace/eslint-devkit": "^1.4.4"
|
|
80
|
-
},
|
|
81
|
-
"devDependencies": {
|
|
82
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
83
|
-
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
84
|
-
},
|
|
85
|
-
"scripts": {
|
|
86
|
-
"build": "tsx ../../scripts/build-package.ts",
|
|
87
|
-
"test": "vitest run",
|
|
88
|
-
"test:coverage": "vitest run --coverage",
|
|
89
|
-
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
90
|
-
},
|
|
91
|
-
"funding": {
|
|
92
|
-
"type": "github",
|
|
93
|
-
"url": "https://github.com/ofri-peretz/eslint"
|
|
94
|
-
}
|
|
95
|
-
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* eslint-plugin-mcp-sdk-security
|
|
8
|
-
*
|
|
9
|
-
* Security rules for servers and clients built on `@modelcontextprotocol/sdk`.
|
|
10
|
-
*
|
|
11
|
-
* Scope promise: every rule here gates on the MCP SDK being imported. This
|
|
12
|
-
* plugin lints the SDK's API shapes — `registerTool`, transports, handler
|
|
13
|
-
* signatures — not the MCP wire protocol, which is not visible from source.
|
|
14
|
-
*
|
|
15
|
-
* @see https://modelcontextprotocol.io/docs/concepts/tools
|
|
16
|
-
*/
|
|
17
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
18
|
-
export { requireToolInputSchema } from './rules/require-tool-input-schema';
|
|
19
|
-
/**
|
|
20
|
-
* MCP SDK security rules.
|
|
21
|
-
*
|
|
22
|
-
* 0.1.x scope — the tool-registration surface. A tool registered without an
|
|
23
|
-
* input schema hands its handler unvalidated client-supplied arguments, which
|
|
24
|
-
* is the entry point for the tool-poisoning and argument-injection classes.
|
|
25
|
-
* Transport auth, resource path traversal and tool-output handling follow.
|
|
26
|
-
*/
|
|
27
|
-
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
28
|
-
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
29
|
-
export declare const configs: {
|
|
30
|
-
minimal: TSESLint.FlatConfig.Config;
|
|
31
|
-
recommended: TSESLint.FlatConfig.Config;
|
|
32
|
-
strict: TSESLint.FlatConfig.Config;
|
|
33
|
-
};
|
|
34
|
-
declare const _default: {
|
|
35
|
-
configs: {
|
|
36
|
-
minimal: TSESLint.FlatConfig.Config;
|
|
37
|
-
recommended: TSESLint.FlatConfig.Config;
|
|
38
|
-
strict: TSESLint.FlatConfig.Config;
|
|
39
|
-
};
|
|
40
|
-
meta?: { [K in keyof TSESLint.FlatConfig.PluginMeta]?: TSESLint.FlatConfig.PluginMeta[K] | undefined; };
|
|
41
|
-
processors?: Partial<Record<string, TSESLint.FlatConfig.Processor>> | undefined;
|
|
42
|
-
rules?: Record<string, TSESLint.LooseRuleDefinition> | undefined;
|
|
43
|
-
};
|
|
44
|
-
export default _default;
|
package/dist/src/index.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
-
* MIT license that can be found in the LICENSE file.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.configs = exports.plugin = exports.rules = exports.requireToolInputSchema = void 0;
|
|
9
|
-
const require_tool_input_schema_1 = require("./rules/require-tool-input-schema");
|
|
10
|
-
var require_tool_input_schema_2 = require("./rules/require-tool-input-schema");
|
|
11
|
-
Object.defineProperty(exports, "requireToolInputSchema", { enumerable: true, get: function () { return require_tool_input_schema_2.requireToolInputSchema; } });
|
|
12
|
-
/**
|
|
13
|
-
* MCP SDK security rules.
|
|
14
|
-
*
|
|
15
|
-
* 0.1.x scope — the tool-registration surface. A tool registered without an
|
|
16
|
-
* input schema hands its handler unvalidated client-supplied arguments, which
|
|
17
|
-
* is the entry point for the tool-poisoning and argument-injection classes.
|
|
18
|
-
* Transport auth, resource path traversal and tool-output handling follow.
|
|
19
|
-
*/
|
|
20
|
-
exports.rules = {
|
|
21
|
-
// CWE-20: Improper Input Validation
|
|
22
|
-
'require-tool-input-schema': require_tool_input_schema_1.requireToolInputSchema,
|
|
23
|
-
};
|
|
24
|
-
exports.plugin = {
|
|
25
|
-
meta: {
|
|
26
|
-
name: 'eslint-plugin-mcp-sdk-security',
|
|
27
|
-
version: '0.1.0',
|
|
28
|
-
},
|
|
29
|
-
rules: exports.rules,
|
|
30
|
-
};
|
|
31
|
-
/** Minimal configuration — for gradual adoption. */
|
|
32
|
-
const minimalConfig = {
|
|
33
|
-
plugins: {
|
|
34
|
-
'mcp-sdk-security': exports.plugin,
|
|
35
|
-
},
|
|
36
|
-
rules: {
|
|
37
|
-
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
/** Recommended configuration — the balanced default. */
|
|
41
|
-
const recommendedConfig = {
|
|
42
|
-
plugins: {
|
|
43
|
-
'mcp-sdk-security': exports.plugin,
|
|
44
|
-
},
|
|
45
|
-
rules: {
|
|
46
|
-
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
/** Strict configuration — everything on. */
|
|
50
|
-
const strictConfig = {
|
|
51
|
-
plugins: {
|
|
52
|
-
'mcp-sdk-security': exports.plugin,
|
|
53
|
-
},
|
|
54
|
-
rules: {
|
|
55
|
-
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
exports.configs = {
|
|
59
|
-
minimal: minimalConfig,
|
|
60
|
-
recommended: recommendedConfig,
|
|
61
|
-
strict: strictConfig,
|
|
62
|
-
};
|
|
63
|
-
exports.default = {
|
|
64
|
-
...exports.plugin,
|
|
65
|
-
configs: exports.configs,
|
|
66
|
-
};
|
package/dist/src/oxlint.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* oxlint sub-export.
|
|
8
|
-
*
|
|
9
|
-
* Consumers wire oxlint to this entry via:
|
|
10
|
-
* { "jsPlugins": ["eslint-plugin-mcp-sdk-security/oxlint"] }
|
|
11
|
-
*
|
|
12
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-mcp-sdk-security/oxlint')` and reads
|
|
13
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
14
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
15
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
16
|
-
*
|
|
17
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
18
|
-
*/
|
|
19
|
-
import { plugin } from './index';
|
|
20
|
-
export = plugin;
|
package/dist/src/oxlint.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
-
* MIT license that can be found in the LICENSE file.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* oxlint sub-export.
|
|
9
|
-
*
|
|
10
|
-
* Consumers wire oxlint to this entry via:
|
|
11
|
-
* { "jsPlugins": ["eslint-plugin-mcp-sdk-security/oxlint"] }
|
|
12
|
-
*
|
|
13
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-mcp-sdk-security/oxlint')` and reads
|
|
14
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
-
*
|
|
18
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
-
*/
|
|
20
|
-
const index_1 = require("./index");
|
|
21
|
-
module.exports = index_1.plugin;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
export declare const requireToolInputSchema: import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingInputSchema", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
package/src/index.test.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Plugin surface lock for eslint-plugin-mcp-sdk-security.
|
|
3
|
-
*
|
|
4
|
-
* Guards the contract consumers actually wire up: the rule map, the plugin
|
|
5
|
-
* object oxlint loads, and the three shipped configs.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect } from 'vitest';
|
|
9
|
-
|
|
10
|
-
import plugin, { rules, configs, plugin as namedPlugin, requireToolInputSchema } from './index';
|
|
11
|
-
|
|
12
|
-
describe('eslint-plugin-mcp-sdk-security', () => {
|
|
13
|
-
it('exposes every rule under its documented id', () => {
|
|
14
|
-
expect(Object.keys(rules).sort()).toEqual(['require-tool-input-schema']);
|
|
15
|
-
expect(rules['require-tool-input-schema']).toBe(requireToolInputSchema);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('names itself for the oxlint loader', () => {
|
|
19
|
-
expect(namedPlugin.meta?.name).toBe('eslint-plugin-mcp-sdk-security');
|
|
20
|
-
expect(namedPlugin.rules).toBe(rules);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('ships minimal, recommended and strict configs', () => {
|
|
24
|
-
expect(Object.keys(configs).sort()).toEqual(['minimal', 'recommended', 'strict']);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('enables the rule under the mcp-sdk-security namespace in every config', () => {
|
|
28
|
-
for (const config of Object.values(configs)) {
|
|
29
|
-
expect(config.plugins).toHaveProperty('mcp-sdk-security');
|
|
30
|
-
expect(config.rules?.['mcp-sdk-security/require-tool-input-schema']).toBe('error');
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('default-exports the plugin with its configs attached', () => {
|
|
35
|
-
expect(plugin.rules).toBe(rules);
|
|
36
|
-
expect(plugin.configs).toBe(configs);
|
|
37
|
-
});
|
|
38
|
-
});
|