@layers/amba-mcp 1.0.1 → 4.0.3

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 (37) hide show
  1. package/README.md +17 -19
  2. package/dist/api-client.d.ts +42 -4
  3. package/dist/categories.d.ts +48 -0
  4. package/dist/expo-build-prompt.js +641 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.js +5388 -715
  7. package/dist/lib/aliases.d.ts +36 -0
  8. package/dist/lib/annotations.d.ts +113 -0
  9. package/dist/lib/tool-result.d.ts +51 -0
  10. package/dist/lib/with-pat.d.ts +125 -0
  11. package/dist/resources/amba-setup-economy.d.ts +14 -0
  12. package/dist/resources/amba-setup-engagement.d.ts +16 -0
  13. package/dist/resources/amba-setup-gamification.d.ts +15 -0
  14. package/dist/resources/amba-setup-identity.d.ts +20 -0
  15. package/dist/resources/amba-setup-infrastructure.d.ts +18 -0
  16. package/dist/resources/amba-setup-social.d.ts +15 -0
  17. package/dist/resources/amba-setup.d.ts +56 -0
  18. package/dist/resources/expo-build-prompt.d.ts +35 -0
  19. package/dist/resources/index.d.ts +108 -0
  20. package/dist/resources/prompts.d.ts +13 -0
  21. package/dist/resources/prompts.js +2 -0
  22. package/dist/tools/__test-fixtures__/rename-map.d.ts +19 -0
  23. package/dist/tools/_pat.d.ts +64 -0
  24. package/dist/tools/ai-prompts-admin.d.ts +35 -0
  25. package/dist/tools/auth.d.ts +32 -9
  26. package/dist/tools/billing.d.ts +29 -0
  27. package/dist/tools/collections.d.ts +37 -0
  28. package/dist/tools/domains.d.ts +33 -0
  29. package/dist/tools/email.d.ts +26 -0
  30. package/dist/tools/functions.d.ts +34 -0
  31. package/dist/tools/funnels.d.ts +3 -0
  32. package/dist/tools/invites.d.ts +22 -0
  33. package/dist/tools/secrets.d.ts +31 -0
  34. package/dist/tools/setup.d.ts +1 -1
  35. package/dist/tools/sites.d.ts +37 -0
  36. package/dist/tools/webhooks.d.ts +27 -0
  37. package/package.json +10 -4
@@ -16,18 +16,41 @@
16
16
  * server's public-tools allowlist lets signup/login/refresh through
17
17
  * unauthenticated.
18
18
  * 2. The signup response includes:
19
- * - `pat` — a long-lived Personal Access Token. Use the
20
- * PAT for agent flows: pass it as the inbound
21
- * Bearer for every subsequent MCP call. Survives
22
- * until rotated.
23
- * - `project` — a real isolated Neon-backed project provisioning
24
- * asynchronously. Includes project_id, client_key,
19
+ * - `pat` — a long-lived Personal Access Token.
20
+ * - `project` — a real isolated Amba project (provisioning
21
+ * asynchronously). Includes project_id, client_key,
25
22
  * server_key, provisioning_status, and verify_url.
26
- * Poll `amba_get_provisioning_status` until the
23
+ * Poll `amba_projects_get_provisioning_status` until the
27
24
  * workflow completes (~10s) before issuing
28
25
  * client-plane traffic.
29
- * 3. Re-issue subsequent MCP calls with `Authorization: Bearer <pat>`.
30
- * All downstream tools (`amba_create_project`, etc.) now work.
26
+ * - `mcp_config` — ready-to-paste config snippets for Claude Code,
27
+ * Cursor, and Windsurf. Each entry carries a
28
+ * `path_hint` (where the file usually lives) and a
29
+ * `snippet` (the JSON to merge into that file under
30
+ * `mcpServers.amba`), with the PAT pre-baked into
31
+ * the Bearer header.
32
+ * - `agent_instructions` — short prose telling the calling agent
33
+ * exactly what to do: keep calling tools in this
34
+ * same session with the freshly-minted `pat` arg,
35
+ * and write the snippet to the customer's MCP
36
+ * config for future sessions.
37
+ * 3. Same-session: the PAT is already in hand. Pass it as `pat` on every
38
+ * subsequent `amba_*` tool call this session — `packages/mcp/src/lib/with-pat.ts`
39
+ * injects a `pat` argument on every non-public tool that overrides
40
+ * the inbound Bearer for that one call. No restart, no waiting.
41
+ * 4. Future sessions: the calling agent writes the matching snippet to
42
+ * the customer's MCP client config file (Claude Code: `~/.claude.json`
43
+ * or project-local `.mcp.json`; Cursor: `~/.cursor/mcp.json` or
44
+ * `.cursor/mcp.json`; Windsurf: `~/.codeium/windsurf/mcp_config.json`).
45
+ * Merge with any existing `mcpServers` block rather than overwriting.
46
+ * The next time the MCP client starts, the static
47
+ * `Authorization: Bearer <pat>` header takes over automatically — the
48
+ * `pat` arg becomes optional. The customer does nothing.
49
+ *
50
+ * Browser-based MCP clients (Claude.ai web) cannot read a static config
51
+ * file — they discover the OAuth authorization server instead. For those
52
+ * clients the agent should direct the customer to https://mcp.amba.dev/authorize
53
+ * and complete the OAuth 2.1 + PKCE handshake.
31
54
  *
