Case Study · Architecture

Service-Graph MCP Tool — Giving AI Agents a Map of a Microservice Estate

An MCP server that turns a wiki-style documentation repo into a queryable dependency graph AI agents traverse natively — so coding sessions are grounded in real service topology instead of hallucinated architecture.

Private project
Status
ARCHITECT
Year
2026
Role
Solo build
Stack
Node.jsTypeScriptMCP
02

Problem

Large microservice estates have a knowledge problem: no single engineer — and no AI coding assistant — holds the full picture of service dependencies. When asked "what breaks if we change this API?", the answer lives in scattered wikis and tribal knowledge.

The cost is paid on every change. Engineers reconstruct the dependency picture by hand, cross-referencing docs that drifted from reality months ago and pinging the few people who still remember how the pieces fit together. The blast radius of a change is rarely visible before the change ships.

AI assistants make this worse. Without structured context, they suggest changes with hidden blast radius — confidently editing an endpoint without knowing which downstream services consume it, or proposing a refactor that silently breaks a contract three hops away.

The missing piece is not more documentation. It is documentation an agent can traverse — a machine-readable map of the estate that answers dependency questions structurally rather than by reading prose.

03

Solution

A service-graph MCP server that turns a wiki-style documentation repo into a queryable dependency graph AI agents traverse natively.

Each service doc declares its dependencies, consumers, owned data, and contracts in typed YAML frontmatter — a validated schema that acts as the source of truth. The documentation is not a description of the graph; the documentation is the graph. A build step assembles the frontmatter across every doc into a single connected dependency graph.

That graph is exposed to AI agents over the Model Context Protocol. During a coding or planning session, an agent calls graph tools — get_service, trace_dependencies, impact_analysis — to answer topology questions the way it would call any other tool. Retrieval is structural: the agent walks edges rather than reading paragraphs.

A CI validation gate keeps the graph honest. A validator in the pipeline fails builds on malformed frontmatter, unknown service references, or broken edges, so the map cannot silently drift from the estate it describes.

The graph isn't locked to one tool — the same server plugs into Claude Code, IDE agents, or any MCP client.
04

Architecture Diagram

The pipeline runs from documentation to a grounded agent answer. Service docs carry typed frontmatter; a parser lifts that frontmatter into nodes and edges; a graph builder assembles the estate-wide dependency graph; the MCP server exposes traversal tools over it; and AI agents call those tools during their sessions.

A CI validator gates the whole pipeline — nothing enters the graph until its frontmatter is well-formed and every referenced service resolves.

Service-Graph MCP Tool — System Architecture01Wiki Docs (YAML frontmatter)01 — Wiki Docs (YAML frontmatter)02CI Validation Gate02 — CI Validation Gate03Frontmatter Parser03 — Frontmatter Parser04Service Dependency Graph04 — Service Dependency Graph05MCP Server05 — MCP Server06AI Agents06 — AI Agents
Documentation flows through a CI validation gate and a frontmatter parser into a dependency graph, which the MCP server exposes to AI agents as traversal tools.

The Frontmatter Parser is the entry point into the graph. It reads each service doc, extracts the typed frontmatter block — dependencies, consumers, owned data, contracts — and emits nodes and edges. It interprets schema, not prose: the body of the doc is for humans; the frontmatter is for the graph.

The Graph Builder assembles the parsed frontmatter across every doc into one connected estate. A dependency declared in one service resolves to the node for another; consumers are the inverse edges. The result is a single graph where every service knows both what it depends on and what depends on it.

The MCP Server sits between the graph and the agents. It exposes get_service, trace_dependencies, and impact_analysis as Model Context Protocol tools, so any MCP client can query the estate without embedding a copy of the topology in its prompt.

05

Service Graph Model

The Service acts as the root entity within the graph.

Every service doc declares, in typed frontmatter, the facts that connect it to the rest of the estate.

The graph currently models:

  • Dependencies
  • Consumers
  • Owned Data
  • Contracts
  • APIs
  • Owner Team
  • Runtime
  • Documentation
Service Entity Model00Service00 — Service01Dependency01 — Dependency02Consumer02 — Consumer03Owned Data03 — Owned Data04Contract04 — Contract05API05 — API06Owner Team06 — Owner Team07Runtime07 — Runtime08Documentation08 — Documentation
The Service is the root entity; each satellite is a typed frontmatter field that connects it to the rest of the estate.

These facts are declared in the doc's frontmatter and validated against a schema, so the graph is only ever as stale as the last merged pull request.

Relationships provide the real value. Instead of simply knowing that a service exists, the graph captures what it depends on, who consumes it, what data it owns, and which contracts it must honor.

Because dependencies and consumers are inverse edges of the same relationship, the graph answers questions in both directions — upstream ("what does this call?") and downstream ("what calls this?") — from a single declaration.

06

Impact Analysis Flow

The signature query the tool answers is "what breaks if we change this?".

