IrishTaxHub MCP服务器
模型上下文协议(MCP)服务器,将IrishTaxHub API操作公开为工具。
此服务器现在使用FastMCP v2进行更简单的生产就绪实现。
特性
- 仅限动态OpenAPI驱动的工具:
- openapi_list_endpoints(tag?) → 发现可用端点 - openapi_get_request_schema(path, method=POST) → 请求体的JSON模式 - openapi_invoke(path, method=POST, body?, params?) → 动态验证和调用
安装
使用诗歌(推荐)或pip。
# With Poetry
poetry install
# Or with pip
pip install -e .
# If running directly with FastMCP CLI
pip install fastmcp配置
设置环境变量(或复制 .env.example 到 .env):
用于生产用途:
export IRISHTAXHUB_BASE_URL="https://prod.aws.irishtaxhub.ie"
export IRISHTAXHUB_TIMEOUT="30"
# OpenAPI source (file or URL). Defaults to "$IRISHTAXHUB_BASE_URL/apispec_1.json".
export IRISHTAXHUB_OPENAPI="https://prod.aws.irishtaxhub.ie/apispec_1.json"
export IRISHTAXHUB_DEVELOPMENT_MODE=false对于本地开发(如果在本地运行API):
export IRISHTAXHUB_BASE_URL="http://localhost:5000"
export IRISHTAXHUB_TIMEOUT="30"
export IRISHTAXHUB_OPENAPI="http://localhost:5000/openapi.json"
export IRISHTAXHUB_DEVELOPMENT_MODE=true运行(本地)
标准I/O服务器(MCP客户端使用):
python -m irishtaxhub_mcp.server
# or via Poetry
poetry run irishtaxhub-mcp
# or run with the FastMCP CLI (equivalent)
fastmcp run src/irishtaxhub_mcp/server.py与Claude Desktop一起使用
将MCP服务器条目添加到您的Claude Desktop配置中(根据需要替换路径):
用于生产用途:
{
"mcpServers": {
"irishtaxhub": {
"command": "python",
"args": ["-m", "irishtaxhub_mcp.server"],
"env": {
"IRISHTAXHUB_BASE_URL": "https://prod.aws.irishtaxhub.ie",
"IRISHTAXHUB_OPENAPI": "https://prod.aws.irishtaxhub.ie/apispec_1.json"
}
}
}
}对于当地发展:
{
"mcpServers": {
"irishtaxhub": {
"command": "python",
"args": ["-m", "irishtaxhub_mcp.server"],
"env": {
"IRISHTAXHUB_BASE_URL": "http://localhost:5000",
"IRISHTAXHUB_OPENAPI": "http://localhost:5000/openapi.json"
}
}
}
}然后重新启动克劳德桌面;工具将显示为 openapi_list_endpoints, openapi_get_request_schema,以及 openapi_invoke.
示例
动态发现+调用:
{
"tool": "openapi_list_endpoints",
"arguments": { "tag": "Tax Calculators" }
}{
"tool": "openapi_get_request_schema",
"arguments": { "path": "/v1/tax/calculators/refund", "method": "POST" }
}{
"tool": "openapi_invoke",
"arguments": {
"path": "/v1/tax/calculators/refund",
"method": "POST",
"body": {
"marital_status": "single",
"year": 2024,
"employment_income": { "income": 50000 }
}
}
}备注
- 工具调用您部署的HTTP API;它们不导入内部Python模块。这使MCP服务器保持轻量级和解耦。
- 动态工具从文件或通过HTTP加载OpenAPI定义。对于当地的发展,你可以指出
IRISHTAXHUB_OPENAPI在你的仓库openapi.yaml--支持Jinja模板。 - 如果您更喜欢进程内使用,您可以在API回购中创建另一个直接导入门面的变体。
克劳德公关评论(GitHub Action)
此仓库包含一个GitHub Action(.github/workflows/claude-pr-review.yml)使用Claude自动审核PR。它需要一个 CLAUDE_CODE_OAUTH_TOKEN 秘密。
生成令牌
- 跑
claude setup-token在您的终端中,这将打开一个浏览器,使用您的Claude帐户进行身份验证,并输出一个OAuth令牌 - 复制令牌
设置秘密
gh secret set CLAUDE_CODE_OAUTH_TOKEN --repo jhurleyai/irishtaxhub-mcp出现提示时粘贴令牌。
何时再生
该令牌与您的Claude订阅绑定。如果您的订阅过期并续订,则现有令牌将无效——您必须运行 claude setup-token 再次并更新秘密。
