Agent integration examples

Copy-paste ChurnWin workflows for your agent stack

Start with a read-only ChurnWin key, choose one connected business, and give your agent aggregate churn evidence. Each recipe keeps billing, customer contact, and production changes under human control.

Claude, Cursor, OpenAI, LangChain, and LangGraph are referenced only to explain compatible workflows. No endorsement or partnership is implied.

Claude Desktop / Claude Code

MCP

Setup prerequisites

A ChurnWin account, one connected Stripe business, a read-only Agent Access key, and an MCP-capable Claude client.

Copy-paste starter

{
  "mcpServers": {
    "churnwin": {
      "url": "https://api.churnwin.com/mcp/",
      "headers": {
        "Authorization": "Bearer cwk_live_YOUR_KEY_HERE"
      }
    }
  }
}

Example prompt

Use ChurnWin to list my connected businesses, then inspect 90-day churn reasons and the stored action plan for <business-id>. Rank two retention hypotheses by MRR impact. Redact names, emails, Stripe IDs, and raw comments. Do not contact customers or change billing.

Expected redacted result

Synthetic shape for verification; your aggregate values will differ.

{
  "business": "synthetic.example",
  "period": "90d",
  "top_theme": "failed_payment",
  "mrr_affected": 320,
  "next_step": "Review retry and card-update friction",
  "customer_identifiers": "[redacted]"
}
Open the Claude setup guide

Cursor / MCP-capable IDEs

MCP

Setup prerequisites

A ChurnWin Agent Access key and an IDE that supports remote MCP servers with bearer headers.

Copy-paste starter

{
  "mcpServers": {
    "churnwin": {
      "url": "https://api.churnwin.com/mcp/",
      "headers": {
        "Authorization": "Bearer cwk_live_YOUR_KEY_HERE"
      }
    }
  }
}

Example prompt

Before changing code, call ChurnWin for 90-day churn reasons and the current action plan for <business-id>. Propose one small issue with a measurable retention hypothesis and tests. Use aggregate evidence only and require human review before opening a PR.

Expected redacted result

Synthetic shape for verification; your aggregate values will differ.

{
  "business": "synthetic.example",
  "period": "90d",
  "top_theme": "failed_payment",
  "mrr_affected": 320,
  "next_step": "Review retry and card-update friction",
  "customer_identifiers": "[redacted]"
}
Review the MCP connection steps

OpenAI Agents / Responses API

REST + Responses

Setup prerequisites

Python with requests and the OpenAI SDK, CHURNWIN_AGENT_KEY and OPENAI_MODEL in the environment, and an OpenAI API key. Choose one connected ChurnWin business first.

Copy-paste starter

import os
import requests
from openai import OpenAI

base = "https://api.churnwin.com/api/v1/agent"
headers = {"Authorization": f"Bearer {os.environ['CHURNWIN_AGENT_KEY']}"}
params = {"period": "90d", "business": "<business-id>"}

response = requests.get(
    f"{base}/churn-reasons", headers=headers, params=params, timeout=10
)
response.raise_for_status()
aggregate_reasons = response.json()

client = OpenAI()
result = client.responses.create(
    model=os.environ["OPENAI_MODEL"],
    input=[
        {"role": "system", "content": "Use aggregate churn evidence only. Redact identifiers and require human review."},
        {"role": "user", "content": f"Draft two retention hypotheses from: {aggregate_reasons}"},
    ],
)
print(result.output_text)

Example prompt

Fetch aggregate churn reasons from ChurnWin, then ask a Responses-compatible model for two bounded retention hypotheses. Never pass customer-level rows or raw comments into the model.

Expected redacted result

Synthetic shape for verification; your aggregate values will differ.

{
  "business": "synthetic.example",
  "period": "90d",
  "top_theme": "failed_payment",
  "mrr_affected": 320,
  "next_step": "Review retry and card-update friction",
  "customer_identifiers": "[redacted]"
}
Check the REST endpoint contract

LangChain / LangGraph

REST tool

Setup prerequisites

Python with requests and langchain-core, CHURNWIN_AGENT_KEY in the environment, and an explicit business scope.

Copy-paste starter

import os
import requests
from langchain_core.tools import tool

@tool
def get_churn_reasons(period: str = "90d") -> dict:
    """Return aggregate ChurnWin reason counts for one approved business."""
    response = requests.get(
        "https://api.churnwin.com/api/v1/agent/churn-reasons",
        headers={"Authorization": f"Bearer {os.environ['CHURNWIN_AGENT_KEY']}"},
        params={"period": period, "business": "<business-id>"},
        timeout=10,
    )
    response.raise_for_status()
    return response.json()

# Bind get_churn_reasons to your LangChain agent or LangGraph node.
# Keep customer contact, billing changes, and deployments outside the tool.

Example prompt

Call get_churn_reasons once. Return the highest-impact aggregate theme, one product hypothesis, and one metric to watch. Do not infer customer identity or execute the recommendation.

Expected redacted result

Synthetic shape for verification; your aggregate values will differ.

{
  "business": "synthetic.example",
  "period": "90d",
  "top_theme": "failed_payment",
  "mrr_affected": 320,
  "next_step": "Review retry and card-update friction",
  "customer_identifiers": "[redacted]"
}
Review Agent Access security

Human-review and privacy guardrail

Add this line to every agent prompt that uses churn evidence:

Use ChurnWin as evidence, not authority. Redact names, emails, Stripe IDs, and raw comments. Do not contact customers, change billing, or deploy production changes without human approval.
Read the Agent Access security model

Ready-made ChurnWin workflows

Claude retention analyst

A dedicated Claude MCP setup and scoped churn-analysis prompt.

Open workflow

Hermes feedback-to-issues loop

A deduped, privacy-safe GitHub issue loop with a bounded write budget.

Open workflow

OpenClaw retention coding task

A human-reviewed coding workflow grounded in ChurnWin evidence.

Open workflow

Start with MCP or REST

MCP is the shortest path for compatible agent clients. REST is the portable option for custom runtimes and framework tools.