@wastech-mdlint/mcp-server 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.
@@ -0,0 +1,64 @@
1
+ import { compileContext } from "@wastech-mdlint/core";
2
+ import { z } from "zod";
3
+ import { resolveToolConfiguration, toolCwdBase, } from "../shared/tool-context.js";
4
+ import { errorResult, READ_ONLY_ANNOTATIONS } from "../shared/tool-response.js";
5
+ // `compile-context` — compile the project skill (the same deterministic `SKILL.md` the CLI's
6
+ // `compile` command produces) over MCP. Core owns the whole pipeline; this handler is a thin
7
+ // adapter.
8
+ //
9
+ // Unlike its five sibling tools, `compile-context` returns NO `structuredContent`/`outputSchema`:
10
+ // structured output is scoped to exactly five tools (`lint`, `lint-files`, `context-graph`,
11
+ // `context-slice`, `impact-analysis`), and this one returns two content blocks instead. A compiled
12
+ // SKILL.md is a document, not a record set: there is no field a client would read out of it that
13
+ // the text does not already carry. So the
14
+ // `registerTool` call omits `outputSchema` and the handler returns exactly two text blocks — hence
15
+ // `successResult` (which always attaches `structuredContent`) is deliberately not reused here.
16
+ // Identical `cwd?`/`configPath?` shape to `ToolFileInput`; this tool adds no field, so it takes
17
+ // `ToolFileInput` directly rather than aliasing a one-field-wider input type.
18
+ const compileContextInputShape = {
19
+ configPath: z.string().optional(),
20
+ cwd: z.string().optional(),
21
+ };
22
+ export async function handleCompileContext(input) {
23
+ // Outside the `try` for the same reason as its four file-based siblings: an errno raised while
24
+ // resolving the configuration has no resolved `loaded.cwd` to render its path against.
25
+ const cwd = toolCwdBase(input);
26
+ try {
27
+ const loaded = await resolveToolConfiguration(input);
28
+ // `compileContext` throws `CompileConfigMissingError` (code `COMPILE_CONFIG_MISSING`, already in
29
+ // `TOOL_ERROR_CODES`, carrying `.hint`) when `config.compile` is absent, so `errorResult` passes
30
+ // it through verbatim with no translation wrapper — exactly like `impact-analysis`, and unlike
31
+ // `lint.ts` whose `RuleResolutionError` codes aren't in the taxonomy.
32
+ const result = await compileContext(loaded, loaded.cwd);
33
+ const { documentCount, ruleCount, componentCount } = result.metadata;
34
+ return {
35
+ content: [
36
+ // `skillContent` passes through byte-for-byte (the AC's determinism/parity criterion): the
37
+ // CLI and this tool share the same `compileContext` call boundary, so returning it verbatim
38
+ // guarantees identical output. The metadata line is a plain-text summary, not Markdown, and
39
+ // lives here as a local template because it has exactly one call site today (the CLI prints
40
+ // `skillContent` or a write confirmation, never this line) — promote it to core only if a
41
+ // second consumer appears.
42
+ { type: "text", text: result.skillContent },
43
+ {
44
+ type: "text",
45
+ text: `Documents: ${documentCount}, Rules: ${ruleCount}, Components: ${componentCount}`,
46
+ },
47
+ ],
48
+ };
49
+ }
50
+ catch (error) {
51
+ // No `successFields`: this is the one tool with no `outputSchema` to satisfy.
52
+ return errorResult(error, { cwd });
53
+ }
54
+ }
55
+ export function registerCompileContextTool(server) {
56
+ server.registerTool("compile-context", {
57
+ title: "Compile the project skill",
58
+ description: "Compile the project skill (SKILL.md) from `config.compile`, producing the same deterministic " +
59
+ "output as the CLI `compile` command: the skill content plus a Documents/Rules/Components " +
60
+ "metadata line. Requires `config.compile`; its absence returns an actionable error. Read-only.",
61
+ inputSchema: compileContextInputShape,
62
+ annotations: READ_ONLY_ANNOTATIONS,
63
+ }, (input) => handleCompileContext(input));
64
+ }
@@ -0,0 +1,9 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import { type ToolFileInput } from "../shared/tool-context.js";
4
+ type ContextGraphToolInput = ToolFileInput & {
5
+ format?: "raw" | "summary";
6
+ };
7
+ export declare function handleContextGraph(input: ContextGraphToolInput): Promise<CallToolResult>;
8
+ export declare function registerContextGraphTool(server: McpServer): void;
9
+ export {};
@@ -0,0 +1,116 @@
1
+ import { computeGraphCoverage, formatContextGraphSummary, summarizeContextGraph, } from "@wastech-mdlint/core";
2
+ import { z } from "zod";
3
+ import { resolveToolContext, toolCwdBase, } from "../shared/tool-context.js";
4
+ import { errorResult, READ_ONLY_ANNOTATIONS, successResult, withErrorOutput, } from "../shared/tool-response.js";
5
+ // `context-graph` — build the project's `ContextGraph` and return it either verbatim
6
+ // (`format: "raw"`, the default) or as the derived `ContextGraphSummary` (`format: "summary"`). Core
7
+ // owns graph construction via `resolveToolContext` → `loadContext`; this handler only picks
8
+ // which projection to return, and calls `computeGraphCoverage` for the one that carries coverage.
9
+ //
10
+ // The branch was once named `"json"`. On a JSON-RPC tool *every* projection is JSON,
11
+ // so `json` never named an axis here — and it collided with the CLI's `graph --format json`, which
12
+ // denotes the summary document, not the raw graph. `raw` vs `summary` names the axis that exists.
13
+ // Local Zod mirrors of `ContextGraphNode`/`ContextGraphEdge` (hand-maintained per this package's
14
+ // `lint-message-schema.ts` convention — each has a single consumer here, so it stays local rather
15
+ // than promoted to a shared schema module).
16
+ const contextGraphNodeSchema = z.object({
17
+ path: z.string(),
18
+ inDegree: z.number().int(),
19
+ outDegree: z.number().int(),
20
+ });
21
+ const contextGraphEdgeSchema = z.object({
22
+ from: z.string(),
23
+ to: z.string(),
24
+ type: z.enum(["link", "anchor", "image", "import", "id-ref"]),
25
+ line: z.number().int().optional(),
26
+ text: z.string().optional(),
27
+ rawTarget: z.string().optional(),
28
+ });
29
+ // Local Zod mirror of `GraphCoverage`, same hand-maintained convention as the two schemas above.
30
+ const graphCoverageSchema = z.object({
31
+ nodeCount: z.number().int(),
32
+ edgeCount: z.number().int(),
33
+ filesOutsideCorpus: z.array(z.string()),
34
+ });
35
+ const contextGraphInputShape = {
36
+ configPath: z.string().optional(),
37
+ cwd: z.string().optional(),
38
+ format: z.enum(["raw", "summary"]).optional(),
39
+ };
40
+ // One tool, two structured shapes: `format: "raw"` returns `{ nodes, edges, cycles }` (the verbatim
41
+ // `ContextGraph`), `format: "summary"` returns
42
+ // `{ nodes, edges, components, readingOrder, excluded, coverage }` — the same document the CLI's
43
+ // `graph --format json` prints, which is the parity between hosts. `registerTool` takes a
44
+ // single `outputSchema`, so the format-specific fields are individually optional — a superset schema
45
+ // rather than a discriminated union, which would require echoing a `format` field neither core type
46
+ // carries. `nodes`/`edges` stay required because both shapes always carry them.
47
+ const contextGraphOutputShape = {
48
+ nodes: z.array(contextGraphNodeSchema),
49
+ edges: z.array(contextGraphEdgeSchema),
50
+ cycles: z.array(z.array(z.string())).optional(),
51
+ components: z.array(z.array(z.string())).optional(),
52
+ readingOrder: z.array(z.string()).optional(),
53
+ excluded: z.array(z.string()).optional(),
54
+ coverage: graphCoverageSchema.optional(),
55
+ };
56
+ // `context-graph`'s success schema is already a deliberate superset of two success payloads
57
+ // (`raw` graph vs `summary` projection). Reusing that same superset on errors keeps the wire
58
+ // validator satisfied without weakening the required shared fields (`nodes`, `edges`).
59
+ const EMPTY_CONTEXT_GRAPH_OUTPUT = {
60
+ nodes: [],
61
+ edges: [],
62
+ };
63
+ export async function handleContextGraph(input) {
64
+ // Outside the `try`: `resolveToolContext` is itself a throw site (config read, corpus walk), so the
65
+ // catch needs the base independently of whether resolution got far enough to produce one.
66
+ const cwd = toolCwdBase(input);
67
+ try {
68
+ // `cwd` is already taken by the base above; this is the *validated* resolution of it, and the
69
+ // root `computeGraphCoverage` probes for out-of-corpus files.
70
+ const { config, cwd: corpusRoot, documents, graph, settings, } = await resolveToolContext(input);
71
+ // Default `"raw"`: the unprocessed graph is the more fundamental of the two shapes, `"summary"`
72
+ // is the derived view. Keeping raw the default is also what makes the rename
73
+ // behavior-preserving for a caller that omits `format`.
74
+ const format = input.format ?? "raw";
75
+ const structured = format === "summary"
76
+ ? // Coverage is computed on this branch only: `raw` must stay exactly `ContextGraph`, and the
77
+ // disk re-scan coverage needs is work the default branch has no mandate to do.
78
+ // Mirrors the CLI's own call so neither host can drift on rootDir/siteRouter.
79
+ summarizeContextGraph(graph, computeGraphCoverage(documents, graph, {
80
+ rootDir: corpusRoot,
81
+ siteRouter: settings.siteRouter,
82
+ }))
83
+ : { nodes: graph.nodes, edges: graph.edges, cycles: graph.cycles };
84
+ // The same text renderer serves both branches: it is a pure function over `graph` either way, so
85
+ // both formats get one consistent human-readable summary rather than a second renderer.
86
+ //
87
+ // The threshold is threaded for the reason the CLI threads it: the summary's `top hubs` list and
88
+ // the `hub` role in a generated skill answer the same question, so they read the same configured
89
+ // in-degree rather than one of them silently using the default.
90
+ return successResult({
91
+ summary: formatContextGraphSummary(graph, {
92
+ hubMinInDegree: config.compile?.hubMinInDegree,
93
+ }),
94
+ structured,
95
+ });
96
+ }
97
+ catch (error) {
98
+ return errorResult(error, {
99
+ successFields: EMPTY_CONTEXT_GRAPH_OUTPUT,
100
+ cwd,
101
+ });
102
+ }
103
+ }
104
+ export function registerContextGraphTool(server) {
105
+ server.registerTool("context-graph", {
106
+ title: "Build the context graph",
107
+ description: 'Build the project\'s context graph. `format: "raw"` (default) returns the graph verbatim ' +
108
+ '(nodes, edges, cycles); `format: "summary"` returns nodes, edges, connected components, ' +
109
+ "topological reading order, the nodes a cycle excluded from that order, and the coverage " +
110
+ "signal (node/edge counts plus Markdown files linked-to but outside the corpus) — the same " +
111
+ "document the CLI's `graph --format json` prints. Read-only.",
112
+ inputSchema: contextGraphInputShape,
113
+ outputSchema: withErrorOutput(contextGraphOutputShape),
114
+ annotations: READ_ONLY_ANNOTATIONS,
115
+ }, (input) => handleContextGraph(input));
116
+ }
@@ -0,0 +1,10 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import { type ToolFileInput } from "../shared/tool-context.js";
4
+ type ContextSliceToolInput = ToolFileInput & {
5
+ query: string;
6
+ depth?: number;
7
+ };
8
+ export declare function handleContextSlice(input: ContextSliceToolInput): Promise<CallToolResult>;
9
+ export declare function registerContextSliceTool(server: McpServer): void;
10
+ export {};
@@ -0,0 +1,70 @@
1
+ import { getContextSlice, renderContextSliceSummary, SLICE_RESOLUTION_DESCRIPTION, } from "@wastech-mdlint/core";
2
+ import { z } from "zod";
3
+ import { resolveToolContext, toolCwdBase, } from "../shared/tool-context.js";
4
+ import { errorResult, READ_ONLY_ANNOTATIONS, successResult, withErrorOutput, } from "../shared/tool-response.js";
5
+ const contextSliceInputShape = {
6
+ query: z.string(),
7
+ // `.min(0)` mirrors the CLI's `--depth` parse guard: a negative hop bound is not a meaningful
8
+ // traversal request (it silently degrades to a start-only slice), so it is rejected at input
9
+ // validation rather than accepted and quietly misinterpreted.
10
+ depth: z.number().int().min(0).optional(),
11
+ configPath: z.string().optional(),
12
+ cwd: z.string().optional(),
13
+ };
14
+ // Local mirrors of `SliceMatchKind`/`QueryVisit`, matching `ContextSliceResult` exactly.
15
+ const sliceMatchKindSchema = z.enum(["id", "anchor", "heading", "path"]);
16
+ const queryVisitSchema = z.object({
17
+ path: z.string(),
18
+ depth: z.number().int(),
19
+ via: z.string().nullable(),
20
+ });
21
+ const contextSliceOutputShape = {
22
+ query: z.string(),
23
+ matchKind: sliceMatchKindSchema.nullable(),
24
+ starts: z.array(z.string()),
25
+ files: z.array(z.string()),
26
+ visited: z.array(queryVisitSchema),
27
+ };
28
+ export async function handleContextSlice(input) {
29
+ // Outside the `try`: `resolveToolContext` is itself a throw site, so the catch needs the base
30
+ // independently of whether resolution got far enough to produce one.
31
+ const cwd = toolCwdBase(input);
32
+ try {
33
+ const { graph, documents, settings } = await resolveToolContext(input);
34
+ // `input.depth` is passed straight through even when `undefined`: `getContextSlice`'s own default
35
+ // parameter (`depth = 2`) applies to an explicit `undefined` argument, so no `?? 2` is needed.
36
+ const result = getContextSlice(graph, documents, input.query, input.depth, settings.idRef);
37
+ // An unresolved query is not an error: it returns `matchKind: null` with empty arrays. This is
38
+ // the honest-empty-result contract — do not throw.
39
+ return successResult({
40
+ summary: renderContextSliceSummary(result),
41
+ structured: result,
42
+ });
43
+ }
44
+ catch (error) {
45
+ // Preserve the caller's query on the error path so the payload still satisfies the required
46
+ // success schema fields without inventing a misleading alternate lookup target.
47
+ return errorResult(error, {
48
+ successFields: {
49
+ query: input.query,
50
+ matchKind: null,
51
+ starts: [],
52
+ files: [],
53
+ visited: [],
54
+ },
55
+ cwd,
56
+ });
57
+ }
58
+ }
59
+ export function registerContextSliceTool(server) {
60
+ server.registerTool("context-slice", {
61
+ title: "Compute a context slice",
62
+ // Embeds the exact `SLICE_RESOLUTION_DESCRIPTION` string so the tool advertises the same honest
63
+ // exact-match semantics core promises, instead of drifting into over-promising copy.
64
+ description: "Files reachable within `depth` hops of a resolved query, following graph edges forward. " +
65
+ `${SLICE_RESOLUTION_DESCRIPTION} Read-only.`,
66
+ inputSchema: contextSliceInputShape,
67
+ outputSchema: withErrorOutput(contextSliceOutputShape),
68
+ annotations: READ_ONLY_ANNOTATIONS,
69
+ }, (input) => handleContextSlice(input));
70
+ }
@@ -0,0 +1,9 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import { type ToolFileInput } from "../shared/tool-context.js";
4
+ type ImpactAnalysisToolInput = ToolFileInput & {
5
+ file: string;
6
+ };
7
+ export declare function handleImpactAnalysis(input: ImpactAnalysisToolInput): Promise<CallToolResult>;
8
+ export declare function registerImpactAnalysisTool(server: McpServer): void;
9
+ export {};
@@ -0,0 +1,74 @@
1
+ import { classifyImpact, relativizeImpact, renderImpactSummary, } from "@wastech-mdlint/core";
2
+ import { z } from "zod";
3
+ import { resolveToolContext, toolCwdBase, } from "../shared/tool-context.js";
4
+ import { errorResult, READ_ONLY_ANNOTATIONS, successResult, withErrorOutput, } from "../shared/tool-response.js";
5
+ const impactAnalysisInputShape = {
6
+ file: z.string(),
7
+ configPath: z.string().optional(),
8
+ cwd: z.string().optional(),
9
+ };
10
+ // Local mirrors of `DirectlyAffected`/`TransitivelyAffected`, matching `ImpactClassification`
11
+ // exactly. `via` on a transitive entry is always a real predecessor path (never null) — every
12
+ // depth≥2 visit has one, per impact-analysis.ts's own invariant.
13
+ const directlyAffectedSchema = z.object({
14
+ path: z.string(),
15
+ references: z.number().int(),
16
+ });
17
+ const transitivelyAffectedSchema = z.object({
18
+ path: z.string(),
19
+ depth: z.number().int(),
20
+ via: z.string(),
21
+ });
22
+ const impactAnalysisOutputShape = {
23
+ file: z.string(),
24
+ directlyAffected: z.array(directlyAffectedSchema),
25
+ transitivelyAffected: z.array(transitivelyAffectedSchema),
26
+ readingOrder: z.array(z.string()),
27
+ excluded: z.array(z.string()),
28
+ };
29
+ export async function handleImpactAnalysis(input) {
30
+ // Outside the `try`: `resolveToolContext` is itself a throw site, so the catch needs the base
31
+ // independently of whether resolution got far enough to produce one.
32
+ const cwd = toolCwdBase(input);
33
+ try {
34
+ const { graph } = await resolveToolContext(input);
35
+ // `classifyImpact` throws `ImpactAnalysisError` (code `TARGET_NOT_FOUND`, already in
36
+ // `TOOL_ERROR_CODES`) when `file` is not in the corpus, so `errorResult` passes it through with
37
+ // no translation wrapper — unlike `lint.ts`, whose `RuleResolutionError` codes aren't in the
38
+ // taxonomy.
39
+ const classification = classifyImpact(graph, input.file);
40
+ // Identity transform: this tool's `cwd` is both the corpus root the graph is built from and the
41
+ // base the classification's paths are already relative to, so "repo-relative cwd" is `""`. The
42
+ // call is still made (first real consumer of `relativizeImpact`); it just changes no path here.
43
+ const relativized = relativizeImpact(classification, "");
44
+ return successResult({
45
+ summary: renderImpactSummary(relativized),
46
+ structured: relativized,
47
+ });
48
+ }
49
+ catch (error) {
50
+ // Preserve the requested `file` while zeroing the graph-derived lists so the error remains
51
+ // machine-parseable under the same required schema a successful impact result uses.
52
+ return errorResult(error, {
53
+ successFields: {
54
+ file: input.file,
55
+ directlyAffected: [],
56
+ transitivelyAffected: [],
57
+ readingOrder: [],
58
+ excluded: [],
59
+ },
60
+ cwd,
61
+ });
62
+ }
63
+ }
64
+ export function registerImpactAnalysisTool(server) {
65
+ server.registerTool("impact-analysis", {
66
+ title: "Analyze change impact",
67
+ description: "Compute the blast radius of changing a Markdown file: files that reference it directly, " +
68
+ "files affected transitively, and the reading order over the affected subgraph. A file not " +
69
+ "in the corpus returns an actionable error. Read-only.",
70
+ inputSchema: impactAnalysisInputShape,
71
+ outputSchema: withErrorOutput(impactAnalysisOutputShape),
72
+ annotations: READ_ONLY_ANNOTATIONS,
73
+ }, (input) => handleImpactAnalysis(input));
74
+ }
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerTools(server: McpServer): void;
@@ -0,0 +1,27 @@
1
+ import { registerCompileContextTool } from "./compile-context.js";
2
+ import { registerContextGraphTool } from "./context-graph.js";
3
+ import { registerContextSliceTool } from "./context-slice.js";
4
+ import { registerImpactAnalysisTool } from "./impact-analysis.js";
5
+ import { registerLintFilesTool } from "./lint-files.js";
6
+ import { registerLintTool } from "./lint.js";
7
+ // Modular tool layout: the single registration seam. Each tool is its own
8
+ // module and appends its registrar here — one module per tool, registered from this
9
+ // index, so no single mega-file.
10
+ //
11
+ // The list stays function-only (not `{ name, register }[]`): a parallel name list would be a second
12
+ // hand-maintained source of truth that could drift from the real registerTool() calls — exactly the
13
+ // "5 vs 6 tools" mismatch the generated inventory exists to prevent. Doc generation introspects the
14
+ // live McpServer instance instead of reading a name array here.
15
+ const TOOL_REGISTRARS = [
16
+ registerLintTool,
17
+ registerLintFilesTool,
18
+ registerContextGraphTool,
19
+ registerContextSliceTool,
20
+ registerImpactAnalysisTool,
21
+ registerCompileContextTool,
22
+ ];
23
+ export function registerTools(server) {
24
+ for (const register of TOOL_REGISTRARS) {
25
+ register(server);
26
+ }
27
+ }
@@ -0,0 +1,9 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import { type ToolFileInput } from "../shared/tool-context.js";
4
+ type LintFilesToolInput = ToolFileInput & {
5
+ patterns?: string[];
6
+ };
7
+ export declare function handleLintFiles(input: LintFilesToolInput): Promise<CallToolResult>;
8
+ export declare function registerLintFilesTool(server: McpServer): void;
9
+ export {};
@@ -0,0 +1,65 @@
1
+ import { formatLintResultText, lintFiles, } from "@wastech-mdlint/core";
2
+ import { z } from "zod";
3
+ import { lintMessageSchema } from "../shared/lint-message-schema.js";
4
+ import { resolveToolConfiguration, toolCwdBase, } from "../shared/tool-context.js";
5
+ import { errorResult, READ_ONLY_ANNOTATIONS, successResult, withErrorOutput, } from "../shared/tool-response.js";
6
+ const lintFilesInputShape = {
7
+ patterns: z.array(z.string()).optional(),
8
+ configPath: z.string().optional(),
9
+ cwd: z.string().optional(),
10
+ };
11
+ // Mirrors `LintResult` directly — field names already match, so `structured: result` needs no
12
+ // reshaping.
13
+ const lintFilesOutputShape = {
14
+ messages: z.array(lintMessageSchema),
15
+ files: z.array(z.string()),
16
+ errorCount: z.number().int(),
17
+ warningCount: z.number().int(),
18
+ };
19
+ // Match the required `LintResult` fields on the error path so schema-validating MCP clients accept
20
+ // the structured error payload instead of rejecting the response before the caller sees the code.
21
+ const EMPTY_LINT_FILES_OUTPUT = {
22
+ messages: [],
23
+ files: [],
24
+ errorCount: 0,
25
+ warningCount: 0,
26
+ };
27
+ export async function handleLintFiles(input) {
28
+ // Outside the `try` so the catch can still name it: an errno thrown *by* `resolveToolConfiguration`
29
+ // (an unreadable config, a `configPath` naming a directory) has no `loaded.cwd` to render against.
30
+ const cwd = toolCwdBase(input);
31
+ try {
32
+ const loaded = await resolveToolConfiguration(input);
33
+ // An explicit `patterns` arg *replaces* `config.include` (not merges). When it's absent we leave
34
+ // `config.include` untouched so core's own defaults apply — `resolveCorpusScope`
35
+ // (`config/corpus-scope.ts`) supplies both `DEFAULT_INCLUDE_GLOBS` and the default `exclude`.
36
+ // That "what is the corpus when the config is silent" decision stays core's job, not
37
+ // reimplemented here — which also means an explicit `patterns` naming a path under a
38
+ // default-excluded tree still resolves to nothing.
39
+ const config = input.patterns === undefined
40
+ ? loaded.config
41
+ : { ...loaded.config, include: input.patterns };
42
+ const result = await lintFiles({
43
+ cwd: loaded.cwd,
44
+ config,
45
+ rules: loaded.rules,
46
+ settings: loaded.settings,
47
+ });
48
+ return successResult({
49
+ summary: formatLintResultText(result),
50
+ structured: result,
51
+ });
52
+ }
53
+ catch (error) {
54
+ return errorResult(error, { successFields: EMPTY_LINT_FILES_OUTPUT, cwd });
55
+ }
56
+ }
57
+ export function registerLintFilesTool(server) {
58
+ server.registerTool("lint-files", {
59
+ title: "Lint project files",
60
+ description: "Lint the project's Markdown files using the resolved config (or the zero-config `**/*.md` default). Read-only.",
61
+ inputSchema: lintFilesInputShape,
62
+ outputSchema: withErrorOutput(lintFilesOutputShape),
63
+ annotations: READ_ONLY_ANNOTATIONS,
64
+ }, (input) => handleLintFiles(input));
65
+ }
@@ -0,0 +1,11 @@
1
+ import { type CustomRuleConfigEntry, type RuleConfigEntry } from "@wastech-mdlint/core";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
4
+ type LintRuleRequest = RuleConfigEntry | CustomRuleConfigEntry;
5
+ type LintToolInput = {
6
+ content: string;
7
+ rules: LintRuleRequest[];
8
+ };
9
+ export declare function handleLint(input: LintToolInput): CallToolResult;
10
+ export declare function registerLintTool(server: McpServer): void;
11
+ export {};