@sentientui/mcp 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,70 @@
1
+ # SentientUI — AI Agent Guide
2
+
3
+ SentientUI is a UI personalization platform that assigns visitors to variant components and reorders page sections per persona. The MCP gives agents read + limited write access to project data.
4
+
5
+ ## Key Concepts
6
+
7
+ **Persona / Cluster** — visitors are clustered by behavior into labeled groups. A `reliability_score` (0–1) measures confidence in the assignment. Low reliability means the engine won't personalize for that session even if a cluster is assigned.
8
+
9
+ **Variant** — a version of an adaptive component. Variants start as **draft** after `create_variant`; they must be activated from the dashboard before traffic is assigned. There is no MCP tool to activate or resume variants.
10
+
11
+ **Guardrail** — automatic safety circuit that pauses variants whose CVR drops below threshold. `list_guardrail_events` shows what's been paused. Pausing via `pause_variant` is irreversible via MCP (no resume tool).
12
+
13
+ **Shadow mode** — project-level flag (toggled in dashboard settings). When ON: personalization is computed and logged but visitors receive the default layout/variant. Use it to validate the algorithm before committing to live changes.
14
+
15
+ **Insights** — AI-generated. Two tiers: narrator observations (all plans) + advisor recommendations (Growth tier). Insights go stale after 6 hours. Always check `isStale` before presenting them.
16
+
17
+ **Layout stats** — per-persona section ordering driven by a bandit algorithm. `pulls` = times a layout was applied, `avgReward` = normalized conversion signal (not raw CVR).
18
+
19
+ ## Auth
20
+
21
+ Server keys start with `sk_` — required for the management API. Public keys (`pk_`) are for the React SDK only and will be rejected. Key is scoped to the account; all owned projects are accessible.
22
+
23
+ ## Tool Quick Reference
24
+
25
+ | Tool | Notes |
26
+ |------|-------|
27
+ | `list_projects` | Start here to get project IDs |
28
+ | `get_project_stats` | Health status + 24h event/session volume |
29
+ | `list_components` | Components + variant counts + impression totals |
30
+ | `get_variant_performance` | CVR 7d vs prior 7d + momentum direction |
31
+ | `get_persona_breakdown` | Cluster distribution + avg reliability per cluster |
32
+ | `get_goal_funnel` | Goal hit counts + per-variant completion rates |
33
+ | `list_guardrail_events` | Auto-paused variants (last 24h) |
34
+ | `get_layout_stats` | Per-persona layout order + bandit pulls/reward |
35
+ | `get_insights` | Narrator bullets + (Growth) advisor bullets |
36
+ | `refresh_insights` | Async trigger — wait ~15s then call `get_insights` |
37
+ | `create_variant` | Creates DRAFT — user must activate in dashboard |
38
+ | `pause_variant` | Stops traffic; no MCP resume |
39
+
40
+ ## Canonical Workflows
41
+
42
+ **Diagnose a conversion drop**
43
+ 1. `get_project_stats` — confirm events are flowing
44
+ 2. `get_goal_funnel` — find which goals/variants are down
45
+ 3. `get_variant_performance` — check CVR momentum
46
+ 4. `list_guardrail_events` — see if the guardrail fired
47
+ 5. `refresh_insights` → wait 15s → `get_insights` — read AI summary
48
+
49
+ **Add a new variant**
50
+ 1. `list_components` — confirm the component ID
51
+ 2. `create_variant` — creates draft
52
+ 3. Tell the user to activate it from the dashboard
53
+
54
+ **Understand the audience**
55
+ 1. `get_persona_breakdown` — cluster sizes + reliability
56
+ 2. `get_layout_stats` — what layout order each persona gets
57
+ 3. `get_insights` — AI narrative on what changed
58
+
59
+ **Validate before going live (shadow mode)**
60
+ - Shadow mode is enabled/disabled in the dashboard (Project Settings)
61
+ - When ON: personalization runs silently, no live impact
62
+ - When confident: turn OFF to start serving personalized experiences
63
+
64
+ ## Common Mistakes
65
+
66
+ - Presenting stale insights without checking `isStale` — always check, and offer to `refresh_insights`
67
+ - Assuming `create_variant` is live — it's always a draft
68
+ - Calling `pause_variant` without warning the user it's irreversible via MCP
69
+ - Using a `pk_` key instead of `sk_` — it will be rejected
70
+ - Interpreting `avgReward` in layout stats as a conversion rate — it's a bandit reward signal, not CVR
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # @sentientui/mcp
2
+
3
+ MCP server for [SentientUI](https://sentient-ui.com) — gives AI agents in Claude Code, Cursor, and Copilot direct access to your experiment data and management actions.
4
+
5
+ ## Quick start
6
+
7
+ **1. Get a server key**
8
+
9
+ Dashboard → Project → **Settings → API key → Server key** → Generate (requires Starter or Growth plan).
10
+
11
+ **2. Add to your AI assistant**
12
+
13
+ **Claude Code** — `~/.claude/settings.json`:
14
+ ```json
15
+ {
16
+ "mcpServers": {
17
+ "sentientui": {
18
+ "command": "npx",
19
+ "args": ["-y", "@sentientui/mcp"],
20
+ "env": {
21
+ "SENTIENTUI_API_KEY": "sk_live_your_key_here"
22
+ }
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ **Cursor** — `~/.cursor/mcp.json`:
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "sentientui": {
33
+ "command": "npx",
34
+ "args": ["-y", "@sentientui/mcp"],
35
+ "env": {
36
+ "SENTIENTUI_API_KEY": "sk_live_your_key_here"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ **VS Code + Copilot** — `.vscode/mcp.json`:
44
+ ```json
45
+ {
46
+ "servers": {
47
+ "sentientui": {
48
+ "type": "stdio",
49
+ "command": "npx",
50
+ "args": ["-y", "@sentientui/mcp"],
51
+ "env": {
52
+ "SENTIENTUI_API_KEY": "sk_live_your_key_here"
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ **3. Restart your IDE.** The server connects at startup.
60
+
61
+ ## Demo mode
62
+
63
+ No account? Run without an API key:
64
+
65
+ ```bash
66
+ npx @sentientui/mcp
67
+ ```
68
+
69
+ A sandboxed demo token is provisioned automatically — 10 calls/month, no sign-up required. The token is cached in `~/.config/sentientui/mcp-anon.json`.
70
+
71
+ ## Tools
72
+
73
+ | Tool | What it does |
74
+ |------|-------------|
75
+ | `list_projects` | List all projects in the account |
76
+ | `get_project_stats` | Events, sessions, agent calls, and health status |
77
+ | `list_components` | All adaptive components with variant counts |
78
+ | `get_variant_performance` | CVR, momentum, and impressions per variant (7d vs prior 7d) |
79
+ | `get_insights` | AI-generated narrator observations and advisor recommendations |
80
+ | `refresh_insights` | Trigger fresh AI insight generation |
81
+ | `get_persona_breakdown` | Visitor cluster distribution with reliability scores |
82
+ | `get_goal_funnel` | Goal hit counts and conversion rates per variant |
83
+ | `list_guardrail_events` | Variants auto-paused by the guardrail (last 24h) |
84
+ | `get_layout_stats` | Per-persona section layout rankings and reward weights |
85
+ | `create_variant` | Create a new draft variant (Starter+) |
86
+ | `pause_variant` | Pause a variant to stop traffic assignment |
87
+
88
+ ## Example prompts
89
+
90
+ - *"What projects do I have?"*
91
+ - *"Show me the CVR trends for the hero banner this week"*
92
+ - *"Are any variants paused by the guardrail right now?"*
93
+ - *"What do the AI insights say about what changed this week?"*
94
+ - *"Refresh insights for project X"*
95
+ - *"Create a new variant called 'short-copy' for the pricing CTA"*
96
+
97
+ ## Configuration
98
+
99
+ | Environment variable | Default | Description |
100
+ |----------------------|---------|-------------|
101
+ | `SENTIENTUI_API_KEY` | — | Your `sk_live_...` server key. Required (or demo mode activates). |
102
+ | `SENTIENTUI_API_URL` | `https://api.sentient-ui.com` | Override for self-hosted or staging deployments. |
103
+
104
+ ## Auth model
105
+
106
+ The server key you provide is passed as a `Bearer` token on every call to the SentientUI management API. It is scoped to your account — all projects you own are accessible. Keys are never logged or stored by the MCP package; they exist only in the process environment.
107
+
108
+ Server keys start with `sk_` (not `pk_`). Public keys (`pk_`) are for the React SDK only and will be rejected by the management API.
109
+
110
+ ## AI agent context
111
+
112
+ `AGENTS.md` (included in this package) gives your AI assistant deeper context about SentientUI concepts, tool ordering, and common pitfalls. Wire it up once and it applies to every conversation.
113
+
114
+ | Assistant | How to use |
115
+ |-----------|-----------|
116
+ | **Claude Code** | Copy to `~/.claude/skills/sentientui/SKILL.md` |
117
+ | **Cursor** | Copy to `.cursor/rules/sentientui.mdc` |
118
+ | **GitHub Copilot** | Append to `.github/copilot-instructions.md` |
119
+ | **Other** | Paste into your assistant's system prompt |
120
+
121
+ ## Requirements
122
+
123
+ - Node.js 18+
124
+ - A SentientUI account (or use demo mode)
package/dist/index.cjs CHANGED
@@ -379,7 +379,7 @@ async function main() {
379
379
  if (!apiKey) {
380
380
  apiKey = await resolveDemoToken();
381
381
  }
382
- const client = new ApiClient({ apiKey });
382
+ const client = new ApiClient({ apiKey, baseUrl: process.env.SENTIENTUI_API_URL });
383
383
  const server = createMcpServer(client);
384
384
  const transport = new import_stdio.StdioServerTransport();
385
385
  await server.connect(transport);
package/dist/index.js CHANGED
@@ -378,7 +378,7 @@ async function main() {
378
378
  if (!apiKey) {
379
379
  apiKey = await resolveDemoToken();
380
380
  }
381
- const client = new ApiClient({ apiKey });
381
+ const client = new ApiClient({ apiKey, baseUrl: process.env.SENTIENTUI_API_URL });
382
382
  const server = createMcpServer(client);
383
383
  const transport = new StdioServerTransport();
384
384
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "MCP server for SentientUI — exposes project data and actions to AI agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,7 +18,8 @@
18
18
  },
19
19
  "files": [
20
20
  "dist",
21
- "README.md"
21
+ "README.md",
22
+ "AGENTS.md"
22
23
  ],
23
24
  "scripts": {
24
25
  "build": "tsup",