mcp

v4.30.0
@synergy-design-system/mcp Checked 9 hours ago Published 4 days ago

MCP Server for the Synergy Design System

The @synergy-design-system/mcp package provides a Model Context Protocol (MCP) server for the Synergy Design System. It exposes Synergy components, setup guidance, tokens, styles, templates, icons, and migration content to AI assistants over stdio or http. Data is provided via the low level @synergy-design-system/metadata package. To integrate with VS Code and AI assistants, add this configuration to your settings.json under mcp.servers:

Summary extracted from the README.

@synergy-design-system/mcp

The @synergy-design-system/mcp package provides a Model Context Protocol (MCP) server for the Synergy Design System. It exposes Synergy components, setup guidance, tokens, styles, templates, icons, and migration content to AI assistants over stdio or http.

Data is provided via the low level @synergy-design-system/metadata package.

Features

  • Metadata-backed component docs: Retrieve component data directly from @synergy-design-system/metadata.
  • Setup guidance: Return package setup instructions for components, framework adapters, tokens, styles, fonts, assets, and migrations.
  • Asset and icon discovery: Browse icon sets and search icons across the Synergy asset libraries.
  • Token access: Read CSS, JavaScript, and Sass token outputs.
  • Styles and templates: Retrieve CSS utility guidance and static template content.
  • Migration guidance: Access both DaVinci migration guides and Synergy package migration documents.
  • AI response rules: Optionally prepends package-local guidance files from rules/ to selected tool responses.
  • stdio and HTTP transports: Ready for editor, assistant, CLI, and containerised deployments.

Quick Start

Installation

npm install --save @synergy-design-system/mcp

Running the Server

The package ships a syn-mcp binary:

# Run via stdio (default, for editor integration)
npx @synergy-design-system/mcp

# Or if installed globally
syn-mcp

# Start with an explicit runtime config
syn-mcp --config ./synergy-mcp.json

# Start HTTP server on default port 9119
syn-mcp --interface http

# Start HTTP server on a custom port
syn-mcp --interface http --port 3000

# Listen on all IPv4 interfaces for container/cloud deployment
syn-mcp --interface http --host 0.0.0.0

# Start HTTPS server with TLS certificates
syn-mcp --interface http --tls-key ./server.key --tls-cert ./server.crt

# Enable local tool-call logging to a directory
syn-mcp --log ./logs

# Explicitly disable logging (also disabled when omitted)
syn-mcp --log false

# Emit tool-call logs as JSONL to stdout (HTTP mode only)
syn-mcp --interface http --log-stdout

# Use both providers simultaneously
syn-mcp --interface http --log ./logs --log-stdout

# Suppress non-essential startup/status output
syn-mcp --silent

# Enable experimental toon format compression for responses
syn-mcp --compression toon

Available CLI flags:

  • --help, -h: Show usage information
  • --version, -v: Print the package version
  • --config <path>: Load runtime defaults from a synergy-mcp.json file
  • --interface <stdio|http>: Server interface (default: stdio)
  • --port <number>: HTTP server port (default: 9119, only used with --interface http)
  • --host <address>: HTTP bind address (default: 127.0.0.1)
  • --log <value>: Local tool-call log directory path, or false / null to disable
  • --log-stdout: Emit tool-call logs as JSONL to stdout (incompatible with --interface stdio)
  • --silent: Suppress non-essential startup/status output (logo, startup banner, endpoint line)
  • --tls-key <path>: Path to TLS private key file (enables HTTPS)
  • --tls-cert <path>: Path to TLS certificate file (enables HTTPS)
  • --compression <none|toon>: Response compression mode (default: none; experimental)

VS Code Integration

To integrate with VS Code and AI assistants, add this configuration to your settings.json under mcp.servers:

{
  "mcp": {
    "servers": {
      "synergy": {
        "type": "stdio",
        "command": "npx",
        "args": ["@synergy-design-system/mcp"],
      },
    },
  },
}

Claude Desktop Integration

For Claude Desktop, add this to claude_desktop_config.json:

{
  "mcpServers": {
    "synergy": {
      "command": "npx",
      "args": ["@synergy-design-system/mcp"]
    }
  }
}

Configuration

The server can read optional runtime defaults from a synergy-mcp.json file passed via --config.

Server Interface

You can run the server in two modes:

  • stdio (default): Communicate via stdin/stdout with the parent process. This is the recommended mode for editor and CLI integrations.
  • http: Run as an HTTP/HTTPS server listening on a specified port. This enables standalone deployments.

Configuration File

Example:

