mastercss_extract_classes
Extract class positions and validation summaries from project files or an in-memory source buffer.
Contract
Find exact class tokens and source positions in a buffer, or inspect extraction across selected project files.
Input
Complete input schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "context": { "type": "string", "enum": [ "project", "preset" ] }, "content": { "type": "string" }, "filePath": { "type": "string" }, "patterns": { "type": "array", "items": { "type": "string" } }, "includeRules": { "type": "boolean" } }}Example
Call mastercss_extract_classes from a connected MCP client with these arguments:
{ "content": "<button class=\"flex gap-sm p-md\">Save</button>", "filePath": "src/button.html", "includeRules": true}This buffer is inspected without writing src/button.html.
Output
files contains language IDs and class records with tokens, ranges, locations, matching, CSS-syntax and CSS-value statuses, diagnostics, and inspection data. inputs.mode distinguishes content from project mode. summary counts files and classes; project mode also includes scanner counts and diagnostics.
Every tool returns an object with version: 3, metadata, diagnostics and result. Success payload fields described above live in result.data; failure has result.status: "error" and a required { code, message } error. JSON text equals structuredContent. Tool errors set isError. Metadata records actual context, package/language/binding versions, manifest fingerprint, entries and dependencies; unavailable information is null or an empty array.
Complete output schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "version": { "type": "number", "const": 3 }, "metadata": { "type": "object", "properties": { "versions": { "anyOf": [ { "type": "object", "properties": { "languageVersion": { "type": "number" }, "bindingAbiVersion": { "type": "number" }, "packageVersion": { "type": "string" } }, "required": [ "languageVersion", "bindingAbiVersion", "packageVersion" ], "additionalProperties": {} }, { "type": "null" } ] }, "context": { "anyOf": [ { "type": "string", "enum": [ "project", "preset" ] }, { "type": "null" } ] }, "manifestFingerprint": { "type": [ "string", "null" ] }, "entries": { "type": "array", "items": { "type": "string" } }, "dependencies": { "type": "array", "items": { "type": "string" } } }, "required": [ "versions", "context", "manifestFingerprint", "entries", "dependencies" ], "additionalProperties": false }, "diagnostics": { "type": "array", "items": { "type": "object", "properties": { "code": { "type": "string" }, "phase": { "type": "string" }, "severity": { "type": [ "string", "number" ] }, "message": { "type": "string" }, "notes": { "type": "array", "items": { "type": "string" } }, "alternatives": { "type": "array", "items": { "type": "string" } }, "source": { "type": "string" }, "range": { "anyOf": [ { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, { "type": "object", "properties": { "start": { "type": "object", "properties": { "line": { "type": "number" }, "character": { "type": "number" } }, "required": [ "line", "character" ], "additionalProperties": false }, "end": { "type": "object", "properties": { "line": { "type": "number" }, "character": { "type": "number" } }, "required": [ "line", "character" ], "additionalProperties": false } }, "required": [ "start", "end" ], "additionalProperties": false } ] } }, "required": [ "message" ], "additionalProperties": {} } }, "result": { "oneOf": [ { "type": "object", "properties": { "status": { "type": "string", "const": "success" }, "data": { "type": "object", "properties": { "manifest": { "type": "object", "properties": { "context": { "type": "string", "enum": [ "project", "preset" ] }, "status": { "type": "string", "enum": [ "loaded", "error" ] }, "fingerprint": { "type": [ "string", "null" ] }, "entries": { "type": "array", "items": { "type": "string" } }, "dependencies": { "type": "array", "items": { "type": "string" } }, "versions": { "type": "object", "properties": { "languageVersion": { "type": "number" }, "bindingAbiVersion": { "type": "number" }, "packageVersion": { "type": "string" } }, "required": [ "languageVersion", "bindingAbiVersion", "packageVersion" ], "additionalProperties": {} } }, "required": [ "context", "status", "fingerprint", "entries", "dependencies" ], "additionalProperties": {} }, "files": { "type": "array", "items": { "type": "object", "properties": { "filePath": { "type": "string" }, "languageId": { "type": "string" }, "occurrences": { "type": "array", "items": { "type": "object", "properties": { "candidate": { "type": "string" }, "source": { "type": "string" }, "range": { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, "contextRange": { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, "rangeKind": { "type": "string", "enum": [ "token", "expression" ] }, "extractor": { "type": "string" }, "contentKind": { "type": "string" }, "owner": { "type": "string" }, "included": { "type": "boolean" }, "reason": { "type": "string" } }, "required": [ "candidate", "source", "range", "contextRange", "rangeKind", "extractor", "contentKind", "owner", "included", "reason" ], "additionalProperties": false } }, "classes": { "type": "array", "items": { "type": "object", "properties": { "raw": { "type": "string" }, "token": { "type": "string" }, "range": { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, "loc": { "type": "object", "properties": { "start": { "type": "object", "properties": { "line": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "character": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": [ "line", "character" ], "additionalProperties": false }, "end": { "type": "object", "properties": { "line": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "character": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": [ "line", "character" ], "additionalProperties": false } }, "required": [ "start", "end" ], "additionalProperties": false }, "contextRange": { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, "sourceKind": { "type": "string" }, "provenance": { "type": "object", "properties": { "candidate": { "type": "string" }, "source": { "type": "string" }, "range": { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, "contextRange": { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, "rangeKind": { "type": "string", "enum": [ "token", "expression" ] }, "extractor": { "type": "string" }, "contentKind": { "type": "string" }, "owner": { "type": "string" }, "included": { "type": "boolean" }, "reason": { "type": "string" } }, "required": [ "candidate", "source", "range", "contextRange", "rangeKind", "extractor", "contentKind", "owner", "included", "reason" ], "additionalProperties": false }, "status": { "type": "string" }, "matchStatus": { "type": "string", "enum": [ "matched", "unmatched", "ambiguous", "syntax-error" ] }, "cssSyntaxStatus": { "type": "string", "enum": [ "valid", "invalid", "unknown", "not-checked" ] }, "cssValueStatus": { "type": "string", "enum": [ "valid", "invalid", "unknown", "not-checked" ] }, "browserSupport": { "type": "string", "enum": [ "supported", "unsupported", "unknown", "not-checked" ] }, "inspection": { "type": "object", "properties": { "className": { "type": "string" }, "matchStatus": { "type": "string", "enum": [ "matched", "unmatched", "ambiguous", "syntax-error" ] }, "cssSyntaxStatus": { "type": "string", "enum": [ "valid", "invalid", "unknown", "not-checked" ] }, "cssValueStatus": { "type": "string", "enum": [ "valid", "invalid", "unknown", "not-checked" ] }, "browserSupport": { "type": "string", "enum": [ "supported", "unsupported", "unknown", "not-checked" ] }, "checks": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" }, "phase": { "type": "string" }, "scope": { "type": "string" } }, "required": [ "name", "version", "phase", "scope" ], "additionalProperties": false } }, "declarations": { "type": "array", "items": { "type": "object", "properties": { "property": { "type": "string" }, "value": { "type": "string" }, "status": { "type": "string", "enum": [ "valid", "invalid", "unknown", "not-checked" ] }, "range": { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, "error": { "type": "string" } }, "required": [ "property", "value", "status" ], "additionalProperties": {} } }, "rules": { "type": "array", "items": { "type": "object", "properties": { "className": { "type": "string" }, "key": { "type": "string" }, "layer": { "type": "string", "enum": [ "base", "defaults", "components", "utilities" ] }, "type": { "type": "number" }, "sortTier": { "type": "number" }, "text": { "type": "string" }, "selectorText": { "type": "string" }, "priority": { "type": "object", "properties": { "features": { "type": "array", "items": { "type": "object", "properties": { "domain": { "type": "string" }, "feature": { "type": "string" }, "unit": { "type": "string" }, "lower": { "anyOf": [ { "type": "object", "properties": { "value": { "type": "number" }, "inclusive": { "type": "boolean" } }, "required": [ "value", "inclusive" ], "additionalProperties": false }, { "type": "null" } ] }, "upper": { "anyOf": [ { "type": "object", "properties": { "value": { "type": "number" }, "inclusive": { "type": "boolean" } }, "required": [ "value", "inclusive" ], "additionalProperties": false }, { "type": "null" } ] } }, "required": [ "domain", "feature", "unit", "lower", "upper" ], "additionalProperties": false } }, "selector": { "type": "number" }, "conditions": { "type": "array", "items": { "type": "string" } }, "sortKey": { "type": "string" }, "valuePriority": { "type": "number" } }, "required": [ "features", "selector" ], "additionalProperties": false }, "nodes": { "type": "array", "items": { "type": "object", "properties": { "text": { "type": "string" } }, "required": [ "text" ], "additionalProperties": false } }, "variableNames": { "type": "array", "items": { "type": "string" } }, "animationNames": { "type": "array", "items": { "type": "string" } } }, "required": [ "className", "key", "layer", "type", "sortTier", "priority" ], "additionalProperties": false } }, "variables": { "type": "array", "items": { "type": "object", "properties": { "key": { "type": "string" }, "variable": { "type": "object", "properties": { "key": { "type": "string" }, "name": { "type": "string" }, "namespace": { "type": "string" }, "type": { "type": "string" }, "value": { "anyOf": [ { "type": "string" }, { "type": "number" }, { "type": "boolean", "const": false }, { "type": "array", "items": { "type": [ "string", "number" ] } } ] }, "numeric": { "type": "object", "properties": { "value": { "type": "number" }, "unit": { "type": "string" } }, "required": [ "value" ], "additionalProperties": false }, "dependencies": { "type": "array", "items": { "type": "string" } }, "modes": { "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { "type": "object", "properties": { "type": { "type": "string", "enum": [ "string", "number" ] }, "value": { "type": [ "string", "number" ] }, "numeric": { "type": "object", "properties": { "value": { "type": "number" }, "unit": { "type": "string" } }, "required": [ "value" ], "additionalProperties": false } }, "required": [ "type", "value" ], "additionalProperties": false } }, "inline": { "type": "boolean" }, "static": { "type": "boolean" }, "mode": { "type": "string" } }, "required": [ "key", "name", "type", "dependencies" ], "additionalProperties": false } }, "required": [ "key", "variable" ], "additionalProperties": false } }, "diagnostics": { "type": "array", "items": { "type": "object", "properties": { "code": { "type": "string" }, "phase": { "type": "string" }, "severity": { "type": [ "string", "number" ] }, "message": { "type": "string" }, "notes": { "type": "array", "items": { "type": "string" } }, "alternatives": { "type": "array", "items": { "type": "string" } }, "source": { "type": "string" }, "range": { "anyOf": [ { "type": "object", "properties": { "start": { "type": "number" }, "end": { "type": "number" } }, "required": [ "start", "end" ], "additionalProperties": false }, { "type": "object", "properties": { "start": { "type": "object", "properties": { "line": { "type": "number" }, "character": { "type": "number" } }, "required": [ "line", "character" ], "additionalProperties": false }, "end": { "type": "object", "properties": { "line": { "type": "number" }, "character": { "type": "number" } }, "required": [ "line", "character" ], "additionalProperties": false } }, "required": [ "start", "end" ], "additionalProperties": false } ] } }, "required": [ "message" ], "additionalProperties": {} } } }, "required": [ "className", "matchStatus", "cssSyntaxStatus", "cssValueStatus", "browserSupport", "checks", "declarations", "rules", "variables" ], "additionalProperties": {} } }, "required": [ "raw", "token", "range", "loc", "contextRange", "sourceKind", "provenance", "status", "matchStatus", "cssSyntaxStatus", "cssValueStatus", "browserSupport", "inspection" ], "additionalProperties": false } } }, "required": [ "filePath", "languageId", "occurrences", "classes" ], "additionalProperties": false } }, "summary": { "type": "object", "properties": { "files": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "classes": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "matched": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "unmatched": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "diagnostics": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": [ "files", "classes", "matched", "unmatched" ], "additionalProperties": false } }, "required": [ "manifest", "files", "summary" ], "additionalProperties": {} } }, "required": [ "status", "data" ], "additionalProperties": false }, { "type": "object", "properties": { "status": { "type": "string", "const": "error" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": [ "code", "message" ], "additionalProperties": false } }, "required": [ "status", "error" ], "additionalProperties": false } ] } }, "required": [ "version", "metadata", "diagnostics", "result" ], "additionalProperties": false}Project context and lifecycle
This operation does not write workspace files.
The local stdio server uses the workspace passed to --root. Confirm the root and intended CSS entries with mastercss_workspace_info before relying on project-dependent values.
See the MCP workflow guide for client setup and the preview/apply workflow.