eslint-plugin-mcp-sdk-security 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -24
- package/package.json +11 -23
- package/src/index.d.ts +17 -0
- package/src/index.js +56 -0
- package/src/oxlint.d.ts +17 -0
- package/src/oxlint.js +3 -0
- package/src/rules/no-command-injection-in-tool/index.js +173 -0
- package/src/rules/no-tool-description-injection/index.js +114 -0
- package/src/rules/no-unvalidated-tool-args/index.js +141 -0
- package/{dist/src → src}/rules/require-tool-input-schema/index.js +0 -35
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -108
- package/dist/package.json +0 -95
- package/dist/src/index.d.ts +0 -44
- package/dist/src/index.js +0 -66
- package/dist/src/oxlint.d.ts +0 -20
- package/dist/src/oxlint.js +0 -21
- package/dist/src/rules/require-tool-input-schema/index.d.ts +0 -8
- package/src/index.test.ts +0 -38
- package/src/index.ts +0 -85
- package/src/oxlint.ts +0 -23
- package/src/rules/require-tool-input-schema/index.ts +0 -150
- package/src/rules/require-tool-input-schema/require-tool-input-schema.test.ts +0 -215
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
|
-
});
|