brandsystem-mcp
AGENTS.md14 starsChanged 5 months agoMITView on GitHub
MCP server that extracts and manages brand identity (logo, colors, typography, voice, visual rules) for AI tools. Creates a .brand/ directory with structured YAML, DTCG tokens, and portable HTML reports. Build must pass before committing. The entry point is src/index.ts (stdio transport) which creates the server from src/server.ts. main is protected by a ruleset (main-protection): no direct pushes, no force-pushes, PR required, and the CI matrix (build-and-test (20/22/24)) must pass before merge. Zero human approvals are required — CI is…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 22
Create a branch (feat/..., fix/...) and commit there
- Distinctive: line 27
Do not attempt to push directly to main.
- Very specific: line 59
All tools return responses via buildResponse() from src/lib/response.ts:
- Very specific: line 89
Create src/tools/brand-<name>.ts with this structure:
- Very specific: line 116
Import and register in src/server.ts in the appropriate section.
- Distinctive: line 118
Run the Architecture Alignment Checklist (below) before committing.
- Distinctive: line 122
WHEN to use it (trigger words/conditions)
- Very specific: line 125
Every Zod parameter must have .describe() with examples where helpful.
- Distinctive: line 130
Start with a verb: "Extract...", "Generate...", "Check...", "Define..."
- Distinctive: line 137
Run this checklist when adding a new tool, changing tool behavior, or making architecture changes that affect what the MCP produces or how …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
brandsystem-mcp
MCP server that extracts and manages brand identity (logo, colors, typography, voice, visual rules) for AI tools. Creates a .brand/ directory with structured YAML, DTCG tokens, and portable HTML reports.
Build and Test
npm install # Install dependencies
npm run build # Compile TypeScript to dist/
npm test # Run vitest tests
npm run lint # Type-check without emitting (tsc --noEmit)
npm run dev # Watch mode for development
npm start # Start the server (stdio transport)Build must pass before committing. The entry point is src/index.ts (stdio transport) which creates the server from src/server.ts.
Branch and PR Workflow
main is protected by a ruleset (main-protection): no direct pushes, no force-pushes, PR required, and the CI matrix (build-and-test (20/22/24)) must pass before merge. Zero human approvals are required — CI is the gate. To land changes:
- Create a branch (
feat/...,fix/...) and commit there - Push and open a PR against
main - Enable auto-merge:
gh pr merge --auto --squash— the PR lands when CI is green - The branch is deleted automatically on merge
Do not attempt to push directly to main; the ruleset rejects it.
Architecture
src/
index.ts # Stdio transport entry point
server.ts # Creates McpServer, registers all 43 tools in priority order
tools/ # One file per tool, mostly (41 files, 43 tools — brand-feedback.ts registers 3). Each exports a register(server) function.
# Counts drift; verify via `ls src/tools/*.ts | wc -l` and `grep -rc 'server\.tool(' src/tools/*.ts`
lib/ # Shared utilities (brand-dir, css-parser, dtcg-compiler, content-scorer, etc.)
types/ # TypeScript type definitions
schemas/ # Zod schemas for validation
bin/
brandsystem-mcp.mjs # CLI entry point (npx @brandsystem/mcp)Tool Registration Order (in server.ts)
Tools are registered in the order agents see them. Entry points first:
brand_start-- always first (entry point for new brands)brand_status-- always second ("what can I do?" / resume point)- Session 1 tools (extract, compile, clarify, audit, report)
- Session 2 tools (deepen identity, ingest assets, preflight)
- Session 3 tools (extract messaging, compile messaging)
- Session 4 tools (personas, journey, themes, matrix)
- Content scoring tools (audit-content, check-compliance, audit-drift)
- Runtime (brand_runtime -- read compiled runtime contract)
- Cross-session utilities (write, export, feedback)
Response Format
All tools return responses via buildResponse() from src/lib/response.ts:
{
what_happened: string, // One-line summary of what the tool did
next_steps: string[], // What the agent should do next
data: Record<string, unknown> // Structured output data
}Many tools include a conversation_guide in the data to help agents present results well.
Key Libraries
src/lib/brand-dir.ts-- All.brand/directory I/O (read/write YAML, JSON, markdown, assets)src/lib/css-parser.ts-- CSS color and font extraction from raw CSS textsrc/lib/dtcg-compiler.ts-- Compile CoreIdentity into DTCG-format tokens.jsonsrc/lib/design-synthesis.ts-- Generate design-synthesis.json + DESIGN.md from evidence/current brand statesrc/lib/confidence.ts-- Confidence scoring, source precedence, merge logicsrc/lib/logo-extractor.ts-- Logo candidate detection from HTMLsrc/lib/svg-resolver.ts-- SVG sanitization, inlining, base64 encodingsrc/lib/report-html.ts-- HTML report generationsrc/lib/vim-generator.ts-- Visual Identity Manifest markdown generationsrc/lib/runtime-compiler.ts-- Compile brand-runtime.json from 4 source YAMLssrc/lib/interaction-policy-compiler.ts-- Compile interaction-policy.json (enforceable rules)src/lib/content-scorer.ts-- Brand compliance scoring enginesrc/lib/color-namer.ts-- Human-readable color name generationsrc/lib/response.ts-- Structured MCP response builder
How to Add a New Tool
- Create
src/tools/brand-<name>.tswith this structure:import { z } from "zod"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { BrandDir } from "../lib/brand-dir.js"; import { buildResponse } from "../lib/response.js"; const paramsShape = { // Zod schemas with .describe() on EVERY parameter }; async function handler(input: Params) { const brandDir = new BrandDir(process.cwd()); // ... tool logic ... return buildResponse({ what_happened, next_steps, data }); } export function register(server: McpServer) { server.tool( "brand_<name>", "Description: WHAT it does, WHEN to use it, what it RETURNS.", paramsShape, async (args) => handler(args as Params) ); } - Import and register in
src/server.tsin the appropriate section. - Run the Architecture Alignment Checklist (below) before committing.
- Tool description must include:
- WHAT the tool does (one sentence)
- WHEN to use it (trigger words/conditions)
- What it RETURNS (output format hint)
- Every Zod parameter must have
.describe()with examples where helpful.
Tool Description Guidelines
Tool descriptions are the #1 thing agents read to decide whether to call a tool. Every description should:
- Start with a verb: "Extract...", "Generate...", "Check...", "Define..."
- Include trigger phrases (what the user might say that should invoke this tool)
- End with what the tool returns
- Be under 300 characters for the first sentence (some clients truncate)
Architecture Alignment Checklist
Run this checklist when adding a new tool, changing tool behavior, or making architecture changes that affect what the MCP produces or how users interact with it.
Current Architecture (as of v0.3.2)
The MCP has three operating lanes:
- Local self-contained — extract from website/Figma, compile to
.brand/directory - Brandcode Studio connector — connect/sync/status with hosted brands
- Content enforcement — score, compliance gate, preflight, drift detection
Session 1 outputs: brand.config.yaml, core-identity.yaml, extraction-evidence.json (optional), design-synthesis.json, DESIGN.md, tokens.json, brand-runtime.json, interaction-policy.json, needs-clarification.yaml, brand-report.html
MCP resources: brand://runtime and brand://policy (subscribable)
The canonical field for the brand name is client_name (not brand_name).
When adding a new tool
- Description starts with a verb and includes trigger phrases
- Description mentions what it returns
- Description includes NOT-for disambiguation if it overlaps with existing tools
- If the tool produces compiled output, it delegates to the canonical compiler (runtime-compiler.ts, interaction-policy-compiler.ts, dtcg-compiler.ts) rather than reimplementing
- If the tool has a
what_happenedmessage, it accurately describes what was written - If the tool has
next_steps, they reference the current architecture (including connector path when relevant) - If the tool has
conversation_guide, it mentions runtime/policy artifacts and the Brandcode Studio option where appropriate - Tool is registered in
src/server.tsin the correct section - Tool is listed in
brand_statusgetting-started guide - Tool is covered by at least one smoke test in
test/tools/smoke.test.ts
When changing compiled output format
brand_startauto mode produces the same artifacts asbrand_compile, includingdesign-synthesis.jsonandDESIGN.mdbrand_statussession descriptions match actual outputsbrand_auditchecks for new output filesllms.txtKey Capabilities section is updatedREADME.md.brand/ directory listing is updatedCHANGELOG.mddocuments the change- MCP resources (brand-resources.ts) serve the new format if applicable
- Integration tests verify the new output
When changing the connector
brand_statusconnector section reflects the changebrand_startconversation_guide mentions the updated connector flowbrand_brandcode_connect,brand_brandcode_sync,brand_brandcode_statusdescriptions are consistentllms.txtconnector capability line is current- Connector types in
src/connectors/brandcode/types.tsmatch the API contract
Common drift patterns to watch for
- Duplicated compile logic — any tool that reimplements token/runtime/policy generation instead of calling the canonical compiler
- Stale Session 1 description — "Produces tokens.json and brand-report.html" should be "Produces design-synthesis.json, DESIGN.md, tokens.json, brand-runtime.json, interaction-policy.json, and brand-report.html"
- Missing connector mention — entry tools (brand_start, brand_status) should mention the connector path as an option
- Field name inconsistency —
client_nameis canonical, notbrand_name - next_steps that skip the current session — after Session 1, tools should mention Session 2 OR Brandcode Studio connector, not just Session 2
Commit Style
Imperative mood, no trailing period, concise. Example: "Add password-protected Engine client microsite"
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

