@layers/amba-mcp 4.0.11 → 4.0.12

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/README.md CHANGED
@@ -33,7 +33,7 @@ registerAllTools(server, apiClient);
33
33
 
34
34
  Every tool except the public auth tools (`amba_developer_signup`, `amba_developer_login`, `amba_developer_refresh`) requires a developer Bearer token.
35
35
 
36
- 1. Call `amba_developer_signup` with no Authorization header — the response includes a long-lived Personal Access Token (`pat`) and a freshly provisioned project.
36
+ 1. Call `amba_developer_signup` with no Authorization header — the response includes a long-lived Personal Access Token (`pat`) and a freshly provisioned project. While new accounts are invite-only, include `invite_code`; a missing or rejected code answers 403 `INVITE_REQUIRED` / `INVITE_INVALID` (and `SIGNUPS_CLOSED` when no accounts are being created), with `error.details.request_access_url` pointing at the request-access page.
37
37
  2. Pass the `pat` as the inbound Bearer on every subsequent MCP call.
38
38
  3. Poll `amba_get_provisioning_status` until the project flips to `status: "active"` before issuing client traffic.
39
39
 
@@ -20,9 +20,33 @@
20
20
  export declare class AmbaApiError extends Error {
21
21
  readonly status: number;
22
22
  readonly code: string | undefined;
23
- constructor(status: number, code: string | undefined, message: string);
23
+ /** The API's own `error.message`, without the `API error <status>:` prefix. */
24
+ readonly apiMessage: string;
25
+ /**
26
+ * The API's `error.details`, when the response carried one: for example a
27
+ * 402 `FREE_TIER_LIMIT_REACHED` names the limit, the reset date, the
28
+ * billing URL and the one-call upgrade there. Tool results pass it to the
29
+ * agent (`lib/tool-result.ts` `apiErrorResult`).
30
+ */
31
+ readonly details: unknown;
32
+ constructor(status: number, code: string | undefined, message: string, details?: unknown);
24
33
  }
