{
  "openapi": "3.0.3",
  "info": {
    "title": "BaziTools — Official Public REST & MCP API",
    "version": "1.0.2",
    "description": "BaziTools computes traditional Chinese Four Pillars of Destiny (BaZi) charts using astronomical Equation of Time and birth-longitude True Solar Time corrections. It identifies the Day Master (Heavenly Stem), balances Five Elements (Wood, Fire, Earth, Metal, Water), and pairs favorable elements with authentic classical Chinese names sourced from the Classic of Poetry (Shijing), Songs of Chu (Chuci), and Tang poetry. Available on the web, GitHub (`bazitools-mcp`), Vercel `skills.sh`, ClawHub, and public MCP/OpenAPI.",
    "contact": {
      "name": "BaziTools",
      "url": "https://bazitools.com",
      "email": "admin@bazitools.com"
    },
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "externalDocs": {
    "description": "BaziTools Official Web Workbench",
    "url": "https://bazitools.com"
  },
  "servers": [
    {
      "url": "https://bazitools.com",
      "description": "Production Cloudflare Global Edge"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Optional API Key for Albato / automation tracking (e.g. pk_live_bazitools_2026)"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/api/v1/me": {
      "get": {
        "operationId": "verifyApiConnection",
        "summary": "Verify BaziTools API Key & Service Health",
        "description": "Authentication test and metadata endpoint for Albato App Integrator, RapidAPI, Make, and custom workflows.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "responses": {
          "200": {
            "description": "Authenticated connection status and tool count",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "authenticated": {
                      "type": "boolean",
                      "example": true
                    },
                    "service": {
                      "type": "string",
                      "example": "BaziTools"
                    },
                    "domain": {
                      "type": "string",
                      "example": "bazitools.com"
                    },
                    "version": {
                      "type": "string",
                      "example": "1.0.2"
                    },
                    "toolsCount": {
                      "type": "integer",
                      "example": 4
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools": {
      "get": {
        "operationId": "listAvailableTools",
        "summary": "List All BaziTools Read-Only Tools & Schemas",
        "responses": {
          "200": {
            "description": "Array of available read-only tools"
          }
        }
      }
    },
    "/api/mcp": {
      "get": {
        "operationId": "getMcpServerMetadata",
        "summary": "Get BaziTools MCP Server Metadata",
        "responses": {
          "200": {
            "description": "MCP Server metadata and Grade-A tool annotations"
          }
        }
      },
      "post": {
        "operationId": "invokeMcpJsonRpc",
        "summary": "Execute Streamable HTTP JSON-RPC 2.0 MCP Request",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jsonrpc",
                  "id",
                  "method"
                ],
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "example": "2.0"
                  },
                  "id": {
                    "type": "integer",
                    "example": 1
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "initialize",
                      "tools/list",
                      "tools/call"
                    ],
                    "example": "tools/list"
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 response envelope"
          }
        }
      }
    },
    "/api/v1/tools/calculate_bazi_four_pillars": {
      "post": {
        "operationId": "calculate_bazi_four_pillars",
        "summary": "True Solar Time Four Pillars (BaZi) & Day Master Calculator",
        "description": "Calculate Year, Month, Day, and Hour Four Pillars of Destiny (BaZi) with astronomical Equation of Time and birth-longitude True Solar Time correction.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "year": {
                    "type": "integer",
                    "description": "Gregorian birth year (e.g. 1994)"
                  },
                  "month": {
                    "type": "integer",
                    "description": "Birth month 1-12"
                  },
                  "day": {
                    "type": "integer",
                    "description": "Birth day 1-31"
                  },
                  "hour": {
                    "type": "integer",
                    "description": "Birth clock hour 0-23 (default: 12)"
                  },
                  "longitude": {
                    "type": "number",
                    "description": "Birth city longitude (e.g. -122.4 for SF, 121.5 for Shanghai)"
                  }
                },
                "required": [
                  "year",
                  "month",
                  "day"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON output from calculate_bazi_four_pillars"
          }
        }
      }
    },
    "/api/v1/tools/generate_poetic_chinese_names": {
      "post": {
        "operationId": "generate_poetic_chinese_names",
        "summary": "Classical Shijing & Chuci Chinese Name Generator",
        "description": "Generate authentic Chinese given names with Pinyin tone marks, Five-Element balance, and poetic verses from Classic of Poetry (Shijing), Songs of Chu (Chuci), and Tang poetry.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "favorableElement": {
                    "type": "string",
                    "enum": [
                      "Wood",
                      "Fire",
                      "Earth",
                      "Metal",
                      "Water"
                    ],
                    "description": "Favorable Five Element (Xi Yong Shen)"
                  },
                  "surname": {
                    "type": "string",
                    "description": "Optional Chinese surname (e.g. \"林\", \"陈\", \"李\")"
                  }
                },
                "required": [
                  "favorableElement"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON output from generate_poetic_chinese_names"
          }
        }
      }
    },
    "/api/v1/tools/lookup_ten_heavenly_stems_guide": {
      "post": {
        "operationId": "lookup_ten_heavenly_stems_guide",
        "summary": "Ten Heavenly Stems (TianGan) Day Master Archetype Lookup",
        "description": "Look up Yin/Yang polarity, Five-Element nature, and classical imagery for any of the 10 Heavenly Stems (Jia, Yi, Bing, Ding, Wu, Ji, Geng, Xin, Ren, Gui).",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "stem": {
                    "type": "string",
                    "description": "Pinyin or Hanzi stem (e.g. \"Jia\", \"Bing\", \"Geng\", \"Ren\", \"甲\", \"壬\")"
                  }
                },
                "required": [
                  "stem"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON output from lookup_ten_heavenly_stems_guide"
          }
        }
      }
    },
    "/api/v1/tools/lookup_chinese_surname_origins": {
      "post": {
        "operationId": "lookup_chinese_surname_origins",
        "summary": "Common Chinese Surname Pinyin, Tone & Meaning Reference",
        "description": "Look up Mandarin Pinyin with tone marks, character strokes, Five-Element resonance, and historical origins of major Chinese surnames.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "surname": {
                    "type": "string",
                    "description": "Surname in English Pinyin or Hanzi (e.g. \"Wang\", \"Li\", \"Zhang\", \"Chen\", \"Liu\", \"Lin\")"
                  }
                },
                "required": [
                  "surname"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic JSON output from lookup_chinese_surname_origins"
          }
        }
      }
    }
  }
}