{
  "openapi": "3.1.1",
  "info": {
    "title": "Resistor Color Code API",
    "version": "1.0.0",
    "summary": "Decode and encode resistor bands",
    "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://ohmforgeresistorcolorcode.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Decode and encode resistor bands",
        "description": "Decode four, five or six color bands or encode an exactly representable resistance, with tolerance and temperature coefficient.\n\nMethodology:\n- Reads two significant digits for four bands and three for five or six bands, then applies the multiplier and tolerance.\n- The optional sixth band is the temperature coefficient in ppm/K. Uses the conventional mappings documented in the linked Vishay chart.\n- Encoding requires an exactly representable value and never silently rounds to a preferred series.\n- The minimum and maximum are nominal resistance multiplied by one minus or plus tolerance; they do not include temperature effects.\n- The nominal value is also checked against the IEC 60063 preferred-number series E6, E12, E24, E48, E96 and E192 (exact match of the significant digits).\n\nThis covers conventional four-, five- and six-band resistor markings. Manufacturers may use different markings, and color appearance or orientation can be ambiguous. Confirm against the component datasheet and measure when uncertain.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ohmforge_resistor_color_code",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OhmforgeResistorColorCodeInput"
              },
              "examples": {
                "example1": {
                  "summary": "Decode brown, black, red, gold",
                  "value": {
                    "mode": "decode",
                    "bandCount": "4",
                    "digit1": "brown",
                    "digit2": "black",
                    "multiplier": "red",
                    "tolerance": "gold"
                  }
                },
                "example2": {
                  "summary": "Encode a 4.7 kΩ precision resistor",
                  "value": {
                    "mode": "encode",
                    "bandCount": "5",
                    "ohms": 4700,
                    "tolerance": "brown"
                  }
                },
                "example3": {
                  "summary": "Six bands with temperature coefficient",
                  "value": {
                    "mode": "decode",
                    "bandCount": "6",
                    "digit1": "brown",
                    "digit2": "black",
                    "digit3": "black",
                    "multiplier": "red",
                    "tolerance": "brown",
                    "temperature": "red"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OhmforgeResistorColorCodeResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "OhmforgeResistorColorCodeInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Calculate",
            "type": "string",
            "enum": [
              "decode",
              "encode"
            ],
            "default": "decode"
          },
          "bandCount": {
            "title": "Number of bands",
            "type": "string",
            "enum": [
              "4",
              "5",
              "6"
            ],
            "default": "4"
          },
          "digit1": {
            "title": "First significant band (decode)",
            "type": "string",
            "enum": [
              "brown",
              "red",
              "orange",
              "yellow",
              "green",
              "blue",
              "violet",
              "gray",
              "white"
            ],
            "default": "brown"
          },
          "digit2": {
            "title": "Second significant band (decode)",
            "type": "string",
            "enum": [
              "black",
              "brown",
              "red",
              "orange",
              "yellow",
              "green",
              "blue",
              "violet",
              "gray",
              "white"
            ],
            "default": "black"
          },
          "digit3": {
            "title": "Third significant band (5 or 6 bands, decode)",
            "type": "string",
            "enum": [
              "black",
              "brown",
              "red",
              "orange",
              "yellow",
              "green",
              "blue",
              "violet",
              "gray",
              "white"
            ],
            "default": "black"
          },
          "multiplier": {
            "title": "Multiplier band (decode)",
            "type": "string",
            "enum": [
              "silver",
              "gold",
              "black",
              "brown",
              "red",
              "orange",
              "yellow",
              "green",
              "blue",
              "violet",
              "gray",
              "white"
            ],
            "default": "red"
          },
          "tolerance": {
            "title": "Tolerance band",
            "type": "string",
            "enum": [
              "silver",
              "gold",
              "brown",
              "red",
              "green",
              "blue",
              "violet",
              "gray"
            ],
            "default": "gold"
          },
          "temperature": {
            "title": "Temperature coefficient band (6 bands)",
            "type": "string",
            "enum": [
              "brown",
              "red",
              "yellow",
              "orange",
              "blue",
              "violet"
            ],
            "default": "brown"
          },
          "ohms": {
            "title": "Resistance in ohms (encode)",
            "type": "number",
            "minimum": 0.1,
            "maximum": 999000000000,
            "default": 1000,
            "x-unit": "Ω"
          }
        },
        "required": []
      },
      "OhmforgeResistorColorCodeResult": {
        "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",
            "required": [
              "bands",
              "ohms",
              "tolerancePercent",
              "minimumOhms",
              "maximumOhms",
              "temperatureCoefficientPpmPerK",
              "preferredSeries"
            ],
            "properties": {
              "bands": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "ohms": {
                "type": "number"
              },
              "tolerancePercent": {
                "type": "number"
              },
              "minimumOhms": {
                "type": "number"
              },
              "maximumOhms": {
                "type": "number"
              },
              "temperatureCoefficientPpmPerK": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "preferredSeries": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "E6",
                    "E12",
                    "E24",
                    "E48",
                    "E96",
                    "E192"
                  ]
                }
              }
            },
            "additionalProperties": false
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}