{
  // Server interface mode: "stdio" (default) or "http"
  "interface": "http",

  // HTTP server port (only used when interface is "http")
  "port": 3000,

  // HTTP bind address.
  // Use 127.0.0.1 for local-only access or 0.0.0.0 for container/cloud deployments.
  "host": "127.0.0.1",

  // TLS configuration (optional, enables HTTPS)
  // Both keyPath and certPath must be provided together
  "tls": {
    "keyPath": "./server.key",
    "certPath": "./server.crt",
  },

  // Include custom ai rules for each tool.
  "includeAiRules": true,

  // Suppress non-essential startup/status output on stdout.
  // Does not affect MCP protocol traffic or configured logging providers.
  "silent": false,

  // Optional logging providers
  "logging": {
    "localFile": {
      // Base folder for logs (YY-MM-DD/SESSION.json)
      // Set to null to disable local file logging
      "path": "./logs",
    },
    "stdout": {
      // Emit each tool-call log entry as a JSONL line to stdout.
      // Only supported when interface is "http".
      // Combining this with interface "stdio" is an error (stdout carries the MCP wire protocol).
      "enabled": false,
    },
  },

  // Response compression mode (experimental!)
  // "none" (default): No compression
  // "toon": Encode structured data to compact toon text format
  "compression": "none",

  // Default parameters for each endpoint can be overridden
  "tools": {
    "assetInfo": {
      "iconset": "current",
    },
    "componentInfo": {
      // Set to angular, react or vue, depending on your framework
      "framework": "vanilla",
      // Defines which type of information to return.
      // full = filtered source files,
      // examples = markdown examples,
      // interface = markdown API overview,
      // rules = markdown usage, design, and accessibility guidance.
      // Note that examples and interface are only available
      // for vanilla components at the moment.
      "layer": "full",
    },
    "intentCategoriesList": {
      // Deprecated compatibility tool; prefer intentDiscover.
      "includePhases": ["experimental"],
    },
    "intentDiscover": {
      // Default phases for hierarchical intent discovery
      "includePhases": ["experimental"],
    },
    "intentComponentGuide": {
      // Framework profile used when omitted in tool call
      "framework": "vanilla",
      "includePhases": ["experimental"],
    },
    "intentComponentValidate": {
      "framework": "vanilla",
      "includePhases": ["experimental"],
    },
    "intentOptions": {
      "framework": "vanilla",
      "includeDiagnostics": false,
      "includePhases": ["experimental"],
      "maxAlternatives": 5,
    },
    "intentTaskRecommendations": {
      "framework": "vanilla",
      "includePhases": ["experimental"],
      "maxAlternatives": 5,
    },
    "tokenInfo": {
      // If you are preferring scss, use "sass" here
      "type": "css",
    },
  },
}

This lets you change per-tool defaults without modifying the MCP server code. Intent tools and resources are enabled by default; see Reference for the full inventory.

CLI Override Precedence

CLI flags take precedence over configuration file values:

# Config file specifies port 3000, but CLI overrides it to 8080
syn-mcp --config ./synergy-mcp.json --port 8080

# Config file specifies a local-only bind, but CLI overrides it for deployment
syn-mcp --config ./synergy-mcp.json --host 0.0.0.0

# Config enables logging, but CLI disables it for this run
syn-mcp --config ./synergy-mcp.json --log false

# Config shows startup banner, but CLI suppresses it for this run
syn-mcp --config ./synergy-mcp.json --silent

Tool-call logging

Tool-call logging is provider-based. Multiple providers can be active simultaneously. The following providers are available:

Local file provider

Writes one JSONL entry per line to:

  • YY-MM-DD/SESSION.json

Enable via --log <path> or logging.localFile.path in config.

Stdout provider

Emits each tool-call log entry as a JSONL line to stdout. Intended for containerised deployments (Kubernetes, Docker) where log aggregators collect from stdout.

Enable via --log-stdout or logging.stdout.enabled: true in config.

Note: Stdout logging requires interface: http. Enabling it together with interface: stdio is an error — in stdio mode stdout carries the MCP wire protocol and mixing log lines into it would corrupt the stream. The server will log an error to stderr and exit.

Both providers can run at the same time:

syn-mcp --interface http --log ./logs --log-stdout
Log entry fields

Each entry includes:

  • timestamp
  • kind (tool, prompt, resource)
  • name
  • parameters
  • durationMs
  • sessionId (stdio when no session id exists)
  • transport (stdio or http)
  • success and optional errorMessage
  • tokenCount (optional, populated when tiktoken is available)
Optional Token Counting

The MCP server can automatically count output tokens for each tool call when the optional tiktoken dependency is available.

Installation:

Token counting is an optional feature. To enable it, install tiktoken:

npm install tiktoken
# or
pnpm add tiktoken

The MCP package declares tiktoken as both a dev dependency (for build/test) and optional dependency (for runtime). When installed, token counts are automatically computed and logged for every successful tool call.

Behavior:

  • If tiktoken is installed, tokenCount is populated with the output token count for the tool response using the o200k_base encoding.
  • If tiktoken is not available, tokenCount will be omitted from log entries.
  • Token counting failure does not fail the tool call; it only results in tokenCount being absent from the log entry.

Example log entry with tokenCount:

{
  "durationMs": 187.69,
  "kind": "tool",
  "name": "asset-list",
  "parameters": {},
  "sessionId": "stdio",
  "success": true,
  "timestamp": "2026-04-22T09:21:47.533Z",
  "tokenCount": 421,
  "transport": "stdio"
}

Notes:

  • Logging is disabled by default.
  • Use --log <path> or set logging.localFile.path in config to enable local file logging.
  • --log false and --log null explicitly disable local file logging.
  • Use --log-stdout or set logging.stdout.enabled: true to enable stdout logging (HTTP mode only).
  • Use --silent or set silent: true to suppress non-essential startup/status output.
  • Token counting is always optional and non-blocking; the server runs fine without it.

Deployment

HTTP Server Endpoint

