Skip to main content
Glama
Aiyatullah

estv-tax

by Aiyatullah

Swiss Tax Calculator — MCP Server 与 Python API

Aiyatullah Saiyed 根据 MIT 许可证发布。

这是一个瑞士税务双用途工具包:你可以在自己的应用中将其实例化为 Python API 客户端,或者将其作为 MCP 服务器 运行,供 Claude 等 AI 助手使用。它封装了官方 ESTV Swiss Federal Tax Calculator — 无需 API 密钥或身份验证。

覆盖 2010–2026 纳税年度瑞士所有市镇的所得税、财富税、一次性资本提取税、遗产/赠与税和企业所得税。


功能

类别

工具

家庭税务

find_locationcalculate_taxlist_deductionscalculate_tax_from_taxable_amounts

地区比较

compare_locationsfind_cheapest_nearby

税务规划

plan_capital_withdrawalsdeduction_value

其他税种

calculate_capital_payment_taxcalculate_inheritance_taxcalculate_company_tax

参考资料

explain_tax_bracketsget_tax_years


Related MCP server: Swiss Health MCP Server

快速开始

安装

# Clone the repository
git clone https://github.com/aiyatullah/swiss-tax-calculator-mcp.git
cd swiss-tax-calculator-mcp

# Install dependencies
uv sync

作为 Python API 使用

直接在 Python 代码中导入 EstvClient,以编程方式查询 ESTV 税务计算器。

基础示例 — 查找位置

from estv_mcp import EstvClient

client = EstvClient()

# Search for a municipality by name or postal code
locations = client.search_location("Zug", tax_year=2026)
for loc in locations[:3]:
    print(f"{loc['City']} ({loc['Canton']}) — ID: {loc['TaxLocationID']}")

计算所得税

from estv_mcp.api import EstvClient, RELATIONSHIP, CONFESSION, INCOME_TYPE

client = EstvClient()

# Step 1: Find the tax location
locations = client.search_location("8001", tax_year=2026)
location_id = locations[0]["TaxLocationID"]

# Step 2: Get the tax budget (deduction sheet)
budget = client.tax_budget({
    "SimKey": None,
    "TaxYear": 2026,
    "TaxLocationID": location_id,
    "Relationship": RELATIONSHIP["single"],
    "Confession1": CONFESSION["none"],
    "Confession2": 0,
    "Children": [],
    "Age1": 35,
    "RevenueType1": INCOME_TYPE["employed"],
    "Revenue1": 120_000,
    "Age2": 0,
    "RevenueType2": 0,
    "Revenue2": 0,
    "Fortune": 50_000,
})

# Step 3: Calculate detailed taxes
result = client.detailed_taxes({
    "SimKey": None,
    "TaxYear": 2026,
    "TaxLocationID": location_id,
    "Relationship": RELATIONSHIP["single"],
    "Confession1": CONFESSION["none"],
    "Confession2": 0,
    "Children": [],
    "Age1": 35,
    "RevenueType1": INCOME_TYPE["employed"],
    "Revenue1": 120_000,
    "Age2": 0,
    "RevenueType2": 0,
    "Revenue2": 0,
    "Fortune": 0,
    "Budget": budget,
})

print(f"Total tax: CHF {result['TotalTax']:,.0f}")
print(f"Federal:   CHF {result.get('IncomeTaxFed', 0):,.0f}")
print(f"Cantonal:  CHF {result.get('IncomeTaxCanton', 0):,.0f}")
print(f"Municipal: CHF {result.get('IncomeTaxCity', 0):,.0f}")

比较各市镇

from estv_mcp.api import EstvClient, RELATIONSHIP, CONFESSION, INCOME_TYPE, GROUP_CAPITALS

client = EstvClient()

