{
  "openapi": "3.0.3",
  "info": {
    "title": "ChinaTaxCalc — Official Public REST & MCP API",
    "version": "1.0.0",
    "description": "Stateless read-only China Individual Income Tax (IIT) API covering 7-bracket progressive rates, Fapiao-backed expat BIA housing/tuition exemptions, MOF/STA 2023 No. 30 annual bonus cliff diagnostics, STA 2018 No. 56 cumulative withholding, Greater Bay Area 15% fiscal subsidies, 7-hub cross-border benchmarks, 6-year worldwide tax reset logic, and SAFE Circular 2020 No. 14 salary repatriation.",
    "contact": {
      "name": "ChinaTaxCalc",
      "url": "https://chinataxcalc.com",
      "email": "admin@chinataxcalc.com"
    },
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "externalDocs": {
    "description": "ChinaTaxCalc Official Portal",
    "url": "https://chinataxcalc.com"
  },
  "servers": [
    {
      "url": "https://chinataxcalc.com",
      "description": "Production Edge & Cloud Run"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/api/v1/me": {
      "get": {
        "operationId": "verifyApiConnection",
        "summary": "Verify ChinaTaxCalc Connection & Tool Count",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "responses": {
          "200": {
            "description": "Service status and MCP tool inventory count"
          }
        }
      }
    },
    "/api/v1/tools": {
      "get": {
        "operationId": "listChinaTaxCalcTools",
        "summary": "List All ChinaTaxCalc Tools",
        "responses": {
          "200": {
            "description": "JSON schema inventory of all 8 ChinaTaxCalc tools"
          }
        }
      }
    },
    "/api/v1/tools/calculate_china_expat_iit_and_net_salary": {
      "post": {
        "operationId": "calculate_china_expat_iit_and_net_salary",
        "summary": "China Expat IIT, Social Security Cap & BIA Net Pay Engine",
        "description": "Compute annual and monthly net take-home cash, marginal brackets, employer costs, and tax savings from eight Fapiao-backed BIA allowances across six Chinese cities.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "grossAmount": {
                    "type": "number",
                    "description": "Base cash remuneration expressed in the chosen currency before payroll deductions or tax."
                  },
                  "incomePeriod": {
                    "type": "string",
                    "enum": [
                      "monthly",
                      "annual"
                    ],
                    "description": "Specifies whether grossAmount and BIA inputs are monthly or annualized figures."
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "RMB",
                      "USD",
                      "EUR",
                      "GBP",
                      "SGD",
                      "HKD"
                    ],
                    "description": "Reporting currency code used for base pay, BIA items, and returned net figures."
                  },
                  "cityId": {
                    "type": "string",
                    "enum": [
                      "shanghai",
                      "beijing",
                      "shenzhen",
                      "guangzhou",
                      "hangzhou",
                      "chengdu"
                    ],
                    "description": "Municipality determining local social insurance base caps and employer rate tables."
                  },
                  "socialSecurityMode": {
                    "type": "string",
                    "enum": [
                      "exempt",
                      "standard"
                    ],
                    "description": "Select exempt for Shanghai opt-out or treaty protection, otherwise standard capped contributions."
                  },
                  "annualBonus": {
                    "type": "number",
                    "description": "Separate annual lump-sum bonus taxed under MOF/STA Announcement 2023 No. 30."
                  },
                  "housingRental": {
                    "type": "number",
                    "description": "Fapiao-substantiated housing rent allowance matching the chosen incomePeriod and currency."
                  },
                  "childrenEducation": {
                    "type": "number",
                    "description": "Accredited international school tuition reimbursed per period with official invoices."
                  }
                },
                "required": [
                  "grossAmount"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    },
    "/api/v1/tools/simulate_cumulative_monthly_withholding": {
      "post": {
        "operationId": "simulate_cumulative_monthly_withholding",
        "summary": "12-Month Cumulative Payroll Tax Withholding Simulator",
        "description": "Simulate January-to-December paycheck variance under STA Announcement 2018 No. 56, highlighting bracket jump months and lumpy school tuition spikes.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "monthlyGrossRMB": {
                    "type": "number",
                    "description": "Regular monthly gross salary in Chinese Yuan before statutory exemptions or withholdings."
                  },
                  "monthlySSRMB": {
                    "type": "number",
                    "description": "Monthly employee social insurance contribution in RMB (pass 0 when exempt in Shanghai)."
                  },
                  "monthlyBIARMB": {
                    "type": "number",
                    "description": "Average monthly tax-exempt BIA reimbursements in RMB backed by vendor VAT invoices."
                  },
                  "lumpyTuitionMode": {
                    "type": "boolean",
                    "description": "When true, allocates annualTuitionRMB into 50% semiannual offsets during January and August."
                  },
                  "annualTuitionRMB": {
                    "type": "number",
                    "description": "Total annual international school tuition in RMB used when lumpyTuitionMode is enabled."
                  }
                },
                "required": [
                  "monthlyGrossRMB"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    },
    "/api/v1/tools/compare_annual_bonus_separate_vs_combined_tax": {
      "post": {
        "operationId": "compare_annual_bonus_separate_vs_combined_tax",
        "summary": "Annual One-Off Bonus Tax Cliff & Separate Filing Optimizer",
        "description": "Contrast MOF/STA Announcement 30 separate bonus taxation against combined comprehensive filing and warn about statutory bracket cliff traps.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "annualTaxableSalaryRMB": {
                    "type": "number",
                    "description": "Regular annual comprehensive taxable income in RMB after standard 60,000 deduction and exemptions."
                  },
                  "annualBonusRMB": {
                    "type": "number",
                    "description": "One-off year-end bonus amount in RMB under evaluation for separate versus combined treatment."
                  }
                },
                "required": [
                  "annualTaxableSalaryRMB",
                  "annualBonusRMB"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    },
    "/api/v1/tools/analyze_landlord_fapiao_surcharge_roi": {
      "post": {
        "operationId": "analyze_landlord_fapiao_surcharge_roi",
        "summary": "Rental Fapiao Tax Surcharge vs IIT Deduction ROI Analyzer",
        "description": "Evaluate whether paying a landlord surcharge to obtain official housing VAT invoices generates positive after-tax savings at your marginal rate.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "monthlyRentRMB": {
                    "type": "number",
                    "description": "Contractual monthly apartment rent in RMB before any landlord invoice markup."
                  },
                  "surchargeRatePct": {
                    "type": "number",
                    "description": "Percentage fee demanded by the landlord or agent to issue official tax bureau Fapiao (e.g., 5)."
                  },
                  "marginalRate": {
                    "type": "number",
                    "description": "Employee top applicable IIT decimal rate between 0.03 and 0.45 (e.g., 0.30 for 30%)."
                  }
                },
                "required": [
                  "monthlyRentRMB",
                  "surchargeRatePct",
                  "marginalRate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    },
    "/api/v1/tools/calculate_gba_15pct_talent_tax_subsidy": {
      "post": {
        "operationId": "calculate_gba_15pct_talent_tax_subsidy",
        "summary": "Greater Bay Area 15% Overseas Talent Fiscal Rebate Calculator",
        "description": "Quantify municipal fiscal refunds across nine Greater Bay Area hubs like Shenzhen Qianhai and Guangzhou Nansha where effective burden caps at 15 percent.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "actualIITPaidRMB": {
                    "type": "number",
                    "description": "Total China Individual Income Tax actually remitted to the tax bureau for the calendar year in RMB."
                  },
                  "taxableIncomeRMB": {
                    "type": "number",
                    "description": "Corresponding annual taxable income base in RMB used by Qianhai or Nansha fiscal rebate rules."
                  },
                  "gbaCityId": {
                    "type": "string",
                    "enum": [
                      "shenzhen",
                      "guangzhou",
                      "zhuhai",
                      "foshan",
                      "dongguan",
                      "zhongshan",
                      "jiangmen",
                      "huizhou",
                      "zhaoqing"
                    ],
                    "description": "Target Guangdong-Hong Kong-Macao Greater Bay Area municipality administering the 15% refund."
                  }
                },
                "required": [
                  "actualIITPaidRMB",
                  "taxableIncomeRMB"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    },
    "/api/v1/tools/compare_cross_border_relocation_net_pay": {
      "post": {
        "operationId": "compare_cross_border_relocation_net_pay",
        "summary": "China vs US, UK, Germany, Singapore & HK After-Tax Benchmark",
        "description": "Benchmark equivalent USD compensation across seven global financial hubs against Shanghai expat net pay with cost-of-living index comparisons.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "grossUSD": {
                    "type": "number",
                    "description": "Comparable annual gross compensation package denominated in US Dollars."
                  },
                  "comparisonHubs": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "us_ca",
                        "us_ny",
                        "us_tx",
                        "uk_london",
                        "germany",
                        "singapore",
                        "hongkong"
                      ]
                    },
                    "description": "List of overseas jurisdictions to benchmark alongside Shanghai China (defaults to all seven hubs)."
                  },
                  "chinaCityId": {
                    "type": "string",
                    "enum": [
                      "shanghai",
                      "beijing",
                      "shenzhen",
                      "guangzhou",
                      "hangzhou",
                      "chengdu"
                    ],
                    "description": "Mainland Chinese comparison city used for the domestic expat benchmark calculation."
                  },
                  "chinaHousingAllowanceUSD": {
                    "type": "number",
                    "description": "Annual Fapiao-backed housing allowance in USD included inside the China package (defaults to 24000)."
                  }
                },
                "required": [
                  "grossUSD"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    },
    "/api/v1/tools/diagnose_six_year_worldwide_tax_rule": {
      "post": {
        "operationId": "diagnose_six_year_worldwide_tax_rule",
        "summary": "China 6-Year Worldwide Income Rule & 31-Day Reset Diagnostic",
        "description": "Track consecutive 183-day residency years and verify whether a continuous 30+ day absence resets non-domiciled offshore income protection.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "records": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "year": {
                          "type": "number",
                          "description": "Four-digit calendar tax year under review."
                        },
                        "residedOver183Days": {
                          "type": "boolean",
                          "description": "True if physical days inside mainland China reached at least 183 days in that year."
                        },
                        "singleAbsenceOver30Days": {
                          "type": "boolean",
                          "description": "True if at least one single departure outside mainland China exceeded 30 consecutive days."
                        }
                      },
                      "required": [
                        "year",
                        "residedOver183Days",
                        "singleAbsenceOver30Days"
                      ]
                    },
                    "description": "Chronological calendar-year presence flags ordered oldest to newest (up to 6+ years)."
                  }
                },
                "required": [
                  "records"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    },
    "/api/v1/tools/generate_safe_salary_repatriation_checklist": {
      "post": {
        "operationId": "generate_safe_salary_repatriation_checklist",
        "summary": "SAFE Circular [2020] No. 14 Salary Remittance Bank Counter Kit",
        "description": "Assemble the six mandatory counter verification items, Tax App registration tips, and bilingual SAFE quota exemption text for wiring RMB abroad.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "remitAmountRMB": {
                    "type": "number",
                    "description": "After-tax RMB balance intended for outward cross-border bank wire (defaults to 100000)."
                  },
                  "targetCurrency": {
                    "type": "string",
                    "enum": [
                      "USD",
                      "EUR",
                      "GBP",
                      "SGD",
                      "HKD"
                    ],
                    "description": "Foreign settlement currency requested at the Chinese commercial bank counter."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic China IIT, bonus, GBA subsidy, or SAFE compliance output"
          }
        }
      }
    }
  }
}