When running in HTTP mode, the MCP protocol is served at the /mcp path:

http://127.0.0.1:9119/mcp
https://127.0.0.1:3000/mcp

Non-/mcp paths return HTTP 404.

Metadata cache behavior in HTTP mode

The MCP server reads data via @synergy-design-system/metadata, which now uses a process-local cache for index, entity, and layer file reads. In HTTP mode this reduces repeated filesystem reads across requests and sessions inside the same process.

Operationally, treat metadata as immutable for the process lifetime and roll out updates via restart/redeploy. If you run multiple replicas, each replica maintains its own in-memory cache.

For public or containerized deployments, bind to all interfaces explicitly:

syn-mcp --interface http --host 0.0.0.0

Docker and Kubernetes

The MCP package is container-ready and can be deployed as an HTTP service in Kubernetes.

Container runtime contract

  • Protocol: HTTP
  • Port: 9119 (override with PORT)
  • MCP endpoint: /mcp
  • Default config path: /config/synergy-mcp.json
  • TLS, certificates, ingress, and DNS are handled outside the container (for example via Kubernetes ingress/controllers).

Prebuilt images

Every release publishes the image to the GitHub Container Registry and mirrors it to Docker Hub. Both registries carry a latest tag and an immutable tag matching the npm package version, for example 4.3.0. Pin the version tag for reproducible deployments.

docker pull ghcr.io/synergy-design-system/mcp:latest
docker pull sickdavinci/synergy-mcp:latest

Start it:

docker run --rm -d --name synergy-mcp -p 9119:9119 ghcr.io/synergy-design-system/mcp:latest

The server listens on http://127.0.0.1:9119/mcp. Point an MCP client at it:

{
  "servers": {
    "synergy": {
      "type": "http",
      "url": "http://127.0.0.1:9119/mcp"
    }
  }
}

To change defaults, mount a config file as described in Run with injected config. Stop the container with docker rm -f synergy-mcp.

The published images are linux/amd64. On Apple Silicon they run under emulation, which is fine for local use but slower to start.

Build image from release tarballs

The Docker image uses packed release artifacts for Synergy packages to avoid npm propagation timing issues.

For repeatable local builds, use the helper script in packages/mcp/docker:

./packages/mcp/docker/build-local.sh /path/to/custom/ca.crt synergy-design-system/mcp:local

The script:

  • checks that colima, docker, and pnpm exist
  • validates that the CA file exists
  • installs the CA into Colima
  • restarts Colima and verifies Docker base-image access
  • builds and packs the required Synergy packages
  • builds the MCP Docker image with the CA mounted as a BuildKit secret

If your network does not require a custom CA, you can still build manually.

Manual fallback:

cd packages/mcp

pnpm --dir ../.. --filter @synergy-design-system/assets build
pnpm --dir ../.. --filter @synergy-design-system/metadata build
pnpm --dir ../.. --filter @synergy-design-system/mcp build

# Packs assets, metadata and mcp into packages/mcp/artifacts, then builds the image
pnpm run docker:build

Once the container is running, verify it with a real MCP session:

pnpm run docker:smoke

If your network uses TLS interception (for example a corporate firewall), pass your CA certificate as a BuildKit secret during build:

docker build \
  --progress=plain \
  --secret id=corp_ca,src=/path/to/ca.crt \
  -t synergy-design-system/mcp:local \
  .

The corp_ca file is mounted only for the npm install step and is not persisted in image layers. The release tarballs are bind-mounted for the same step rather than copied, so they do not end up in a layer either.

Image contents

The image installs @synergy-design-system/assets, @synergy-design-system/metadata and @synergy-design-system/mcp globally, then removes assets/src. Those ~9600 raw SVG files are already inlined as strings into assets/dist, which is what create-spritesheet reads, so nothing in the server needs them. Deep imports such as @synergy-design-system/assets/sick2025/<icon>.svg therefore do not resolve inside the container; use the npm package directly if you need the raw files.

Run with injected config

docker run \
  -p 9119:9119 \
  -v "$(pwd)/synergy-mcp.json:/config/synergy-mcp.json:ro" \
  synergy-design-system/mcp:local

The container starts MCP using:

syn-mcp --interface http --host 0.0.0.0 --port 9119 --config /config/synergy-mcp.json

If the config file is not mounted, the server starts with built-in defaults and still listens on HTTP.

Kubernetes config injection

Mount a ConfigMap or Secret at /config so the container can read /config/synergy-mcp.json.

Example mount shape:

volumeMounts:
  - name: mcp-config
    mountPath: /config
    readOnly: true

For production, pin deployments to immutable version tags (for example ghcr.io/synergy-design-system/mcp:4.3.0) instead of latest.

Example deployment patterns:

# Docker / Kubernetes: listen on all interfaces inside the container
syn-mcp --interface http --host 0.0.0.0 --port 3000

# Reverse proxy / load balancer forwards external traffic to the MCP endpoint
# https://mcp.example.com/mcp  ->  http://127.0.0.1:3000/mcp
syn-mcp --interface http --host 127.0.0.1 --port 3000

In general:

  • Use 127.0.0.1 when the server should only be reachable through the local machine or a reverse proxy on the same host.
  • Use 0.0.0.0 when the runtime environment needs the process to accept traffic from outside its own network namespace, such as Docker, Kubernetes, ECS, or EC2.

