@layers/amba-mcp 0.1.1 → 1.0.0
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/dist/api-client.d.ts +66 -0
- package/dist/auth.d.ts +7 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +3230 -0
- package/dist/tools/achievements.d.ts +3 -0
- package/dist/tools/analytics.d.ts +3 -0
- package/dist/tools/auth.d.ts +37 -0
- package/dist/tools/challenges.d.ts +3 -0
- package/dist/tools/config.d.ts +3 -0
- package/dist/tools/content.d.ts +3 -0
- package/dist/tools/economy.d.ts +3 -0
- package/dist/tools/events.d.ts +3 -0
- package/dist/tools/integrations.d.ts +3 -0
- package/dist/tools/leaderboards.d.ts +3 -0
- package/dist/tools/platform.d.ts +3 -0
- package/dist/tools/projects.d.ts +3 -0
- package/dist/tools/push.d.ts +3 -0
- package/dist/tools/segments.d.ts +3 -0
- package/dist/tools/setup.d.ts +3 -0
- package/dist/tools/social.d.ts +3 -0
- package/dist/tools/streaks.d.ts +3 -0
- package/dist/tools/users.d.ts +3 -0
- package/dist/tools/xp.d.ts +3 -0
- package/package.json +7 -6
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export interface ApiClientOptions {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
/**
|
|
4
|
+
* Optional override for token resolution. When provided, the client uses
|
|
5
|
+
* this in place of `loadCredentials()` (the CLI's `~/.amba/credentials.json`
|
|
6
|
+
* flow) — this is what the hosted MCP server uses to forward the developer's
|
|
7
|
+
* Bearer token from the inbound HTTP request to the downstream API call.
|
|
8
|
+
*
|
|
9
|
+
* The provider is invoked once per request, so callers can rotate or refresh
|
|
10
|
+
* tokens transparently. Sync values should be wrapped in `() => Promise.resolve(token)`.
|
|
11
|
+
*/
|
|
12
|
+
getToken?: () => Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
export declare class ApiClient {
|
|
15
|
+
private baseUrl;
|
|
16
|
+
private apiRoot;
|
|
17
|
+
private tokenProvider?;
|
|
18
|
+
constructor(options?: ApiClientOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Returns the configured admin-prefixed base URL (e.g.
|
|
21
|
+
* `https://api.amba.dev/admin`). Auth tools (`amba_developer_signup`,
|
|
22
|
+
* `amba_developer_login`, `amba_developer_refresh`) need a sibling root
|
|
23
|
+
* because the public `/auth/developer/*` endpoints are NOT under `/admin`.
|
|
24
|
+
*/
|
|
25
|
+
getBaseUrl(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the API root with the trailing `/admin` segment stripped —
|
|
28
|
+
* computed once at construction so tools targeting sibling routes
|
|
29
|
+
* (`/auth/developer/*`) get a stable root regardless of trailing-slash
|
|
30
|
+
* normalisation. The constructor enforces the `/admin` suffix invariant.
|
|
31
|
+
*/
|
|
32
|
+
getApiRoot(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the current developer Bearer token, going through the configured
|
|
35
|
+
* tokenProvider (or `~/.amba/credentials.json` for the CLI fallback).
|
|
36
|
+
*
|
|
37
|
+
* Returns `null` if no provider is configured AND no credentials file exists
|
|
38
|
+
* — useful for tools like `amba_developer_signup` that may run with no
|
|
39
|
+
* inbound Bearer at all. All other code paths should treat a thrown error
|
|
40
|
+
* as a hard auth failure (e.g. expired token).
|
|
41
|
+
*/
|
|
42
|
+
resolveTokenOrNull(): Promise<string | null>;
|
|
43
|
+
private getToken;
|
|
44
|
+
private request;
|
|
45
|
+
get<T>(path: string, query?: Record<string, string>): Promise<T>;
|
|
46
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
47
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
48
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
49
|
+
delete<T>(path: string): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* GET that returns the raw response body as a string and only reads up to
|
|
52
|
+
* `maxBytes` bytes. Used by export tools that hit CSV/NDJSON streaming
|
|
53
|
+
* endpoints — JSON parsing isn't applicable, and we cap at 10k rows worth
|
|
54
|
+
* of bytes so a multi-million-row export can't blow the MCP context window.
|
|
55
|
+
*
|
|
56
|
+
* Errors are still parsed via the JSON envelope where possible to keep the
|
|
57
|
+
* thrown message human-readable (matches the regular request() behavior).
|
|
58
|
+
*/
|
|
59
|
+
getRaw(path: string, query?: Record<string, string>, options?: {
|
|
60
|
+
maxBytes?: number;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
body: string;
|
|
63
|
+
truncated: boolean;
|
|
64
|
+
contentType: string | null;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
package/dist/auth.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library entry for `@layers/amba-mcp`.
|
|
3
|
+
*
|
|
4
|
+
* Reusable MCP tool registry consumed by `mcp.amba.dev`. It registers
|
|
5
|
+
* 100+ MCP tools — every Amba admin operation, basically — against an
|
|
6
|
+
* injected `McpServer` and `ApiClient`. It does NOT bootstrap a transport.
|
|
7
|
+
*
|
|
8
|
+
* The hosted server mounts the registry behind the official MCP
|
|
9
|
+
* **Streamable HTTP** transport so AI agents (Claude Desktop, Cursor,
|
|
10
|
+
* Windsurf, …) can connect by URL +
|
|
11
|
+
* `Authorization: Bearer <developer-access-token>`.
|
|
12
|
+
*
|
|
13
|
+
* Tool-group files in `./tools/*` only depend on `McpServer` + `ApiClient`.
|
|
14
|
+
* They MUST stay free of transport coupling so the registry can run inside
|
|
15
|
+
* any MCP transport, including future ones (SSE, WebSockets, …).
|
|
16
|
+
*/
|
|
17
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
18
|
+
import { ApiClient } from './api-client.js';
|
|
19
|
+
/**
|
|
20
|
+
* Register every Amba MCP tool group against the given server, using the
|
|
21
|
+
* given API client. A single `McpServer` instance should only have this
|
|
22
|
+
* called against it once.
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerAllTools(server: McpServer, apiClient: ApiClient): void;
|
|
25
|
+
/**
|
|
26
|
+
* Convenience factory used by the hosted MCP server to build a per-request
|
|
27
|
+
* `ApiClient` whose Bearer token comes from the inbound HTTP `Authorization`
|
|
28
|
+
* header. Equivalent to `new ApiClient({ baseUrl, getToken: async () => token })`.
|
|
29
|
+
*
|
|
30
|
+
* If `token` is omitted the client falls back to `~/.amba/credentials.json`
|
|
31
|
+
* — that path is only useful for tests or local-dev scripts; production
|
|
32
|
+
* hosted-MCP traffic always passes an explicit token.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createApiClient(options: {
|
|
35
|
+
baseUrl?: string;
|
|
36
|
+
token?: string;
|
|
37
|
+
}): ApiClient;
|
|
38
|
+
export { ApiClient } from './api-client.js';
|
|
39
|
+
export type { ApiClientOptions } from './api-client.js';
|