analyze_link_graph
Visualize document connections in markdown projects to understand relationships and validate links using graph formats like mermaid, JSON, or DOT.
Instructions
Visualize connections between documents
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "analyze_link_graph"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | No | Path to manuscript directory (defaults to current directory) | |
| scope | No | File scope pattern | |
| format | No | Output format | mermaid |
Implementation Reference
- src/tools/WriterToolHandlers.ts:193-208 (handler)Core implementation of the analyze_link_graph tool. Parses arguments, calls writersAid.checkLinks to get links, and returns a Mermaid graph or JSON based on format.
private async analyzeLinkGraph(args: Record<string, unknown>) { const format = (args.format as string) || "mermaid"; const scope = args.scope as string | undefined; const limit = resolvePaginationLimit("analyze_link_graph", args.limit as number | undefined); const links = await this.writersAid.checkLinks({ scope, limit }); if (format === "mermaid") { return { format: "mermaid", graph: "graph TD\n A[Chapter 1] --> B[Chapter 2]\n B --> C[Chapter 3]", }; } return { links, format }; } - src/tools/WriterToolHandlers.ts:36-37 (registration)Tool registration in the handleTool switch statement that dispatches to the analyzeLinkGraph handler.
case "analyze_link_graph": return this.analyzeLinkGraph(args); - MCP tool schema definition including input parameters (project_path, scope, format) for the analyze_link_graph tool.
{ name: "analyze_link_graph", description: "Visualize connections between documents", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to manuscript directory (defaults to current directory)" }, scope: { type: "string", description: "File scope pattern" }, format: { type: "string", enum: ["mermaid", "json", "dot"], description: "Output format", default: "mermaid", }, }, }, }, - src/markdown/types.ts:360-369 (schema)TypeScript interface defining the response structure for the analyze_link_graph tool.
/** * Response from analyze_link_graph tool */ export interface AnalyzeLinkGraphResponse { graph: LinkGraph; orphaned_files: string[]; broken_links: MarkdownLink[]; format: 'json' | 'mermaid' | 'dot'; visualization?: string; }