Available Resources

The MCP server currently registers 6 stable resources by default. Resources expose static, read-only data that does not change during server runtime. Clients that support MCP resources can read them directly without calling a tool. All resources use the application/json MIME type.

1. synergy://components/list

Name: component-list

Title: Synergy component index

Description: Static JSON index of Synergy component tag names. Read directly for discovery; use component-info for API, examples, and rules.

Example:

["syn-button", "syn-checkbox", "syn-dialog", ...]

2. synergy://assets/list

Name: asset-list

Title: Synergy icon set index

Description: Static JSON index of Synergy icon sets with IDs, names, versions, themes, and icon counts. Use asset-info to search icons.

Example:

[
  {
    "iconCount": 512,
    "id": "current",
    "name": "Current",
    "since": "1.0.0",
    "theme": "default"
  }
]

3. synergy://component-clusters/list

Name: component-clusters-list

Title: Synergy component cluster index

Description: Static JSON index of Synergy component clusters with IDs, names, and descriptions. Use component-list to retrieve cluster members.

Example:

[
  {
    "id": "components-by-tag/structure",
    "name": "Structure",
    "description": "Layout and structure components"
  }
]

4. synergy://styles/list

Name: styles-list

Title: Synergy style index

Description: Static JSON index of Synergy CSS utility and style names. Use styles-info for examples and usage.

Example:

["animation", "breakpoints", "spacing", ...]

5. synergy://templates/list

Name: templates-list

Title: Synergy template index

Description: Static JSON index of Synergy template names. Use template-info for example markup and documentation.

Example:

["app-shell", "dashboard", "form", ...]

6. synergy://intent-categories/list

Name: intent-categories-list

Title: Synergy intent category index

Description: Static JSON index of registered Synergy intent categories. Use intent-discover to browse exact intent IDs.

Example:

{
  "data": [
    {
      "description": "User actions and commands",
      "id": "action",
      "phase": "experimental"
    }
  ]
}

Available Tools

The MCP server registers 26 tools by default: 20 core tools and 6 intent policy tools.

Use component-list-examples, template-list-examples, or styles-list-examples with an exact entity name to discover example IDs, titles, and descriptions. Pass a returned exampleId to the corresponding info tool to retrieve only that example. For component-info, explicitly set layer to examples when providing a non-empty exampleId; other layers and omitted layers are rejected. Omitting exampleId or passing an empty string preserves the existing response for the requested layer. IDs may change when the underlying Storybook story is renamed.

Example-list tools return the available entity catalog for an unknown component, style, or template. Info tools also return the available entity catalog when the name is unknown, and include the available example IDs when an exampleId is not found.

Parameter schemas are not duplicated here. Call tools/list against a running server for the authoritative input schema of every tool, including defaults resolved from your runtime config.

1. component-list

Description: List Synergy component tag names, optionally filtered by cluster. Use component-cluster-list to discover cluster IDs and component-info for documentation.

Example prompts:

  • "Show me all available Synergy components"
  • "List all components in the structure cluster"
  • "What components are available in the Synergy Design System?"
  • "List all syn-* components"

2. component-cluster-list

Description: List Synergy component clusters with descriptions and member components. Use returned cluster IDs to filter component-list.

Note: The corresponding MCP resource uses the pluralized name component-clusters-list at URI synergy://component-clusters/list.

Example prompts:

  • "What component clusters are available?"
  • "List all Synergy component clusters"
  • "Show me cluster ids I can use with component-list"

Cluster-first workflow

Use this two-step flow when you want to narrow component discovery to one group:

  1. Call component-cluster-list and pick one cluster id from the result (for example components-by-tag/structure).
  2. Call component-list with cluster set to that id.

Example prompts:

  • "List component clusters, then show me components for components-by-tag/structure."
  • "Give me all components in the components-by-tag/navigation cluster."

3. component-info

Description: Get API, examples, rules, or full documentation for one Synergy component and optional framework. Use an exact component tag returned by component-list.

Example prompts:

  • "How do I use syn-button in React?"
  • "Show me the interface docs for syn-dialog"
  • "Give me examples for syn-card"
  • "Show me the rules for syn-accordion"

If component-info, intent-component-guide, or intent-component-validate receives an unknown component tag, it returns the submitted value, the complete sorted component catalog, and references to component-list and synergy://components/list. The server does not fuzzy-match or silently substitute component names.

4. asset-list

Description: List available Synergy icon set IDs and metadata, grouped by theme. Use returned icon set IDs with asset-info.

Example prompts:

  • "What icon sets are available?"
  • "Show me all available icon libraries"
  • "List all Synergy icon sets"

5. asset-info

Description: Find Synergy icons by icon set and optional name or tag filters. Returns matching icons grouped by category; use asset-list to discover icon set IDs.

Example prompts:

  • "Show me icons with add in the name"
  • "Find icons for close and cancel"
  • "List 10 icons from the current icon set"

6. token-info

Description: Get raw Synergy design token files by format, scope, and optional CSS theme. Use tokens-list to discover supported values and defaults.

Example prompts:

  • "Show me the CSS tokens for sick2025-light"
  • "Give me the JavaScript token output"
  • "Show me the Sass design tokens"

7. tokens-list

