使用说明
Keitaro MCP服务器
MCP服务器 Keitaro跟踪器 API管理员。提供 37工具 用于活动管理、流量分析、报告和原始点击/转换数据——可从以下网址访问 克劳德代码、Cursor和其他MCP兼容的AI代理。
快速开始
先决条件
步骤1:克隆存储库
git clone https://github.com/KeitaroManager/keitaro-mcp.git
选择克隆位置。它可以在任何地方——你的主目录、工具文件夹等:
# Example locations:
git clone https://github.com/KeitaroManager/keitaro-mcp.git ~/keitaro-mcp
git clone https://github.com/KeitaroManager/keitaro-mcp.git ~/tools/keitaro-mcp
git clone https://github.com/KeitaroManager/keitaro-mcp.git /opt/keitaro-mcp
步骤2:安装MCP服务器
从下面两个范围中选择一个。将占位符值替换为真实的跟踪器URL和API键。
选项A——项目范围 (仅在特定项目目录中工作时可用):
cd /path/to/your/project
claude mcp add keitaro -s project \
-e KEITARO_URL=https://your-tracker.example.com \
-e KEITARO_API_KEY=your-api-key-here \
-- uv --directory /absolute/path/to/keitaro-mcp run python -m keitaro_mcp
选项B——用户范围 (适用于全球所有项目):
claude mcp add keitaro -s user \
-e KEITARO_URL=https://your-tracker.example.com \
-e KEITARO_API_KEY=your-api-key-here \
-- uv --directory /absolute/path/to/keitaro-mcp run python -m keitaro_mcp
第3步:完成
重新启动克劳德代码。这 keitaro_* 工具现在可用。尝试:
You: "List my Keitaro campaigns"
You: "Show ROI by campaign for last 7 days"
You: "Create a campaign named Test"
完整示例(复制粘贴就绪)
# 1. Clone
git clone https://github.com/KeitaroManager/keitaro-mcp.git ~/keitaro-mcp
# 2. Install (project scope — run this inside your project directory)
claude mcp add keitaro -s project \
-e KEITARO_URL=https://tracker.mycompany.com \
-e KEITARO_API_KEY=abc123def456 \
-- uv --directory ~/keitaro-mcp run python -m keitaro_mcp
# 3. Restart Claude Code and use it
如何获取API密钥
- 登录您的Keitaro跟踪器管理面板
- 首选 维护→ Users (或单击您的帐户图标→ 账户→ API密钥)
- 点击 创建API密钥
- 复制密钥——创建后无法再次查看
API密钥需要管理员或专家级别的权限。
更新
当新版本发布时,拉取最新代码:
cd /path/to/keitaro-mcp
git pull
就是这样。下次Claude Code启动时,它将自动使用更新的版本。无需重新安装-- uv 直接读取源代码。
卸载
# Remove from project scope
claude mcp remove keitaro -s project
# Or remove from user scope
claude mcp remove keitaro -s user
多个Keitaro实例
如果您有多个Keitaro跟踪器(例如生产+暂存),请创建一个JSON配置文件:
[
{
"name": "production",
"url": "https://tracker.example.com",
"api_key": "prod-api-key",
"description": "Production tracker"
},
{
"name": "staging",
"url": "https://staging.example.com",
"api_key": "staging-api-key",
"description": "Staging tracker"
}
]
保存它(例如。 ~/keitaro-instances.json),然后安装:
claude mcp add keitaro -s project \
-e KEITARO_CONFIG_FILE=/absolute/path/to/keitaro-instances.json \
-- uv --directory /absolute/path/to/keitaro-mcp run python -m keitaro_mcp
当配置多个实例时,工具接受可选 instance 参数。如果只存在一个实例,则会自动选择它。
连接到游标
添加到光标设置(设置→ MCP服务器→ Add):
{
"keitaro": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/keitaro-mcp", "run", "python", "-m", "keitaro_mcp"],
"env": {
"KEITARO_URL": "https://your-tracker.example.com",
"KEITARO_API_KEY": "your-api-key"
}
}
}
它的作用
37工具分类
| 类别 | 工具 | 操作 |
|---|---|---|
| 活动 | 7 | 列出、获取、创建、更新、存档、克隆、启用/禁用 |
| 溪流(流量) | 6 | 列出、获取、创建、更新、删除、启用/禁用 |
| 优惠 | 5 | 列出、获取、创建、更新、存档 |
| 着陆页 | 5 | 列出、获取、创建、更新、存档 |
| 流量来源 | 3 | 列出、获取、创建 |
| 联盟行销 | 3 | 列出、获取、创建 |
| 领域 | 3 | 列出、获取、检查DNS/SSL |
| 群组 | 1 | 按类型列出 |
| 报告 | 1 | 构建聚合报告(维度、度量、筛选器、排序) |
| 点击次数 | 1 | 查询分页的原始点击日志 |
| 转化 | 1 | 分页查询原始转换日志 |
| 平台 | 1 | 列出已配置的实例 |
分析:报表生成器
这 keitaro_build_report 工具是主要的分析界面:
- 30+指标:点击量、转化率、收入、利润、投资回报率、CR、CPC、CPA、EPC、成本、潜在客户、销售额。..
- 50+尺寸:活动、报价、登陆、国家、日期、时间、设备、浏览器、操作系统、sub_id_1..30。。。
- 20+过滤器操作员:EQUALS,greaterthan,包含IN_LIST,BETWEEN,MATCH_REGEXP。..
- 日期范围:任何支持时区的从/到
例子:
User: "Show me ROI by campaign for the last 7 days, sorted by profit"
→ keitaro_build_report(date_from="2026-03-17", date_to="2026-03-24",
dimensions=["campaign"], measures=["clicks", "conversions", "revenue", "profit", "roi"],
sort=[{name: "profit", order: "DESC"}])
原始数据:点击和转换
通过列选择、筛选和分页查询单个点击和转换记录。可用于调试流量质量、检查特定子ID或调查转换。
完整工具列表
Read Tools (safe, no side effects) — 19 tools
| 工具 | 说明 |
|---|---|
keitaro_list_instances |
列出已配置的跟踪器实例 |
keitaro_list_campaigns |
列出活动(支持限制/抵消) |
keitaro_get_campaign |
按ID获取活动 |
keitaro_list_streams |
列出活动的流 |
keitaro_get_stream |
按ID获取流 |
keitaro_list_offers |
列出所有优惠 |
keitaro_get_offer |
按ID获取报价 |
keitaro_list_landing_pages |
列出所有登录页面 |
keitaro_get_landing_page |
按ID获取登录页面 |
keitaro_list_traffic_sources |
列出所有流量来源 |
keitaro_get_traffic_source |
按ID获取流量来源 |
keitaro_list_affiliate_networks |
列出所有联盟网络 |
keitaro_get_affiliate_network |
通过ID获取联盟网络 |
keitaro_list_domains |
列出所有域 |
keitaro_get_domain |
按ID获取域 |
keitaro_list_groups |
按类型列出组 |
keitaro_build_report |
构建汇总分析报告 |
keitaro_get_clicks |
查询原始点击记录 |
keitaro_get_conversions |
查询原始转换记录 |
Write Tools (create, update, modify) — 18 tools
| 工具 | 说明 |
|---|---|
keitaro_create_campaign |
创建新活动 |
keitaro_update_campaign |
更新活动字段 |
keitaro_delete_campaign |
存档活动(软删除,可逆) |
keitaro_clone_campaign |
带有流的重复活动 |
keitaro_toggle_campaign |
启用或禁用活动 |
keitaro_create_offer |
创建新报价 |
keitaro_update_offer |
更新报价字段 |
keitaro_delete_offer |
存档优惠 |
keitaro_create_stream |
在活动中创建流 |
keitaro_update_stream |
更新流字段 |
keitaro_delete_stream |
删除流 |
keitaro_toggle_stream |
启用或禁用流 |
keitaro_create_landing_page |
创建登录页面 |
keitaro_update_landing_page |
更新登录页面 |
keitaro_delete_landing_page |
存档登录页 |
keitaro_create_traffic_source |
创建流量源 |
keitaro_create_affiliate_network |
创建联盟网络 |
keitaro_check_domain |
检查域DNS/SSL状态(触发主动探测) |
建筑
keitaro-mcp/
├── pyproject.toml # Package config, dependencies
├── README.md # This file
├── LICENSE # MIT
├── .env.example # Configuration template
├── keitaro-instances.example.json # Multi-instance config template
└── src/keitaro_mcp/
├── __init__.py # Entry point
├── __main__.py # python -m keitaro_mcp
├── server.py # MCP Server — 37 tools, match/case routing
├── client.py # HTTP client (curl subprocess)
├── registry.py # Multi-instance support
└── errors.py # Error types
为什么使用curl而不是requests/httpx?
Keitaro跟踪器通常位于Cloudflare之后。Python HTTP库(urllib, httpx, requests)使用Cloudflare识别并使用403 Forbidden阻止的TLS指纹。 curl 使用不同的TLS堆栈。这是一个深思熟虑的架构选择。
设计原则
- 低级MCP服务器 和
match/case布线——适用于37+种工具 - 零Python依赖 超越
mcp>=1.0.0--使用系统curl对于HTTP - 多实例 --一台服务器可以连接多个Keitaro跟踪器
- 结构化错误 --所有错误返回JSON
{"error": "..."},服务器永远不会崩溃 - AI优化 --每个工具都有详细的描述,包括字段列表、枚举和使用提示
Keitaro API参考
此服务器包装 Keitaro管理员API v 1.满 OpenAPI规范 覆盖119个端点。此MCP服务器涵盖了最常用的操作。
关键的Keitaro概念:
- 活动 → has 流 (流量)→ 每条溪流都通往 着陆 和 优惠
- 优惠 属于 联盟行销 (用于回发跟踪)
- 流量来源 定义点击的来源(脸书、谷歌等)
- 领域 跟踪器URL是否用于活动链接
- 群组 将活动、优惠和登陆分为不同类别
贡献
- 克隆仓库
- 安装开发依赖项:
uv pip install -e ".[dev]"(或pip install -e ".[dev]") - 进行更改
src/keitaro_mcp/ - 测试:
python -c "from keitaro_mcp.server import TOOLS; print(f'{len(TOOLS)} tools OK')" - 提交PR
要添加新工具,请执行以下操作:
- 将API方法添加到
client.py - 添加
Tool()定义到TOOLS列入server.py - 添加
match case处理程序在call_tool()在server.py
许可证
麻省理工学院
