← Back to Pull requests

TRT-3105: Create production Sippy MCP server with triage CRUD #4224

Closed
unknown closed this pull request without merging on Nov 25, 2026 20:28 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 17:36 UTC
Author

Summary

Adds a general-purpose Sippy MCP server (sippy, mcp/sippy/) for working with production Sippy data, separate from the existing sippy-dev development server. Component Readiness triage CRUD is its first toolset. It also adds Sippy API support for trusted delegation, so triage authorization and audit records name the requesting user instead of the calling service account.

Jira: TRT-3105. Consumer integration (ship-help-bot / ai-helpers) is TRT-3111. Deployment changes are out of scope and belong in continuous-release-jobs.

Sippy API changes

  • --trusted-delegator <principal> (repeatable, on sippy serve and sippy component-readiness, passed to NewServer). This is an allowlist of exact X-Forwarded-User values. Matching is exact: no wildcards, substrings, suffixes, namespaces, or case folding. Blank or padded entries fail startup. If the flag is absent or empty, no delegation is enabled, and no principal is hard-coded.

  • Delegation middleware (pkg/sippyserver/identity.go, which also holds getUserForRequest and the DEV_MODE mock fallback) runs before any handler:

  • - An allowlisted principal must send a non-blank, trimmed X-Acting-For on mutating requests (anything other than GET/HEAD/OPTIONS). Without one, the request gets 400 and no handler runs, so the bot is never recorded as the user. Reads without the header run as the principal itself.
    - Any other principal's X-Acting-For is ignored.
    - Unauthenticated requests and the DEV_MODE mock user never delegate.
    - getUserForRequest (the shared identity helper) returns the resolved identity, so triage audit logs, force close, Jira filing, symptom edits and BigQuery labels all see the same user. withRequestIdentity runs delegation before request logging so BigQuery labels get the delegated user. Delegation changes only the identity. Endpoints and capabilities are unchanged.
  • Triage create/update/delete return 401 when no user can be determined, instead of writing audit rows with an empty user. Update and delete of a nonexistent triage now return 404 (previously 400 / 500).

  • Bug fix: a full-record PUT that resubmits an unchanged resolved instant keeps the stored resolution_reason (it no longer resets to user, and the client cannot overwrite this system-owned field). The comparison uses time.Equal, because a JSON round trip changes the time's location. This mattered for preserving omitted fields on partial updates.
  • Sippy MCP server (sippy)

  • Extensible layout: the sippy_mcp package holds the runtime. client.py has the shared configuration, the authenticated async HTTP client (SippyClient.send), error mapping, and acting_for validation. triage.py has the triage toolset: TriageService methods, whose docstrings and signatures become the tool descriptions and schemas, plus register_tools, which registers the bound methods. server.py holds only wiring: the TOOLSETS registry and transport settings. A new capability adds a module and a Toolset entry.

  • Five triage tools: list_triages, get_triage, create_triage, update_triage, delete_triage. Every request carries the service account bearer token read from SIPPY_MCP_AUTH_TOKEN_FILE. The mutating tools require acting_for (printable ASCII), which is sent as X-Acting-For. The read tools take no identity.

  • Fails closed. There is no default endpoint, and SIPPY_MCP_API_URL must be https unless it points at a loopback address. URLs with credentials, invalid ports, internal whitespace or control characters, or query/fragment delimiters are rejected, and so is a missing, unreadable, or malformed token file. Loopback requests bypass any inherited HTTP proxy. The server does not load .devcontainer/.env, does not import the dev server, and registers no dev tools.

  • MCP inputs are validated strictly (no coercion such as true to 1); a triage url must be an absolute http(s) URL without whitespace or control characters. The HTTP listener enables FastMCP Host/Origin protection, so only loopback, the bind address, or SIPPY_MCP_ALLOWED_HOSTS values are accepted (421 otherwise).

  • Partial updates: the server fetches the full record, applies only the fields the caller supplied, then sends a full PUT.

  • - null or an omitted field means "keep the current value".
    - description: "" clears the description.
    - resolved and clear_resolved cannot be combined.
    - Regressions change only through explicit add_regression_ids / remove_regression_ids. Empty lists, overlapping ids, already-linked or unlinked ids, and no-op requests are rejected.
    - This read-modify-write is not atomic (Sippy has no version or precondition check), so concurrent writes can overwrite each other (last writer wins). This is documented.
  • Results: create and update return the persisted record from Sippy's POST/PUT response, and delete treats a successful DELETE as confirmed, so no extra reads are made. Mutations are never replayed. A timeout, a truncated response, or a create success without a triage id returns outcome_unknown. Each request is an httpx2 stream wrapped in anyio.fail_after(SIPPY_MCP_REQUEST_TIMEOUT). That one total deadline covers proxy CONNECT, the TLS handshake, headers, and the body (including a chunked trailer), so a trickling peer cannot hold a call open. Whether a request counts as a mutation comes from its HTTP method, and error messages name the failing request (for example PUT /api/component_readiness/triages/5). Bodies over 32 MiB are rejected. list_triages fetches Sippy's unpaginated listing and filters locally (documented). With include_archived, it requests Sippy's existing fields selection without regressions (the full archived listing exceeds the 32 MiB cap), so archived summaries report regression_ids as null and regression_id cannot be combined with include_archived. Errors use stable codes, never include the token, and reduce upstream response bodies to Sippy's JSON message. Redirects are not followed, so the token is never resent.

  • Image: mcp/sippy/Dockerfile plus make sippy-mcp-image. It is a multi-stage build: a ubi9/python-312 builder installs the hashed, locked dependencies (pinned to the same versions as the dev venv) into a virtualenv, and the ubi9/ubi-minimal runtime adds only python3.12, that virtualenv, and the sippy_mcp package directory (no compilers, development packages, or pip). It runs python -m sippy_mcp, so a new toolset module needs no Dockerfile change. It serves streamable-http on 127.0.0.1:8090 (/mcp, /healthz) and runs as UID 1001. No credentials or delegator values are baked in.

  • Snyk: .snyk excludes mcp/sippy/sippy_mcp/server.py, following the existing mcp/server.py entry. Snyk Code flagged its startup token check as path traversal, but the path is operator configuration (SIPPY_MCP_AUTH_TOKEN_FILE, a mounted secret by design). The file is only parsed as a validated bearer token and is never returned to clients. client.py and triage.py are still scanned.
  • Docs

    mcp/sippy/README.md concisely covers the identity contract, configuration, tools, error codes, and how to add a toolset. Also updated: a short config/README.md section on trusted delegators, pkg/api/README.md (MCP listing note and force-close identity), DEVELOPMENT.md, mcp/README.md, and .apm/instructions/mcp.instructions.md (regenerated with make apm).

    Tests

  • Go unit tests:

  • - Resolver with two delegators, an absent or empty allowlist, missing or blank acting-for on mutating and safe methods, an unlisted chai-bot, unauthenticated requests, and suffix/namespace/case/padding mismatches.
    - Middleware tests, including DEV_MODE, and a test that BigQuery request labels carry the delegated user (this guards the middleware order).
    - Every handler that shares the identity helper (create, update, delete, force close, Jira bug).
    - Flag validation and applyResolutionReason.
  • Go e2e (delegation_test.go):

  • - Create/update/delete audit attribution for both e2e delegators, checked in the DB and through the audit API.
    - Missing or blank acting-for, unauthenticated requests, and an unlisted principal, each verified to make no change and write no audit row.
    - Delegator reads without acting-for succeed, 404 for nonexistent records, and resolution-reason preservation.
  • Python unit tests (make test): an in-memory fake Sippy with PUT replacement semantics, plus failure-path tests at the transport seam. They cover config, requests, list/get/create/update/delete, invalid input, not found, failures that are not replayed, unexpected write responses, response deadline and size bounds, tool registration and separation, strict MCP input validation, Host protection, upstream message sanitizing, and the real httpx2 transport. Transport tests cover truncated responses, the size limit, a trickled body and a trickled chunked trailer on a POST each hitting the total deadline without a replay, a trickled HTTPS proxy CONNECT response and TLS handshake each hitting the deadline, and loopback proxy bypass versus proxy use for remote hosts.

  • Python unit tests also cover registering an additional toolset.

  • The Makefile MCP test invocation now includes sippy/. scripts/e2e.sh and the Prow e2e-scripts/sippy-e2e-sippy-e2e-test-commands.sh start the server with the same two --trusted-delegator values (matching the test/e2e/util constants), so the delegation e2e cases always run.
  • Validation

  • make e2e (sippy-dev run_e2e): passed, exit 0, on the PR's commits before they were rebased onto main a10160ef1 (not rerun since). 172 Go tests (2 pre-existing skips; the triage delegation package ran). One earlier run on this tree failed 4 Redis cache-fixture tests (failed to find proper ComponentReport key) unrelated to the diff; the rerun passed.

  • make lint (sippy-dev run_lint): passed on the tree rebased onto main a10160ef1. golangci-lint reported 0 issues, ESLint was clean, and the npm audit passed. make verify-apm also passed.

  • make test (sippy-dev run_tests): passed, exit 0, on the tree rebased onto main a10160ef1. BDD 126 passed, Go 16753 (32 pre-existing skips), Vitest 202 passed, and MCP pytest 502 passed.

  • Image (before the rebase, not rerun since): podman build -f mcp/sippy/Dockerfile mcp/sippy built successfully. Without configuration python -m sippy_mcp exits 2 with the expected configuration error, and the package, httpx2, and anyio import under Python 3.12.
  • No UI changes, so there are no screenshots.

    🤖 Generated with Claude Code

    ---
    Generated with Claude Code

    <!-- coderabbit-review -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added a separate Sippy MCP server for authenticated triage searches and create, update, and delete operations.
    Triage lists can be filtered by type, status, URL, and regression; updates support resolution and regression-link changes.
    Trusted delegators can perform writes on behalf of an identified user, with changes attributed to that user.
    Bug Fixes
    Triage updates that leave the resolution time unchanged now preserve the existing resolution reason.
    * Triage write requests without a user identity are rejected.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: patrickdillon Review duration: 8812m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4224"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%