Description: List available Synergy token formats, CSS themes, scopes, and defaults. Use supported values with token-info.

Example prompts:

  • "What token formats are available?"
  • "List the supported token themes"
  • "Show me which token outputs this server can provide"

8. styles-list

Description: List available Synergy CSS utility and style names. Use a returned name with styles-info for examples and usage.

Example prompts:

  • "What styles are available in Synergy?"
  • "Show me all available CSS utility classes"
  • "List all style modules"

9. styles-info

Description: Get examples and usage documentation for one Synergy CSS utility. Use an exact style name returned by styles-list.

Example prompts:

  • "Show me information about visually-hidden"
  • "What does the spacing utility package contain?"
  • "Tell me about a specific Synergy style"

Unknown style names return the complete sorted style catalog with references to styles-list and synergy://styles/list.

10. template-list

Description: List available static templates built with Synergy components. Use a returned template name with template-info.

Example prompts:

  • "What templates are available in Synergy?"
  • "Show me all available static templates"
  • "List all templates"

11. template-info

Description: Get example markup and documentation for one static Synergy template. Use an exact template name returned by template-list.

Example prompts:

  • "Show me the form template"
  • "Give me information about the dashboard template"
  • "How do I use the form template?"

Unknown template names return the complete sorted template catalog with references to template-list and synergy://templates/list.

12. davinci-migration-list

Description: List DaVinci components with migration guidance for a selected package. Use a returned component name with davinci-migration-info.

Example prompts:

  • "What DaVinci components can be migrated to Synergy?"
  • "Show me all available DaVinci migration entries"
  • "List components with migration information"

13. davinci-migration-info

Description: Get migration guidance from one DaVinci component to Synergy. Use an exact component name returned by davinci-migration-list.

Example prompts:

  • "How do I migrate from davinci-button to Synergy?"
  • "Show me the migration guide for davinci-input"
  • "What's the Synergy equivalent of davinci-auto-suggest?"

Unknown DaVinci component names return valid migration component names scoped to the selected package. No fuzzy matching or silent substitution is performed.

14. migration-list

Description: List available migration documents for one Synergy package in a compact format. Use a returned filename with migration-info to retrieve only the required guide.

Behavior:

  • For components, this returns a compact index of the migration overview, path guides, and package-level docs.
  • For component path guides, the tool also derives metadata such as from, to, fromTheme, toTheme, title, and a short summary where possible.

Example prompts:

  • "List all Synergy component migration guides"
  • "Show me available migration docs for tokens"
  • "What migration paths exist from Synergy 2 to Synergy 3?"

15. migration-info

Description: Get detailed migration documentation for one Synergy package and optional filename. Use migration-list first and provide a returned filename for focused component guidance.

Behavior:

  • For components with filename, returns exactly that document.
  • For components without filename, returns the overview and high-level package docs, not every path guide.
  • For assets, styles, and tokens, returns the available migration documents for the selected package.
  • Unknown filenames return valid filenames scoped to the selected package and point back to migration-list.

Example prompts:

  • "List the available Synergy component migrations"
  • "Show me the migration guide from Synergy 2 (SICK 2018) to Synergy 3 (SICK 2018)"
  • "Give me the breaking changes for the tokens package"

16. setup

Description: Get installation and initialization guidance for one Synergy package. Framework packages automatically include base component setup; optionally include known limitations.

Example prompts:

  • "How do I set up Synergy for React?"
  • "Show me the setup instructions for tokens"
  • "Give me the Synergy assets setup and limitations"

17. create-spritesheet

Description: Create an SVG sprite sheet from selected Synergy 2025 icons. Use asset-info with the current icon set to discover valid icon names.

Example prompts:

  • "Create a spritesheet containing these icons: star, home, settings"
  • "Generate a custom Synergy 2025 sprite sheet for my selected icons"
  • "Build an SVG sprite sheet from this icon list"

Intent Policy Tools

18. intent-categories-list

Status: Deprecated compatibility tool. It remains available until the next major release.

Description: Do not use for new requests. Use intent-discover instead. Lists registered intent categories only.

Example prompts:

  • "List intent categories"
  • "Show stable intent categories"

19. intent-discover

Description: Discover registered Synergy intent categories and exact intent IDs. Omit category to list categories; provide an exact category ID to list its intents. Use returned IDs verbatim.

Workflow:

  1. Call without category to discover top-level categories.
  2. Call with one returned category ID to list its intents.
  3. Pass an exact returned intent ID to validation, option, or recommendation tools.

When an unknown category is provided, the tool returns the authoritative category IDs without guessing a replacement.

20. intent-component-guide

Description: Get supported intents, recommended usages, and common misuses for one Synergy component. Use an exact component tag returned by component-list.

Example prompts:

  • "What can I do with syn-button?"
  • "Show intent guide for syn-button in react-web-components"

21. intent-component-validate

Description: Validate component markup against one registered Synergy intent. Use an exact intent ID returned by intent-discover; do not guess or construct intent IDs. Checks intent policy, not complete accessibility or runtime behavior.

Example prompts:

  • "Do I use syn-button right for action.submit?"
  • "Validate this syn-button markup for action.submit: <syn-button type="submit" variant="filled">Send"

22. intent-task-recommendations

