eslint-plugin-mcp-sdk-security 0.1.0 → 0.1.1
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 +10 -22
- package/src/index.d.ts +17 -0
- package/{dist/src → src}/index.js +3 -20
- package/src/oxlint.d.ts +17 -0
- package/src/oxlint.js +3 -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/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
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
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/
|
|
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/logos/interlace.svg" alt="Interlace" height="90" /></a>
|
|
3
3
|
|
|
4
|
-
<a href="https://
|
|
4
|
+
<a href="https://modelcontextprotocol.io" target="_blank"><img src="https://eslint.interlace.tools/logos/mcp.svg" alt="Model Context Protocol" height="90" /></a>
|
|
5
|
+
|
|
6
|
+
<a href="https://oxc.rs" target="_blank"><img src="https://eslint.interlace.tools/logos/oxlint.svg" alt="oxlint" height="90" /></a>
|
|
7
|
+
|
|
8
|
+
<a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/logos/eslint.svg" alt="ESLint" height="90" /></a>
|
|
5
9
|
</p>
|
|
6
10
|
|
|
7
11
|
<p align="center">
|
|
@@ -26,12 +30,27 @@ Security rules for code built on [`@modelcontextprotocol/sdk`](https://www.npmjs
|
|
|
26
30
|
|
|
27
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.
|
|
28
32
|
|
|
29
|
-
##
|
|
33
|
+
## Getting Started
|
|
34
|
+
|
|
35
|
+
- To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security). 📚
|
|
36
|
+
- 要查看中文 [指南](https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security). 📚
|
|
37
|
+
- [가이드](https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security)에서 확인하실 수 있습니다. 📚
|
|
38
|
+
- [ガイド](https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security)は [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security)でご確認ください。 📚
|
|
39
|
+
- Para ver la [guía](https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security), visita [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security). 📚
|
|
40
|
+
- للاطلاع على [الدليل](https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security). 📚
|
|
30
41
|
|
|
31
42
|
```bash
|
|
32
|
-
npm install
|
|
43
|
+
npm install eslint-plugin-mcp-sdk-security --save-dev
|
|
33
44
|
```
|
|
34
45
|
|
|
46
|
+
## ⚙️ Configuration Presets
|
|
47
|
+
|
|
48
|
+
| Preset | Description |
|
|
49
|
+
| :--- | :--- |
|
|
50
|
+
| `recommended` | Enables every rule at `error`. |
|
|
51
|
+
| `strict` | Same set as `recommended`; reserved for rules that are not yet safe by default. |
|
|
52
|
+
| `minimal` | Same set as `recommended`; reserved for a reduced high-signal subset. |
|
|
53
|
+
|
|
35
54
|
## Usage
|
|
36
55
|
|
|
37
56
|
```js
|
|
@@ -66,39 +85,66 @@ Every rule in this plugin runs on [oxlint](https://oxc.rs) as well as ESLint:
|
|
|
66
85
|
{ "jsPlugins": ["eslint-plugin-mcp-sdk-security/oxlint"] }
|
|
67
86
|
```
|
|
68
87
|
|
|
88
|
+
## 📦 Compatibility
|
|
89
|
+
|
|
90
|
+
| Package | Version |
|
|
91
|
+
| :--- | :--- |
|
|
92
|
+
| `@modelcontextprotocol/sdk` | [](https://www.npmjs.com/package/@modelcontextprotocol/sdk) |
|
|
93
|
+
| ESLint | [](https://www.npmjs.com/package/eslint) |
|
|
94
|
+
| Node.js | [](https://nodejs.org/) |
|
|
95
|
+
|
|
96
|
+
See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) for the full matrix.
|
|
97
|
+
|
|
69
98
|
## Rules
|
|
70
99
|
|
|
71
|
-
|
|
72
|
-
| --- | --- | --- | --- |
|
|
73
|
-
| [require-tool-input-schema](./docs/rules/require-tool-input-schema.md) | Require an input schema when registering an MCP tool | CWE-20 | ✅ error |
|
|
100
|
+
**Legend**
|
|
74
101
|
|
|
75
|
-
|
|
102
|
+
| Icon | Description |
|
|
103
|
+
| :---: | :--- |
|
|
104
|
+
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
105
|
+
| ⚠️ | **Warns**: Set to warn in recommended preset. |
|
|
106
|
+
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
107
|
+
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
108
|
+
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
109
|
+
| 🟢 | **Type-unaware**: AST-only, runs in oxlint JS-plugin tier. |
|
|
110
|
+
| 🟡 | **Type-aware (refining)**: pure-AST primary path; types refine precision. |
|
|
111
|
+
| 🟠 | **Type-aware (graceful)**: requires TS program; silent without it. |
|
|
76
112
|
|
|
77
|
-
|
|
78
|
-
|
|
113
|
+
| Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
114
|
+
| :--- | :--- | :--- | :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
115
|
+
| [require-tool-input-schema](./docs/rules/require-tool-input-schema.md) | CWE-20 | A03:2021 | 7.5 | Require an input schema when registering an MCP tool | 🟢 | 💼 | | | | |
|
|
79
116
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return readFileSync(args.path, 'utf8');
|
|
83
|
-
});
|
|
117
|
+
<!-- INTERLACE:STAR_CTA:START -->
|
|
118
|
+
## ⭐ Support & follow
|
|
84
119
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```
|
|
120
|
+
If this plugin caught a real bug for you, **[star the repo](https://github.com/ofri-peretz/eslint)** — stars are the signal that keeps the Interlace ESLint ecosystem maintained — and **[follow the writeups on Dev.to](https://dev.to/ofri-peretz)** for the benchmarks and security research behind these rules.
|
|
121
|
+
|
|
122
|
+
[](https://github.com/ofri-peretz/eslint)
|
|
123
|
+
|
|
124
|
+
<!-- INTERLACE:STAR_CTA:END -->
|
|
125
|
+
|
|
126
|
+
## 🔗 Related ESLint Plugins
|
|
93
127
|
|
|
94
|
-
|
|
128
|
+
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
95
129
|
|
|
96
|
-
|
|
130
|
+
| Plugin | Downloads | Description |
|
|
131
|
+
| :--- | :---: | :--- |
|
|
132
|
+
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security — prompt injection, output handling. |
|
|
133
|
+
| [`eslint-plugin-openai-security`](https://www.npmjs.com/package/eslint-plugin-openai-security) | [](https://www.npmjs.com/package/eslint-plugin-openai-security) | OpenAI SDK security. |
|
|
134
|
+
| [`eslint-plugin-anthropic-security`](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | [](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | Anthropic SDK and Claude Agent SDK security. |
|
|
135
|
+
| [`eslint-plugin-gemini-security`](https://www.npmjs.com/package/eslint-plugin-gemini-security) | [](https://www.npmjs.com/package/eslint-plugin-gemini-security) | Google Gemini SDK security. |
|
|
136
|
+
| [`eslint-plugin-mcp-sdk-security`](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | [](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | Model Context Protocol SDK security. |
|
|
137
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines. |
|
|
138
|
+
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [](https://www.npmjs.com/package/eslint-plugin-node-security) | Node.js core-module security (fs, child_process, vm, crypto, Buffer). |
|
|
97
139
|
|
|
98
140
|
## 📄 License
|
|
99
141
|
|
|
100
142
|
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
101
143
|
|
|
144
|
+
<p align="center">
|
|
145
|
+
<a href="https://eslint.interlace.tools/docs/security/plugin-mcp-sdk-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-mcp-sdk-security"><img src="https://eslint.interlace.tools/images/og-mcp-sdk-security.png" alt="ESLint Interlace Plugin" width="100%" /></a>
|
|
146
|
+
</p>
|
|
147
|
+
|
|
102
148
|
<p align="center">
|
|
103
149
|
<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>
|
|
104
150
|
</p>
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-mcp-sdk-security",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
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
5
|
"type": "commonjs",
|
|
6
|
-
"main": "./
|
|
7
|
-
"types": "./
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"default": "./
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./oxlint": {
|
|
14
14
|
"types": "./src/oxlint.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
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
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/ofri-peretz/eslint",
|
|
23
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git",
|
|
24
24
|
"directory": "packages/eslint-plugin-mcp-sdk-security"
|
|
25
25
|
},
|
|
26
26
|
"bugs": {
|
|
@@ -31,10 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"src/",
|
|
34
|
-
"dist/",
|
|
35
34
|
"README.md",
|
|
36
|
-
"LICENSE"
|
|
37
|
-
"CHANGELOG.md"
|
|
35
|
+
"LICENSE"
|
|
38
36
|
],
|
|
39
37
|
"keywords": [
|
|
40
38
|
"eslint",
|
|
@@ -67,7 +65,8 @@
|
|
|
67
65
|
"node": ">=18.0.0"
|
|
68
66
|
},
|
|
69
67
|
"peerDependencies": {
|
|
70
|
-
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
68
|
+
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
69
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
71
70
|
},
|
|
72
71
|
"peerDependenciesMeta": {
|
|
73
72
|
"@modelcontextprotocol/sdk": {
|
|
@@ -75,18 +74,7 @@
|
|
|
75
74
|
}
|
|
76
75
|
},
|
|
77
76
|
"dependencies": {
|
|
78
|
-
"
|
|
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"
|
|
77
|
+
"@interlace/eslint-devkit": "^1.8.0"
|
|
90
78
|
},
|
|
91
79
|
"funding": {
|
|
92
80
|
"type": "github",
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
|
@@ -1,34 +1,19 @@
|
|
|
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.configs = exports.plugin = exports.rules = exports.requireToolInputSchema = void 0;
|
|
9
|
-
const require_tool_input_schema_1 = require("./rules/require-tool-input-schema");
|
|
10
4
|
var require_tool_input_schema_2 = require("./rules/require-tool-input-schema");
|
|
11
5
|
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
6
|
exports.rules = {
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
get 'require-tool-input-schema'() { return require("./rules/require-tool-input-schema").requireToolInputSchema; },
|
|
8
|
+
|
|
23
9
|
};
|
|
24
10
|
exports.plugin = {
|
|
25
11
|
meta: {
|
|
26
12
|
name: 'eslint-plugin-mcp-sdk-security',
|
|
27
|
-
version: '0.1.
|
|
13
|
+
version: '0.1.1',
|
|
28
14
|
},
|
|
29
15
|
rules: exports.rules,
|
|
30
16
|
};
|
|
31
|
-
/** Minimal configuration — for gradual adoption. */
|
|
32
17
|
const minimalConfig = {
|
|
33
18
|
plugins: {
|
|
34
19
|
'mcp-sdk-security': exports.plugin,
|
|
@@ -37,7 +22,6 @@ const minimalConfig = {
|
|
|
37
22
|
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
38
23
|
},
|
|
39
24
|
};
|
|
40
|
-
/** Recommended configuration — the balanced default. */
|
|
41
25
|
const recommendedConfig = {
|
|
42
26
|
plugins: {
|
|
43
27
|
'mcp-sdk-security': exports.plugin,
|
|
@@ -46,7 +30,6 @@ const recommendedConfig = {
|
|
|
46
30
|
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
47
31
|
},
|
|
48
32
|
};
|
|
49
|
-
/** Strict configuration — everything on. */
|
|
50
33
|
const strictConfig = {
|
|
51
34
|
plugins: {
|
|
52
35
|
'mcp-sdk-security': exports.plugin,
|
package/src/oxlint.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/oxlint.js
ADDED
|
@@ -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/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
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,85 +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
|
-
/**
|
|
8
|
-
* eslint-plugin-mcp-sdk-security
|
|
9
|
-
*
|
|
10
|
-
* Security rules for servers and clients built on `@modelcontextprotocol/sdk`.
|
|
11
|
-
*
|
|
12
|
-
* Scope promise: every rule here gates on the MCP SDK being imported. This
|
|
13
|
-
* plugin lints the SDK's API shapes — `registerTool`, transports, handler
|
|
14
|
-
* signatures — not the MCP wire protocol, which is not visible from source.
|
|
15
|
-
*
|
|
16
|
-
* @see https://modelcontextprotocol.io/docs/concepts/tools
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
20
|
-
|
|
21
|
-
import { requireToolInputSchema } from './rules/require-tool-input-schema';
|
|
22
|
-
|
|
23
|
-
export { requireToolInputSchema } from './rules/require-tool-input-schema';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* MCP SDK security rules.
|
|
27
|
-
*
|
|
28
|
-
* 0.1.x scope — the tool-registration surface. A tool registered without an
|
|
29
|
-
* input schema hands its handler unvalidated client-supplied arguments, which
|
|
30
|
-
* is the entry point for the tool-poisoning and argument-injection classes.
|
|
31
|
-
* Transport auth, resource path traversal and tool-output handling follow.
|
|
32
|
-
*/
|
|
33
|
-
export const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>> = {
|
|
34
|
-
// CWE-20: Improper Input Validation
|
|
35
|
-
'require-tool-input-schema': requireToolInputSchema,
|
|
36
|
-
} satisfies Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
37
|
-
|
|
38
|
-
export const plugin: TSESLint.FlatConfig.Plugin = {
|
|
39
|
-
meta: {
|
|
40
|
-
name: 'eslint-plugin-mcp-sdk-security',
|
|
41
|
-
version: '0.1.0',
|
|
42
|
-
},
|
|
43
|
-
rules,
|
|
44
|
-
} satisfies TSESLint.FlatConfig.Plugin;
|
|
45
|
-
|
|
46
|
-
/** Minimal configuration — for gradual adoption. */
|
|
47
|
-
const minimalConfig: TSESLint.FlatConfig.Config = {
|
|
48
|
-
plugins: {
|
|
49
|
-
'mcp-sdk-security': plugin,
|
|
50
|
-
},
|
|
51
|
-
rules: {
|
|
52
|
-
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
53
|
-
},
|
|
54
|
-
} satisfies TSESLint.FlatConfig.Config;
|
|
55
|
-
|
|
56
|
-
/** Recommended configuration — the balanced default. */
|
|
57
|
-
const recommendedConfig: TSESLint.FlatConfig.Config = {
|
|
58
|
-
plugins: {
|
|
59
|
-
'mcp-sdk-security': plugin,
|
|
60
|
-
},
|
|
61
|
-
rules: {
|
|
62
|
-
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
63
|
-
},
|
|
64
|
-
} satisfies TSESLint.FlatConfig.Config;
|
|
65
|
-
|
|
66
|
-
/** Strict configuration — everything on. */
|
|
67
|
-
const strictConfig: TSESLint.FlatConfig.Config = {
|
|
68
|
-
plugins: {
|
|
69
|
-
'mcp-sdk-security': plugin,
|
|
70
|
-
},
|
|
71
|
-
rules: {
|
|
72
|
-
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
73
|
-
},
|
|
74
|
-
} satisfies TSESLint.FlatConfig.Config;
|
|
75
|
-
|
|
76
|
-
export const configs = {
|
|
77
|
-
minimal: minimalConfig,
|
|
78
|
-
recommended: recommendedConfig,
|
|
79
|
-
strict: strictConfig,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default {
|
|
83
|
-
...plugin,
|
|
84
|
-
configs,
|
|
85
|
-
};
|
package/src/oxlint.ts
DELETED
|
@@ -1,23 +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
|
-
/**
|
|
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
|
-
|
|
21
|
-
import { plugin } from './index';
|
|
22
|
-
|
|
23
|
-
export = plugin;
|
|
@@ -1,150 +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
|
-
/**
|
|
8
|
-
* @fileoverview Require an input schema when registering an MCP tool
|
|
9
|
-
* @description A tool registered without an input schema receives whatever
|
|
10
|
-
* arguments the client sends. The handler then operates on unvalidated,
|
|
11
|
-
* attacker-influenced input — the entry point for the MCP tool-poisoning and
|
|
12
|
-
* argument-injection classes.
|
|
13
|
-
* @see https://modelcontextprotocol.io/docs/concepts/tools
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { TSESTree, createRule, formatLLMMessage, MessageIcons } from '@interlace/eslint-devkit';
|
|
17
|
-
|
|
18
|
-
type MessageIds = 'missingInputSchema';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The rule only fires in files that actually import the MCP SDK. Gating on the
|
|
22
|
-
* SDK — rather than on a receiver name like `server` — is what keeps this rule
|
|
23
|
-
* inside its package's scope promise: it cannot fire on code that does not use
|
|
24
|
-
* `@modelcontextprotocol/sdk`.
|
|
25
|
-
*/
|
|
26
|
-
const MCP_MODULE_PREFIX = '@modelcontextprotocol/sdk';
|
|
27
|
-
|
|
28
|
-
const REGISTER_TOOL = 'registerTool';
|
|
29
|
-
const LEGACY_TOOL = 'tool';
|
|
30
|
-
|
|
31
|
-
/** Node types that stand in for a tool handler in the legacy `tool()` arity. */
|
|
32
|
-
const HANDLER_NODE_TYPES = new Set<string>([
|
|
33
|
-
'ArrowFunctionExpression',
|
|
34
|
-
'FunctionExpression',
|
|
35
|
-
'Identifier',
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
type SchemaVerdict = 'declared' | 'missing' | 'unreadable';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Whether the config object literal declares `inputSchema`.
|
|
42
|
-
*
|
|
43
|
-
* Returns `unreadable` for a spread: the schema may well be in the spread
|
|
44
|
-
* source, which is not visible from this node. Reporting there would flag
|
|
45
|
-
* correct code, so the rule stays silent instead.
|
|
46
|
-
*/
|
|
47
|
-
function readInputSchema(config: TSESTree.ObjectExpression): SchemaVerdict {
|
|
48
|
-
for (const prop of config.properties) {
|
|
49
|
-
if (prop.type === 'SpreadElement') return 'unreadable';
|
|
50
|
-
if (prop.computed) continue;
|
|
51
|
-
if (prop.key.type === 'Identifier' && prop.key.name === 'inputSchema') return 'declared';
|
|
52
|
-
if (prop.key.type === 'Literal' && prop.key.value === 'inputSchema') return 'declared';
|
|
53
|
-
}
|
|
54
|
-
return 'missing';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const requireToolInputSchema = createRule<[], MessageIds>({
|
|
58
|
-
name: 'require-tool-input-schema',
|
|
59
|
-
meta: {
|
|
60
|
-
type: 'problem',
|
|
61
|
-
docs: {
|
|
62
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-mcp-sdk-security/docs/rules/require-tool-input-schema.md',
|
|
63
|
-
description: 'Require an input schema when registering an MCP tool',
|
|
64
|
-
cwe: 'CWE-20',
|
|
65
|
-
cvss: 7.5,
|
|
66
|
-
},
|
|
67
|
-
messages: {
|
|
68
|
-
missingInputSchema: formatLLMMessage({
|
|
69
|
-
icon: MessageIcons.SECURITY,
|
|
70
|
-
issueName: 'MCP Tool Registered Without an Input Schema',
|
|
71
|
-
cwe: 'CWE-20',
|
|
72
|
-
owasp: 'A03:2021',
|
|
73
|
-
cvss: 7.5,
|
|
74
|
-
description:
|
|
75
|
-
'Tool "{{tool}}" is registered without an input schema, so its handler receives unvalidated client-supplied arguments',
|
|
76
|
-
severity: 'HIGH',
|
|
77
|
-
compliance: ['SOC2'],
|
|
78
|
-
fix: 'Declare the accepted shape: registerTool("{{tool}}", { inputSchema: { path: z.string() } }, handler)',
|
|
79
|
-
documentationLink: 'https://modelcontextprotocol.io/docs/concepts/tools',
|
|
80
|
-
}),
|
|
81
|
-
},
|
|
82
|
-
schema: [],
|
|
83
|
-
},
|
|
84
|
-
defaultOptions: [],
|
|
85
|
-
create(context) {
|
|
86
|
-
let importsMcpSdk = false;
|
|
87
|
-
// Registrations are collected and judged at Program:exit so the rule does
|
|
88
|
-
// not depend on the import appearing above them.
|
|
89
|
-
const candidates: Array<{ node: TSESTree.CallExpression; tool: string }> = [];
|
|
90
|
-
|
|
91
|
-
function toolNameOf(node: TSESTree.CallExpression): string {
|
|
92
|
-
const first = node.arguments[0];
|
|
93
|
-
if (first?.type === 'Literal' && typeof first.value === 'string') return first.value;
|
|
94
|
-
return 'unknown';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
ImportDeclaration(node: TSESTree.ImportDeclaration) {
|
|
99
|
-
if (node.source.value.startsWith(MCP_MODULE_PREFIX)) importsMcpSdk = true;
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
CallExpression(node: TSESTree.CallExpression) {
|
|
103
|
-
// require('@modelcontextprotocol/sdk/...')
|
|
104
|
-
if (
|
|
105
|
-
node.callee.type === 'Identifier' &&
|
|
106
|
-
node.callee.name === 'require' &&
|
|
107
|
-
node.arguments[0]?.type === 'Literal' &&
|
|
108
|
-
typeof node.arguments[0].value === 'string' &&
|
|
109
|
-
node.arguments[0].value.startsWith(MCP_MODULE_PREFIX)
|
|
110
|
-
) {
|
|
111
|
-
importsMcpSdk = true;
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (node.callee.type !== 'MemberExpression' || node.callee.computed) return;
|
|
116
|
-
if (node.callee.property.type !== 'Identifier') return;
|
|
117
|
-
|
|
118
|
-
const method = node.callee.property.name;
|
|
119
|
-
|
|
120
|
-
if (method === REGISTER_TOOL) {
|
|
121
|
-
const config = node.arguments[1];
|
|
122
|
-
// A config passed by reference could carry the schema — not readable
|
|
123
|
-
// here, so not reported.
|
|
124
|
-
if (config?.type !== 'ObjectExpression') return;
|
|
125
|
-
if (readInputSchema(config) === 'missing') {
|
|
126
|
-
candidates.push({ node, tool: toolNameOf(node) });
|
|
127
|
-
}
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (method === LEGACY_TOOL && node.arguments.length === 2) {
|
|
132
|
-
// tool(name, handler) is the only legacy arity with no schema slot
|
|
133
|
-
// between the name and the callback. The length check above is what
|
|
134
|
-
// keeps `tool(name, schemaVariable, handler)` from being flagged.
|
|
135
|
-
const handler = node.arguments[1] as TSESTree.CallExpressionArgument;
|
|
136
|
-
if (HANDLER_NODE_TYPES.has(handler.type)) {
|
|
137
|
-
candidates.push({ node, tool: toolNameOf(node) });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
'Program:exit'() {
|
|
143
|
-
if (!importsMcpSdk) return;
|
|
144
|
-
for (const { node, tool } of candidates) {
|
|
145
|
-
context.report({ node, messageId: 'missingInputSchema', data: { tool } });
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
},
|
|
150
|
-
});
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Tests for require-tool-input-schema rule
|
|
3
|
-
*
|
|
4
|
-
* Coverage intent: every branch of the SDK gate, both registration arities,
|
|
5
|
-
* and the shapes the rule must stay silent on (a config it cannot read is not
|
|
6
|
-
* evidence of a missing schema).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
10
|
-
import { requireToolInputSchema } from './index';
|
|
11
|
-
|
|
12
|
-
const ruleTester = new RuleTester({
|
|
13
|
-
languageOptions: {
|
|
14
|
-
ecmaVersion: 2022,
|
|
15
|
-
sourceType: 'module',
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const IMPORT = `import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';`;
|
|
20
|
-
|
|
21
|
-
ruleTester.run('require-tool-input-schema', requireToolInputSchema, {
|
|
22
|
-
valid: [
|
|
23
|
-
// inputSchema declared as a shorthand identifier key
|
|
24
|
-
{
|
|
25
|
-
code: `
|
|
26
|
-
${IMPORT}
|
|
27
|
-
server.registerTool('read_file', { inputSchema: { path: z.string() } }, handler);
|
|
28
|
-
`,
|
|
29
|
-
},
|
|
30
|
-
// inputSchema declared as a string-literal key
|
|
31
|
-
{
|
|
32
|
-
code: `
|
|
33
|
-
${IMPORT}
|
|
34
|
-
server.registerTool('read_file', { 'inputSchema': { path: z.string() } }, handler);
|
|
35
|
-
`,
|
|
36
|
-
},
|
|
37
|
-
// Legacy arity WITH a schema between name and callback
|
|
38
|
-
{
|
|
39
|
-
code: `
|
|
40
|
-
${IMPORT}
|
|
41
|
-
server.tool('read_file', { path: z.string() }, async (args) => ({}));
|
|
42
|
-
`,
|
|
43
|
-
},
|
|
44
|
-
// No MCP import — the rule must not fire even on the vulnerable shape.
|
|
45
|
-
// This is the scope promise: no SDK, no findings.
|
|
46
|
-
{
|
|
47
|
-
code: `server.registerTool('read_file', { description: 'x' }, handler);`,
|
|
48
|
-
},
|
|
49
|
-
// Non-MCP import must not arm the rule
|
|
50
|
-
{
|
|
51
|
-
code: `
|
|
52
|
-
import { z } from 'zod';
|
|
53
|
-
server.registerTool('read_file', { description: 'x' }, handler);
|
|
54
|
-
`,
|
|
55
|
-
},
|
|
56
|
-
// require() of a non-MCP module must not arm the rule
|
|
57
|
-
{
|
|
58
|
-
code: `
|
|
59
|
-
const z = require('zod');
|
|
60
|
-
server.registerTool('read_file', { description: 'x' }, handler);
|
|
61
|
-
`,
|
|
62
|
-
},
|
|
63
|
-
// require() with a non-literal specifier must not throw or arm the rule
|
|
64
|
-
{
|
|
65
|
-
code: `
|
|
66
|
-
const mod = require(dynamicName);
|
|
67
|
-
server.registerTool('read_file', { description: 'x' }, handler);
|
|
68
|
-
`,
|
|
69
|
-
},
|
|
70
|
-
// Config passed by reference — the schema may well be in there. Guessing
|
|
71
|
-
// would be a false positive on correct code.
|
|
72
|
-
{
|
|
73
|
-
code: `
|
|
74
|
-
${IMPORT}
|
|
75
|
-
server.registerTool('read_file', toolConfig, handler);
|
|
76
|
-
`,
|
|
77
|
-
},
|
|
78
|
-
// No config argument at all — nothing to judge
|
|
79
|
-
{
|
|
80
|
-
code: `
|
|
81
|
-
${IMPORT}
|
|
82
|
-
server.registerTool('read_file');
|
|
83
|
-
`,
|
|
84
|
-
},
|
|
85
|
-
// Spread-only config — cannot be read, so stays silent
|
|
86
|
-
{
|
|
87
|
-
code: `
|
|
88
|
-
${IMPORT}
|
|
89
|
-
server.registerTool('read_file', { ...base }, handler);
|
|
90
|
-
`,
|
|
91
|
-
},
|
|
92
|
-
// Computed key named inputSchema is not a literal declaration
|
|
93
|
-
// (kept valid-shaped here only to exercise the computed branch of the
|
|
94
|
-
// property scan; the call still reports, so it lives in `invalid` below).
|
|
95
|
-
|
|
96
|
-
// Legacy arity where the second argument is neither schema nor function
|
|
97
|
-
{
|
|
98
|
-
code: `
|
|
99
|
-
${IMPORT}
|
|
100
|
-
server.tool('read_file', 42);
|
|
101
|
-
`,
|
|
102
|
-
},
|
|
103
|
-
// Computed member call — server['tool'](...) is not matched
|
|
104
|
-
{
|
|
105
|
-
code: `
|
|
106
|
-
${IMPORT}
|
|
107
|
-
server['registerTool']('read_file', { description: 'x' }, handler);
|
|
108
|
-
`,
|
|
109
|
-
},
|
|
110
|
-
// Plain function call, not a member expression
|
|
111
|
-
{
|
|
112
|
-
code: `
|
|
113
|
-
${IMPORT}
|
|
114
|
-
registerTool('read_file', { description: 'x' }, handler);
|
|
115
|
-
`,
|
|
116
|
-
},
|
|
117
|
-
// Unrelated member method
|
|
118
|
-
{
|
|
119
|
-
code: `
|
|
120
|
-
${IMPORT}
|
|
121
|
-
server.registerResource('file', { description: 'x' }, handler);
|
|
122
|
-
`,
|
|
123
|
-
},
|
|
124
|
-
// Private-method call — a non-computed member whose property is a
|
|
125
|
-
// PrivateIdentifier, not an Identifier.
|
|
126
|
-
{
|
|
127
|
-
code: `
|
|
128
|
-
${IMPORT}
|
|
129
|
-
class Server { #tool() {} run() { this.#tool(); } }
|
|
130
|
-
`,
|
|
131
|
-
},
|
|
132
|
-
// require() of a non-string literal must not throw or arm the rule
|
|
133
|
-
{
|
|
134
|
-
code: `
|
|
135
|
-
const mod = require(42);
|
|
136
|
-
server.registerTool('read_file', { description: 'x' }, handler);
|
|
137
|
-
`,
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
|
|
141
|
-
invalid: [
|
|
142
|
-
// The core case: registered with a config that carries no inputSchema
|
|
143
|
-
{
|
|
144
|
-
code: `
|
|
145
|
-
${IMPORT}
|
|
146
|
-
server.registerTool('read_file', { description: 'Read a file' }, handler);
|
|
147
|
-
`,
|
|
148
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
149
|
-
},
|
|
150
|
-
// Armed via require() rather than import
|
|
151
|
-
{
|
|
152
|
-
code: `
|
|
153
|
-
const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
154
|
-
server.registerTool('read_file', { description: 'Read a file' }, handler);
|
|
155
|
-
`,
|
|
156
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
157
|
-
},
|
|
158
|
-
// Legacy arity: name + inline callback, no schema
|
|
159
|
-
{
|
|
160
|
-
code: `
|
|
161
|
-
${IMPORT}
|
|
162
|
-
server.tool('read_file', async (args) => ({ content: [] }));
|
|
163
|
-
`,
|
|
164
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
165
|
-
},
|
|
166
|
-
// Legacy arity: name + function expression
|
|
167
|
-
{
|
|
168
|
-
code: `
|
|
169
|
-
${IMPORT}
|
|
170
|
-
server.tool('read_file', function (args) { return {}; });
|
|
171
|
-
`,
|
|
172
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
173
|
-
},
|
|
174
|
-
// Legacy arity: name + handler passed by identifier
|
|
175
|
-
{
|
|
176
|
-
code: `
|
|
177
|
-
${IMPORT}
|
|
178
|
-
server.tool('read_file', handler);
|
|
179
|
-
`,
|
|
180
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
181
|
-
},
|
|
182
|
-
// Computed key cannot declare the schema — still a finding
|
|
183
|
-
{
|
|
184
|
-
code: `
|
|
185
|
-
${IMPORT}
|
|
186
|
-
server.registerTool('read_file', { [key]: schema }, handler);
|
|
187
|
-
`,
|
|
188
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
189
|
-
},
|
|
190
|
-
// Non-matching literal key
|
|
191
|
-
{
|
|
192
|
-
code: `
|
|
193
|
-
${IMPORT}
|
|
194
|
-
server.registerTool('read_file', { 'description': 'x' }, handler);
|
|
195
|
-
`,
|
|
196
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
197
|
-
},
|
|
198
|
-
// Registration ordered before the import — Program:exit makes order irrelevant
|
|
199
|
-
{
|
|
200
|
-
code: `
|
|
201
|
-
server.registerTool('read_file', { description: 'x' }, handler);
|
|
202
|
-
${IMPORT}
|
|
203
|
-
`,
|
|
204
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
205
|
-
},
|
|
206
|
-
// Non-literal tool name falls back to "unknown" in the message data
|
|
207
|
-
{
|
|
208
|
-
code: `
|
|
209
|
-
${IMPORT}
|
|
210
|
-
server.registerTool(toolName, { description: 'x' }, handler);
|
|
211
|
-
`,
|
|
212
|
-
errors: [{ messageId: 'missingInputSchema' }],
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
});
|