34
+ /**
35
+ * Read a non-2xx response's `{ error: { code, message, details } }` envelope
36
+ * into an `AmbaApiError`. A body that is not that JSON envelope falls back to
37
+ * the status text.
38
+ */
39
+ export declare function ambaApiErrorFromResponse(res: Response): Promise<AmbaApiError>;
25
40
  export interface ApiClientOptions {
41
+ /**
42
+ * Extra headers sent on the public developer-auth calls (signup, login,
43
+ * refresh and friends; see `tools/auth.ts`). The hosted MCP server uses
44
+ * this to attest the calling agent's IP to apps/api
45
+ * (`X-Amba-Client-IP` + `X-Amba-Proxy-Secret`), so per-IP signup and login
46
+ * limits key on the agent's IP and the MCP server's egress IP stays out of
47
+ * the bucket key. Local and CLI usage leaves it unset.
48
+ */
49
+ authProxyHeaders?: Record<string, string>;
26
50
  baseUrl?: string;
27
51
  /**
28
52
  * Optional override for token resolution. When provided, the client uses
@@ -43,6 +67,7 @@ export interface ApiClientOptions {
43
67
  signupToken?: string;
44
68
  }
45
69
  export declare class ApiClient {
70
+ private authProxyHeaders;
46
71
  private baseUrl;
47
72
  private apiRoot;
48
73
  private tokenProvider?;
@@ -78,6 +103,13 @@ export declare class ApiClient {
78
103
  * normalisation. The constructor enforces the `/admin` suffix invariant.
79
104
  */
80
105
  getApiRoot(): string;
106
+ /**
107
+ * Headers to add to public developer-auth calls (see
108
+ * `ApiClientOptions.authProxyHeaders`). Those calls always run on the
109
+ * client the tools were registered with, so a `withToken` sibling does not
110
+ * need to carry them.
111
+ */
112
+ getAuthProxyHeaders(): Record<string, string>;
81
113
  /**
82
114
  * Resolve the current developer Bearer token, going through the configured
83
115
  * tokenProvider (or `~/.amba/credentials.json` for the CLI fallback).
@@ -89,6 +121,16 @@ export declare class ApiClient {
89
121
  */
90
122
  resolveTokenOrNull(): Promise<string | null>;
91
123
  private getToken;
124
+ /**
125
+ * Account notices (`X-Amba-Notice`, e.g. the unclaimed-sandbox claim
126
+ * instruction) seen on responses since the last `takeNotices()`. The
127
+ * `registerTool` wrapper drains them into the tool result so the agent
128
+ * reads them alongside the data it asked for.
129
+ */
130
+ private readonly notices;
131
+ /** Return and clear the notices collected since the last call. */
132
+ takeNotices(): string[];
133
+ private captureNotice;
92
134
  private request;
93
135
  get<T>(path: string, query?: Record<string, string>): Promise<T>;
94
136
  post<T>(path: string, body?: unknown, query?: Record<string, string>): Promise<T>;
@@ -94,6 +94,8 @@ Tell the user where their credentials live:
94
94
  - \`project_id\`, \`client_key\` — the values they paste into their app's \`.env.local\` / \`.env\`.
95
95
  - \`server_key\` — never ship to user devices; only into a server \`.env\` or a secret manager. The \`amb_dev_sk_\` / \`amb_live_sk_\` prefix is the marker.
96
96
 
97
+ **Signup refused with 403 \`INVITE_REQUIRED\` or \`INVITE_INVALID\`?** New accounts need an invite code right now. Ask the developer for theirs (it starts with \`AMBA-\` and arrives in their invite email) and call \`amba_developer_signup\` again with the same arguments plus \`invite_code\`. If they have no code, or the answer is \`SIGNUPS_CLOSED\`, offer to request access for them: \`POST https://api.amba.dev/v1/auth/developer/waitlist\` with \`{ "email": "<their own email>", "note": "<optional>" }\`, or send them to the \`error.details.request_access_url\` page. Tell them the invite code arrives by email, then stop. Retry only with a code the developer hands you; never retry in a loop, invent codes, or try other email addresses. From a terminal, the code goes to \`npx @layers/amba init --invite <code>\` (or the \`AMBA_INVITE_CODE\` env var).
98
+
97
99
  **Already have a PAT?** Skip the signup. Call \`amba_developer_me({})\` to verify the Bearer; if it succeeds, either reuse the most recent project (\`amba_projects_list\`) or call \`amba_projects_create({ name: "<app-name>", platform: "all" })\` and then \`amba_api_keys_create\` twice to mint client + server keys for \`environment: "development"\`.
98
100
 
99
101
  **Can't reach \`amba_developer_signup\` — it's not in your tool list, or your harness blocks the call?** Do NOT try to work around it by adding the MCP server yourself, running an installer, or editing your own settings/permissions — refusing to self-modify or widen your own permissions is the correct call, and you should not circumvent it. Instead, hand the developer **one** command to run in **their own** terminal (which is not subject to your sandbox):
@@ -247,8 +249,8 @@ Be specific. List resources by key, not "some achievements". If something needs
247
249
  ## Get credentials (cheat sheet)
248
250
 
249
251
  - No terminal, in an MCP client: call \`amba_developer_signup\` (no Bearer required) — this guide's Step 0.
250
- - With a terminal: \`npx -y @layers/amba init\` signs up, mints a project + client/server keys, writes \`.env.local\` + \`AMBA.md\`, installs the \`/amba\` skill, and wires \`mcpServers.amba\` into every detected MCP-client config in one command. Auto-detects non-TTY invocations (the coding-agent bash-tool case) and runs headlessly.
251
- - Bind the sandbox account to a real email later: \`npx @layers/amba claim me@example.com\`. The backend emails a one-click magic link; clicking it lifts the sandbox cap to the Free tier.
252
+ - With a terminal: \`npx -y @layers/amba init\` signs up, mints a project + client/server keys, writes \`.env.local\` + \`AMBA.md\`, installs the \`/amba\` skill, and wires \`mcpServers.amba\` into every detected MCP-client config in one command. Auto-detects non-TTY invocations (the coding-agent bash-tool case) and runs headlessly. While signups are invite-only, add \`--invite <code>\` (or set \`AMBA_INVITE_CODE\`).
253
+ - Bind the sandbox account to its human owner as soon as you know who that is: \`amba_developer_claim\` with their email (or \`npx @layers/amba claim me@example.com\`). The backend emails a one-click magic link; clicking it lifts the sandbox cap to the Free tier. Each free project of an unclaimed sandbox runs its own clock from when it was created: a claim notice from day 7, a hold on day 14, and an archive on day 90 after a full hold (archiving deletes nothing); claiming lifts all of it.
252
254
  - Hosted MCP endpoint: \`https://mcp.amba.dev/mcp\` (Streamable HTTP, Bearer auth).
253
255
 
254
256
  ## SDKs
package/dist/index.d.ts CHANGED
@@ -39,6 +39,8 @@ export declare function createApiClient(options: {
39
39
  baseUrl?: string;
40
40
  token?: string;
41
41
  signupToken?: string;
42
+ /** See `ApiClientOptions.authProxyHeaders`. */
43
+ authProxyHeaders?: Record<string, string>;
42
44
  }): ApiClient;
43
45
  export { ApiClient } from './api-client.js';
44
46
  export type { ApiClientOptions } from './api-client.js';