@wastech-mdlint/mcp-server 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/shared/since.d.ts +32 -0
- package/dist/shared/since.js +32 -0
- package/dist/shared/tool-context.js +1 -1
- package/dist/shared/tool-response.d.ts +1 -1
- package/dist/tools/context-slice.js +6 -3
- package/dist/tools/impact-analysis.d.ts +2 -1
- package/dist/tools/impact-analysis.js +27 -7
- package/dist/tools/lint-files.d.ts +1 -0
- package/dist/tools/lint-files.js +16 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,10 +31,10 @@ Node.js `>=24.17.0`. Readiness is announced on stderr; stdout carries only the p
|
|
|
31
31
|
| Tool | What it does |
|
|
32
32
|
| --- | --- |
|
|
33
33
|
| `lint` | Lint ad-hoc Markdown content against an explicit rule list. Does not load project config. |
|
|
34
|
-
| `lint-files` | Lint the project's Markdown files using the resolved config, or the zero-config default. |
|
|
34
|
+
| `lint-files` | Lint the project's Markdown files using the resolved config, or the zero-config default. With `since` (a branch, tag or commit), only the findings the work tree adds since where it left that ref, read with git. |
|
|
35
35
|
| `context-graph` | Build the project's context graph — nodes, edges, cycles, or a summary document. |
|
|
36
36
|
| `context-slice` | The files reachable within `depth` hops of a query resolved by exact match. |
|
|
37
|
-
| `impact-analysis` | The blast radius of changing one file: direct and transitive dependents. |
|
|
37
|
+
| `impact-analysis` | The blast radius of changing one file: direct and transitive dependents. With `since` in place of `file`, the same for every document the work tree changed since where it left that ref. |
|
|
38
38
|
| `compile-context` | Compile the project skill (`SKILL.md`) from `config.compile`. |
|
|
39
39
|
|
|
40
40
|
All six carry a `readOnlyHint` annotation. Five return `structuredContent` alongside an `outputSchema`; `compile-context` returns two plain-text content blocks instead.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type LoadedConfiguration, type SinceAnalysis } from "@wastech-mdlint/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const sinceInput: z.ZodOptional<z.ZodString>;
|
|
4
|
+
export declare const sinceSummarySchema: z.ZodObject<{
|
|
5
|
+
ref: z.ZodString;
|
|
6
|
+
base: z.ZodString;
|
|
7
|
+
mergeBase: z.ZodString;
|
|
8
|
+
head: z.ZodString;
|
|
9
|
+
changed: z.ZodArray<z.ZodString>;
|
|
10
|
+
removed: z.ZodArray<z.ZodObject<{
|
|
11
|
+
ruleId: z.ZodString;
|
|
12
|
+
severity: z.ZodEnum<{
|
|
13
|
+
error: "error";
|
|
14
|
+
warning: "warning";
|
|
15
|
+
}>;
|
|
16
|
+
message: z.ZodString;
|
|
17
|
+
filePath: z.ZodString;
|
|
18
|
+
line: z.ZodNumber;
|
|
19
|
+
column: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
fixable: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
+
helpUri: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
/**
|
|
27
|
+
* The work tree's changes since `ref`, or an input error naming why there is nothing to compare —
|
|
28
|
+
* not a git work tree, no `git`, a ref that names nothing — with git's remedy as the hint. An error
|
|
29
|
+
* rather than an empty answer, because "no new findings" from a comparison that never ran is the
|
|
30
|
+
* plausible answer to a different question.
|
|
31
|
+
*/
|
|
32
|
+
export declare function analyzeSinceOrThrow(cwd: string, configuration: LoadedConfiguration, ref: string): Promise<SinceAnalysis>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { analyzeSince, } from "@wastech-mdlint/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { lintMessageSchema } from "./lint-message-schema.js";
|
|
4
|
+
import { ToolInputError } from "./tool-input-error.js";
|
|
5
|
+
// The `since` input both file-based tools accept, and the record of the comparison both return.
|
|
6
|
+
// One schema, so `lint-files` and `impact-analysis` describe "since" identically to a client that
|
|
7
|
+
// generates types from their output schemas.
|
|
8
|
+
export const sinceInput = z.string().optional();
|
|
9
|
+
export const sinceSummarySchema = z.object({
|
|
10
|
+
ref: z.string(),
|
|
11
|
+
base: z.string(),
|
|
12
|
+
mergeBase: z.string(),
|
|
13
|
+
head: z.string(),
|
|
14
|
+
changed: z.array(z.string()),
|
|
15
|
+
removed: z.array(lintMessageSchema),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* The work tree's changes since `ref`, or an input error naming why there is nothing to compare —
|
|
19
|
+
* not a git work tree, no `git`, a ref that names nothing — with git's remedy as the hint. An error
|
|
20
|
+
* rather than an empty answer, because "no new findings" from a comparison that never ran is the
|
|
21
|
+
* plausible answer to a different question.
|
|
22
|
+
*/
|
|
23
|
+
export async function analyzeSinceOrThrow(cwd, configuration, ref) {
|
|
24
|
+
if (ref.trim() === "") {
|
|
25
|
+
throw new ToolInputError("since must name a branch, tag or commit", 'Pass the base branch, for example "main", or omit "since".');
|
|
26
|
+
}
|
|
27
|
+
const analysis = await analyzeSince({ cwd, configuration, ref });
|
|
28
|
+
if ("available" in analysis) {
|
|
29
|
+
throw new ToolInputError(analysis.message, analysis.hint);
|
|
30
|
+
}
|
|
31
|
+
return analysis;
|
|
32
|
+
}
|
|
@@ -48,7 +48,7 @@ export async function resolveToolCwd(input) {
|
|
|
48
48
|
// the exact failure this guard exists to name. Not expressed as `.min(1)` on the tools'
|
|
49
49
|
// `inputSchema`s: a schema rejection is refused before the handler runs, arriving as a bare
|
|
50
50
|
// `InvalidParams` with no `structuredContent` and no `hint`.
|
|
51
|
-
if (input.cwd
|
|
51
|
+
if (input.cwd?.trim() === "") {
|
|
52
52
|
throw new ToolInputError("cwd must not be empty", hint);
|
|
53
53
|
}
|
|
54
54
|
const resolved = toolCwdBase(input);
|
|
@@ -9,4 +9,4 @@ export declare function errorResult(error: unknown, options?: {
|
|
|
9
9
|
successFields?: Readonly<Record<string, unknown>>;
|
|
10
10
|
cwd?: string;
|
|
11
11
|
}): CallToolResult;
|
|
12
|
-
export declare function withErrorOutput(success: Readonly<Record<string, z.
|
|
12
|
+
export declare function withErrorOutput(success: Readonly<Record<string, z.ZodType>>): Record<string, z.ZodType>;
|
|
@@ -31,9 +31,12 @@ export async function handleContextSlice(input) {
|
|
|
31
31
|
const cwd = toolCwdBase(input);
|
|
32
32
|
try {
|
|
33
33
|
const { graph, documents, settings } = await resolveToolContext(input);
|
|
34
|
-
// `input.depth` is passed straight through even when `undefined`: `getContextSlice`
|
|
35
|
-
//
|
|
36
|
-
const result = getContextSlice(graph, documents, input.query,
|
|
34
|
+
// `input.depth` is passed straight through even when `undefined`: `getContextSlice` defaults an
|
|
35
|
+
// explicit `undefined` depth to 2 as it does an absent one, so no `?? 2` is needed.
|
|
36
|
+
const result = getContextSlice(graph, documents, input.query, {
|
|
37
|
+
depth: input.depth,
|
|
38
|
+
idRef: settings.idRef,
|
|
39
|
+
});
|
|
37
40
|
// An unresolved query is not an error: it returns `matchKind: null` with empty arrays. This is
|
|
38
41
|
// the honest-empty-result contract — do not throw.
|
|
39
42
|
return successResult({
|
|
@@ -2,7 +2,8 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { type ToolFileInput } from "../shared/tool-context.js";
|
|
4
4
|
type ImpactAnalysisToolInput = ToolFileInput & {
|
|
5
|
-
file
|
|
5
|
+
file?: string;
|
|
6
|
+
since?: string;
|
|
6
7
|
};
|
|
7
8
|
export declare function handleImpactAnalysis(input: ImpactAnalysisToolInput): Promise<CallToolResult>;
|
|
8
9
|
export declare function registerImpactAnalysisTool(server: McpServer): void;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { classifyImpact, relativizeImpact, renderImpactSummary, } from "@wastech-mdlint/core";
|
|
1
|
+
import { classifyImpact, relativizeImpact, renderImpactSummary, renderSinceHeader, sinceImpact, } from "@wastech-mdlint/core";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { analyzeSinceOrThrow, sinceInput, sinceSummarySchema, } from "../shared/since.js";
|
|
4
|
+
import { resolveToolConfiguration, resolveToolContext, toolCwdBase, } from "../shared/tool-context.js";
|
|
5
|
+
import { ToolInputError } from "../shared/tool-input-error.js";
|
|
4
6
|
import { errorResult, READ_ONLY_ANNOTATIONS, successResult, withErrorOutput, } from "../shared/tool-response.js";
|
|
5
7
|
const impactAnalysisInputShape = {
|
|
6
|
-
file: z.string(),
|
|
8
|
+
file: z.string().optional(),
|
|
9
|
+
since: sinceInput,
|
|
7
10
|
configPath: z.string().optional(),
|
|
8
11
|
cwd: z.string().optional(),
|
|
9
12
|
};
|
|
@@ -19,8 +22,11 @@ const transitivelyAffectedSchema = z.object({
|
|
|
19
22
|
depth: z.number().int(),
|
|
20
23
|
via: z.string(),
|
|
21
24
|
});
|
|
25
|
+
// `file` for one changed file; `files` and `since` for every document changed since a ref.
|
|
22
26
|
const impactAnalysisOutputShape = {
|
|
23
|
-
file: z.string(),
|
|
27
|
+
file: z.string().optional(),
|
|
28
|
+
files: z.array(z.string()).optional(),
|
|
29
|
+
since: sinceSummarySchema.optional(),
|
|
24
30
|
directlyAffected: z.array(directlyAffectedSchema),
|
|
25
31
|
transitivelyAffected: z.array(transitivelyAffectedSchema),
|
|
26
32
|
readingOrder: z.array(z.string()),
|
|
@@ -31,12 +37,24 @@ export async function handleImpactAnalysis(input) {
|
|
|
31
37
|
// independently of whether resolution got far enough to produce one.
|
|
32
38
|
const cwd = toolCwdBase(input);
|
|
33
39
|
try {
|
|
40
|
+
if ((input.file === undefined) === (input.since === undefined)) {
|
|
41
|
+
throw new ToolInputError('impact-analysis takes either "file" or "since"', 'Pass "file" for one changed Markdown file, or "since" (a branch, tag or commit) for every document the work tree changed since where it left that ref.');
|
|
42
|
+
}
|
|
43
|
+
if (input.since !== undefined) {
|
|
44
|
+
const loaded = await resolveToolConfiguration(input);
|
|
45
|
+
const result = sinceImpact(await analyzeSinceOrThrow(loaded.cwd, loaded, input.since));
|
|
46
|
+
return successResult({
|
|
47
|
+
summary: `${renderSinceHeader(result.since)}${renderImpactSummary(result)}`,
|
|
48
|
+
structured: result,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const file = input.file ?? "";
|
|
34
52
|
const { graph } = await resolveToolContext(input);
|
|
35
53
|
// `classifyImpact` throws `ImpactAnalysisError` (code `TARGET_NOT_FOUND`, already in
|
|
36
54
|
// `TOOL_ERROR_CODES`) when `file` is not in the corpus, so `errorResult` passes it through with
|
|
37
55
|
// no translation wrapper — unlike `lint.ts`, whose `RuleResolutionError` codes aren't in the
|
|
38
56
|
// taxonomy.
|
|
39
|
-
const classification = classifyImpact(graph,
|
|
57
|
+
const classification = classifyImpact(graph, file);
|
|
40
58
|
// Identity transform: this tool's `cwd` is both the corpus root the graph is built from and the
|
|
41
59
|
// base the classification's paths are already relative to, so "repo-relative cwd" is `""`. The
|
|
42
60
|
// call is still made (first real consumer of `relativizeImpact`); it just changes no path here.
|
|
@@ -51,7 +69,7 @@ export async function handleImpactAnalysis(input) {
|
|
|
51
69
|
// machine-parseable under the same required schema a successful impact result uses.
|
|
52
70
|
return errorResult(error, {
|
|
53
71
|
successFields: {
|
|
54
|
-
file: input.file,
|
|
72
|
+
...(input.file === undefined ? {} : { file: input.file }),
|
|
55
73
|
directlyAffected: [],
|
|
56
74
|
transitivelyAffected: [],
|
|
57
75
|
readingOrder: [],
|
|
@@ -66,7 +84,9 @@ export function registerImpactAnalysisTool(server) {
|
|
|
66
84
|
title: "Analyze change impact",
|
|
67
85
|
description: "Compute the blast radius of changing a Markdown file: files that reference it directly, " +
|
|
68
86
|
"files affected transitively, and the reading order over the affected subgraph. A file not " +
|
|
69
|
-
"in the corpus returns an actionable error.
|
|
87
|
+
"in the corpus returns an actionable error. With `since` (a branch, tag or commit) in place " +
|
|
88
|
+
"of `file`, the same for every document the work tree changed since where it left that ref, " +
|
|
89
|
+
"read with git. Read-only.",
|
|
70
90
|
inputSchema: impactAnalysisInputShape,
|
|
71
91
|
outputSchema: withErrorOutput(impactAnalysisOutputShape),
|
|
72
92
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
@@ -3,6 +3,7 @@ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
|
3
3
|
import { type ToolFileInput } from "../shared/tool-context.js";
|
|
4
4
|
type LintFilesToolInput = ToolFileInput & {
|
|
5
5
|
patterns?: string[];
|
|
6
|
+
since?: string;
|
|
6
7
|
};
|
|
7
8
|
export declare function handleLintFiles(input: LintFilesToolInput): Promise<CallToolResult>;
|
|
8
9
|
export declare function registerLintFilesTool(server: McpServer): void;
|
package/dist/tools/lint-files.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { formatLintResultText, lintFiles, } from "@wastech-mdlint/core";
|
|
1
|
+
import { formatLintResultText, lintFiles, renderSinceHeader, sinceLintResult, } from "@wastech-mdlint/core";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { lintMessageSchema } from "../shared/lint-message-schema.js";
|
|
4
|
+
import { analyzeSinceOrThrow, sinceInput, sinceSummarySchema, } from "../shared/since.js";
|
|
4
5
|
import { resolveToolConfiguration, toolCwdBase, } from "../shared/tool-context.js";
|
|
5
6
|
import { errorResult, READ_ONLY_ANNOTATIONS, successResult, withErrorOutput, } from "../shared/tool-response.js";
|
|
6
7
|
const lintFilesInputShape = {
|
|
7
8
|
patterns: z.array(z.string()).optional(),
|
|
8
9
|
configPath: z.string().optional(),
|
|
9
10
|
cwd: z.string().optional(),
|
|
11
|
+
since: sinceInput,
|
|
10
12
|
};
|
|
11
13
|
// Mirrors `LintResult` directly — field names already match, so `structured: result` needs no
|
|
12
14
|
// reshaping.
|
|
@@ -15,6 +17,8 @@ const lintFilesOutputShape = {
|
|
|
15
17
|
files: z.array(z.string()),
|
|
16
18
|
errorCount: z.number().int(),
|
|
17
19
|
warningCount: z.number().int(),
|
|
20
|
+
// Present when `since` was given: the comparison the findings are new against.
|
|
21
|
+
since: sinceSummarySchema.optional(),
|
|
18
22
|
};
|
|
19
23
|
// Match the required `LintResult` fields on the error path so schema-validating MCP clients accept
|
|
20
24
|
// the structured error payload instead of rejecting the response before the caller sees the code.
|
|
@@ -39,6 +43,15 @@ export async function handleLintFiles(input) {
|
|
|
39
43
|
const config = input.patterns === undefined
|
|
40
44
|
? loaded.config
|
|
41
45
|
: { ...loaded.config, include: input.patterns };
|
|
46
|
+
if (input.since !== undefined) {
|
|
47
|
+
// The CLI's `lint --since` from the same core calls: only the findings the work tree adds
|
|
48
|
+
// since where the branch left `since`, with the comparison named in both renderings.
|
|
49
|
+
const since = sinceLintResult(await analyzeSinceOrThrow(loaded.cwd, { ...loaded, config }, input.since));
|
|
50
|
+
return successResult({
|
|
51
|
+
summary: `${renderSinceHeader(since.since)}${formatLintResultText(since)}`,
|
|
52
|
+
structured: since,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
42
55
|
const result = await lintFiles({
|
|
43
56
|
cwd: loaded.cwd,
|
|
44
57
|
config,
|
|
@@ -57,7 +70,8 @@ export async function handleLintFiles(input) {
|
|
|
57
70
|
export function registerLintFilesTool(server) {
|
|
58
71
|
server.registerTool("lint-files", {
|
|
59
72
|
title: "Lint project files",
|
|
60
|
-
description: "Lint the project's Markdown files using the resolved config (or the zero-config `**/*.md` default).
|
|
73
|
+
description: "Lint the project's Markdown files using the resolved config (or the zero-config `**/*.md` default). " +
|
|
74
|
+
"With `since` (a branch, tag or commit), report only the findings the work tree adds since where it left that ref, read with git. Read-only.",
|
|
61
75
|
inputSchema: lintFilesInputShape,
|
|
62
76
|
outputSchema: withErrorOutput(lintFilesOutputShape),
|
|
63
77
|
annotations: READ_ONLY_ANNOTATIONS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wastech-mdlint/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "MCP server for Markdown linting: read-only Model Context Protocol tools for lint findings, the context graph, and change impact.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
44
|
-
"@wastech-mdlint/core": "0.
|
|
44
|
+
"@wastech-mdlint/core": "0.4.1",
|
|
45
45
|
"zod": "^4.6.6"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|