@astramindapp/mcp-server 0.2.0 → 0.3.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/README.md +90 -3
- package/dist/mind-client.d.ts +6 -0
- package/dist/mind-client.d.ts.map +1 -1
- package/dist/mind-client.js +1 -1
- package/dist/mind-client.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -3
- package/dist/server.js.map +1 -1
- package/package.json +5 -1
- package/.claude/settings.local.json +0 -9
- package/src/cli.ts +0 -47
- package/src/index.ts +0 -15
- package/src/mind-client.ts +0 -378
- package/src/server.ts +0 -633
- package/src/setup.ts +0 -372
- package/tsconfig.json +0 -20
package/src/mind-client.ts
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIND API Client
|
|
3
|
-
*
|
|
4
|
-
* Thin wrapper around the MIND Developer API.
|
|
5
|
-
* All methods return typed responses or throw on HTTP errors.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export interface MindClientConfig {
|
|
9
|
-
baseUrl: string;
|
|
10
|
-
apiKey: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface QueryRequest {
|
|
14
|
-
query: string;
|
|
15
|
-
mode?: "mix" | "hybrid" | "graph" | "vector";
|
|
16
|
-
limit?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface QueryResponse {
|
|
20
|
-
response: string;
|
|
21
|
-
sources: Array<{
|
|
22
|
-
id?: string;
|
|
23
|
-
title?: string;
|
|
24
|
-
content_preview?: string;
|
|
25
|
-
relevance_score?: number;
|
|
26
|
-
}>;
|
|
27
|
-
credits_used: number;
|
|
28
|
-
credits_remaining: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface DocumentCreateRequest {
|
|
32
|
-
title: string;
|
|
33
|
-
content: string;
|
|
34
|
-
source?: string;
|
|
35
|
-
tags?: string[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface DocumentResponse {
|
|
39
|
-
id: string;
|
|
40
|
-
title: string;
|
|
41
|
-
source: string;
|
|
42
|
-
status: string;
|
|
43
|
-
created_at: string;
|
|
44
|
-
content_preview?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface EntryCreateRequest {
|
|
48
|
-
title?: string;
|
|
49
|
-
content: string;
|
|
50
|
-
entry_type?: string;
|
|
51
|
-
tags?: string[];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface EntryResponse {
|
|
55
|
-
id?: string;
|
|
56
|
-
entry_id?: string;
|
|
57
|
-
title?: string;
|
|
58
|
-
content?: string;
|
|
59
|
-
entry_type?: string;
|
|
60
|
-
tags?: string[];
|
|
61
|
-
created_at?: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface ThoughtCreateRequest {
|
|
65
|
-
content: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface ThoughtResponse {
|
|
69
|
-
id?: string;
|
|
70
|
-
thought_id?: string;
|
|
71
|
-
content: string;
|
|
72
|
-
created_at?: string;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface LifeItemCreateRequest {
|
|
76
|
-
title: string;
|
|
77
|
-
description?: string;
|
|
78
|
-
status?: string;
|
|
79
|
-
priority?: string;
|
|
80
|
-
due_date?: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface LifeItemResponse {
|
|
84
|
-
item_id: string;
|
|
85
|
-
title: string;
|
|
86
|
-
description?: string;
|
|
87
|
-
status?: string;
|
|
88
|
-
priority?: string;
|
|
89
|
-
due_date?: string;
|
|
90
|
-
created_at?: string;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface CrmContactCreateRequest {
|
|
94
|
-
name: string;
|
|
95
|
-
email?: string;
|
|
96
|
-
company?: string;
|
|
97
|
-
type?: string;
|
|
98
|
-
stage?: string;
|
|
99
|
-
source?: string;
|
|
100
|
-
value?: number;
|
|
101
|
-
notes?: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface CrmContactResponse {
|
|
105
|
-
id?: string;
|
|
106
|
-
contact_id?: string;
|
|
107
|
-
name: string;
|
|
108
|
-
email?: string;
|
|
109
|
-
company?: string;
|
|
110
|
-
type?: string;
|
|
111
|
-
stage?: string;
|
|
112
|
-
created_at?: string;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface GraphInfoResponse {
|
|
116
|
-
total_entities: number;
|
|
117
|
-
total_relationships: number;
|
|
118
|
-
popular_labels?: Array<{ label: string | null; count: number }>;
|
|
119
|
-
storage_status?: { workspace_id: string; status: string };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface ProfileResponse {
|
|
123
|
-
username: string;
|
|
124
|
-
tier?: string;
|
|
125
|
-
credits_remaining?: number;
|
|
126
|
-
[key: string]: unknown;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface InsightsResponse {
|
|
130
|
-
insights: Array<{
|
|
131
|
-
id?: string;
|
|
132
|
-
type?: string;
|
|
133
|
-
content?: string;
|
|
134
|
-
created_at?: string;
|
|
135
|
-
}>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
class MindApiError extends Error {
|
|
139
|
-
constructor(
|
|
140
|
-
public status: number,
|
|
141
|
-
public statusText: string,
|
|
142
|
-
public body: string
|
|
143
|
-
) {
|
|
144
|
-
super(`MIND API error ${status}: ${statusText} — ${body}`);
|
|
145
|
-
this.name = "MindApiError";
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export class MindClient {
|
|
150
|
-
private baseUrl: string;
|
|
151
|
-
private apiKey: string;
|
|
152
|
-
|
|
153
|
-
constructor(config: MindClientConfig) {
|
|
154
|
-
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
155
|
-
this.apiKey = config.apiKey;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
private async request<T>(
|
|
159
|
-
method: string,
|
|
160
|
-
path: string,
|
|
161
|
-
body?: unknown,
|
|
162
|
-
params?: Record<string, string>
|
|
163
|
-
): Promise<T> {
|
|
164
|
-
let url = `${this.baseUrl}${path}`;
|
|
165
|
-
if (params) {
|
|
166
|
-
const qs = new URLSearchParams(params).toString();
|
|
167
|
-
if (qs) url += `?${qs}`;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const headers: Record<string, string> = {
|
|
171
|
-
"X-API-Key": this.apiKey,
|
|
172
|
-
"Content-Type": "application/json",
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const res = await fetch(url, {
|
|
176
|
-
method,
|
|
177
|
-
headers,
|
|
178
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const text = await res.text();
|
|
182
|
-
if (!res.ok) {
|
|
183
|
-
throw new MindApiError(res.status, res.statusText, text);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
try {
|
|
187
|
-
return JSON.parse(text) as T;
|
|
188
|
-
} catch {
|
|
189
|
-
return text as unknown as T;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// ─── Query ──────────────────────────────────────────────
|
|
194
|
-
|
|
195
|
-
async query(req: QueryRequest): Promise<QueryResponse> {
|
|
196
|
-
return this.request<QueryResponse>("POST", "/developer/v1/query", req);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// ─── Documents ──────────────────────────────────────────
|
|
200
|
-
|
|
201
|
-
async createDocument(req: DocumentCreateRequest): Promise<DocumentResponse> {
|
|
202
|
-
return this.request<DocumentResponse>("POST", "/developer/v1/documents", req);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
async listDocuments(page = 1, pageSize = 20): Promise<{ documents: DocumentResponse[] }> {
|
|
206
|
-
return this.request("GET", "/developer/v1/documents", undefined, {
|
|
207
|
-
page: String(page),
|
|
208
|
-
page_size: String(pageSize),
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async deleteDocument(docId: string): Promise<void> {
|
|
213
|
-
await this.request("DELETE", `/developer/v1/documents/${docId}`);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// ─── Entries ────────────────────────────────────────────
|
|
217
|
-
|
|
218
|
-
async createEntry(req: EntryCreateRequest): Promise<EntryResponse> {
|
|
219
|
-
return this.request<EntryResponse>("POST", "/developer/v1/entries", req);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
async listEntries(limit = 20): Promise<{ entries: EntryResponse[] }> {
|
|
223
|
-
return this.request("GET", "/developer/v1/entries", undefined, {
|
|
224
|
-
limit: String(limit),
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
async deleteEntry(entryId: string): Promise<void> {
|
|
229
|
-
await this.request("DELETE", `/developer/v1/entries/${entryId}`);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// ─── Thoughts ───────────────────────────────────────────
|
|
233
|
-
|
|
234
|
-
async createThought(req: ThoughtCreateRequest): Promise<ThoughtResponse> {
|
|
235
|
-
return this.request<ThoughtResponse>("POST", "/developer/v1/thoughts", req);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async listThoughts(): Promise<{ thoughts: ThoughtResponse[] }> {
|
|
239
|
-
return this.request("GET", "/developer/v1/thoughts");
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async deleteThought(thoughtId: string): Promise<void> {
|
|
243
|
-
await this.request("DELETE", `/developer/v1/thoughts/${thoughtId}`);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// ─── Life ───────────────────────────────────────────────
|
|
247
|
-
|
|
248
|
-
async createLifeItem(req: LifeItemCreateRequest): Promise<LifeItemResponse> {
|
|
249
|
-
return this.request<LifeItemResponse>("POST", "/developer/v1/life/items", req);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
async listLifeItems(
|
|
253
|
-
status?: string,
|
|
254
|
-
limit = 30
|
|
255
|
-
): Promise<{ items: LifeItemResponse[] }> {
|
|
256
|
-
const params: Record<string, string> = { limit: String(limit) };
|
|
257
|
-
if (status) params.status = status;
|
|
258
|
-
return this.request("GET", "/developer/v1/life/items", undefined, params);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
async updateLifeItem(
|
|
262
|
-
itemId: string,
|
|
263
|
-
patch: Partial<LifeItemCreateRequest & { status: string }>
|
|
264
|
-
): Promise<LifeItemResponse> {
|
|
265
|
-
return this.request<LifeItemResponse>(
|
|
266
|
-
"PATCH",
|
|
267
|
-
`/developer/v1/life/items/${itemId}`,
|
|
268
|
-
patch
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
async deleteLifeItem(itemId: string): Promise<void> {
|
|
273
|
-
await this.request("DELETE", `/developer/v1/life/items/${itemId}`);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// ─── CRM ────────────────────────────────────────────────
|
|
277
|
-
|
|
278
|
-
async createContact(req: CrmContactCreateRequest): Promise<CrmContactResponse> {
|
|
279
|
-
return this.request<CrmContactResponse>("POST", "/developer/v1/crm/contacts", req);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
async listContacts(): Promise<{ contacts: CrmContactResponse[] }> {
|
|
283
|
-
return this.request("GET", "/developer/v1/crm/contacts");
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
async updateContact(
|
|
287
|
-
contactId: string,
|
|
288
|
-
patch: Partial<CrmContactCreateRequest>
|
|
289
|
-
): Promise<CrmContactResponse> {
|
|
290
|
-
return this.request<CrmContactResponse>(
|
|
291
|
-
"PATCH",
|
|
292
|
-
`/developer/v1/crm/contacts/${contactId}`,
|
|
293
|
-
patch
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// ─── Graph ──────────────────────────────────────────────
|
|
298
|
-
|
|
299
|
-
async graphInfo(): Promise<GraphInfoResponse> {
|
|
300
|
-
return this.request<GraphInfoResponse>("GET", "/developer/v1/graph");
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// ─── Profile / Credits ─────────────────────────────────
|
|
304
|
-
|
|
305
|
-
async profile(): Promise<ProfileResponse> {
|
|
306
|
-
return this.request<ProfileResponse>("GET", "/developer/v1/profile");
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
async credits(): Promise<{
|
|
310
|
-
credits_balance: number;
|
|
311
|
-
credits_limit: number;
|
|
312
|
-
tier: string;
|
|
313
|
-
documents_used: number;
|
|
314
|
-
documents_limit: number;
|
|
315
|
-
}> {
|
|
316
|
-
return this.request("GET", "/developer/v1/credits");
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// ─── Insights ───────────────────────────────────────────
|
|
320
|
-
|
|
321
|
-
async insights(): Promise<InsightsResponse> {
|
|
322
|
-
return this.request<InsightsResponse>("GET", "/developer/v1/insights");
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// ─── Admin ──────────────────────────────────────────────
|
|
326
|
-
|
|
327
|
-
async adminCreateUser(req: { username: string; email: string; password: string }): Promise<{
|
|
328
|
-
status: string;
|
|
329
|
-
user: { username: string; email: string; workspace_id: string };
|
|
330
|
-
}> {
|
|
331
|
-
return this.request("POST", "/register", req);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async adminCreateFeaturedMind(req: {
|
|
335
|
-
username: string;
|
|
336
|
-
title: string;
|
|
337
|
-
description?: string;
|
|
338
|
-
tags?: string[];
|
|
339
|
-
price?: number;
|
|
340
|
-
featured?: boolean;
|
|
341
|
-
display_order?: number;
|
|
342
|
-
is_public?: boolean;
|
|
343
|
-
avatar_url?: string;
|
|
344
|
-
}): Promise<{ mind_id: string; username: string; title: string; [key: string]: unknown }> {
|
|
345
|
-
return this.request("POST", "/admin/featured-minds", req);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
async adminListFeaturedMinds(): Promise<
|
|
349
|
-
Array<{ mind_id: string; username: string; title: string; featured: boolean; display_order: number; [key: string]: unknown }>
|
|
350
|
-
> {
|
|
351
|
-
return this.request("GET", "/admin/featured-minds");
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
async adminUpdateFeaturedMind(
|
|
355
|
-
mindId: string,
|
|
356
|
-
patch: Record<string, unknown>
|
|
357
|
-
): Promise<{ mind_id: string; title: string; [key: string]: unknown }> {
|
|
358
|
-
return this.request("PUT", `/admin/featured-minds/${mindId}`, patch);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
async adminListUsers(params?: { q?: string; page?: number }): Promise<{
|
|
362
|
-
users: Array<{ username: string; email?: string; tier?: string; doc_count?: number }>;
|
|
363
|
-
total?: number;
|
|
364
|
-
}> {
|
|
365
|
-
const qp: Record<string, string> = {};
|
|
366
|
-
if (params?.q) qp.q = params.q;
|
|
367
|
-
if (params?.page) qp.page = String(params.page);
|
|
368
|
-
return this.request("GET", "/admin/users", undefined, qp);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
async adminUpdateUserTier(username: string, tier: string): Promise<{ tier: string }> {
|
|
372
|
-
return this.request("PUT", `/admin/users/${username}/tier`, { tier });
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
async adminAdjustCredits(username: string, amount: number): Promise<{ new_balance: number }> {
|
|
376
|
-
return this.request("POST", `/admin/users/${username}/credits`, { amount });
|
|
377
|
-
}
|
|
378
|
-
}
|