A change target enters as a service or contract. The server looks it up, then walks the graph breadth-first along consumer edges to collect every service that transitively depends on it.

Breadth-first traversal orders the result by distance, so the immediate blast radius is distinguishable from the second- and third-order effects.

BFS Impact Tracing01Change Target01 — Change Target02get_service02 — get_service03BFS Traversal03 — BFS Traversal04Consumer Edges04 — Consumer Edges05Rank by Distance05 — Rank by Distance06Blast Radius06 — Blast Radius
impact_analysis walks the graph breadth-first along consumer edges, ordering the downstream blast radius by distance from the change target.

The traversal expands outward one hop at a time. From the change target, it follows consumer edges to the services that call it directly, then follows their consumer edges in turn, until the frontier is exhausted.

For example, a change to a payments contract may surface the checkout service that consumes it directly, the order-history service that consumes checkout, and the analytics pipeline that reads both — each tagged with its distance from the change.

The result is a ranked blast radius rather than a flat list: the services one hop away need coordinated changes now; the services three hops away need a heads-up. What used to take a cross-team Slack thread answers in seconds.

07

MCP Tool Workflow

The agent layer is any MCP client. Rather than embedding topology in a prompt, the agent calls graph tools during its session and reasons over the structured results.

The MCP server exposes three tools, each backed by the same dependency graph.

MCP Tool Orchestration01AI Agent01 — AI Agent02MCP Server02 — MCP Server03get_service03 — get_service04trace_dependencies04 — trace_dependencies05impact_analysis05 — impact_analysis06Service Graph06 — Service Graph07Grounded Answer07 — Grounded Answer
The agent calls get_service, trace_dependencies, or impact_analysis over MCP; each resolves against the shared graph and returns structured topology the agent reasons over.

get_service returns a single service's declared facts — its dependencies, consumers, owned data, and contracts — as the agent's entry point into the estate.

trace_dependencies walks the upstream chain, returning everything a service transitively relies on, so an agent planning a change can see the full set of systems it must reason about.

impact_analysis walks the downstream chain, returning the blast radius. Because all three tools share one graph, an agent can chain them in a single session — look up a service, trace what it needs, then assess what a change would break — and produce recommendations grounded in real topology.

08

Technology Decisions

The platform makes a small number of decisions that together keep the graph trustworthy and portable. Each has a real alternative and a real tradeoff.

DecisionChoiceRationale
Source of truthTyped YAML frontmatter in service docsA separate graph database drifts from the docs engineers actually read. Putting the schema in the doc's frontmatter makes documentation and graph the same artifact — updated in the same pull request.
Agent interfaceModel Context Protocol (MCP)A bespoke API locks the graph to one tool. MCP exposes traversal as standard tools, so the same server plugs into Claude Code, IDE agents, or any MCP client without re-integration.
Impact traversalBreadth-first search over consumer edgesBFS orders the blast radius by distance from the change, distinguishing immediate consumers from second- and third-order effects — the information an engineer needs to sequence a change.
Freshness enforcementCI validation gateDocumentation rots without enforcement. Failing builds on malformed frontmatter, unknown references, or broken edges makes the graph impossible to silently break.
RuntimeNode.js + TypeScriptFirst-class MCP tooling, a typed schema for the frontmatter contract, and a low-friction fit with the CI and editor environments where agents already run.

These decisions share one purpose: keep the map close to the territory. The graph lives with the docs, is enforced by CI, and is reachable by any agent — so the topology an assistant reasons over is the topology the estate actually has.

09

Capabilities

The tool is built around four capabilities that together turn a documentation repo into a live map of the estate.

Typed YAML frontmatter as source of truth

Each service doc declares dependencies, consumers, owned data, and contracts in a validated schema. Documentation is the graph — there is no second system to keep in sync.

Graph traversal tools over MCP

Agents call get_service, trace_dependencies, and impact_analysis during coding and planning sessions, querying topology as native tool calls rather than parsing prose.

BFS impact tracing

The server walks the graph breadth-first to answer "what is the downstream blast radius of this change?", ordering affected services by distance from the change target.

CI validation gate

A validator in the pipeline fails builds on malformed frontmatter, unknown service references, or broken edges. The graph can't silently rot.

10

Outcomes

The tool changes how both engineers and agents reason about the estate.

AI sessions grounded in real topology

Coding assistants reason over the estate's actual dependency graph instead of hallucinated architecture. Change suggestions account for real consumers and contracts rather than guessing at them.

Impact analysis in seconds

Impact analysis that took cross-team Slack threads now answers in seconds. An engineer — or an agent — asks what breaks, and the blast radius comes back ranked by distance.

Documentation freshness enforced by CI

Because the graph is validated in the pipeline, documentation freshness is enforced by CI rather than by goodwill. The map stays aligned with the estate it describes.

Have a product that needs AI features?

Work with me →