家谱生成服务

Pedigree MCP Server 是一个遵循 Bennett 2008/2022 NSGC 标准的家谱树图生成服务,支持 PNG 和 SVG 格式输出,适用于遗传咨询和家族病史分析。

  • by plemio
  • TypeScript
  • 本地部署
  • 10 星标
  • 更新于
在 GitHub 查看 zzgael/pedigree-mcp

使用说明

家谱MCP服务器

An MCP (Model Context Protocol) server for generating family pedigree tree diagrams as PNG images using standard genetic notation per Bennett 2008/2022 NSGC guidelines.

BRCA1 hereditary breast/ovarian cancer family history demonstrating: 3 generations, affected individuals with combined conditions, MZ identical twins, carrier status, deceased indicators, proband + consultand markers, and gene test results (BRCA1+/BRCA1-)

安装

添加到您的MCP客户端配置中(例如,Claude Desktop):

{
  "mcpServers": {
    "pedigree": {
      "command": "npx",
      "args": ["pedigree-mcp"],
      "env": {}
    }
  }
}

从源代码构建

如果您更喜欢从源代码构建:

git clone https://github.com/zzgael/pedigree-mcp.git
cd pedigree-mcp
npm install
npm run build

然后在MCP客户端配置中使用:

{
  "mcpServers": {
    "pedigree": {
      "command": "node",
      "args": ["/absolute/path/to/pedigree-mcp/dist/index.js"],
      "env": {}
    }
  }
}

特性

Bennett 2008标准合规性

此实施遵循 NSGC标准化人类谱系命名法:

符号 描述 属性
方形 男性 sex: "M"
圆圈 女性 sex: "F"
钻石 未知性别 sex: "U"
填充形状 受影响个体 conditions: [...]
对角线 已故 status: 1
箭头(左下) Proband proband: true
双箭头(左下) 咨询台(寻求咨询的人) consultand: true
括号[] 已采用 noparents: true
双线 血缘关系 自动检测到共享祖先
双线文字 血缘关系 consanguinity_degree: "1st cousins"
横杆 MZ(同卵)双胞胎 mztwin: "group_id"
对角线 DZ(异卵)双胞胎 dztwin: "group_id"
中心点 承运商状态 carrier: true
轮廓点 斜载体(推断) obligate_carrier: true
内部符号“P” 怀孕 pregnant: true
“P”+周标签 妊娠期 pregnant: true, terminated_age: 12
小三角 早期流产(<20周) terminated: true, terminated_age: 8
大三角 死产(≥20周) terminated: true, terminated_age: 24
符号下方的“EP” 异位妊娠 ectopic: true
交叉线(X) 不孕 infertility: true
行上的哈希标记 离婚/分居 divorced: true
通过后代排队 选择不生孩子 no_children_by_choice: true
右上角的“A” 德系犹太人血统 ashkenazi: 1
左上角的“*” 基因预测 anticipation: true
“d.XXy”标签 死亡年龄(自动计算) yob: 1950, yod: 2020, status: 1
箭头+“OUT”标签 采用OUT(放置以供采用) adoption_type: "out"
虚线括号 寄养(临时) adoption_type: "foster"
罗马数字I、II、III 兄弟组中的出生顺序 birth_order: 1 (显示为“I”)
“E”标记(蓝色) ART-卵子供体受孕 art_type: "egg_donor"
“S”标记(蓝色) ART-精子捐献者受孕 art_type: "sperm_donor"
“Em”标记(蓝色) ART-胚胎供体受孕 art_type: "embryo_donor"
“GC”标记(蓝色) ART-妊娠携带者(代孕者) art_type: "surrogate"
“SAB”标签 妊娠结局-自然流产 pregnancy_outcome: "miscarriage"
“TOP”标签 妊娠结局-终止妊娠 pregnancy_outcome: "induced_termination"
“SB”标签 妊娠结局-死产 pregnancy_outcome: "stillbirth"
“Het”标签(绿色) 基因拷贝数-杂合 gene_copy_number: "heterozygous"
“Hom”标签(绿色) 基因拷贝数-纯合 gene_copy_number: "homozygous"
“CH”标签(绿色) 基因拷贝数-复合杂合子 gene_copy_number: "compound_heterozygous"
虚线合伙关系 未婚/普通法合伙关系 relationship_type: "unmarried"

条件(贝内特标准-免费文本)

根据Bennett 2008标准,使用 自由文本只需提供 conditions 具有任何疾病/病症名称的数组:

{
  "conditions": [
    { "name": "Breast cancer", "age": 42 },
    { "name": "Ovarian cancer", "age": 55 }
  ]
}

示例:

  • { "name": "Huntington's disease", "age": 45 }
  • { "name": "Type 2 diabetes" } (无年龄=仅受影响状态)
  • { "name": "Cystic fibrosis" }
  • { "name": "Hereditary hemochromatosis", "age": 38 }

颜色是自动分配的 基于唯一条件名称的调色板。多个条件显示为象限(雄性)或饼片(雌性)。

基因检测结果

支持 基因 -使用模式 {gene}_gene_test:

{
  "brca1_gene_test": { "type": "T", "result": "P" },
  "htt_gene_test": { "type": "T", "result": "P" },
  "apoe_gene_test": { "type": "S", "result": "N" }
}

基因检测结果代码:

  • 类型: T (测试), S (筛选), - (未知)
  • 结果: P (阳性), N (否定), - (未知/VUS)

标签显示为: BRCA1+ (阳性), HTT- (否定)

工具

get_pedigree_documentation

