Documentation
¶
Overview ¶
Package mcpserver exposes a matlatl analysis as a read-only MCP server over streamable HTTP, for an agent to query a markdown corpus' link graph. It is the ONLY package that imports the MCP library (github.com/mark3labs/mcp-go, ADR 0002): the dependency is quarantined here so the core tool never depends on MCP and a build that does not invoke `serve` pays nothing for it at runtime (the import is reachable only from `matlatl serve`).
The server runs the matlatl pipeline ONCE over the path at construction time to build the frozen analysis (corpus, graph, metrics), then serves seven read-only tools that return the SAME structured data as the file artifacts by reusing the emit.View + emit/graphjson layers — nothing is reinvented:
- what-links-to(doc) inbound references / backlinks for a document
- list-orphans isolated + unreachable docs (intentional orphans suppressed, per ADR 0007)
- path-between(a,b) a navigational path a→b over the document projection
- get-section(doc#slug) section info (level, title, doc) for an anchor
- corpus-summary the graph.json manifest (nodes/edges/components/HITS/…)
- suggest-links([doc]) topology-based suggested links (ADR 0013): unlinked but structurally-close pairs, doc-scoped or global top-N
- critical-docs critical-path structure (ADR 0015): top load-bearing docs by betweenness centrality + articulation points + bridges
Inputs are DocumentIDs; every tool validates them against the corpus and never reads outside the scan root (the pipeline already enforces root containment; the tools only read the in-memory frozen model).
Index ¶
Constants ¶
const ( // EndpointPath is the HTTP path the streamable-HTTP MCP endpoint is served // on. It matches mcp-go's default and the convention MCP clients expect. EndpointPath = "/mcp" )
Variables ¶
This section is empty.
Functions ¶
func NewServer ¶
NewServer builds the MCP server with the read-only tools registered against the given analysis. It does not start any transport; call Serve (or wrap it in a server.StreamableHTTPServer) to run it.
Types ¶
type Analysis ¶
type Analysis struct {
// contains filtered or unexported fields
}
Analysis is the frozen, read-only snapshot the tools query. It is built once (BuildAnalysis) and never mutated, so the tool handlers are safe for concurrent calls.
func BuildAnalysis ¶
BuildAnalysis runs the matlatl pipeline over rootPath and returns the frozen analysis the MCP tools serve. It uses the production scanner + parser factory; external link checking is OFF (the MCP surface is read-only and deterministic).
func (*Analysis) Tools ¶
func (a *Analysis) Tools() []server.ServerTool
Tools returns the read-only tool set bound to this analysis. Exposed so tests can invoke handlers in-process without a live client or transport.