segment-mcp

io.github.katekruger由 GitHub 账号 katekruger 发布v0.1.2更新于 Nov 3, 2026

Read-first MCP server for Twilio Segment: routing, stale sources, delivery health, governance.

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

面向 Twilio Segment 的只读 MCP 服务器,可回答哪些目标端接收哪些事件、哪些数据源已失效,以及投递与治理哪里出了问题。

可以做什么
  • 审计事件在各目标端与数据源之间的路由
  • 追踪单个事件名称的去向以及是否受治理规则约束
  • 查找长期无数据的数据源,并区分失效埋点与新建数据源
  • 检查某个目标端是否在静默失败
  • 找出未受治理或放行计划外事件的数据源
  • 每个工具都会组合多次 Segment Public API 调用,返回一个结构化答案
适用场景
适合管理 Segment 工作区的人让助手直接回答路由、数据源失效、投递健康和治理相关问题,免去在大量页面间反复点击。它面向审计与排查,而非修改配置,因为目前不提供任何写入工具。
运行要求
通过 stdio 在本机运行,使用 uvx 从 PyPI 安装(需要 Python/uv)。需要 Team 或 Business 级别的 Segment 工作区、由工作区所有者创建的 Public API 令牌(放在 SEGMENT_API_TOKEN),并显式设置 SEGMENT_REGION 为 us 或 eu。令牌、区域或级别不符时服务器会拒绝启动。需要访问 Segment API 的网络。
安装前请注意
需要一个具备工作区级读取权限的 Segment Public API 令牌,应放在 SEGMENT_API_TOKEN 中,不要写入共享配置。SEGMENT_REGION 必须设置正确,区域填错会静默返回空结果。Profile API 的凭据与空间 ID 目前未被任何工具使用,建议保持未设置。现有工具均为只读;write 与 admin 模式虽存在但暂不启用任何功能。

安装

在 SourceWeft 中

  1. 打开 控制台中的 segment-mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

segment-mcp

[CI] [PyPI] [License: MIT]

A read-first MCP server for Twilio Segment. Answers which destinations get which events, which sources are dead, and which are governed by nothing — the questions nobody can answer without clicking through forty screens.

Read-only by default

SEGMENT_MCP_MODE defaults to read, and every tool this server ships today is a read. Shipping with zero write tools is a feature, not a limitation — see BUILD-PLAN.md §2. write and admin modes exist in the tier model (src/segment_mcp/modes.py) for when gated writes land; right now there is nothing for them to unlock.

What this refuses to do — permanently, not "for now"

POST /regulations and POST /regulations/sources/{id} — workspace-scoped, irreversible deletion or suppression of user data across every source — are unreachable in every mode, with no configuration path to enable them. Three independent things enforce this: the mode-authorization layer refuses it before even checking the current mode, the API client refuses to send the request before it reaches the network, and no tool this server registers references it in any form.

This isn't a gate waiting for the right permission level. It's a line, because these endpoints accept an array of subjects and one malformed or hallucinated call can permanently delete thousands of profiles with no undo. Full reasoning: docs/what-this-refuses-to-do.md.

Quick start

Requires a Segment workspace on Team or Business tier and a Public API token (see Prerequisites below).

bash
gh repo clone katekruger/segment-mcpcd segment-mcpuv synccp .env.example .env      # fill in SEGMENT_API_TOKEN and SEGMENT_REGIONuv run segment-mcp

Point an MCP client (Claude Desktop, Claude Code, etc.) at it over stdio. The server refuses to start — loudly, with a clear message — if the token, region, or workspace tier isn't right; see Startup checks.

The five tools

Each composes several Public API calls into one structured answer, not a raw endpoint dump:

ToolQuestion it answers
audit_event_routingWhich destinations get which events?
trace_eventGiven an event name: where does it go, and is it governed by anything?
find_stale_sourcesWhich sources have no recent data — dead instrumentation vs. simply new?
check_delivery_healthIs this destination silently failing?
find_ungoverned_sourcesWhich sources are governed by nothing, or allowing unplanned events through?

Prerequisites

  • Team or Business tier. The Public API is not available on Free or Add-on plans. There is no workaround, and the server's startup checks fail with a clear message rather than a raw 403 if your workspace doesn't qualify.
  • A Public API token. Only a Workspace Owner can mint one: Segment App → Workspace Settings → Access Management → Tokens → Create Token → Public API (not Config API).

Region configuration

SEGMENT_REGION=us   # or eu

There is no default — you must set this explicitly. An EU workspace whose API calls are pointed at the US endpoint doesn't error; it just silently returns nothing, which is a far worse failure mode than a crash. This server's startup checks call the API once with your configured region and fail loudly if the token doesn't actually belong to it, naming the region that does.

Startup checks

All fatal — the server refuses to start rather than fail confusingly on the first tool call:

  1. SEGMENT_REGION is set and one of us/eu.
  2. SEGMENT_API_TOKEN is present and actually authenticates against that region.
  3. The workspace's tier supports the Public API — a Free-tier workspace gets a clear "requires Team or Business tier" message, not a raw 403.

Modes

SEGMENT_MCP_MODE = read (default) | write | admin
  • read — every tool above. No mutation reachable, at any mode.
  • write — would add Tier 3 replace-semantics changes (none shipped yet), each echoed back for confirmation before executing.
  • admin — would add Tier 2 deletes (none shipped yet), gated behind a typed confirmation naming the exact resource — not just confirm=true.

See src/segment_mcp/modes.py for the full tier model and docs/what-this-refuses-to-do.md for what stays out of scope regardless of mode.

Profile API — a separate, higher trust tier

The Profile API returns PII on named individuals — traits, external IDs, event history, and identity links for a specific person. This is the most privacy-sensitive read anywhere in this server's surface, so it is walled off from everything else:

  • A separate credential, SEGMENT_PROFILE_TOKEN — never the main SEGMENT_API_TOKEN. Also requires SEGMENT_PROFILE_SPACE_ID (your Unify Space ID, not your workspace ID).
  • Explicit opt-in. If SEGMENT_PROFILE_TOKEN is unset, no profile tool is registered — the capability doesn't exist for that server instance.
  • Every lookup is logged — collection, id_type, and the caller — before the request is even sent, via client/profile_api.py's segment_mcp.profile_api logger. The log records that a lookup happened and which profile, as a truncated SHA-256 digest of the lookup key, never the raw identifier — this client never logs the raw identifier itself, and it silences httpx's own request-URL log process-wide at construction so the identifier doesn't leak that way either, since the Profile API puts it in the URL path. The digest cannot be reversed back to the identifier, but repeated lookups of the same profile are still correlatable across log lines for auditing.
  • Lookups are case-sensitive. The wrong case returns an empty result, not an error — this client lowercases every lookup value at its boundary and logs a warning when it had to.

No profile-lookup MCP tool is wired into server.py yet — this is the client and trust-boundary machinery a future tool will be built on, per BUILD-PLAN.md's v0.2 scope.

Development

bash
uv syncuv run pre-commit installuv run ruff check . && uv run ruff format --check . && uv run pyright && uv run pytest

See CONTRIBUTING.md and AGENTS.md.

See also

Every project here shares one idea: a GTM system should refuse to act on data it cannot verify.

campaign-preflight — the same refusal to coerce missing evidence into a pass. insufficient_data is its own state in both.

pipeline-waterfall — downstream of this. Reconciles the bookings and pipeline waterfall, and fails the build rather than reporting a bridge that does not tie out.

License

MIT — see LICENSE.

来源:README.md,提交 22d531d

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.2最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分