返回有关谱系数据格式的全面文档。 总是先打电话 在生成家谱之前。

generate_pedigree

生成PNG或SVG格式的家谱树。

参数:

参数 类型 默认值 说明
dataset Individual[] 必填 家庭成员数组
width number 800 图像宽度(像素)
height number 600 图像高度(像素)
symbol_size number 35 节点直径(像素)
background string #fffff 背景颜色
labels string[] [年龄] 要显示的属性
format 'png' | 'svg' “png” 输出格式:png(base64图像)或svg(XML文本)

数据格式

单个对象

interface Individual {
  // Required
  name: string;           // Unique ID (max 7 chars)
  sex: "M" | "F" | "U";   // Male, Female, Unknown

  // Identity
  display_name?: string;  // Human-readable name for display (max 13 chars)
  top_level?: boolean;    // Founding individual (no parents)
  proband?: boolean;      // Index case

  // Relationships
  mother?: string;        // Mother's name (must exist in dataset)
  father?: string;        // Father's name (must exist in dataset)

  // Demographics
  age?: number;           // Current age
  yob?: number;           // Year of birth
  status?: number;        // 0 = alive, 1 = deceased

  // Twins (Bennett standard)
  mztwin?: string;        // MZ twin group ID (identical)
  dztwin?: string;        // DZ twin group ID (fraternal)

  // Special indicators (Bennett standard)
  carrier?: boolean;      // Carrier status (dot in center)
  pregnant?: boolean;     // Current pregnancy (P inside symbol)
  terminated?: boolean;   // Stillbirth/SAB (small triangle)
  divorced?: boolean;     // Divorced from partner (hash marks)
  noparents?: boolean;    // Adopted (brackets around symbol)

  // Conditions (Bennett standard - FREE TEXT)
  conditions?: Array<{
    name: string;         // Any condition: "Breast cancer", "Huntington's disease", etc.
    age?: number;         // Age at diagnosis/onset
  }>;

  // Genetic tests (pattern: {gene}_gene_test)
  brca1_gene_test?: { type: "-"|"S"|"T", result: "-"|"P"|"N" };
  brca2_gene_test?: { type: "-"|"S"|"T", result: "-"|"P"|"N" };
  // ... any gene test
}

例子

📸 查看全部21个场景示例→

查看展示Bennett 2008/2022合规性的标准化谱系场景的完整图库,包括性别多样性、双胞胎、血缘关系、ART指标和复杂的多代家庭。

基本三代谱系

[
  {"name": "MGF", "sex": "M", "top_level": true},
  {"name": "MGM", "sex": "F", "top_level": true, "conditions": [{"name": "Breast cancer", "age": 55}]},
  {"name": "Mother", "sex": "F", "mother": "MGM", "father": "MGF", "conditions": [{"name": "Breast cancer", "age": 42}]},
  {"name": "Father", "sex": "M", "top_level": true},
  {"name": "Proband", "display_name": "Sarah", "sex": "F", "mother": "Mother", "father": "Father", "proband": true, "age": 25, "brca1_gene_test": {"type": "T", "result": "P"}}
]

神经系统疾病谱系

[
  {"name": "GF", "sex": "M", "top_level": true, "status": 1, "conditions": [{"name": "Huntington's disease", "age": 52}]},
  {"name": "GM", "sex": "F", "top_level": true},
  {"name": "Father", "sex": "M", "mother": "GM", "father": "GF", "conditions": [{"name": "Huntington's disease", "age": 48}]},
  {"name": "Mother", "sex": "F", "top_level": true},
  {"name": "Proband", "sex": "M", "mother": "Mother", "father": "Father", "proband": true, "age": 25, "carrier": true}
]

双胞胎示例

[
  {"name": "Dad", "sex": "M", "top_level": true},
  {"name": "Mom", "sex": "F", "top_level": true},
  {"name": "Twin1", "sex": "M", "mother": "Mom", "father": "Dad", "mztwin": "mz1"},
  {"name": "Twin2", "sex": "M", "mother": "Mom", "father": "Dad", "mztwin": "mz1"},
  {"name": "DZTwin1", "sex": "M", "mother": "Mom", "father": "Dad", "dztwin": "dz1"},
  {"name": "DZTwin2", "sex": "F", "mother": "Mom", "father": "Dad", "dztwin": "dz1"}
]

具有贝内特特色的复杂家庭

[
  {"name": "GF", "sex": "M", "top_level": true, "status": 1},
  {"name": "GM", "sex": "F", "top_level": true, "carrier": true},
  {"name": "Father", "sex": "M", "mother": "GM", "father": "GF", "divorced": true},
  {"name": "Mother", "sex": "F", "top_level": true},
  {"name": "Child1", "sex": "F", "mother": "Mother", "father": "Father", "proband": true, "noparents": true},
  {"name": "Loss", "sex": "U", "mother": "Mother", "father": "Father", "terminated": true}
]

发展

# Install dependencies
npm install

# Run in development mode (watch)
npm run dev

# Run all tests
npm test

# Build for production
npm run build

# Type check
npx tsc --noEmit

测试

  • 总共159次测试 涵盖:
    • 验证(父母推荐信、性别限制)
    • SVG渲染(所有符号类型、指示器)
    • 条件标记和多条件饼图
    • 基因检测格式
    • 双渲染(MZ带条形,DZ不带条形)
    • 血缘关系检测
    • Bennett 2008合规性(携带者、怀孕、终止妊娠、离婚)
    • 边缘病例(家族深厚、世代广泛、同父异母兄弟姐妹)

参考文献

许可证

MIT许可证-请参阅 许可证