feat(webfont-mcp): add MCP server, was tools, and public exports#796
Open
jimmyandrade wants to merge 7 commits into
Open
feat(webfont-mcp): add MCP server, was tools, and public exports#796jimmyandrade wants to merge 7 commits into
jimmyandrade wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new internal MCP server workspace (packages/webfont-mcp) that exposes the existing SVG→webfont pipeline as structured MCP tools, and introduces a public “options reference” API from the webfont package so tooling can query defaults + CLI flag metadata programmatically.
Changes:
- Introduce
packages/webfont-mcp(private workspace) implementing stdio MCP tools: conversion, SVG diagnostics, and option listing. - Add
optionsReference/towebfontand export option metadata builders/types frompackages/webfont/src/index.ts. - Move the CLI flag catalog to
src/optionsReference/as the single source for CLI docs + the new reference API, updating docs accordingly.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/webfont/src/optionsReference/formatCliFlagDescription.ts | Helper to normalize multi-line CLI flag descriptions into a single string. |
| packages/webfont/src/optionsReference/cliFlagCatalog.ts | New canonical CLI flag catalog and help content sections for reuse by CLI/docs/tooling. |
| packages/webfont/src/optionsReference/buildWebfontOptionsReference.ts | Builds a structured options reference (defaults + CLI flags + API-only docs). |
| packages/webfont/src/optionsReference/buildWebfontOptionsReference.test.ts | Tests to ensure the exported options reference matches runtime defaults/catalog. |
| packages/webfont/src/optionsReference/apiOnlyOptionsCatalog.ts | Catalog of programmatic-only options not represented in CLI flags. |
| packages/webfont/src/index.ts | Exports the new options reference API and defaultWebfontOptions (plus WebfontOptions type). |
| packages/webfont/src/index.test.ts | Verifies new exports are present on the public entry point. |
| packages/webfont/src/cli/meow/renderCliHelp.ts | Updates the “source of truth” path for generated CLI docs. |
| packages/webfont/src/cli/meow/cliFlagCatalog.ts | Thin re-export shim to keep internal imports stable after moving the catalog. |
| packages/webfont/docs/configuration.md | Documents the new programmatic options reference (buildWebfontOptionsReference). |
| packages/webfont/docs/cli.md | Updates the generated-doc maintainer note to point at the moved catalog. |
| packages/webfont-mcp/vitest.config.ts | Vitest config for the new MCP workspace tests. |
| packages/webfont-mcp/tsconfig.json | TypeScript build configuration for the MCP workspace. |
| packages/webfont-mcp/src/serializeResult.ts | Serializes conversion outputs (written files + metadata) for MCP responses. |
| packages/webfont-mcp/src/resolveSvgInputs.ts | Resolves glob patterns to sandboxed SVG input paths. |
| packages/webfont-mcp/src/pathSandbox.ts | Implements workspace-root path sandboxing for MCP file operations. |
| packages/webfont-mcp/src/pathSandbox.test.ts | Tests for sandbox path resolution constraints. |
| packages/webfont-mcp/src/main.ts | CLI entry for starting the stdio MCP server. |
| packages/webfont-mcp/src/listWebfontOptionsContent.ts | Produces a JSON options reference including MCP-specific tool notes. |
| packages/webfont-mcp/src/listWebfontOptionsContent.test.ts | Tests for MCP options reference content. |
| packages/webfont-mcp/src/diagnoseSvgs.ts | Implements SVG diagnostics tool using diagnoseSvgContents. |
| packages/webfont-mcp/src/diagnoseSvgs.test.ts | Tests diagnostic results against repo fixtures. |
| packages/webfont-mcp/src/createServer.ts | Registers MCP tools and schemas on an McpServer. |
| packages/webfont-mcp/src/convertSvgsToFont.ts | Implements conversion tool using webfont() + writeResultFiles() within sandbox. |
| packages/webfont-mcp/src/convertSvgsToFont.test.ts | Integration-style test for producing a .woff2 output under sandbox. |
| packages/webfont-mcp/README.md | Usage/setup docs for running the MCP server and configuring Cursor. |
| packages/webfont-mcp/package.json | Declares private workspace metadata, deps, scripts, and bin entry. |
| packages/webfont-mcp/.gitignore | Ignores build artifacts and temp dirs for the MCP workspace. |
| package-lock.json | Lockfile updates for newly added MCP dependencies/workspace. |
Expose buildWebfontOptionsReference(), defaultWebfontOptions(), and CLI_FLAG_SECTIONS from the webfont entry so agents can reuse cliFlagCatalog metadata. Add private webfont-mcp package (stdio tools, path sandbox, local tests only). Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Move headless .was helpers to src/was/ for library build, export them from webfont(), and add validate_was_config / convert_from_was MCP tools that reuse the same mapping as --assistant-config. Co-authored-by: Cursor <cursoragent@cursor.com>
2a23cf3 to
0c4a606
Compare
Drop duplicate snapshot 2 left from an accidental update; the async glyphTransformFn test only asserts one template snapshot. Co-authored-by: Cursor <cursoragent@cursor.com>
Ship .cursor/mcp.json with ${workspaceFolder} so contributors can enable
the local webfont MCP without machine-specific absolute paths.
Co-authored-by: Cursor <cursoragent@cursor.com>
Presence (`!== undefined`) is not truthiness — empty exclusive MCP inputs must fail with a field error instead of falling through to JSON.parse. Codify the pattern in AGENTS.md (Copilot review on #796). Co-authored-by: Cursor <cursoragent@cursor.com>
| import { PathSandboxError } from "./pathSandbox.js"; | ||
| import { validateWasConfig } from "./validateWasConfig.js"; | ||
|
|
||
| const formatSchema = z.enum(["eot", "otf", "woff", "woff2", "svg", "ttf"]); |
| import { resolveSvgInputPaths } from "./resolveSvgInputs.js"; | ||
| import { serializeConversionResult } from "./serializeResult.js"; | ||
|
|
||
| export type WebfontFormat = "eot" | "otf" | "woff" | "woff2" | "svg" | "ttf"; |
Comment on lines
+11
to
+15
| const convertWasEntry = async ( | ||
| entry: Awaited<ReturnType<typeof validateWasConfig>>["entries"][number], | ||
| ): Promise<SerializedConversionResult> => { | ||
| const result = await webfont(entry.mappedOptions); | ||
| const dest = entry.mappedOptions.dest; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Proposed changes
packages/webfont-mcpworkspace (stdio MCP server, path sandbox, tools:convert_svgs_to_font,diagnose_svgs,list_webfont_options,validate_was_config,convert_from_was; not published; tests vianpm test -w webfont-mcp).buildWebfontOptionsReference(),buildCliFlagReferences(),defaultWebfontOptions(),CLI_FLAG_SECTIONS, and related types..washelpers fromwebfont():parseWasConfigJson,guardLoadedWasConfigs,loadWasConfigs,mapWasConfigToWebfontOptions,buildWasConfigFromWizard, basename cleaners, andWebfontAssistantWasConfigtypes..wasmodules fromcli/assistant/tosrc/was/so they ship in the library build; CLI assistant imports from there.cliFlagCatalog.tstosrc/optionsReference/(single source for CLI help and the new API); keep a thin re-export shim undercli/meow/; include--assistant/--assistant-configflags from feat(cli): add interactive assistant and webfont-assistant .was support #797.docs/configuration.md; regeneratedocs/cli.md.Related issue
#720
Dependencies added/removed (if applicable)
@modelcontextprotocol/sdk,globby,zod;webfontviafile:../webfont.Testing
How to test
npm test -w webfont— includesoptionsReference,was/, index export, and assistant CLI tests.npm run build -w webfont && npm test -w webfont-mcp— MCP unit/integration tests (13 tests).npm run build -w webfont-mcp && node packages/webfont-mcp/dist/main.jsand wire in Cursor perpackages/webfont-mcp/README.md.Test configuration
N/A
Checklist