{
  "openapi": "3.1.1",
  "info": {
    "title": "Unicode Inspector API",
    "version": "1.0.0",
    "summary": "Every code point with name, script and bytes, plus hidden characters and look-alikes.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://unicodeinspector.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Every code point with name, script and bytes, plus hidden characters and look-alikes.",
        "description": "Breaks text into code points with U+ value, name, general category, script and UTF-8/UTF-16 encoding; counts graphemes; compares NFC/NFD/NFKC/NFKD forms; and flags zero-width and invisible characters, bidirectional controls (Trojan Source) and mixed-script look-alike words used in phishing.\n\nMethodology:\n- The text is split into Unicode code points. General category and script come from the JavaScript regular-expression Unicode property tables of the server (\\p{gc=…}, \\p{Script=…}), which follow the Unicode version of its ICU build.\n- Names: the complete Unicode name list is about 2 MB, so a compact built-in table covers ASCII, Latin-1, basic Greek and Cyrillic, all invisible/format/space characters, common punctuation and variation selectors; CJK ideographs, Hangul syllables, fullwidth forms and tag characters are named algorithmically. Other characters show no name.\n- Grapheme clusters (user-perceived characters) are counted with Intl.Segmenter. Normalization forms come from String.prototype.normalize.\n- Invisible: zero-width characters, format characters (Cf), fillers, variation selectors and tag characters. Bidi controls (U+202A–202E, U+2066–2069) can make source code display differently from how it compiles (CVE-2021-42574, \"Trojan Source\").\n- Look-alikes: words mixing scripts (e.g. Latin + Cyrillic) and characters from a curated subset of Unicode confusables.txt are flagged; the skeleton maps them to Latin for comparison. This is a subset, not the full UTS #39 algorithm.",
        "tags": [
          "developer"
        ],
        "x-mcp-tool": "unicode_inspector",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UnicodeInspectorInput"
              },
              "examples": {
                "example1": {
                  "summary": "Look-alike domain (Cyrillic \"а\" in paypal) with a zero-width space",
                  "value": {
                    "text": "pаypal​.com"
                  }
                },
                "example2": {
                  "summary": "Trojan Source: right-to-left override in code",
                  "value": {
                    "text": "access_level != \"user‮ ⁦// Check if admin⁩ ⁦\""
                  }
                },
                "example3": {
                  "summary": "Emoji family, combining accents and fullwidth letters",
                  "value": {
                    "text": "Café 👨‍👩‍👧 ＡＢＣ"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnicodeInspectorResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "UnicodeInspectorInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "title": "Text",
            "description": "Up to 20,000 characters; the table lists the first 500 code points.",
            "type": "string",
            "maxLength": 20000
          }
        },
        "required": [
          "text"
        ]
      },
      "UnicodeInspectorResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "codePoints",
              "utf16Units",
              "utf8Bytes",
              "graphemes",
              "truncated",
              "chars",
              "scripts",
              "normalization",
              "findings",
              "skeleton",
              "escaped"
            ],
            "properties": {
              "codePoints": {
                "type": "integer"
              },
              "utf16Units": {
                "type": "integer",
                "description": "JavaScript string length."
              },
              "utf8Bytes": {
                "type": "integer"
              },
              "graphemes": {
                "type": "integer",
                "description": "User-perceived characters (extended grapheme clusters)."
              },
              "truncated": {
                "type": "boolean",
                "description": "true when more than 500 code points; chars then lists the first 500."
              },
              "chars": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "index",
                    "codePoint",
                    "char",
                    "name",
                    "category",
                    "categoryName",
                    "script",
                    "utf8",
                    "utf16",
                    "flags"
                  ],
                  "properties": {
                    "index": {
                      "type": "integer"
                    },
                    "codePoint": {
                      "type": "string"
                    },
                    "char": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "category": {
                      "type": "string"
                    },
                    "categoryName": {
                      "type": "string"
                    },
                    "script": {
                      "type": "string"
                    },
                    "utf8": {
                      "type": "string"
                    },
                    "utf16": {
                      "type": "string"
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "scripts": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "normalization": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "form",
                    "equal",
                    "codePoints",
                    "utf8Bytes",
                    "text"
                  ],
                  "properties": {
                    "form": {
                      "type": "string"
                    },
                    "equal": {
                      "type": "boolean"
                    },
                    "codePoints": {
                      "type": "integer"
                    },
                    "utf8Bytes": {
                      "type": "integer"
                    },
                    "text": {
                      "type": "string"
                    }
                  }
                }
              },
              "findings": {
                "type": "object",
                "additionalProperties": true
              },
              "skeleton": {
                "type": "string",
                "description": "NFKC + Latin look-alike mapping, for comparing against an expected string."
              },
              "escaped": {
                "type": "string",
                "description": "The input with invisible/bidi/control characters as \\u{…} escapes."
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}