# Compare tax burden across all 26 cantonal capitals
rows = client.many_simple_taxes({
    "SimKey": None,
    "TaxYear": 2026,
    "TaxGroupID": GROUP_CAPITALS,
    "Relationship": RELATIONSHIP["single"],
    "Confession1": CONFESSION["none"],
    "Confession2": 0,
    "Children": [],
    "Age1": 35,
    "RevenueType1": INCOME_TYPE["employed"],
    "Revenue1": 100_000,
    "Age2": 0,
    "RevenueType2": 0,
    "Revenue2": 0,
    "Fortune": 0,
})

ranked = sorted(rows, key=lambda r: r["TotalTax"])
print("Top 5 cheapest cantonal capitals:")
for r in ranked[:5]:
    loc = r["Location"]
    print(f"  {loc['City']} ({loc['Canton']}): CHF {r['TotalTax']:,.0f}")

遗产税

from estv_mcp.api import EstvClient, BENEFICIARY, GROUP_CAPITALS

client = EstvClient()

# Inheritance tax for a sibling across cantonal capitals
rows = client.many_inheritance_taxes({
    "SimKey": None,
    "TaxYear": 2026,
    "TaxGroupID": GROUP_CAPITALS,
    "OnlyGroupID": BENEFICIARY["sibling"][0],
    "OnlyPersonID": BENEFICIARY["sibling"][1],
    "Donation": False,
    "Amount": 500_000,
})

ranked = sorted(rows, key=lambda r: r["TaxTotal"])
print(f"Cheapest: {ranked[0]['Location']['City']} — CHF {ranked[0]['TaxTotal']:,.0f}")
print(f"Most expensive: {ranked[-1]['Location']['City']} — CHF {ranked[-1]['TaxTotal']:,.0f}")

可用的 API 操作

Method

Description

search_location(query, tax_year)

按名称或邮政编码查找市镇

search_location_geo(lat, lon, radius_km, tax_year)

查找指定半径范围内的市镇

tax_budget(payload)

获取家庭的扣除/预算表

detailed_taxes(payload)

包含详细明细的完整税额计算

simple_taxes(payload)

根据预先计算的应纳税所得额计算税额

many_simple_taxes(payload)

比较多个市镇之间的税额

many_capital_taxes(payload)

跨市镇的一次性资本提取税

many_inheritance_taxes(payload)

跨市镇的遗产/赠与税

many_legal_entity_taxes(payload)

跨市镇的企业税

export_tax_scales(tax_year, tax_group_id)

原始税率表

tax_year_range(calculator)

每个计算器支持的年份范围

tax_version()

当前的 ESTV 数据版本

枚举参考

from estv_mcp.api import (
    RELATIONSHIP,      # single=1, married=2, concubinage=3, registered_partnership=4
    CONFESSION,        # reformed=1, roman_catholic=2, christ_catholic=3, none=4, other=5
    INCOME_TYPE,       # employed=1, self_employed=2, pensioner=3, other=4
    GENDER,            # male=1, female=2
    LANGUAGE,          # de=1, fr=2, it=3, en=4
    CANTON_GROUP,      # AG=1 ... ZH=26
    GROUP_CAPITALS,    # 88 — all 26 cantonal capitals
    GROUP_SWITZERLAND, # 99 — every municipality (~2100)
    CALCULATOR,        # income_wealth=1, capital_payment=2, legal_entity=3, inheritance=5
    BENEFICIARY,       # spouse, child, sibling, unrelated, etc. → (GroupID, PersonID)
)

缓存

响应数据缓存在 ~/.cache/estv-mcp 因素下,存储一周。通过环境变量进行控制:

Variable

Effect

ESTV_MCP_NO_CACHE=1

完全禁用缓存

ESTV_MCP_CACHE_DIR=/path

自定义缓存目录

ESTV_MCP_CACHE_TTL=3600

缓存有效期(秒)


作为 MCP 服务器使用

以 MCP 服务器的形式运行此业务,使 AI 助手(例如 Claude 等)能够使用所有瑞士税务工具。

注册到 Claude Code