32
55
  * The PAT can be rotated via `amba_developer_rotate_pat`. The old PAT
33
56
  * stops working immediately on rotation (may take up to 30s to propagate).
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Per-project billing tools — the "pricing-as-API" unlock for agentic
3
+ * onboarding. An AI agent provisioning new features should be able to ask
4
+ * the platform what tier the project is on, how much headroom is left on
5
+ * each metered axis, and what (if anything) needs a human in the loop
6
+ * before the next step.
7
+ *
8
+ * Three tools land here:
9
+ *
10
+ * - `amba_billing_status` — live per-project state (call before
11
+ * provisioning data-heavy workloads).
12
+ * - `amba_billing_tiers` — static catalog of tiers + overage rates
13
+ * (hardcoded so reasoning works offline
14
+ * and stays stable when the API is down).
15
+ * - `amba_billing_set_ceiling` — write-side: cap the monthly bill or
16
+ * remove the cap. Surface to the human
17
+ * before calling.
18
+ *
19
+ * The status + set-ceiling tools call REST endpoints that W2-B is
20
+ * shipping in parallel (`GET/PUT /v1/admin/projects/:id/billing/...`).
21
+ * If those endpoints aren't live yet the calls will surface as 404s
22
+ * via the standard `AmbaApiError` path — no special-casing here.
23
+ *
24
+ * No vendor leakage: field names + descriptions stay in Amba's
25
+ * customer-facing vocabulary (tier, headroom, paused_at, spend_ceiling).
26
+ */
27
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
28
+ import type { ApiClient } from '../api-client.js';
29
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Collection MCP tools — admin (schema + admin-side row CRUD) and
3
+ * client (end-user row CRUD with auto-RLS) surfaces wrapped 1:1 from
4
+ * `apps/api/src/routes/admin/collections.ts`,
5
+ * `apps/api/src/routes/admin/collection-rows.ts`, and
6
+ * `apps/api/src/routes/client/collections.ts`.
7
+ *
8
+ * Two distinct authentication models split the toolset:
9
+ *
10
+ * - **Admin tools** (`amba_collections_create`, `amba_collections_alter`,
11
+ * `amba_admin_insert_row`, etc.) authenticate the **developer/agent**
12
+ * and accept an optional `pat` argument. When omitted, the handler
13
+ * falls back to the inbound Bearer the hosted MCP server forwards
14
+ * into `ApiClient` (or the CLI's `~/.amba/credentials.json`). Admin
15
+ * operations bypass auto-RLS — the developer sees / mutates every
16
+ * row regardless of `user_id`.
17
+ *
18
+ * - **Client tools** (`amba_client_*`) authenticate the **end-user**
19
+ * and require `api_key` (the project's client X-Api-Key) plus an
20
+ * optional `session_token` (the end-user's session Bearer). The
21
+ * server enforces auto-RLS — every read/write is scoped to the
22
+ * signed-in app_user, no opt-out. Most client tools require a
23
+ * `session_token` because the route's `clientSessionAuth` middleware
24
+ * demands one.
25
+ *
26
+ * Wire shape mirrors the route handlers exactly. See the route source
27
+ * for the authoritative contract — these tools are a thin pass-through
28
+ * so future route changes don't force an MCP rewrite.
29
+ *
30
+ * Pat-arg pattern: this file inlines the `pat ?? apiClient.resolveTokenOrNull()`
31
+ * dance described in `packages/mcp/src/lib/with-pat.ts` (task #36's
32
+ * central helper). When that helper lands, this file should migrate to
33
+ * `registerTool(...)` without changing tool semantics.
34
+ */
35
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
36
+ import type { ApiClient } from '../api-client.js';
37
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Domain purchase MCP tools (T-Registrar / task #25).
3
+ *
4
+ * Lets an agent search for an available domain, see its price, and buy it
5
+ * through Amba — Amba registers the domain and connects it to one of the
6
+ * project's sites as a live custom domain with no DNS setup by the customer.
7
+ *
8
+ * Tools:
9
+ * - `amba_domains_search` — find available domains for a query (free).
10
+ * - `amba_domains_check` — authoritative availability + price for
11
+ * specific domains (free).
12
+ * - `amba_domains_purchase` — buy + connect a domain to a site. Returns a
13
+ * QUOTE you must confirm before money moves;
14
+ * re-call with `confirm: true` + the quoted
15
+ * `accept_price_usd` to execute.
16
+ * - `amba_domains_list` — list domains this project has purchased.
17
+ *
18
+ * Money safety: `amba_domains_purchase` never charges on the first call. It
19
+ * returns the price and `confirmation_required: true`; the agent must
20
+ * surface the cost to the user and re-call with `confirm: true` and
21
+ * `accept_price_usd` matching the quote. Even then, the platform only
22
+ * executes a real registration when purchasing is enabled — otherwise it
23
+ * returns the quote with `gated: true`.
24
+ *
25
+ * Provider neutrality: this is "buy a domain through Amba" — the upstream
26
+ * registrar is never named in tool descriptions or output.
27
+ *
28
+ * Authentication: every tool accepts an optional inline `pat` via the
29
+ * `registerTool` helper (see `../lib/with-pat.ts`).
30
+ */
31
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
32
+ import type { ApiClient } from '../api-client.js';
33
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Transactional email tools — agentic configuration of templates,
3
+ * suppressions, sending, and delivery inspection.
4
+ *
5
+ * Mirrors the REST surface in `apps/api/src/routes/admin/email.ts` 1:1 so
6
+ * an agent setting up a project can wire transactional email end-to-end
7
+ * without leaving the agentic context:
8
+ *
9
+ * amba_email_templates_create POST /email/templates (upsert by name)
10
+ * amba_email_templates_list GET /email/templates
11
+ * amba_email_templates_get GET /email/templates/:name
12
+ * amba_email_templates_update PATCH /email/templates/:name
13
+ * amba_email_templates_delete DELETE /email/templates/:name
14
+ * amba_email_suppressions_create POST /email/suppressions
15
+ * amba_email_suppressions_list GET /email/suppressions
16
+ * amba_email_suppressions_delete DELETE /email/suppressions/:email
17
+ * amba_email_send POST /email/send
18
+ * amba_email_deliveries_list GET /email/deliveries
19
+ * amba_email_deliveries_get GET /email/deliveries/:id
20
+ *
21
+ * Descriptions stay provider-neutral — the underlying email delivery
22
+ * provider is never named.
23
+ */
24
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
25
+ import type { ApiClient } from '../api-client.js';
26
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Function-deployment MCP tools (#38).
3
+ *
4
+ * Surfaces every operation `amba functions ...` exposes through the CLI:
5
+ * deploy a bundled script, list deployments, describe one, delete a
6
+ * function (cascade), and full schedule lifecycle (create, pause,
7
+ * resume, trigger now). Logs read is the last operation in the set —
8
+ * Workers Logpush events for a single function over a bounded time
9
+ * range.
10
+ *
11
+ * Wire details:
12
+ * - All routes mount under `/projects/:projectId/functions/*` on the
13
+ * admin API. The `ApiClient` base already includes `/admin`. Every
14
+ * interpolation goes through `encodeURIComponent` so a malformed
15
+ * `project_id`, function `name`, etc. cannot escape the path
16
+ * segment.
17
+ * - `amba_functions_deploy` hits the server-side dispatch upload
18
+ * route (`POST /functions/deploy`, multipart). The CLI used to
19
+ * POST direct to the CDN with the customer's API token; the
20
+ * server-side route landed in UNBURY-10 / S-301 so amba owns the
21
+ * upstream credential. Same upload here from MCP. Client-side
22
+ * bundle size guard mirrors the API's 10 MiB cap to fail fast
23
+ * instead of wasting an upload.
24
+ * - `amba_functions_delete` requires `?confirm=<name>` per the API's
25
+ * guard against typo'd deletes. The tool sets it automatically
26
+ * from the validated input.
27
+ *
28
+ * Authentication: every tool accepts an optional inline `pat` arg.
29
+ * Resolution order is `args.pat ?? inbound-Authorization-Bearer`
30
+ * (see `_pat.ts`).
31
+ */
32
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
33
+ import type { ApiClient } from '../api-client.js';
34
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { ApiClient } from '../api-client.js';
3
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Project membership + invite tools — agentic collaboration.
3
+ *
4
+ * Per the wave-2 schema (`infra/neon/control/027_project_billing.sql`),
5
+ * a project is owned by one developer (the existing `projects.developer_id`
6
+ * column) but can have additional members invited by email. Roles:
7
+ *
8
+ * - admin: manage members + integrations
9
+ * - member: write data
10
+ * - viewer: read-only
11
+ *
12
+ * Owners cannot be removed; transfer ownership first via
13
+ * `amba_projects_transfer_owner`. Members can remove themselves.
14
+ *
15
+ * The REST endpoints these tools call are shipped by W2-C in parallel
16
+ * (`/v1/admin/projects/:id/invites`, `.../members`, `.../members/:dev_id`,
17
+ * `.../transfer-ownership`). If those aren't live yet, calls surface as
18
+ * 404 via `AmbaApiError`.
19
+ */
20
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
21
+ import type { ApiClient } from '../api-client.js';
22
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Secret MCP tools (#38).
3
+ *
4
+ * Wraps the customer secrets proxy (UNBURY-10 / S-401). A secret is either
5
+ * FUNCTION-SCOPED (`function` set) or PROJECT-WIDE (`function` omitted —
6
+ * one value visible to every function in the project, including ones
7
+ * deployed later). The API carries this via the optional `function` field
8
+ * on POST and the optional `?function=` query param on DELETE. Secrets may
9
+ * be set BEFORE the function is deployed — the sync drains once a
10
+ * deployment lands.
11
+ *
12
+ * Naming:
13
+ * - Secret name: /^[A-Z][A-Z0-9_]{0,62}$/ (uppercase env-var shape).
14
+ * - Function name: /^[a-z][a-z0-9_-]{0,57}$/ (matches the function
15
+ * deploy validator one-for-one).
16
+ *
17
+ * Reserved binding names (AMBA_INTERNAL_TOKEN, EDGE_HEADER_SIGNING_SECRET,
18
+ * STORAGE, EDGE_DB_PROXY, AMBA_API_URL, AMBA_AI_GATEWAY_URL,
19
+ * AMBA_PROJECT_ID) are blocked at the API layer — the proxy returns
20
+ * 400 RESERVED_BINDING. Don't try to shadow them.
21
+ *
22
+ * Plaintext values are NEVER returned. `amba_secrets_list` returns
23
+ * name + version + sync_status (pending/syncing/synced/failed) only.
24
+ *
25
+ * Authentication: every tool accepts an optional inline `pat` arg via the
26
+ * `registerTool` helper in `../lib/with-pat.ts`. Resolution: `args.pat ??
27
+ * inbound-Authorization-Bearer`, with `MISSING_PAT` short-circuit if neither.
28
+ */
29
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
30
+ import type { ApiClient } from '../api-client.js';
31
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -1,3 +1,3 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import type { ApiClient } from '../api-client.js';
3
- export declare function registerTools(server: McpServer, _apiClient: ApiClient): void;
3
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Static-site MCP tools (#38).
3
+ *
4
+ * Mirrors the CLI's `amba sites ...` surface so an agent can register a
5
+ * static site, deploy files, attach custom domains, and tear everything
6
+ * down — all through MCP, no human-in-loop.
7
+ *
8
+ * Wire details:
9
+ * - `amba_sites_deploy` is create-or-deploy in one shot: it POSTs `/sites`
10
+ * to mint the row (tolerating `ALREADY_EXISTS`), then POSTs the
11
+ * per-file multipart bundle to `/sites/:name/deployments`. The two-call
12
+ * pattern matches the CLI's flow exactly, just collapsed for agent
13
+ * ergonomics — one tool call, one canonical public URL out. The
14
+ * 409-tolerance branch is now driven by the upstream `error.code`
15
+ * (via `AmbaApiError`), not regex over the prose, so an unrelated
16
+ * 409 (e.g. quota) is NOT silently swallowed.
17
+ * - `amba_sites_add_domain` runs the upstream custom hostname
18
+ * registration server-side (Wave-3 / #100); customers no longer
19
+ * need a direct upstream API token client-side.
20
+ * - `amba_sites_remove_domain` is idempotent — a 404 from the API is
21
+ * treated as success (the row was already gone).
22
+ *
23
+ * Files: pass an object keyed by repo-relative path
24
+ * (e.g. {"index.html": "<!doctype html>...", "assets/main.css": "..."}).
25
+ * Each value is the file content as a string. Per-file cap is 25 MiB.
26
+ *
27
+ * Hostname inputs are lowercased at the tool boundary (HTTP semantics
28
+ * + matches the API's storage normalisation) so a customer typing
29
+ * "App.Example.com" doesn't end up with an unfindable binding.
30
+ *
31
+ * Authentication: every tool accepts an optional inline `pat` arg via the
32
+ * `registerTool` helper in `../lib/with-pat.ts`. Resolution: `args.pat ??
33
+ * inbound-Authorization-Bearer`, with `MISSING_PAT` short-circuit if neither.
34
+ */
35
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
36
+ import type { ApiClient } from '../api-client.js';
37
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Outbound webhook subscription tools — agentic configuration of
3
+ * server-to-server event delivery.
4
+ *
5
+ * A webhook subscription registers an HTTPS endpoint that Amba POSTs to
6
+ * (HMAC-signed) whenever a matching engagement event fires. These tools
7
+ * mirror the REST surface 1:1 so an agent can stand up, inspect, test, and
8
+ * troubleshoot subscriptions without leaving the agentic context:
9
+ *
10
+ * amba_webhooks_create POST /webhooks/subscriptions
11
+ * amba_webhooks_list GET /webhooks/subscriptions
12
+ * amba_webhooks_get GET /webhooks/subscriptions/:id
13
+ * amba_webhooks_update PATCH /webhooks/subscriptions/:id
14
+ * amba_webhooks_delete DELETE /webhooks/subscriptions/:id
15
+ * amba_webhooks_rotate_secret POST /webhooks/subscriptions/:id/rotate-secret
16
+ * amba_webhooks_test POST /webhooks/subscriptions/:id/test
17
+ * amba_webhooks_deliveries_list GET /webhooks/deliveries
18
+ * amba_webhooks_deliveries_get GET /webhooks/deliveries/:id
19
+ * amba_webhooks_deliveries_replay POST /webhooks/deliveries/:id/replay
20
+ *
21
+ * Param schemas are derived from the REST request shapes in
22
+ * `apps/api/src/routes/admin/webhooks.ts`. Descriptions stay
23
+ * provider-neutral — the underlying delivery infrastructure is never named.
24
+ */
25
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
26
+ import type { ApiClient } from '../api-client.js';
27
+ export declare function registerTools(server: McpServer, apiClient: ApiClient): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layers/amba-mcp",
3
- "version": "1.0.1",
3
+ "version": "4.0.3",
4
4
  "license": "Apache-2.0",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -12,6 +12,10 @@
12
12
  ".": {
13
13
  "types": "./dist/index.d.ts",
14
14
  "import": "./dist/index.js"
15
+ },
16
+ "./prompts": {
17
+ "types": "./dist/resources/prompts.d.ts",
18
+ "import": "./dist/resources/prompts.js"
15
19
  }
16
20
  },
17
21
  "files": [
@@ -22,12 +26,13 @@
22
26
  "dependencies": {
23
27
  "@modelcontextprotocol/sdk": "^1.12.1",
24
28
  "zod": "^3.25.0",
25
- "@layers/amba-shared": "1.0.0"
29
+ "@layers/amba-shared": "4.0.3"
26
30
  },
27
31
  "devDependencies": {
28
32
  "@types/node": "^22.10.2",
29
33
  "tsdown": "^0.12.5",
30
- "typescript": "^5.8.3"
34
+ "typescript": "^5.8.3",
35
+ "vitest": "^3.2.4"
31
36
  },
32
37
  "repository": {
33
38
  "type": "git",
@@ -43,9 +48,10 @@
43
48
  },
44
49
  "description": "MCP server tools for amba — agentic developer onboarding, project provisioning, and SDK introspection over the Model Context Protocol.",
45
50
  "scripts": {
46
- "build": "tsdown && tsc --emitDeclarationOnly",
51
+ "build": "tsdown && tsc --emitDeclarationOnly --project tsconfig.build.json",
47
52
  "dev": "tsdown --watch",
48
53
  "typecheck": "tsc --noEmit",
54
+ "test": "vitest run",
49
55
  "clean": "rm -rf dist"
50
56
  }
51
57
  }