Skip to main content
Glama
TypeScale MCP

TypeScale MCP

README.md
# TypeScale MCP

> A reference system for type and space that adapts to the interface.

![TypeScale editorial specimen showing a modular hierarchy from caption to H1](assets/logo.svg)

**SPECIMEN 01 — The responsive scale**

Type should carry the structure of a page. TypeScale calculates fluid font sizes, spacing, corner radii and target sizes, with support for English and Arabic typography. The output is intended for design systems, web CSS, and Flutter interfaces.

### The default specimen

| Role | At 360px | At 1440px |
|:--|--:|--:|
| Caption | 12.098 | 12.098 |
| Small | 13.913 | 14.4 |
| Body | 16 | 18 |
| H6 | 18.4 | 22.5 |
| H5 | 21.16 | 28.125 |
| H4 | 24.334 | 35.156 |
| H3 | 27.984 | 43.945 |
| H2 | 32.182 | 54.932 |
| H1 | 37.009 | 68.665 |

Values shown in CSS pixels using the default viewport range and 16px rem baseline. These are computed values, not measurements of drawn text in the specimen illustration.

| System | Text | Space |
|:--|:--|:--|
| English & Arabic, LTR/RTL | Nine type roles; fluid CSS | Spacing, radii, control padding, touch targets |
| Node.js 20+; MCP stdio | Font and line-height guidance | CSS, JSON, Flutter-friendly tokens |

**Local by design.** The two read-only tools perform deterministic numerical computation. They do not read project files, make network calls or execute commands. Setup requires installing dependencies.

---

## 01 / Installation

Requires Node.js 20 or newer.

```sh
git clone https://github.com/ahmedsaeed1-eng/typescale-mcp.git
cd typescale-mcp
npm ci
npm test
```

The npm install step obtains dependencies from the package registry; server requests themselves never use a network interface.

## 02 / Connect to Codex

From the repository directory run:

```sh
codex mcp add typescale -- node /absolute/path/to/typescale-mcp/src/server.js
```

Use the actual absolute path to your checkout. On Windows use the absolute Windows path in quotes if it contains spaces. Run `codex mcp list` to confirm registration.

Equivalent configuration in Codex's MCP settings:

```toml
[mcp_servers.typescale]
command = "node"
args = ["/absolute/path/to/typescale-mcp/src/server.js"]
```

The command starts an MCP service communicating on stdin/stdout. It is not an interactive terminal prompt.

## 03 / Tool reference

| Name | Purpose |
|---|---|
| `generate_design_tokens` | Generate fluid typography, spacing, radii, target sizes and layout tokens |
| `typography_recommendations` | Return typography and direction guidance for an English or Arabic interface |

Example prompt for Codex:

> Use TypeScale to generate Arabic RTL design tokens at 360–1440px viewport widths. Keep body text readable and controls comfortable. Show CSS variables and the Flutter mapping.

Example arguments for `generate_design_tokens`:

```json
{"locale":"ar","baseMin":16,"baseMax":18,"ratioMin":1.15,"ratioMax":1.25,"viewportMin":360,"viewportMax":1440,"spacingUnit":4,"density":"comfortable","format":"all"}
```

| Parameter | Accepted range or value | Default |
|---|---|---|
| baseMin / baseMax | 14–24 px; max >= min | 16 / 18 |
| ratioMin / ratioMax | 1.01–1.333; max >= min | 1.15 / 1.25 |
| viewportMin | 280–1440 px, integer | 360 |
| viewportMax | 320–2560 px, integer, > min | 1440 |
| spacingUnit | 2–8 px, integer | 4 |
| density | compact, comfortable | comfortable |
| locale | en, ar | en |
| format | json, css, flutter, all | all |

All inputs are optional. The recommendation tool accepts `locale` only.

## 04 / Apply the scale

Use the returned CSS custom property definitions, then reference them in project styles:

```css
body {
  font-family: var(--font-family);
  font-size: var(--type-body);
  line-height: var(--line-height-body);
}
h1 {
  font-size: var(--type-h1);
  line-height: var(--line-height-heading);
}
button {
  min-block-size: var(--touch-recommended);
  padding-block: var(--control-padding-block);
  padding-inline: var(--control-padding-inline);
}
```

Set `lang="ar"` and `dir="rtl"` on the relevant Arabic document or subtree. The tool provides tokens only; this CSS does not apply itself.

## 05 / Design notes and limitations

Font sizes scale geometrically at both viewport bounds, then interpolate using CSS `clamp()`. The smallest caption is bounded at a 12px design size; scale roles may intentionally coincide in low-ratio designs. A user-configurable browser root font size changes the interpretation of rem units; do not override it to force the example baseline.

The Flutter mapping is JSON with min/max logical-pixel font sizes and line-height multipliers. Applications must apply responsive interpolation themselves and respect platform text scaling. No actual Flutter source is generated.

Targets of 44px and 48px are recommended design defaults, not guarantees of accessibility. Test the rendered interface for contrast, text zoom, hit areas, wrapping and multilingual glyphs. Font stacks are suggestions, not distributed font files. No browser, font or rendered layout measurement is performed.

## 06 / Development

```sh
npm test
```

The suite tests deterministic calculations, range validation, Arabic guidance, format outputs, target sizes, and both tools via the official MCP client and a real stdio connection. CI is configured for Node 20 and 22 across Linux, macOS and Windows.

## Colophon

MIT. See [LICENSE](LICENSE) and [THIRD_PARTY.md](THIRD_PARTY.md).

TDQS

B3.3/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct actions: one generates concrete design tokens, the other returns advisory font/typography guidance. An agent can easily tell which to call based on whether it needs output tokens or recommendations.

Naming Consistency3/5

Both names use snake_case, but the patterns differ: generate_design_tokens is verb-led while typography_recommendations is a noun phrase. Readable, but not a predictable single convention.

Tool Count3/5

Two tools is borderline thin for a design-token server; generation and guidance cover the basics, but the surface feels minimal. It is not extreme, just under-scoped.

Completeness3/5

Core generation and typography advice are present, but notable gaps exist: no token export/format conversion, no preview or validation, and no theme/update lifecycle. Agents must work around these for full design-system workflows.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues