Skip to main content
Glama

コントラスト比を計算

contrast_ratio

Calculates the contrast ratio between two colors and returns WCAG 2.x AA/AAA pass/fail results for normal text, large text, and non-text UI components without using a browser.

Instructions

2 色のコントラスト比を計算し、WCAG 2.x の AA / AAA について通常の文字・大きな文字・UI 部品(非テキスト)ごとの合否を返す。ブラウザは使わない

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "foreground": "<foreground>",
      "background": "<background>"
    },
    "name": "contrast_ratio"
  }
}

Input Schema

NameRequiredDescriptionDefault
boldNo太字(700 以上)か
backgroundYes背景色(#hex / rgb() / rgba())
foregroundYes文字色(#hex / rgb() / rgba())
font_size_pxNo文字サイズ(px)。指定すると該当する判定を強調

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and usefully discloses the return categories (AA/AAA pass/fail by text size and UI component) plus the no-browser behavior. It does not explicitly state that the operation is read-only or deterministic, but the calculation framing makes those traits reasonably clear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two compact sentences, front-loaded with the core action and then the WCAG return scope. There is no redundant or filler wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple calculation tool with complete parameter documentation and no output schema, the description explains the key output categories and the no-browser constraint. It could be slightly more complete by stating whether the raw ratio value is also returned, but it is broadly sufficient for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents foreground, background, bold, and font_size_px in detail. The description adds no parameter-specific meaning beyond the schema and does not explain how bold or font_size_px influence the large-text judgments.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific operation (calculating a contrast ratio for two colors) and precisely states the WCAG 2.x AA/AAA pass/fail scope across normal text, large text, and non-text UI components. It also distinguishes itself from browser-based siblings by explicitly saying it does not use a browser.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The line 'ブラウザは使わない' gives clear context that this is a direct color-pair calculation rather than a page scan, which helps an agent avoid browser-oriented tools. It does not explicitly name alternatives such as contrast_scan or state the exact condition for choosing between them, so it falls short of full when/when-not guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.