{
  "openapi": "3.1.1",
  "info": {
    "title": "PCB Trace Estimator API",
    "version": "1.0.0",
    "summary": "Estimate trace width or current capacity",
    "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://ohmforgepcbtraceestimator.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Estimate trace width or current capacity",
        "description": "Estimate copper trace width or current, resistance, voltage drop, and power loss using the IPC-2221 equation.\n\nMethodology:\n- Uses the empirical IPC-2221 relation I = k × ΔT^0.44 × A^0.725, with copper cross-sectional area in square mils. The coefficient is 0.048 for external and 0.024 for internal layers.\n- Solves the equation for cross-sectional area and width, or solves for current at a given width. A nominal 1 oz/ft² copper weight is converted to 0.0348 mm.\n- Estimates resistance at 20 °C from copper resistivity 1.72 × 10⁻⁸ Ω·m and the specified length and area; voltage drop is I × R and power loss is I² × R.\n- Flags inputs outside the IPC-2221 chart range (up to 35 A, widths up to 400 mil, 10–100 °C rise, 0.5–3 oz/ft² copper), where the curve fit is an extrapolation.\n\nAn empirical estimate for an isolated rectangular trace, not a fabrication design-rule check or board-level thermal analysis. Resistance, voltage drop and loss use copper resistivity at 20 °C and do not include heating, plating, vias or adjacent copper. Input limits are numerical safeguards, not a validated operating range; verify the finished copper thickness and design with your fabricator.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ohmforge_pcb_trace_estimator",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OhmforgePcbTraceEstimatorInput"
              },
              "examples": {
                "example1": {
                  "summary": "Width for 1 A on external 1 oz copper",
                  "value": {
                    "mode": "width",
                    "layer": "external",
                    "currentA": 1,
                    "copper": 1,
                    "copperUnit": "oz",
                    "temperatureRiseC": 10,
                    "length": 100,
                    "lengthUnit": "mm"
                  }
                },
                "example2": {
                  "summary": "Current for a 20 mil internal trace",
                  "value": {
                    "mode": "current",
                    "layer": "internal",
                    "width": 20,
                    "widthUnit": "mil",
                    "copper": 1,
                    "copperUnit": "oz",
                    "temperatureRiseC": 10,
                    "length": 4,
                    "lengthUnit": "in"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OhmforgePcbTraceEstimatorResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "OhmforgePcbTraceEstimatorInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Calculate",
            "type": "string",
            "enum": [
              "width",
              "current"
            ],
            "default": "width"
          },
          "layer": {
            "title": "Copper layer",
            "type": "string",
            "enum": [
              "external",
              "internal"
            ],
            "default": "external"
          },
          "currentA": {
            "title": "Current (used when calculating width)",
            "type": "number",
            "minimum": 0.000001,
            "maximum": 10000,
            "default": 1,
            "x-unit": "A"
          },
          "width": {
            "title": "Trace width (used when calculating current)",
            "type": "number",
            "minimum": 0.000001,
            "maximum": 100000,
            "default": 0.5
          },
          "widthUnit": {
            "title": "Width unit",
            "type": "string",
            "enum": [
              "mm",
              "mil"
            ],
            "default": "mm"
          },
          "copper": {
            "title": "Copper thickness",
            "type": "number",
            "minimum": 0.000001,
            "maximum": 10000,
            "default": 1
          },
          "copperUnit": {
            "title": "Copper thickness unit",
            "type": "string",
            "enum": [
              "oz",
              "mm"
            ],
            "default": "oz"
          },
          "temperatureRiseC": {
            "title": "Allowed temperature rise above ambient",
            "type": "number",
            "minimum": 0.01,
            "maximum": 1000,
            "default": 10,
            "x-unit": "°C"
          },
          "length": {
            "title": "Trace length",
            "description": "Used for the resistance, voltage drop and power loss estimates.",
            "type": "number",
            "minimum": 0,
            "maximum": 1000000,
            "default": 100
          },
          "lengthUnit": {
            "title": "Length unit",
            "type": "string",
            "enum": [
              "mm",
              "in"
            ],
            "default": "mm"
          }
        },
        "required": []
      },
      "OhmforgePcbTraceEstimatorResult": {
        "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": [
              "mode",
              "layer",
              "currentA",
              "widthMm",
              "widthMil",
              "copperThicknessMm",
              "temperatureRiseC",
              "lengthMm",
              "areaMm2",
              "resistanceOhms",
              "voltageDropV",
              "powerLossW",
              "withinChartRange"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "width",
                  "current"
                ]
              },
              "layer": {
                "type": "string",
                "enum": [
                  "external",
                  "internal"
                ]
              },
              "currentA": {
                "type": "number"
              },
              "widthMm": {
                "type": "number"
              },
              "widthMil": {
                "type": "number"
              },
              "copperThicknessMm": {
                "type": "number"
              },
              "temperatureRiseC": {
                "type": "number"
              },
              "lengthMm": {
                "type": "number"
              },
              "areaMm2": {
                "type": "number"
              },
              "resistanceOhms": {
                "type": "number"
              },
              "voltageDropV": {
                "type": "number"
              },
              "powerLossW": {
                "type": "number"
              },
              "withinChartRange": {
                "type": "boolean",
                "description": "False when current, width, temperature rise or copper weight lie outside the IPC-2221 chart range."
              }
            },
            "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"
              }
            }
          }
        }
      }
    }
  }
}