@layers/amba-mcp 4.0.10 → 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 +1 -1
- package/dist/api-client.d.ts +53 -1
- package/dist/expo-build-prompt.js +4 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +464 -157
- package/dist/lib/tool-result.d.ts +30 -0
- package/dist/lib/with-pat.d.ts +11 -1
- package/dist/resources/amba-setup.d.ts +1 -1
- package/dist/tools/billing.d.ts +5 -1
- package/dist/tools/developer-claim.d.ts +15 -0
- package/dist/tools/secrets.d.ts +2 -0
- package/package.json +2 -2
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
|
|
package/dist/api-client.d.ts
CHANGED
|
@@ -20,9 +20,33 @@
|
|
|
20
20
|
export declare class AmbaApiError extends Error {
|
|
21
21
|
readonly status: number;
|
|
22
22
|
readonly code: string | undefined;
|
|
23
|
-
|
|
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
|
|
@@ -34,11 +58,20 @@ export interface ApiClientOptions {
|
|
|
34
58
|
* tokens transparently. Sync values should be wrapped in `() => Promise.resolve(token)`.
|
|
35
59
|
*/
|
|
36
60
|
getToken?: () => Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Signup token forwarded on `/auth/developer/signup` as
|
|
63
|
+
* `X-Amba-Signup-Token`. The hosted MCP server copies it from the inbound
|
|
64
|
+
* request header of the same name so Amba's CI can sign up through MCP
|
|
65
|
+
* while public signup is closed. Unset for every other caller.
|
|
66
|
+
*/
|
|
67
|
+
signupToken?: string;
|
|
37
68
|
}
|
|
38
69
|
export declare class ApiClient {
|
|
70
|
+
private authProxyHeaders;
|
|
39
71
|
private baseUrl;
|
|
40
72
|
private apiRoot;
|
|
41
73
|
private tokenProvider?;
|
|
74
|
+
private signupToken?;
|
|
42
75
|
constructor(options?: ApiClientOptions);
|
|
43
76
|
/**
|
|
44
77
|
* Return a sibling `ApiClient` bound to a different Bearer token.
|
|
@@ -54,6 +87,8 @@ export declare class ApiClient {
|
|
|
54
87
|
* routing stays identical — only the token provider differs.
|
|
55
88
|
*/
|
|
56
89
|
withToken(token: string): ApiClient;
|
|
90
|
+
/** The signup token to forward on `/auth/developer/signup`, if any. */
|
|
91
|
+
getSignupToken(): string | undefined;
|
|
57
92
|
/**
|
|
58
93
|
* Returns the configured admin-prefixed base URL (e.g.
|
|
59
94
|
* `https://api.amba.dev/admin`). Auth tools (`amba_developer_signup`,
|
|
@@ -68,6 +103,13 @@ export declare class ApiClient {
|
|
|
68
103
|
* normalisation. The constructor enforces the `/admin` suffix invariant.
|
|
69
104
|
*/
|
|
70
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>;
|
|
71
113
|
/**
|
|
72
114
|
* Resolve the current developer Bearer token, going through the configured
|
|
73
115
|
* tokenProvider (or `~/.amba/credentials.json` for the CLI fallback).
|
|
@@ -79,6 +121,16 @@ export declare class ApiClient {
|
|
|
79
121
|
*/
|
|
80
122
|
resolveTokenOrNull(): Promise<string | null>;
|
|
81
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;
|
|
82
134
|
private request;
|
|
83
135
|
get<T>(path: string, query?: Record<string, string>): Promise<T>;
|
|
84
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
|
|
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
|
@@ -38,6 +38,9 @@ export declare function registerAllTools(server: McpServer, apiClient: ApiClient
|
|
|
38
38
|
export declare function createApiClient(options: {
|
|
39
39
|
baseUrl?: string;
|
|
40
40
|
token?: string;
|
|
41
|
+
signupToken?: string;
|
|
42
|
+
/** See `ApiClientOptions.authProxyHeaders`. */
|
|
43
|
+
authProxyHeaders?: Record<string, string>;
|
|
41
44
|
}): ApiClient;
|
|
42
45
|
export { ApiClient } from './api-client.js';
|
|
43
46
|
export type { ApiClientOptions } from './api-client.js';
|