# Project-local (this repo only)
claude mcp add estv-tax -- uv run --directory "$PWD" estv-mcp

# User-wide (available in every project)
claude mcp add -s user estv-tax -- uv run --directory "$PWD" estv-mcp

MCP 客户端配置(JSON)

对于任何兼容 MCP 的客户端,请在配置中添加:

{
  "mcpServers": {
    "estv-tax": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/swiss-tax-calculator-mcp", "estv-mcp"]
    }
  }
}

AI 能做到什么

连接成功后,AI 助手可以实现:

  • “在苏黎世,CHF 150,000 需要缴多少税?” — 调用 find_location + calculate_tax

  • “抽查 vs 苏瓦茨,一个已婚家庭有两个小孩” — 调用 compare_locations

  • “苏黎世中央火车站 30 公里内最便宜的地方在哪里?” — 调用 find_cheapest_nearby

  • “我是否应该将第二支柱(pillar 2)的提取分散到多个年份?” — 调用 plan_capital_withdrawals

  • “在日内瓦,兄弟姐妹之间的遗产税是多少?” — 调用 calculate_inheritance_tax

  • “抽查 vs 卢塞恩之公司税?” — 调用 calculate_company_tax


开发

uv sync                                          # Install dependencies (including dev)
uv run pytest -q                                  # Run tests (hits live ESTV API)
uv run python scripts/stdio_smoke.py              # MCP stdio handshake test
uv run ruff check . && uv run ruff format --check .  # Lint & format check

黄金值

tests/golden.json 固定在已闭合的纳税年度的已知税额。每周的 CI 运行都会将这些数值与实时 API 重新验证,以捕捉上游数据的变更。

uv run python scripts/update_golden.py   # Update golden values (prints diffs)

CI

在每个决策提交时都会在 Python 3.11/3.12/3.13 上运行测试,并且有每周定时任务来捕捉 ESTV 数据变化。


重要说明

  • 所有金额均为 每年 CHF(瑞士法郎)

  • income_type='employed' 表示税前工资 — 并自动推导出社会扣缴(AHV/IV/EO、ALV、NBU、BVG)

  • 通过 list_deductions 中的 I D 编号使用 deductions={id: value} 来覆盖扣除项目 (例如隐藏的装有 PRAEMIEN3A,房贷利息对应 SCHULDZINSEN)

  • compare_locations(scope='switzerland') 覆盖约 2,100 个市镇;结果会进行汇总以保持可读性

  • 仅当 confession 不是 none 时,才应用教会税

  • 数值来自纳入官方 ESTV 模型 — 并非具有约束力的税务评估


许可证

MIT 许可证 — 请参见 LICENSE

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    B
    quality
    D
    maintenance
    Enables AI assistants to calculate French individual income tax and retrieve current tax brackets using official government data. Supports household composition calculations and provides up-to-date tax information for French residents.
    11
    14
  • A
    license
    B
    quality
    D
    maintenance
    Provides AI assistants access to 1.6 million Swiss health insurance premium records from 55 insurers across 11 years (2016-2026), enabling price comparisons, historical analysis, and finding the cheapest insurance options based on location, age, and coverage preferences.
    4
    56
    1
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    Provides AI-native access to Swiss Federal Statistical Office datasets through 9 tools for querying education, population, and cross-cantonal comparisons without authentication.
    15
    2
    MIT
  • A
    license
    B
    quality
    C
    maintenance
    Enables AI assistants to answer tax compliance questions (VAT, sales tax, GST) and validate EU VAT numbers in real time via the VIES registry.
    2
    12
    MIT

View all related MCP servers

Related MCP Connectors

  • Current source-cited 2026 US tax constants and calculators for AI agents; every answer cites IRS.

  • Free public tax MCP: GST/VAT, income, company & capital-gains tax for 50+ countries, source-cited.

  • Validate EU, UK, AU VAT numbers for AI agents. EU ViDA e-invoicing compliance.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Aiyatullah/swiss-tax-calculator-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server