mcp-lint 0.3.0 → 0.5.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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 robert19001-cmyk
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 robert19001-cmyk
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 CHANGED
@@ -4,6 +4,7 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/mcp-lint)](https://www.npmjs.com/package/mcp-lint)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
6
  [![Node.js ≥20](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](https://nodejs.org)
7
+ [![MCP server ready](https://img.shields.io/badge/MCP-server_ready-6f42c1)](#mcp-server)
7
8
 
8
9
  **Lint MCP server tool schemas for cross-client compatibility.**
9
10
 
@@ -55,6 +56,9 @@ mcp-lint fix tools.json --in-place
55
56
 
56
57
  # Generate a config file
57
58
  mcp-lint init
59
+
60
+ # Run as an MCP server
61
+ mcp-lint-server
58
62
  ```
59
63
 
60
64
  ---
@@ -326,7 +330,7 @@ jobs:
326
330
  runs-on: ubuntu-latest
327
331
  steps:
328
332
  - uses: actions/checkout@v4
329
- - uses: robert19001-cmyk/mcp-lint@v0.3.0
333
+ - uses: robert19001-cmyk/mcp-lint@v0.5.0
330
334
  with:
331
335
  input: tools.json
332
336
  severity: warning
@@ -440,6 +444,160 @@ const fixed = applyFixes(tools, diagnostics);
440
444
 
441
445
  ---
442
446
 
447
+ ## `mcp-lint preflight` — Runtime Decision Firewall
448
+
449
+ **Lint catches bad schemas. Preflight catches bad actions.**
450
+
451
+ At runtime, your agent is about to call a tool — delete a file, send a request, charge a card. Preflight sits between the agent and the action and answers:
452
+
453
+ - Is it allowed?
454
+ - How risky is it? (0.0–1.0 deterministic score)
455
+ - Is it reversible?
456
+ - Does it need human approval?
457
+ - Is there a safer alternative?
458
+
459
+ ```bash
460
+ $ mcp-lint preflight action.json --policy preflight.yml
461
+
462
+ Preflight Decision
463
+ ────────────────────────────────────────
464
+ Decision: DENY
465
+ Risk score: 1.00
466
+ Reversibility: irreversible
467
+ Policies: block-destructive-prod
468
+ Reasons: base_shell, destructive_pattern, sensitive_target, irreversible_operation
469
+ ```
470
+
471
+ ### Action format
472
+
473
+ ```json
474
+ {
475
+ "tool_type": "shell",
476
+ "tool_name": "bash",
477
+ "action": "rm -rf /prod/data",
478
+ "target": "/prod/data",
479
+ "context": { "environment": "prod" }
480
+ }
481
+ ```
482
+
483
+ ### Policy file (YAML)
484
+
485
+ ```yaml
486
+ version: 1
487
+ defaults:
488
+ approval_threshold: 0.70
489
+ block_threshold: 0.92
490
+
491
+ rules:
492
+ - id: block-prod-delete
493
+ when:
494
+ tool_type: shell
495
+ action_matches: ["rm -rf"]
496
+ target_matches: ["/prod", "/etc"]
497
+ effect: deny
498
+
499
+ - id: rewrite-tmp-delete
500
+ when:
501
+ tool_type: shell
502
+ action_matches: ["rm -rf ./tmp"]
503
+ effect: allow_with_rewrite
504
+ rewrite:
505
+ tool_type: file_delete
506
+ action: move_to_trash
507
+ target: ./tmp
508
+
509
+ - id: approval-payments
510
+ when:
511
+ tool_type: payment
512
+ effect: require_approval
513
+ ```
514
+
515
+ Sample policies in `examples/policies/`: `default.yml`, `strict.yml`, `permissive-dev.yml`.
516
+
517
+ ### SDK — embed in your MCP server or agent runtime
518
+
519
+ ```typescript
520
+ import { preflight, loadPolicy } from 'mcp-lint/preflight';
521
+
522
+ const policy = await loadPolicy('./preflight.yml');
523
+
524
+ const decision = preflight(
525
+ {
526
+ tool_type: 'shell',
527
+ tool_name: 'bash',
528
+ action: 'rm -rf /tmp',
529
+ target: '/tmp',
530
+ },
531
+ policy,
532
+ );
533
+
534
+ if (decision.decision === 'deny') {
535
+ throw new Error(`Blocked: ${decision.reasons.join(', ')}`);
536
+ }
537
+ if (decision.decision === 'require_approval') {
538
+ await askUser(decision);
539
+ }
540
+ if (decision.decision === 'allow_with_rewrite') {
541
+ return executeSafer(decision.safe_alternative);
542
+ }
543
+ ```
544
+
545
+ ### Exit codes
546
+
547
+ | Code | Meaning |
548
+ |------|---------|
549
+ | `0` | allow / allow_with_rewrite |
550
+ | `1` | require_approval |
551
+ | `2` | deny / error |
552
+
553
+ Use them directly in shell wrappers or CI gates.
554
+
555
+ ---
556
+
557
+ ## MCP Server
558
+
559
+ `mcp-lint` also ships as a stdio MCP server for Claude Desktop, Claude Code, Cursor, VS Code, and registry scanners such as Glama.
560
+
561
+ ```bash
562
+ npx -y mcp-lint@latest mcp-lint-server
563
+ ```
564
+
565
+ Client config:
566
+
567
+ ```json
568
+ {
569
+ "mcpServers": {
570
+ "mcp-lint": {
571
+ "command": "npx",
572
+ "args": ["-y", "mcp-lint@latest", "mcp-lint-server"]
573
+ }
574
+ }
575
+ }
576
+ ```
577
+
578
+ Available MCP tools:
579
+
580
+ | Tool | Purpose |
581
+ |------|---------|
582
+ | `mcp_lint_list_rules` | List built-in rules, clients, severities, and fixability |
583
+ | `mcp_lint_explain_rule` | Explain one rule with examples and auto-fix notes |
584
+ | `mcp_lint_check_tools` | Lint MCP tool schemas passed as JSON |
585
+ | `mcp_lint_fix_tools` | Return safely auto-fixed tool schemas without writing files |
586
+ | `mcp_lint_preflight_action` | Score a proposed agent action and return allow/deny/approval/rewrite |
587
+
588
+ All server tools are read-only from the host perspective: they return diagnostics, fixed JSON, or policy decisions and never execute the action being evaluated.
589
+
590
+ ### Docker
591
+
592
+ ```bash
593
+ docker build -t mcp-lint-server .
594
+ docker run --rm -i mcp-lint-server
595
+ ```
596
+
597
+ The repository includes `glama.json` and a production Dockerfile so MCP directories can build, start, and introspect the server.
598
+
599
+ ---
600
+
443
601
  ## License
444
602
 
445
603
  MIT © Robert
@@ -0,0 +1,2 @@
1
+ import type { Command } from 'commander';
2
+ export declare function registerPreflightCommand(program: Command): void;
@@ -0,0 +1,109 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import chalk from 'chalk';
3
+ import { preflight } from '../../preflight/engine.js';
4
+ import { loadPolicy } from '../../preflight/policy.js';
5
+ export function registerPreflightCommand(program) {
6
+ program
7
+ .command('preflight [action-file]')
8
+ .description('Evaluate a proposed agent action against a policy before execution')
9
+ .option('--policy <path>', 'Path to preflight policy YAML file')
10
+ .option('--format <format>', 'Output format: terminal|json', 'terminal')
11
+ .option('--no-color', 'Disable terminal colors')
12
+ .option('--stdin', 'Read action JSON from stdin')
13
+ .action(async (actionFile, options) => {
14
+ if (!options.color)
15
+ chalk.level = 0;
16
+ try {
17
+ const action = await readAction(actionFile, options.stdin ?? false);
18
+ const policy = options.policy ? await loadPolicy(options.policy) : undefined;
19
+ const decision = preflight(action, policy);
20
+ if (options.format === 'json') {
21
+ process.stdout.write(JSON.stringify(decision, null, 2) + '\n');
22
+ }
23
+ else {
24
+ process.stdout.write(renderTerminal(decision));
25
+ }
26
+ const exitCode = decisionExitCode(decision);
27
+ process.exit(exitCode);
28
+ }
29
+ catch (err) {
30
+ process.stderr.write(`Error: ${err.message}\n`);
31
+ process.exit(2);
32
+ }
33
+ });
34
+ }
35
+ async function readAction(path, stdin) {
36
+ let raw;
37
+ if (stdin || !path) {
38
+ if (process.stdin.isTTY && !stdin) {
39
+ throw new Error('Specify an action file or use --stdin');
40
+ }
41
+ raw = await readStdin();
42
+ }
43
+ else {
44
+ raw = await readFile(path, 'utf8');
45
+ }
46
+ return JSON.parse(raw);
47
+ }
48
+ async function readStdin() {
49
+ const chunks = [];
50
+ for await (const chunk of process.stdin) {
51
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
52
+ }
53
+ return Buffer.concat(chunks).toString('utf8');
54
+ }
55
+ function decisionExitCode(d) {
56
+ switch (d.decision) {
57
+ case 'allow':
58
+ case 'allow_with_rewrite':
59
+ return 0;
60
+ case 'require_approval':
61
+ return 1;
62
+ case 'deny':
63
+ return 2;
64
+ }
65
+ }
66
+ function renderTerminal(d) {
67
+ const lines = [];
68
+ const decisionColor = d.decision === 'deny'
69
+ ? chalk.red
70
+ : d.decision === 'require_approval'
71
+ ? chalk.yellow
72
+ : d.decision === 'allow_with_rewrite'
73
+ ? chalk.cyan
74
+ : chalk.green;
75
+ lines.push('');
76
+ lines.push(chalk.bold('Preflight Decision'));
77
+ lines.push('─'.repeat(40));
78
+ lines.push(`Decision: ${decisionColor(d.decision.toUpperCase())}`);
79
+ lines.push(`Risk score: ${riskColor(d.risk_score)}`);
80
+ lines.push(`Reversibility: ${d.reversibility}`);
81
+ lines.push(`Est. cost: $${d.estimated_cost_usd.toFixed(2)}`);
82
+ if (d.matched_policies.length > 0) {
83
+ lines.push(`Policies: ${d.matched_policies.join(', ')}`);
84
+ }
85
+ if (d.reasons.length > 0) {
86
+ lines.push(`Reasons: ${d.reasons.join(', ')}`);
87
+ }
88
+ if (d.safe_alternative) {
89
+ lines.push('');
90
+ lines.push(chalk.bold('Safe alternative:'));
91
+ lines.push(` ${d.safe_alternative.tool_type} → ${d.safe_alternative.action}`);
92
+ if (d.safe_alternative.target) {
93
+ lines.push(` target: ${d.safe_alternative.target}`);
94
+ }
95
+ }
96
+ lines.push('');
97
+ return lines.join('\n');
98
+ }
99
+ function riskColor(score) {
100
+ const s = score.toFixed(2);
101
+ if (score >= 0.9)
102
+ return chalk.red(s);
103
+ if (score >= 0.7)
104
+ return chalk.yellow(s);
105
+ if (score >= 0.4)
106
+ return chalk.cyan(s);
107
+ return chalk.green(s);
108
+ }
109
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../src/cli/commands/preflight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAA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package/dist/index.js CHANGED
@@ -6,16 +6,18 @@ import { registerInitCommand } from './cli/commands/init.js';
6
6
  import { registerCompatCommand } from './cli/commands/compat.js';
7
7
  import { registerExplainCommand } from './cli/commands/explain.js';
8
8
  import { registerDiffCommand } from './cli/commands/diff.js';
9
+ import { registerPreflightCommand } from './cli/commands/preflight.js';
9
10
  const program = new Command();
10
11
  program
11
12
  .name('mcp-lint')
12
13
  .description('Lint MCP server tool schemas for cross-client compatibility')
13
- .version('0.3.0');
14
+ .version('0.5.0');
14
15
  registerCheckCommand(program);
15
16
  registerFixCommand(program);
16
17
  registerInitCommand(program);
17
18
  registerCompatCommand(program);
18
19
  registerExplainCommand(program);
19
20
  registerDiffCommand(program);
21
+ registerPreflightCommand(program);
20
22
  program.parse();
21
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,6DAA6D,CAAC;KAC1E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC5B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAE7B,OAAO,CAAC,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,6DAA6D,CAAC;KAC1E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC5B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAElC,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { loadFile } from './file-loader.js';
2
+ export { loadSSE } from './sse-loader.js';
3
+ export { loadStdio } from './stdio-loader.js';
@@ -0,0 +1,4 @@
1
+ export { loadFile } from './file-loader.js';
2
+ export { loadSSE } from './sse-loader.js';
3
+ export { loadStdio } from './stdio-loader.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ export declare function createMcpLintServer(): McpServer;
@@ -0,0 +1,242 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { z } from 'zod';
6
+ import { LintEngine } from './core/engine.js';
7
+ import { applyFixes } from './core/fixer.js';
8
+ import { computeQualityReport } from './core/quality-score.js';
9
+ import { DEFAULT_CONFIG } from './config/config.js';
10
+ import { allRules } from './rules/index.js';
11
+ import { preflight } from './preflight/engine.js';
12
+ import { parsePolicy } from './preflight/policy.js';
13
+ const VERSION = '0.5.0';
14
+ const ClientIdSchema = z.enum([
15
+ 'claude',
16
+ 'cursor',
17
+ 'gemini',
18
+ 'vscode',
19
+ 'windsurf',
20
+ 'cline',
21
+ 'openai',
22
+ 'continue',
23
+ ]);
24
+ const SeveritySchema = z.enum(['error', 'warning', 'info']);
25
+ const RuleSeveritySchema = z.union([SeveritySchema, z.literal('off')]);
26
+ const JsonObjectSchema = z.object({}).passthrough();
27
+ const MCPToolInputSchema = z.object({
28
+ name: z.string().min(1).describe('MCP tool name to lint.'),
29
+ description: z.string().optional().describe('Optional MCP tool description.'),
30
+ inputSchema: JsonObjectSchema.describe('JSON Schema object exposed by the MCP tool.'),
31
+ });
32
+ const ConfigShape = {
33
+ clients: z.array(ClientIdSchema).optional().describe('Only run rules for these MCP clients.'),
34
+ ignore: z.array(z.string()).optional().describe('Tool names to ignore.'),
35
+ rules: z.record(z.string(), RuleSeveritySchema).optional().describe('Rule severity overrides by rule id.'),
36
+ maxDepth: z.number().int().min(1).max(20).optional().describe('Maximum schema nesting depth before warning.'),
37
+ };
38
+ const ActionSchema = z.object({
39
+ actor_id: z.string().optional(),
40
+ workspace_id: z.string().optional(),
41
+ tool_type: z.enum([
42
+ 'shell',
43
+ 'file_read',
44
+ 'file_write',
45
+ 'file_delete',
46
+ 'http',
47
+ 'mcp_tool',
48
+ 'email',
49
+ 'payment',
50
+ 'database',
51
+ 'other',
52
+ ]),
53
+ tool_name: z.string().min(1),
54
+ action: z.string().min(1),
55
+ target: z.string().optional(),
56
+ context: z.record(z.string(), z.unknown()).optional(),
57
+ estimated_cost_usd: z.number().min(0).optional(),
58
+ });
59
+ function normalizeConfig(input) {
60
+ return {
61
+ clients: input.clients ?? DEFAULT_CONFIG.clients,
62
+ ignore: input.ignore ?? DEFAULT_CONFIG.ignore,
63
+ maxDepth: input.maxDepth ?? DEFAULT_CONFIG.maxDepth,
64
+ rules: input.rules,
65
+ };
66
+ }
67
+ function lintTools(tools, configInput) {
68
+ const config = normalizeConfig(configInput);
69
+ const engine = new LintEngine(allRules, config);
70
+ const diagnostics = engine.lint(tools);
71
+ const summary = {
72
+ tools: tools.length,
73
+ diagnostics: diagnostics.length,
74
+ errors: diagnostics.filter((d) => d.severity === 'error').length,
75
+ warnings: diagnostics.filter((d) => d.severity === 'warning').length,
76
+ info: diagnostics.filter((d) => d.severity === 'info').length,
77
+ };
78
+ return { config, diagnostics, summary };
79
+ }
80
+ function result(output) {
81
+ return {
82
+ content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
83
+ structuredContent: output,
84
+ };
85
+ }
86
+ export function createMcpLintServer() {
87
+ const server = new McpServer({
88
+ name: 'mcp-lint-mcp-server',
89
+ version: VERSION,
90
+ });
91
+ server.registerTool('mcp_lint_list_rules', {
92
+ title: 'List mcp-lint Rules',
93
+ description: 'List every built-in mcp-lint rule with severity, supported clients, fixability, and description.',
94
+ outputSchema: {
95
+ rules: z.array(JsonObjectSchema),
96
+ total: z.number(),
97
+ },
98
+ annotations: {
99
+ readOnlyHint: true,
100
+ destructiveHint: false,
101
+ idempotentHint: true,
102
+ openWorldHint: false,
103
+ },
104
+ }, async () => {
105
+ const rules = allRules.map((rule) => ({
106
+ id: rule.id,
107
+ severity: rule.severity,
108
+ clients: rule.clients,
109
+ fixable: Boolean(rule.docs?.fixNote),
110
+ description: rule.description,
111
+ }));
112
+ return result({ total: rules.length, rules });
113
+ });
114
+ server.registerTool('mcp_lint_explain_rule', {
115
+ title: 'Explain mcp-lint Rule',
116
+ description: 'Return detailed documentation, examples, and auto-fix notes for one mcp-lint rule id.',
117
+ inputSchema: {
118
+ ruleId: z.string().min(1).describe('Rule id such as openai/no-additional-properties.'),
119
+ },
120
+ outputSchema: {
121
+ rule: JsonObjectSchema,
122
+ },
123
+ annotations: {
124
+ readOnlyHint: true,
125
+ destructiveHint: false,
126
+ idempotentHint: true,
127
+ openWorldHint: false,
128
+ },
129
+ }, async ({ ruleId }) => {
130
+ const rule = allRules.find((candidate) => candidate.id === ruleId);
131
+ if (!rule) {
132
+ throw new Error(`Unknown rule "${ruleId}". Use mcp_lint_list_rules to discover available rule ids.`);
133
+ }
134
+ return result({
135
+ rule: {
136
+ id: rule.id,
137
+ severity: rule.severity,
138
+ clients: rule.clients,
139
+ fixable: Boolean(rule.docs?.fixNote),
140
+ description: rule.description,
141
+ docs: rule.docs ?? null,
142
+ },
143
+ });
144
+ });
145
+ server.registerTool('mcp_lint_check_tools', {
146
+ title: 'Lint MCP Tool Schemas',
147
+ description: 'Lint MCP tool schemas for compatibility across Claude, Cursor, Gemini, VS Code, Windsurf, Cline, OpenAI Agents SDK, and Continue.dev.',
148
+ inputSchema: {
149
+ tools: z.array(MCPToolInputSchema).describe('Array of MCP tools with name, description, and inputSchema.'),
150
+ includeScore: z.boolean().default(false).describe('Include quality score and grade per tool.'),
151
+ ...ConfigShape,
152
+ },
153
+ outputSchema: {
154
+ summary: JsonObjectSchema,
155
+ diagnostics: z.array(JsonObjectSchema),
156
+ quality: JsonObjectSchema.optional(),
157
+ },
158
+ annotations: {
159
+ readOnlyHint: true,
160
+ destructiveHint: false,
161
+ idempotentHint: true,
162
+ openWorldHint: false,
163
+ },
164
+ }, async ({ tools, includeScore, clients, ignore, rules, maxDepth }) => {
165
+ const { diagnostics, summary } = lintTools(tools, {
166
+ clients,
167
+ ignore,
168
+ rules,
169
+ maxDepth,
170
+ });
171
+ const output = {
172
+ summary,
173
+ diagnostics,
174
+ ...(includeScore ? { quality: computeQualityReport(tools, diagnostics) } : {}),
175
+ };
176
+ return result(output);
177
+ });
178
+ server.registerTool('mcp_lint_fix_tools', {
179
+ title: 'Auto-fix MCP Tool Schemas',
180
+ description: 'Apply safe mcp-lint schema fixes and return the corrected tool definitions without writing to disk.',
181
+ inputSchema: {
182
+ tools: z.array(MCPToolInputSchema).describe('Array of MCP tools to lint and fix.'),
183
+ onlyRules: z.array(z.string()).optional().describe('Optional list of fixable rule ids to apply.'),
184
+ ...ConfigShape,
185
+ },
186
+ outputSchema: {
187
+ fixedTools: z.array(JsonObjectSchema),
188
+ fixesApplied: z.number(),
189
+ diagnosticsBeforeFix: z.array(JsonObjectSchema),
190
+ diagnosticsAfterFix: z.array(JsonObjectSchema),
191
+ },
192
+ annotations: {
193
+ readOnlyHint: true,
194
+ destructiveHint: false,
195
+ idempotentHint: true,
196
+ openWorldHint: false,
197
+ },
198
+ }, async ({ tools, onlyRules, clients, ignore, rules, maxDepth }) => {
199
+ const config = { clients, ignore, rules, maxDepth };
200
+ const before = lintTools(tools, config);
201
+ const fixedTools = applyFixes(tools, before.diagnostics, onlyRules);
202
+ const after = lintTools(fixedTools, config);
203
+ return result({
204
+ fixedTools,
205
+ fixesApplied: before.diagnostics.filter((d) => d.fix && (!onlyRules || onlyRules.includes(d.ruleId))).length,
206
+ diagnosticsBeforeFix: before.diagnostics,
207
+ diagnosticsAfterFix: after.diagnostics,
208
+ });
209
+ });
210
+ server.registerTool('mcp_lint_preflight_action', {
211
+ title: 'Preflight Agent Action',
212
+ description: 'Evaluate a proposed agent tool call before execution and return allow, deny, approval, or safe rewrite guidance. This tool never executes the action.',
213
+ inputSchema: {
214
+ action: ActionSchema.describe('Action object to score and evaluate.'),
215
+ policyYaml: z.string().optional().describe('Optional mcp-lint preflight policy YAML. Defaults to built-in thresholds.'),
216
+ },
217
+ outputSchema: {
218
+ decision: JsonObjectSchema,
219
+ },
220
+ annotations: {
221
+ readOnlyHint: true,
222
+ destructiveHint: false,
223
+ idempotentHint: true,
224
+ openWorldHint: false,
225
+ },
226
+ }, async ({ action, policyYaml }) => {
227
+ const policy = policyYaml ? parsePolicy(policyYaml) : undefined;
228
+ return result({ decision: preflight(action, policy) });
229
+ });
230
+ return server;
231
+ }
232
+ async function main() {
233
+ const server = createMcpLintServer();
234
+ await server.connect(new StdioServerTransport());
235
+ }
236
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
237
+ main().catch((error) => {
238
+ process.stderr.write(`mcp-lint MCP server failed: ${error.message}\n`);
239
+ process.exit(1);
240
+ });
241
+ }
242
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,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AAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2EAA2E,CAAC;SACxH;QACD,YAAY,EAAE;YACZ,QAAQ,EAAE,gBAAgB;SAC3B;QACD,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,KAAK;SACrB;KACF,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAChE,OAAO,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAgB,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACrC,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/E,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAAgC,KAAe,CAAC,OAAO,IAAI,CAAC,CAAC;QAClF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { Action, Decision, Policy } from './types.js';
2
+ export declare function preflight(action: Action, policy?: Policy): Decision;