Description: Recommend Synergy targets and snippets for one registered task intent. Use an exact intent ID returned by intent-discover; do not guess or construct intent IDs.

Example prompts:

  • "What does Synergy provide to submit a form?"
  • "Recommend components for action.submit"

23. intent-options

Description: Get renderable Synergy targets and preview markup for one registered intent. Use an exact intent ID returned by intent-discover; do not guess or construct intent IDs.

Example prompts:

  • "What are my renderable options for navigation.link-list.grouped?"
  • "Show intent options for action.submit"

If an exact intent ID is unknown, the validation, options, and recommendation tools return bounded recovery data: intents from a recognized category namespace, or top-level categories when the namespace is unknown. They preserve the submitted ID and never fuzzy-match or silently substitute intent semantics.

Available Prompts

The MCP server currently registers 2 prompts.

1. explain-component-rules

Description: Explains the usage rules, design guidelines, and accessibility considerations for a Synergy component.

Example prompts:

  • "Explain the rules for syn-button"
  • "What are the design and accessibility guidelines for syn-dialog?"
  • "Give me the usage guidance for syn-accordion"

2. create-spritesheet

Description: Generates a task-specific instruction prompt for creating an SVG sprite sheet from icon usage found in a folder, including registration and usage guidance.

Example prompts:

  • "/mcp.synergy.create-spritesheet"
  • "Create a sprite sheet prompt for icons used in src/components"
  • "Generate create-spritesheet instructions for apps/demo with name app-icons"
  • "Help me produce a spritesheet from icon usage in my UI folder"

Usage Examples

Command Line Interface

# Start the MCP server
syn-mcp

# Start with custom defaults
syn-mcp --config ./synergy-mcp.json

Programmatic Usage

Individual example-list tools can also be registered on an existing MCP server:

import { componentListExamplesTool } from "@synergy-design-system/mcp/tools/component-list-examples.js";
import { stylesListExamplesTool } from "@synergy-design-system/mcp/tools/styles-list-examples.js";
import { templateListExamplesTool } from "@synergy-design-system/mcp/tools/template-list-examples.js";

componentListExamplesTool(server);
stylesListExamplesTool(server);
templateListExamplesTool(server);

StdIO transport:

import { createServer } from "@synergy-design-system/mcp";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

const server = createServer();
const transport = new StdioServerTransport();

await server.connect(transport);

HTTP transport (session-aware):

import { randomUUID } from "node:crypto";
import { createServer as createHttpServer } from "node:http";
import { createServer } from "@synergy-design-system/mcp";
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";

const sessions = new Map<string, StreamableHTTPServerTransport>();
const nodeServer = createHttpServer();

nodeServer.on("request", async (req, res) => {
  if (!(req.url || "/").startsWith("/mcp")) {
    res.statusCode = 404;
    res.end("Not Found\\n");
    return;
  }

  const sessionId = req.headers["mcp-session-id"] as string | undefined;

  if (sessionId) {
    const existing = sessions.get(sessionId);
    if (!existing) {
      res.statusCode = 400;
      res.setHeader("Content-Type", "application/json");
      res.end(
        JSON.stringify({
          jsonrpc: "2.0",
          id: null,
          error: { code: -32000, message: "Unknown session ID" },
        }),
      );
      return;
    }

    await existing.handleRequest(req, res);
    return;
  }

  const server = createServer();
  const transport = new StreamableHTTPServerTransport({
    sessionIdGenerator: () => randomUUID(),
    onsessioninitialized: sid => {
      sessions.set(sid, transport);
    },
  });

  transport.onclose = () => {
    if (transport.sessionId) {
      sessions.delete(transport.sessionId);
    }
  };

  await server.connect(transport);
  await transport.handleRequest(req, res);
});

nodeServer.listen(9119, "127.0.0.1");

AI Assistant Examples

Once connected to an AI assistant, you can use prompts like:

Show me how to use syn-button in React
Explain the rules for syn-accordion
Give me the interface docs for syn-select
What token formats are available?
How do I set up Synergy for Vue?
Find icons related to search and filter
How do I migrate from davinci-textarea to Synergy?
What migration paths exist from Synergy 2 to Synergy 3?
List all available Synergy templates

Developer Documentation

Project Structure

