@nullplatform/mcp 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +52 -217
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,25 +1,35 @@
1
- # ai-mcp — nullplatform from your code assistant
2
-
3
- An MCP server that turns your code assistant (Claude Code, Cursor, Windsurf, …) into the
4
- **frontend for nullplatform**. Status, deploys, traffic, rollbacks, logs and config — from
5
- the place you already work, aware of the repo you're sitting in.
1
+ <h2 align="center">
2
+ <a href="https://nullplatform.com" target="blank_">
3
+ <img height="100" alt="nullplatform" src="https://nullplatform.com/favicon/android-chrome-192x192.png" />
4
+ </a>
5
+ <br>
6
+ <br>
7
+ nullplatform MCP
8
+ <br>
9
+ </h2>
10
+
11
+ Turn your code assistant (Claude Code, Cursor, Claude Desktop, …) into the **frontend for nullplatform**.
12
+ Deploy, move traffic, roll back, read logs and config — from the place you already work, aware of the
13
+ repo you're in. Most actions take **zero arguments** inside a linked repo.
6
14
 
7
15
  ```text
8
- you › deploy this
9
- claude › 🚀 Deploying #4312 on dev — waiting for instances
16
+ you › deploy this
17
+ claude › Deploying #4312 on dev — waiting for instances
10
18
  Created release 1.4.2 from build #991 (main @ab12cd34)
11
- → Next: traffic percent:25 … traffic action:"finalize"
19
+ → Next: move traffic to 25%
12
20
  ```
13
21
 
14
- ## Why
22
+ ## What it does
15
23
 
16
- The web dashboard walks you through create build release scopedeploy observe.
17
- Your assistant already knows your repo, your branch and what you just changed — so the same
18
- journey collapses into a sentence: most tools work with **zero arguments** inside a linked repo.
24
+ - **Deploy & release** ship the latest build, cut the release, walk traffic (canary 100%), finalize or roll back.
25
+ - **Observe** recent builds, logs, and golden-signal metrics per scope.
26
+ - **Configure** environment variables & file parameters (secret values masked).
27
+ - **"Is anything broken?"** — an org-wide digest across all your apps, no app name needed.
28
+ - **Interactive** — on hosts that render MCP Apps (claude.ai, ChatGPT) you get live panels, a traffic slider, and log/metric views; terminals get clean markdown.
19
29
 
20
- ## 60-second setup
30
+ ## Installation
21
31
 
22
- You need a nullplatform API key. The server runs locally via `npx` — no install, no clone.
32
+ You need a nullplatform API key (create one in the dashboard, or run `np login`). It runs via `npx` — no install, no clone.
23
33
 
24
34
  **Claude Code**
25
35
 
@@ -27,7 +37,7 @@ You need a nullplatform API key. The server runs locally via `npx` — no instal
27
37
  claude mcp add nullplatform -e NP_API_KEY=<your-key> -- npx -y @nullplatform/mcp
28
38
  ```
29
39
 
30
- **Claude Desktop** — Settings → Developer → Edit Config (`claude_desktop_config.json`), then fully restart:
40
+ **Claude Desktop** — Settings → Developer → Edit Config, then fully restart:
31
41
 
32
42
  ```json
33
43
  {
@@ -41,212 +51,37 @@ claude mcp add nullplatform -e NP_API_KEY=<your-key> -- npx -y @nullplatform/mcp
41
51
  }
42
52
  ```
43
53
 
44
- **Cursor / Windsurf / others** — same shape in their `mcp.json` (`command: "npx"`, `args: ["-y", "@nullplatform/mcp"]`).
54
+ **Cursor / Windsurf / others** — same shape in their `mcp.json` (`command: "npx"`, `args: ["-y", "@nullplatform/mcp"]`, `env.NP_API_KEY`).
45
55
 
46
- **Remote/HTTP mode — bring your own key.** `npx -y @nullplatform/mcp --http 8080` → `http://host:8080/mcp`.
47
- The server holds **no credential** (it refuses to start if `NP_API_KEY`/`NP_BEARER` are in its
48
- environment). Every caller authenticates each request with their *own* key, so nullplatform's
49
- RBAC applies to each user individually — you can only see and do what your platform user can:
56
+ ## Usage
50
57
 
