eslint-plugin-mcp-sdk-security 0.1.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 +21 -0
- package/README.md +104 -0
- package/dist/LICENSE +21 -0
- package/dist/README.md +108 -0
- package/dist/package.json +95 -0
- package/dist/src/index.d.ts +44 -0
- package/dist/src/index.js +66 -0
- package/dist/src/oxlint.d.ts +20 -0
- package/dist/src/oxlint.js +21 -0
- package/dist/src/rules/require-tool-input-schema/index.d.ts +8 -0
- package/dist/src/rules/require-tool-input-schema/index.js +141 -0
- package/package.json +95 -0
- package/src/index.test.ts +38 -0
- package/src/index.ts +85 -0
- package/src/oxlint.ts +23 -0
- package/src/rules/require-tool-input-schema/index.ts +150 -0
- package/src/rules/require-tool-input-schema/require-tool-input-schema.test.ts +215 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Security rules for <a href="https://www.npmjs.com/package/@modelcontextprotocol/sdk">@modelcontextprotocol/sdk</a> — the Model Context Protocol SDK.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<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>
|
|
13
|
+
<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>
|
|
14
|
+
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
> ⭐ 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.
|
|
18
|
+
|
|
19
|
+
## Description
|
|
20
|
+
|
|
21
|
+
Security rules for code built on [`@modelcontextprotocol/sdk`](https://www.npmjs.com/package/@modelcontextprotocol/sdk).
|
|
22
|
+
|
|
23
|
+
**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.
|
|
24
|
+
|
|
25
|
+
## Philosophy
|
|
26
|
+
|
|
27
|
+
**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
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install --save-dev eslint-plugin-mcp-sdk-security
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
// eslint.config.js
|
|
39
|
+
import mcpSdkSecurity from 'eslint-plugin-mcp-sdk-security';
|
|
40
|
+
|
|
41
|
+
export default [
|
|
42
|
+
mcpSdkSecurity.configs.recommended,
|
|
43
|
+
];
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or wire the rules yourself:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import mcpSdkSecurity from 'eslint-plugin-mcp-sdk-security';
|
|
50
|
+
|
|
51
|
+
export default [
|
|
52
|
+
{
|
|
53
|
+
plugins: { 'mcp-sdk-security': mcpSdkSecurity },
|
|
54
|
+
rules: {
|
|
55
|
+
'mcp-sdk-security/require-tool-input-schema': 'error',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### oxlint
|
|
62
|
+
|
|
63
|
+
Every rule in this plugin runs on [oxlint](https://oxc.rs) as well as ESLint:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{ "jsPlugins": ["eslint-plugin-mcp-sdk-security/oxlint"] }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Rules
|
|
70
|
+
|
|
71
|
+
| Rule | Description | CWE | Recommended |
|
|
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 |
|
|
74
|
+
|
|
75
|
+
## What it catches
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
79
|
+
|
|
80
|
+
// ❌ handler receives whatever the client sends
|
|
81
|
+
server.registerTool('read_file', { description: 'Read a file' }, async (args) => {
|
|
82
|
+
return readFileSync(args.path, 'utf8');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// ✅ arguments are constrained before the handler runs
|
|
86
|
+
server.registerTool('read_file', {
|
|
87
|
+
description: 'Read a file',
|
|
88
|
+
inputSchema: { path: z.string() },
|
|
89
|
+
}, async (args) => {
|
|
90
|
+
return readFileSync(args.path, 'utf8');
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Roadmap
|
|
95
|
+
|
|
96
|
+
`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.
|
|
97
|
+
|
|
98
|
+
## 📄 License
|
|
99
|
+
|
|
100
|
+
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
101
|
+
|
|
102
|
+
<p align="center">
|
|
103
|
+
<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
|
+
</p>
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
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>
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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;
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
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.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
|
+
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
|
+
const MCP_MODULE_PREFIX = '@modelcontextprotocol/sdk';
|
|
25
|
+
const REGISTER_TOOL = 'registerTool';
|
|
26
|
+
const LEGACY_TOOL = 'tool';
|
|
27
|
+
/** Node types that stand in for a tool handler in the legacy `tool()` arity. */
|
|
28
|
+
const HANDLER_NODE_TYPES = new Set([
|
|
29
|
+
'ArrowFunctionExpression',
|
|
30
|
+
'FunctionExpression',
|
|
31
|
+
'Identifier',
|
|
32
|
+
]);
|
|
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
|
+
function readInputSchema(config) {
|
|
41
|
+
for (const prop of config.properties) {
|
|
42
|
+
if (prop.type === 'SpreadElement')
|
|
43
|
+
return 'unreadable';
|
|
44
|
+
if (prop.computed)
|
|
45
|
+
continue;
|
|
46
|
+
if (prop.key.type === 'Identifier' && prop.key.name === 'inputSchema')
|
|
47
|
+
return 'declared';
|
|
48
|
+
if (prop.key.type === 'Literal' && prop.key.value === 'inputSchema')
|
|
49
|
+
return 'declared';
|
|
50
|
+
}
|
|
51
|
+
return 'missing';
|
|
52
|
+
}
|
|
53
|
+
exports.requireToolInputSchema = (0, eslint_devkit_1.createRule)({
|
|
54
|
+
name: 'require-tool-input-schema',
|
|
55
|
+
meta: {
|
|
56
|
+
type: 'problem',
|
|
57
|
+
docs: {
|
|
58
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-mcp-sdk-security/docs/rules/require-tool-input-schema.md',
|
|
59
|
+
description: 'Require an input schema when registering an MCP tool',
|
|
60
|
+
cwe: 'CWE-20',
|
|
61
|
+
cvss: 7.5,
|
|
62
|
+
},
|
|
63
|
+
messages: {
|
|
64
|
+
missingInputSchema: (0, eslint_devkit_1.formatLLMMessage)({
|
|
65
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
66
|
+
issueName: 'MCP Tool Registered Without an Input Schema',
|
|
67
|
+
cwe: 'CWE-20',
|
|
68
|
+
owasp: 'A03:2021',
|
|
69
|
+
cvss: 7.5,
|
|
70
|
+
description: 'Tool "{{tool}}" is registered without an input schema, so its handler receives unvalidated client-supplied arguments',
|
|
71
|
+
severity: 'HIGH',
|
|
72
|
+
compliance: ['SOC2'],
|
|
73
|
+
fix: 'Declare the accepted shape: registerTool("{{tool}}", { inputSchema: { path: z.string() } }, handler)',
|
|
74
|
+
documentationLink: 'https://modelcontextprotocol.io/docs/concepts/tools',
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
schema: [],
|
|
78
|
+
},
|
|
79
|
+
defaultOptions: [],
|
|
80
|
+
create(context) {
|
|
81
|
+
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
|
+
const candidates = [];
|
|
85
|
+
function toolNameOf(node) {
|
|
86
|
+
const first = node.arguments[0];
|
|
87
|
+
if (first?.type === 'Literal' && typeof first.value === 'string')
|
|
88
|
+
return first.value;
|
|
89
|
+
return 'unknown';
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
ImportDeclaration(node) {
|
|
93
|
+
if (node.source.value.startsWith(MCP_MODULE_PREFIX))
|
|
94
|
+
importsMcpSdk = true;
|
|
95
|
+
},
|
|
96
|
+
CallExpression(node) {
|
|
97
|
+
// require('@modelcontextprotocol/sdk/...')
|
|
98
|
+
if (node.callee.type === 'Identifier' &&
|
|
99
|
+
node.callee.name === 'require' &&
|
|
100
|
+
node.arguments[0]?.type === 'Literal' &&
|
|
101
|
+
typeof node.arguments[0].value === 'string' &&
|
|
102
|
+
node.arguments[0].value.startsWith(MCP_MODULE_PREFIX)) {
|
|
103
|
+
importsMcpSdk = true;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (node.callee.type !== 'MemberExpression' || node.callee.computed)
|
|
107
|
+
return;
|
|
108
|
+
if (node.callee.property.type !== 'Identifier')
|
|
109
|
+
return;
|
|
110
|
+
const method = node.callee.property.name;
|
|
111
|
+
if (method === REGISTER_TOOL) {
|
|
112
|
+
const config = node.arguments[1];
|
|
113
|
+
// A config passed by reference could carry the schema — not readable
|
|
114
|
+
// here, so not reported.
|
|
115
|
+
if (config?.type !== 'ObjectExpression')
|
|
116
|
+
return;
|
|
117
|
+
if (readInputSchema(config) === 'missing') {
|
|
118
|
+
candidates.push({ node, tool: toolNameOf(node) });
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
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
|
+
const handler = node.arguments[1];
|
|
127
|
+
if (HANDLER_NODE_TYPES.has(handler.type)) {
|
|
128
|
+
candidates.push({ node, tool: toolNameOf(node) });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
'Program:exit'() {
|
|
133
|
+
if (!importsMcpSdk)
|
|
134
|
+
return;
|
|
135
|
+
for (const { node, tool } of candidates) {
|
|
136
|
+
context.report({ node, messageId: 'missingInputSchema', data: { tool } });
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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": "./dist/src/index.js",
|
|
7
|
+
"types": "./dist/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
|
+
"default": "./dist/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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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;
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
});
|