src/
├── bin/
│   ├── clean.js         # Removes dist/ before builds
│   └── start.ts         # CLI entry point for syn-mcp
├── server.ts            # MCP server creation, tool, prompt and resource registration
├── middleware/          # Tool execution middleware pipeline
│   ├── compose.ts       # composeMiddlewares (reduceRight composition)
│   ├── compression.ts   # withCompressionMiddleware (experimental)
│   ├── error-handler.ts # withErrorHandlingMiddleware
│   ├── logging.ts       # withToolLoggingMiddleware
│   ├── types.ts         # ToolMiddleware, ToolMiddlewareContext, RawToolHandler, WithErrorHandlerOptions
│   └── index.ts         # Middleware module entrypoint
├── prompts/             # MCP prompt implementations
│   ├── component-rules.ts
│   ├── create-spritesheet.ts
│   └── index.ts
├── resources/           # MCP resource implementations (static, read-only data)
│   ├── component-list.ts
│   ├── asset-list.ts
│   ├── component-cluster-list.ts
│   ├── intent-categories-list.ts
│   ├── styles-list.ts
│   ├── templates-list.ts
│   └── index.ts
├── tools/               # MCP tool implementations
│   ├── asset-info.ts
│   ├── asset-list.ts
│   ├── component-cluster-list.ts
│   ├── component-info.ts
│   ├── component-list.ts
│   ├── component-list-examples.ts
│   ├── create-spritesheet.ts
│   ├── davinci-migration-info.ts
│   ├── davinci-migration-list.ts
│   ├── intent-categories-list.ts
│   ├── intent-component-guide.ts
│   ├── intent-component-validate.ts
│   ├── intent-discover.ts
│   ├── intent-options.ts
│   ├── intent-task-recommendations.ts
│   ├── migration-info.ts
│   ├── migration-list.ts
│   ├── setup.ts
│   ├── styles-info.ts
│   ├── styles-list.ts
│   ├── styles-list-examples.ts
│   ├── template-info.ts
│   ├── template-list.ts
│   ├── template-list-examples.ts
│   ├── token-info.ts
│   ├── tokens-list.ts
│   └── index.ts
├── transports/          # Transport factory and implementations
├── types/               # Shared type definitions
└── utilities/           # Runtime config, metadata adapters, component/intent discovery, and CLI helpers
rules/                   # Markdown guidance files prepended to selected tool output, including compatibility notices
test/
├── e2e/                 # End-to-end MCP tests
├── fixtures/            # Self-signed TLS test certificates
├── unit/                # Unit tests
├── utilities/           # Test helpers
└── watermarks/          # Token watermark scenarios, baseline, and runner

There is no in-package metadata. This is now handled via @synergy-design-system/metadata.

Available Scripts

The package currently exposes these development scripts:

# Compile TypeScript into dist/
pnpm build

# Remove dist/
pnpm clean

# Run all lint tasks
pnpm lint

# Lint the source tree with ESLint
pnpm lint:js

# Run the end-to-end test suite
pnpm test

# Run watermark measurements (report-only)
pnpm watermark:report

# Write/update local watermark baseline file
pnpm watermark:baseline

# Enforce watermark budgets and baseline regressions
pnpm lint:watermark

# Run tests in watch mode
pnpm test:watch

# Launch the MCP inspector
pnpm debug

Token Watermarks

The MCP package includes token watermark verification for AI-facing tool responses.

  • Scenarios are defined in test/watermarks/scenarios.ts.
  • The runner is test/watermarks/run.ts.
  • Baseline data is stored in test/watermarks/baseline.latest-release.json.
  • The baseline records encoding, generatedAt, source, and per-scenario token counts.

Current tokenizer configuration:

  • The runner uses a fixed tokenizer encoding: o200k_base.
  • This keeps token measurements deterministic across runs.
  • Baseline encoding is persisted to make provenance explicit and support future validation or migrations.

Recommended workflow:

  1. Run pnpm watermark:report to generate a report.
  2. Run pnpm watermark:baseline when intentionally refreshing baseline values.
  3. Run pnpm lint:watermark in CI or pregate checks to enforce budgets.

Development Workflow

  1. Install dependencies with pnpm install.
  2. Build the package with pnpm build.
  3. Start the server with npx @synergy-design-system/mcp, node dist/bin/start.js, or syn-mcp --config ./synergy-mcp.json.
  4. Run pnpm test for end-to-end verification.
  5. Run pnpm watermark:report to review token watermark report output.
  6. Run pnpm lint before shipping changes.

If the MCP server appears to be missing data, check the state of @synergy-design-system/metadata first. This package reads runtime content from the metadata package and does not generate component, token, style, or migration data itself.

Setting up the MCP Inspector for local debugging

You may start the mcp inspector by issuing the command pnpm debug. This will automatically install the MCP inspector and launch it once downloaded. You can use the following configuration for the available transports:

STDIO transport

To test the STDIO transport, use the following values:

  1. Transport Type: STDIO
  2. Command: node
  3. Arguments: PATH_TO_MCP_DOWNLOAD/dist/bin/start.js

HTTP transport

To test the http transport, use the following values:

  1. Start the http mcp server (node PATH_TO_MCP_DOWNLOAD/dist/bin/start.js --interface http)
  2. Transport Type: Streamable HTTP
  3. URL: http://localhost:9119/mcp

Architecture

The MCP server is intentionally small:

  • src/bin/start.ts parses CLI arguments, loads optional runtime config, resolves overrides, and starts the selected transport.
  • src/transports/ contains the transport factory and runtime implementations for stdio and HTTP/HTTPS.
  • src/server.ts creates the McpServer instance and registers all exported tools from src/tools/index.ts and all exported resources from src/resources/index.ts.
  • Tool implementations in src/tools/ call the public APIs of @synergy-design-system/metadata to retrieve data.
  • Resource implementations in src/resources/ expose static, read-only data that does not change during server runtime. Resources bypass the tool middleware pipeline entirely — no compression, logging, or error wrapping is applied.
  • Utilities in src/utilities/ handle runtime config, MCP response shaping, DaVinci migration extraction, and package migration document loading.
  • Markdown files in rules/ provide assistant-facing response guidance for selected tools and frameworks.

Middleware Pipeline