51
- ```bash
52
- claude mcp add --transport http nullplatform https://host/mcp \
53
- --header "Authorization: Bearer <your-NP_API_KEY>"
54
- ```
58
+ Open your assistant in a repo linked to a nullplatform application and just ask:
59
+
60
+ - "what's the status?" · "is anything broken?"
61
+ - "deploy this to dev"
62
+ - "move traffic to 50%" · "finalize" · "roll me back"
63
+ - "show logs" · "show metrics"
64
+ - "set `DATABASE_URL` as a secret"
65
+
66
+ Most tools infer the application from your git remote, so you rarely pass arguments. There are also three
67
+ slash-command prompts: **/ship**, **/setup**, **/rollback**.
55
68
 
56
- A pre-issued JWT works in place of the api key, and hosts that reserve `Authorization` can send
57
- `X-NP-API-Key: <key>` instead. Unauthenticated requests get a `401` + `WWW-Authenticate` hint.
58
- `GET /healthz` is the unauthenticated liveness probe. Requests carrying a browser `Origin` are
59
- rejected unless allow-listed (DNS-rebinding guard), there's a 1 MiB body cap, and a generous
60
- per-IP rate limit (default 600 req/min, tunable) so a key-rotating caller can't amplify load
61
- against the platform's `/token`.
62
-
63
- **Deploy it behind a TLS-terminating reverse proxy on a trusted network** — every request
64
- carries a bearer credential, so plain HTTP must never be exposed. The proxy should also enforce
65
- its own per-IP rate limits and connection caps; the in-process limiter is a backstop, not a
66
- replacement. `X-Forwarded-For` is only trusted when `NP_TRUST_PROXY` is set.
67
-
68
- The api_key → access-token **exchange is the trust boundary** and is treated like one. The
69
- customer's key is **never retained**: it arrives with each request, exists only in that
70
- request's async scope, and is used at most once per expiry window to (re)exchange — what's
71
- cached per user (keyed by the key's SHA-256, never the key) is only the platform-issued
72
- short-lived access token. Every credential is verified with the platform *before* it reaches
73
- any tool (invalid ones stop at the edge as `401 invalid_token`), verification and exchange are
74
- single-flighted per credential across concurrent requests, rejected keys are negative-cached
75
- for a minute (they can't hammer the platform's `/token` or evict verified users), and secrets
76
- never appear in logs or error bodies.
77
-
78
- | Env | Meaning |
79
- | --- | --- |
80
- | `NP_API_KEY` | **stdio only** — your API key (exchanged for a bearer automatically) |
81
- | `NP_BEARER` | **stdio only** — a pre-issued token instead (expires; for quick tests) |
82
- | `NP_API_BASE` | Override the API host (default `https://api.nullplatform.com`) |
83
- | `NP_BFF_BASE` | Override the dashboard BFF host (metrics) |
84
- | `NP_ALLOWED_ORIGINS` | `--http` only: comma-separated browser origins allowed to call (server-to-server MCP clients send no Origin and always pass) |
85
- | `NP_RATE_LIMIT_RPM` | `--http` only: per-IP requests/minute (default `600`; `0` disables — rely on the fronting proxy then) |
86
- | `NP_TRUST_PROXY` | `--http` only: set to `1`/`true` to key the rate limit off `X-Forwarded-For` (only behind a proxy that sets it) |
87
- | `NP_LANG` | Fallback answer language (`en`/`es`). The real driver is the **conversation**: every tool takes a `language` argument the assistant sets to the language the user is speaking, which wins over `Accept-Language` (HTTP) and `NP_LANG`/`LANG` (stdio). |
88
-
89
- ## The tools (15)
90
-
91
- Every answer is scannable markdown with one **→ Next:** hint, plus structured JSON for the model.
92
- Write tools are **convergent under retries** — an agent that re-issues a call after a timeout
93
- converges instead of duplicating (see "Built for agents, not browsers" below).
94
-
95
- | Tool | What it does |
96
- | --- | --- |
97
- | `application_get` | **Start here.** Scopes × what's live (release + traffic), latest build/release, next action. Zero-arg in a linked repo; `deployment:<id>` watches one rollout. |
98
- | `organization_get` | Org-wide digest with no web equivalent: what's mid-rollout and what last failed, across all apps. Answers "is anything broken?" without naming an app. |
99
- | `application_list` | Org-wide app search (parallel + cached). |
100
- | `application_build_list` | Recent CI builds — status, branch, commit, age, whether released. Closes the push→CI→deploy gap; `build:<id>` shows its assets. |
101
- | `application_log_list` | Recent log lines for the app/scope. |
102
- | `application_parameter_list` | List configuration parameters (secrets masked). |
103
- | `application_metric_list` | Golden signals per scope — throughput, response time, error rate, CPU, memory — with sparkline trends (1h/3h/24h/7d). |
104
- | `application_deployment_create` | Ship: picks the latest successful build, cuts the release for you (semver bump), targets the only scope — all overridable. Reuses an in-flight rollout on retry. |
105
- | `application_deployment_update` | Move traffic (snaps to 1/5/10/25/50/75/90/95/99/100), `finalize`, or `rollback`. Finds the active rollout itself. |
106
- | `application_release_create` | Cut a release from a build explicitly (reuses an existing one for the same build). |
107
- | `application_parameter_create` | Create/update env vars & file params (mark `secret`) — upserts, never duplicates. Apply on next deploy. |
108
- | `application_create` | Link the current repo as a new application (name/URL inferred from the git remote). Returns the existing app if already linked. |
109
- | `application_scope_create` | Create a deploy target (lists the org's scope types when ambiguous). Returns the existing scope if the name is taken. |
110
- | `application_approval_list` | List the approvals gating an app (e.g. a deploy stuck on a policy) and `approve`/`cancel` one — using your own permissions, so the platform denies what you can't do. |
111
- | `application_service_list` | List an app's dependency services (DBs, queues…) and the provisionable catalog; deep-links into the dashboard to create. |
112
-
113
- Plus three slash-command prompts: **/ship** (deploy + walk traffic to 100% with health checks),
114
- **/setup** (link this repo), **/rollback** (get me out, now).
115
-
116
- ## Built for agents, not browsers
117
-
118
- MCP usage differs from web usage, and the tools are shaped for it:
119
-
120
- - **Convergent writes.** Agents retry on timeout; a web user doesn't double-submit a form. So
121
- every write reconciles against current state instead of blindly POSTing: `application_parameter_create` reuses
122
- an existing parameter definition, `application_release_create` reuses a release already cut from the same
123
- build, `application_create`/`application_scope_create` return the existing entity, and `application_deployment_create` returns the
124
- in-flight rollout for the same release. Re-running a tool is safe.
125
- - **Org-wide reads.** `organization_get` answers cross-application questions ("what's broken?") that the
126
- dashboard only answers one entity-page at a time.
127
- - **Approvals as a loop, not a notification.** When a deploy blocks on a policy, `application_approval_list`
128
- lets the agent see and (if permitted) clear the gate rather than dead-ending.
129
- - **Honest async + permissions.** Long operations say so and hand back an id to re-query;
130
- `401`/`403` surface in plain language because every call carries the caller's own token.
131
-
132
- ## Interactive UI (MCP Apps)
133
-
134
- On hosts that render MCP Apps (claude.ai web/desktop, ChatGPT), the journey is interactive —
135
- text-only hosts (terminals) keep the markdown answers automatically:
136
-
137
- | Widget | Bound to | What you can do in it |
138
- | --- | --- | --- |
139
- | **Application panel** | `application_get`, `application_deployment_create`, `application_deployment_update` | Scope cards with live release/traffic/domain, release chips with one-click **ship**, **Deploy latest**, create-scope when empty — and it morphs into the live rollout: traffic slider (snapped marks), **Finalize**/**Rollback** with confirm, deployment log, self-refreshing. |
140
- | **Create application** | `application_create` | Name + repo + namespace form (opens automatically when no git remote is inferable), creates and reports provisioning. |
141
- | **Parameters** | `application_parameter_list` | Editable table — add env vars/files, mark secrets, save via `application_parameter_create`. |
142
- | **Logs** | `application_log_list` | Terminal pane with filter, refresh and auto-tail. |
143
- | **Metrics** | `application_metric_list` | Golden-signal cards with live canvas charts, window selector (1h/3h/24h/7d), auto-refresh. |
144
- | **Applications** | `application_list` | Filterable picker — click an app to open its panel. |
145
-
146
- Widgets are single self-contained HTML files (~330KB: Preact-compat runtime + the ext-apps
147
- SDK, whose embedded zod accounts for most of it) built inline with esbuild — the sandbox
148
- blocks CDN fetches. They speak MCP Apps protocol `2026-01-26`. They **adopt the host's
149
- design tokens** (`hostContext.styles`: colors, border radii, fonts) so the UI looks native —
150
- Claude-styled in Claude, ChatGPT-styled in ChatGPT — with dark/light handled live and our own
151
- palette only as the fallback for hosts that don't send tokens.
152
-
153
- ## Skills ship with the server
154
-
155
- The connector also ships **operating playbooks** — the methodology travels with the tools:
156
-
157
- | Playbook | Teaches |
158
- | --- | --- |
159
- | `deploying-safely` | Pre-flight checks, canary traffic steps gated on metrics, finalize/rollback criteria |
160
- | `incident-response` | Mitigate-first triage: rollback, then read logs/metrics/params for the cause |
161
- | `platform-conventions` | Entity chain semantics, dimensions, versioning, parameters, traffic lifecycle, known gotchas |
162
-
163
- They're plain markdown under `skills/` — platform teams change agent behavior by editing
164
- text, no server redeploy. The model reads them through the **`playbook_get` tool**: a tool is
165
- the one MCP primitive every coding assistant (Claude Code, Cursor, Claude Desktop, …) exposes
166
- to the model, so this works everywhere and on demand. The server instructions carry the
167
- catalog (name + when-to-use) so the model knows which to read before which task; they're also
168
- listed as passive `playbook://nullplatform/<name>` resources. MCP has no "skills" primitive —
169
- standard Agent Skills load client-side — and the earlier `skill://` scheme made Claude Desktop
170
- route to its native Agent Skills executor ("Unknown skill") instead, which is why this is a
171
- tool.
172
-
173
- ## How it knows your app
174
-
175
- 1. Your client's MCP **roots** (workspace folders) → `git remote get-url origin`
176
- 2. Fallback: the server's working directory
177
- 3. The remote URL is matched against applications' `repository_url` (ssh/https equivalent), then by repo name
178
- 4. No match? Tools say exactly that and offer `application_create` / `application_list`
179
-
180
- ## Design principles
181
-
182
- - **Journey-shaped, not endpoint-shaped** — one tool per developer intent; the API chain
183
- (build → asset → release → deployment) is the server's problem.
184
- - **Defaults that match what you meant** — `application_deployment_create` does what the dashboard needs five screens for.
185
- - **Markdown is the UI** — tables, status glyphs, a traffic bar, one next-step per answer.
186
- - **Honest writes** — provisioning/asynchronous things say so and tell you how to watch;
187
- errors carry the platform's message, never a stack trace.
188
- - **The dashboard stays one click away** — entities link to `https://<org>.app.nullplatform.io/nrn/<nrn>`.
189
-
190
- ## Develop
69
+ ## Self-hosting (multi-user)
70
+
71
+ Run it as a shared HTTP server where every caller brings their own key:
191
72
 
192
73
  ```bash
193
- npm install
194
- npm test # unit + full in-memory MCP round-trips over a fake API (builds widgets first)
195
- npm run lint # Biome (lint + format)
196
- npm run typecheck # server + widgets, strict (noUncheckedIndexedAccess on)
197
- npm run dev # stdio server (tsx)
198
- npm run build # dist/ + minified widgets (NP_WIDGET_DEBUG=1 keeps identifiers)
74
+ npx -y @nullplatform/mcp --http 8080 # → http://host:8080/mcp
199
75
  ```
200
76
 
201
- ### Testing (the MCP way)
202
-
203
- The suite covers every level a real client exercises, without ever touching the live platform:
204
-
205
- | Layer | File | What it proves |
206
- | --- | --- | --- |
207
- | Unit | `test/unit.test.ts` | pure logic: semver, traffic snapping, locale matching, credential parsing, the presenter |
208
- | Protocol round-trip | `test/tools.test.ts` | the **SDK pattern**: a real MCP `Client` over `InMemoryTransport` against the real server — tool surface, text replies, structured contracts, widget bindings, skills, UI negotiation |
209
- | Tool scenarios | `test/scenarios.test.ts` | the behavior matrix: ask-backs (which scope?), dimension targeting, action side effects asserted on the recorded platform calls, 403→permission mapping, partial failures, `#id`/git-remote resolution, prompt rendering per language |
210
- | Widget DOM | `test/widgets.test.tsx` | **ui-mode**: widgets render each tool's `structuredContent` and user actions go back through the (mocked) host bridge as `tools/call` — ship chips, traffic slider snapping, confirm gates, form submission |
211
- | Transport boundary | `test/http.test.ts` | multi-user HTTP: per-request auth, token-exchange trust boundary, isolation, guards, per-request language |
212
- | Black box | `test/stdio.test.ts` | the **raw pattern**: spawns `src/index.ts` as a child process and speaks MCP over stdio like an installed client — entry point, env credential policy, negotiated text-only surface |
213
-
214
- Everything runs against `test/fake-api.ts`, an in-memory fake of the nullplatform API faithful
215
- to the live-verified contract (query scoping, snake_case bodies, async statuses, the multi-asset
216
- deploy trap) — fast, deterministic, and it records every call so action tests assert exactly
217
- what hit the platform.
218
-
219
- ### Layers
220
-
221
- | Layer | Where | What it owns |
222
- | --- | --- | --- |
223
- | Platform API | `src/np/` | auth + token exchange, HTTP client, org context/caches, the typed journey API (builds → releases → scopes → deployments → metrics/logs). Tools never call the raw client — they go through `journey.ts`. |
224
- | Tool framework | `src/tool.ts` | `ToolSpec`/`ToolReply`, the presenter (one place replies become wire results), the per-tool error net |
225
- | Tools | `src/tools/` | one file per tool + `index.ts` registry + `shared.ts` resolution helpers |
226
- | Prompts | `src/prompts.ts` | declarative slash-command prompts |
227
- | Presentation (text) | `src/md.ts`, `src/render.ts` | the markdown design language and views |
228
- | Presentation (ui) | `src/ui.ts`, `src/widgets-react/` | widget registry, MCP Apps glue, the React widgets |
229
- | i18n | `src/i18n.ts` | `en`/`es` catalogs (compile-checked), locale scoping |
230
- | Transport | `src/http.ts`, `src/index.ts` | multi-user HTTP boundary (per-request auth, per-user backends, guards) and stdio entry |
231
- | Assembly | `src/server.ts` | Config → Deps → McpServer, wired from the registries |
232
-
233
- ### Dual-mode replies
234
-
235
- Every tool returns one `ToolReply { markdown, data }`: the markdown is the complete answer
236
- for text hosts, the data feeds both the model (structuredContent) and the bound widget on
237
- ui hosts. In stdio sessions widgets are only registered once the client actually negotiates
238
- the MCP Apps extension; in stateless HTTP they're always offered and hosts that don't speak
239
- the extension simply ignore them (that's the spec's graceful degradation).
240
-
241
- ### Extend
242
-
243
- - **New tool**: create `src/tools/<name>.ts` exporting `defineTool({...})` (schema, handler
244
- returning a `ToolReply`, optional `widget` binding), add it to `src/tools/index.ts`. Its
245
- widget auto-registers; the framework supplies error handling and presentation.
246
- - **New widget**: drop `src/widgets-react/widgets/<name>.tsx`, add it to the `WIDGETS` map in
247
- `src/ui.ts`, bind it from a tool spec. The build picks it up.
248
- - **New prompt**: append a spec to `src/prompts.ts`.
249
- - **New playbook**: drop `skills/<name>/SKILL.md` — picked up automatically by the `playbook_get`
250
- tool and the instruction catalog.
251
- - **New language**: add one catalog object in `src/i18n.ts` — completeness is compile-checked.
252
- - **New platform call**: add a typed function to `src/np/journey.ts`; tools never touch the raw client.
77
+ The server holds **no credentials** — each request authenticates with the caller's own nullplatform key, so
78
+ platform RBAC applies per user. Run it behind a TLS-terminating reverse proxy on a trusted network.
79
+
80
+ ## Documentation
81
+
82
+ Full tool reference, the multi-user security model, design rationale, and the development guide:
83
+ **[docs/ARCHITECTURE.md](https://github.com/nullplatform/ai-mcp/blob/main/docs/ARCHITECTURE.md)**.
84
+
85
+ ## License
86
+
87
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nullplatform/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "nullplatform from your code assistant — an MCP server that replaces the dashboard for the everyday developer journey",
5
5
  "license": "MIT",
6
6
  "author": "nullplatform",