@mtaap/mcp 0.2.13 → 0.5.1

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/index.d.ts CHANGED
@@ -11,10 +11,19 @@ import { TaskState, ErrorType } from '@mtaap/core';
11
11
 
12
12
  /**
13
13
  * API Client Configuration
14
+ *
15
+ * Supports two authentication methods:
16
+ * - apiKey: Traditional API key authentication (X-API-Key header)
17
+ * - oauthToken: OAuth 2.0 Bearer token (Authorization header)
18
+ *
19
+ * At least one authentication method must be provided.
14
20
  */
15
21
  interface ApiClientConfig {
16
22
  baseUrl: string;
17
- apiKey: string;
23
+ /** API key for X-API-Key authentication */
24
+ apiKey?: string;
25
+ /** OAuth access token for Bearer authentication */
26
+ oauthToken?: string;
18
27
  timeout?: number;
19
28
  debug?: boolean;
20
29
  }
@@ -23,8 +32,9 @@ interface ApiClientConfig {
23
32
  */
24
33
  interface AuthContext {
25
34
  userId: string;
26
- organizationId: string | undefined;
27
- permissions: string[];
35
+ organizationId?: string;
36
+ /** Permission level: "READ" | "WRITE" | "ADMIN" for OAuth, or string[] for API keys */
37
+ permissions: string | string[];
28
38
  userName: string;
29
39
  userEmail: string;
30
40
  }
@@ -84,6 +94,8 @@ interface Task {
84
94
  message: string;
85
95
  checkpoints: string[];
86
96
  userId: string;
97
+ apiKeyNickname: string | null;
98
+ createdVia: "UI" | "API_KEY" | "OAUTH";
87
99
  createdAt: string;
88
100
  }>;
89
101
  notes?: Array<{
@@ -91,6 +103,8 @@ interface Task {
91
103
  content: string;
92
104
  userId: string;
93
105
  userName: string | null;
106
+ apiKeyNickname: string | null;
107
+ createdVia: "UI" | "API_KEY" | "OAUTH";
94
108
  createdAt: string;
95
109
  }>;
96
110
  createdAt: string;
@@ -124,21 +138,40 @@ declare class ApiError extends Error {
124
138
  status: number;
125
139
  details?: Record<string, unknown> | undefined;
126
140
  constructor(message: string, code: string, status: number, details?: Record<string, unknown> | undefined);
141
+ /**
142
+ * Whether this error is transient and the request can be retried.
143
+ * Retries on network errors (status 0), timeouts (408), and server errors (5xx).
144
+ */
145
+ get isRetryable(): boolean;
127
146
  }
128
147
  /**
129
148
  * MCP API Client
130
149
  */
131
150
  declare class MCPApiClient {
132
151
  private baseUrl;
133
- private apiKey;
152
+ private apiKey?;
153
+ private oauthToken?;
134
154
  private timeout;
135
155
  private debug;
136
156
  private authContext;
157
+ private cache;
137
158
  constructor(config: ApiClientConfig);
138
159
  /**
139
- * Make an HTTP request to the API
160
+ * Get a cached value if it exists and hasn't expired.
161
+ */
162
+ private getCached;
163
+ /**
164
+ * Store a value in cache with a TTL.
165
+ */
166
+ private setCache;
167
+ /**
168
+ * Make an HTTP request to the API with automatic retry on transient failures.
140
169
  */
141
170
  private request;
171
+ /**
172
+ * Execute a single HTTP request to the API.
173
+ */
174
+ private requestOnce;
142
175
  /**
143
176
  * Authenticate and get user context
144
177
  */
@@ -148,7 +181,7 @@ declare class MCPApiClient {
148
181
  */
149
182
  getAuthContext(): Promise<AuthContext>;
150
183
  /**
151
- * List accessible projects
184
+ * List accessible projects (cached for 30s)
152
185
  */
153
186
  listProjects(workspaceType?: string): Promise<Project[]>;
154
187
  /**
@@ -156,7 +189,7 @@ declare class MCPApiClient {
156
189
  */
157
190
  getProject(projectId: string): Promise<Project>;
158
191
  /**
159
- * Get project context (README, stack, conventions)
192
+ * Get project context (README, stack, conventions) (cached for 60s)
160
193
  */
161
194
  getProjectContext(projectId: string): Promise<ProjectContext>;
162
195
  /**
@@ -330,7 +363,8 @@ declare class MCPApiClient {
330
363
  prompt: string;
331
364
  }>;
332
365
  /**
333
- * Update task details (DRAFT/TODO states only)
366
+ * Update task details (DRAFT/TODO states only).
367
+ * Task stays in its current state.
334
368
  */
335
369
  updateTask(taskId: string, projectId: string, data: {
336
370
  title?: string;
@@ -340,27 +374,7 @@ declare class MCPApiClient {
340
374
  id?: string;
341
375
  description: string;
342
376
  }>;
343
- }): Promise<{
344
- success: boolean;
345
- taskId: string;
346
- previousState: string;
347
- newState: string;
348
- revertedToDraft: boolean;
349
- message: string;
350
- task: {
351
- id: string;
352
- title: string;
353
- description: string;
354
- priority: string;
355
- state: string;
356
- verificationStatus: string;
357
- acceptanceCriteria: Array<{
358
- id: string;
359
- description: string;
360
- order: number;
361
- }>;
362
- };
363
- }>;
377
+ }): Promise<Record<string, unknown>>;
364
378
  }
365
379
 
366
380
  declare const VERSION: string;