Every tool call passes through a composed middleware stack defined in src/middleware/. Middlewares are applied with composeMiddlewares using reduceRight, meaning execution order is left-to-right (first entry in the array wraps outermost, last entry wraps closest to the handler).

Current stack (in declaration order):

  1. withErrorHandlingMiddleware — outermost; catches any uncaught error and returns a structured error response.
  2. withToolLoggingMiddleware — records duration, token count, and success/failure metadata. Exits early (skipping token counting) when logging is disabled via config.
  3. withCompressionMiddleware — innermost; encodes structured data to toon text format when compression is toon. Disabled by default.

Note: Compression runs before logging so token counts reflect the compressed payload size.

All middlewares share the ToolMiddleware<TArgs> type from src/middleware/types.ts:

type ToolMiddleware<TArgs extends Record<string, unknown>> = (
  next: RawToolHandler<TArgs>,
  context: ToolMiddlewareContext,
) => RawToolHandler<TArgs>;

The ToolMiddlewareContext carries the full runtime config (McpRuntimeConfig), so any middleware can read its own config key without additional plumbing:

type ToolMiddlewareContext = {
  config: McpRuntimeConfig; // e.g. context.config.logging, context.config.compression
  options: WithErrorHandlerOptions;
  toolName: string;
};

To add a new middleware (e.g., compression), create src/middleware/compression.ts, export it from src/middleware/index.ts, and add it to the middlewareStack in src/utilities/metadata.ts.

Response Compression (Experimental)

The MCP server can compress tool response payloads using the optional @toon-format/toon library. Compression encodes structured data into a compact text format while leaving string entries unchanged.

Installation:

npm install @toon-format/toon

Usage:

syn-mcp --compression toon

Behavior:

  • compression: 'none' (default): No compression
  • compression: 'toon': Non-string entries encoded to toon format; strings pass through unchanged
  • If toon library not installed: gracefully disabled (non-fatal)
  • Token counts reflect compressed payload size when logging enabled

Notes:

  • Experimental feature; may be subject to changes
  • Disabled by default; explicitly enable via --compression toon

Data Sources

Runtime data is resolved from @synergy-design-system/metadata:

  • Component docs and component lists come from metadata package component APIs.
  • Setup guidance comes from metadata setup entities.
  • DaVinci migrations are extracted from the setup content exposed by the metadata package.
  • Synergy package migration docs are resolved from metadata store layer files.
  • Tokens, styles, templates, and assets are all read from metadata package APIs at request time.

Adding New Resources

To add a new resource:

  1. Create a file in src/resources/.
  2. Register the resource with server.registerResource(...) using a synergy:// URI.
  3. Export it from src/resources/index.ts.
  4. Add or update an E2E resource contract test.
  5. Update this README so the public resource inventory stays aligned with the code.

Static discovery resources use the title pattern Synergy <domain> index and begin descriptions with Static JSON index of .... The remainder must describe the exact payload and point to the related detail tool when one exists.

Example:

import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { listThings } from "@synergy-design-system/metadata";

const RESOURCE_URI = "synergy://things/list";

export const thingsListResource = (server: McpServer) => {
  server.registerResource(
    "things-list",
    RESOURCE_URI,
    {
      description:
        "Static JSON index of Synergy thing names. Use thing-info for details.",
      mimeType: "application/json",
      title: "Synergy thing index",
    },
    async _uri => {
      const things = await listThings();
      const names = things.data.map(t => t.name).toSorted();
      return {
        contents: [
          {
            mimeType: "application/json",
            text: JSON.stringify(names, null, 2),
            uri: RESOURCE_URI,
          },
        ],
      };
    },
  );
};

Note: Resource callbacks receive the request URI and return a ReadResourceResult directly. They do not go through the tool middleware pipeline (no compression, logging, or error wrapping).

Adding New Tools

To add a new tool:

  1. Create a file in src/tools/.
  2. Register the tool with server.registerTool(...).
  3. Export it from src/tools/index.ts.
  4. If needed, add a matching guidance file under rules/.
  5. Add unit tests for pure discovery/transformation logic and E2E tests for the MCP contract.
  6. Update this README so the public tool inventory stays aligned with the code.

Tool descriptions are part of the model-facing API. Keep them to one or two concise, action-oriented sentences that state what the tool does, when to use it, what it returns, and any important prerequisite or boundary. Parameter descriptions must identify exact-value sources such as a neighboring list or discovery tool; examples must not imply that identifiers can be guessed.

Example:

import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import {
  createToolAnnotations,
  getRuntimeConfig,
  getToolRule,
  withErrorHandler,
} from "../utilities/index.js";

export const myTool = (server: McpServer) => {
  server.registerTool(
    "my-tool",
    {
      annotations: createToolAnnotations(),
      description: "Description of what the tool does",
      inputSchema: {
        param: z.string().describe("Parameter description"),
      },
      title: "My Tool",
    },
    async ({ param }) =>
      withErrorHandler(async () => {
        // Get the AI rules for this tool, used as a preface for LLM output quality.
        const aiRules = await getToolRule("my-tool");
        const content = `You provided ${param} as parameter`;
        return [aiRules, content];
      }),
  );
};

Binary Distribution

The package exposes the syn-mcp binary via package.json:

{
  "bin": {
    "syn-mcp": "./dist/bin/start.js"
  }
}

License

MIT