← All work

Case study · VistaPrint · AI tooling

SWAN MCP server

An MCP server that gives AI coding agents SWAN docs, tokens, icons and deprecations, measured by an eval suite on every change.

The problem

AI coding agents write good React, but they don’t know a company’s design system. Left alone, they invent props, hard-code colours and reach for components that were deprecated a year ago.

SWAN’s MCP server was meant to fix that by giving agents SWAN’s documentation, tokens, icons and deprecations as tools. But it began as a vibe-coded prototype, written quickly with an AI assistant to prove the idea. It demoed well, and it lagged in real use.

Where it fell short

When we measured it properly, it passed 29% of our evaluations; another 36% were only partial passes. A deep dive into how it actually found and returned content showed why:

  • It silently dropped content. It turned the docs site’s raw page data into text by hand, and only understood some kinds of content block. Do/Don’t cards and some grid content came back empty, with no error.
  • It was fragile. That conversion depended on the exact shape of the docs CMS, so an ordinary change to the docs could quietly remove content from answers.
  • It missed pages and links. Some page types, such as the changelog and versions pages, weren’t in the search index, and links between pages were followed only on component pages.
  • It went stale. Prop and token data came from whichever SWAN version the server was deployed with, so it drifted after every release.
  • Agents didn’t know when to use it. Tool descriptions were vague and overlapped, and there were no server instructions, so models often picked the wrong tool or none at all.
  • Nothing measured it. There was no eval suite, so no change could be shown to help or hurt.

How I fixed it

I led the rework in three phases, ordered so the big change happened once and nothing had to be redone.

  1. Better source content and a way to measure. Instead of reverse-engineering page data, the docs site now generates a clean Markdown file for every page at build time, published to S3. It captures what the old data never had and doesn’t break when the CMS changes. In parallel I set up the eval suite with Promptfoo: tool-selection evals check that a model picks the right tool for a realistic prompt, and end-to-end evals check that the final answer is accurate, grounded in SWAN’s docs and free of invented components or props.
  2. One source, rebuilt tools. Every tool moved to the Markdown content, and each tool description was rewritten. New server instructions tell agents to use SWAN components and tokens instead of one-off styles, avoid deprecated APIs, and say so when they’re stuck rather than guess.
  3. Hardening. Rate limiting, tiered caching, the remaining tool-level fixes, and documentation, ready for a stable release.

The evals run on every merge request and block it if the pass rate drops, so a change to a tool description can’t quietly make agents worse.

One rule kept the work honest: AI answers are never fully deterministic. When an eval failed, we fixed a clear root cause. When it came down to guessing, we didn’t, because a fix built on a guess tends to cause the next regression.

Impact

The eval pass rate rose from 29% to about 90% across 60+ evals, well past the 85% bar, and the blocking evals keep it there on every merge request.