{
  "openapi": "3.0.3",
  "info": {
    "title": "IXNO Gene Pool API",
    "description": "IXNO 是一个开放的 AI 工具基因池，12000+ 条经过进化验证的代码基因，覆盖中医、软件开发、AI 智能体、办公效率四大领域。免 Key 搜索，免费使用。",
    "version": "1.0.0",
    "contact": {
      "url": "https://ixno.com"
    },
    "license": {
      "name": "Free to use, read-only"
    }
  },
  "servers": [
    {
      "url": "https://ixno.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/v1/search": {
      "get": {
        "summary": "搜索基因",
        "description": "全字段四层回退搜索（FULLTEXT → LIKE → keywords 2-gram → body 全文），中文友好。",
        "operationId": "searchGenes",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "搜索关键词，支持中英文",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "按大类筛选",
            "schema": {
              "type": "string",
              "enum": [
                "中医",
                "软件开发",
                "AI",
                "办公技能",
                "External"
              ]
            }
          },
          {
            "name": "sub",
            "in": "query",
            "required": false,
            "description": "按子类筛选（33 子类，如 经方、方剂学、前端、后端 等）",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "返回条数上限，默认 20",
            "schema": {
              "type": "integer",
              "default": 20,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "搜索结果",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer",
                      "description": "匹配总数"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Gene"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/stats": {
      "get": {
        "summary": "基因池统计",
        "description": "返回基因池总量、领域分布、分类数、适应度均值、层级分布。",
        "operationId": "getStats",
        "responses": {
          "200": {
            "description": "统计信息",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_genes": {
                      "type": "integer"
                    },
                    "total_domains": {
                      "type": "integer"
                    },
                    "tagged_genes": {
                      "type": "integer"
                    },
                    "skill_categories": {
                      "type": "integer"
                    },
                    "fitness_mean": {
                      "type": "number"
                    },
                    "layers": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/genes/{gene_id}": {
      "get": {
        "summary": "获取单条基因详情",
        "operationId": "getGene",
        "parameters": [
          {
            "name": "gene_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "基因详情",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Gene"
                }
              }
            }
          },
          "404": {
            "description": "基因不存在"
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "schemas": {
      "Gene": {
        "type": "object",
        "properties": {
          "gene_id": {
            "type": "string",
            "description": "基因唯一标识"
          },
          "name": {
            "type": "string",
            "description": "基因名称"
          },
          "desc": {
            "type": "string",
            "description": "基因描述"
          },
          "fitness": {
            "type": "number",
            "description": "适应度分数 0-1"
          },
          "domain": {
            "type": "string",
            "description": "所属领域"
          },
          "layer": {
            "type": "string",
            "description": "进化层级"
          },
          "source": {
            "type": "string",
            "description": "来源"
          },
          "method": {
            "type": "string",
            "description": "采集方法"
          },
          "tags": {
            "type": "string",
            "description": "标签 JSON 数组"
          },
          "version": {
            "type": "string",
            "description": "版本号"
          },
          "_score": {
            "type": "number",
            "description": "搜索相关度得分"
          }
        }
      }
    }
  },
  "security": [],
  "x-mcp-endpoint": "https://ixno.com/mcp",
  "x-mcp-tools": [
    {
      "name": "health",
      "description": "检查 IXNO 基因池服务健康状态。当你需要确认服务是否可用时调用。"
    },
    {
      "name": "stats",
      "description": "获取基因池统计信息（总量、领域分布、适应度均值）。当你需要了解基因池规模时调用。"
    },
    {
      "name": "search",
      "description": "当你需要解决复杂的工程或中医问题，或当前缺乏解决方案时，优先调用此工具搜索基因池。若第一次全字段检索无结果，请自动提取更短的核心名词并减少筛选条件再次重试。参数：q(必填,关键词), category(可选,大类), sub(可选,子类), limit(可选,默认20)。"
    }
  ]
}