@getjack/jack 0.1.14 → 0.1.15
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/package.json +1 -2
- package/src/commands/clone.ts +6 -6
- package/src/commands/down.ts +21 -3
- package/src/commands/link.ts +8 -3
- package/src/commands/secrets.ts +11 -14
- package/src/commands/services.ts +148 -5
- package/src/commands/update.ts +53 -0
- package/src/index.ts +31 -0
- package/src/lib/auth/login-flow.ts +11 -3
- package/src/lib/control-plane.ts +47 -0
- package/src/lib/hooks.ts +22 -45
- package/src/lib/project-operations.ts +19 -11
- package/src/lib/prompts.ts +23 -21
- package/src/lib/services/db-create.ts +187 -0
- package/src/lib/services/db-list.ts +56 -0
- package/src/lib/version-check.ts +170 -0
- package/src/mcp/resources/index.ts +32 -0
- package/src/mcp/tools/index.ts +131 -1
package/src/mcp/tools/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { z } from "zod";
|
|
|
4
4
|
import { JackError, JackErrorCode } from "../../lib/errors.ts";
|
|
5
5
|
import { createProject, deployProject, getProjectStatus } from "../../lib/project-operations.ts";
|
|
6
6
|
import { listAllProjects } from "../../lib/project-resolver.ts";
|
|
7
|
+
import { createDatabase } from "../../lib/services/db-create.ts";
|
|
8
|
+
import { listDatabases } from "../../lib/services/db-list.ts";
|
|
7
9
|
import { Events, track, withTelemetry } from "../../lib/telemetry.ts";
|
|
8
10
|
import type { DebugLogger, McpServerOptions } from "../types.ts";
|
|
9
11
|
import { formatErrorResponse, formatSuccessResponse } from "../utils.ts";
|
|
@@ -36,6 +38,21 @@ const ListProjectsSchema = z.object({
|
|
|
36
38
|
.describe("Filter projects by status (defaults to 'all')"),
|
|
37
39
|
});
|
|
38
40
|
|
|
41
|
+
const CreateDatabaseSchema = z.object({
|
|
42
|
+
name: z.string().optional().describe("Database name (auto-generated if not provided)"),
|
|
43
|
+
project_path: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Path to project directory (defaults to current directory)"),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const ListDatabasesSchema = z.object({
|
|
50
|
+
project_path: z
|
|
51
|
+
.string()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Path to project directory (defaults to current directory)"),
|
|
54
|
+
});
|
|
55
|
+
|
|
39
56
|
export function registerTools(server: McpServer, _options: McpServerOptions, debug: DebugLogger) {
|
|
40
57
|
// Register tool list handler
|
|
41
58
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
@@ -107,6 +124,37 @@ export function registerTools(server: McpServer, _options: McpServerOptions, deb
|
|
|
107
124
|
},
|
|
108
125
|
},
|
|
109
126
|
},
|
|
127
|
+
{
|
|
128
|
+
name: "create_database",
|
|
129
|
+
description:
|
|
130
|
+
"Create a D1 database for a project. Returns deploy_required=true since binding needs deploy to activate.",
|
|
131
|
+
inputSchema: {
|
|
132
|
+
type: "object",
|
|
133
|
+
properties: {
|
|
134
|
+
name: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "Database name (auto-generated if not provided)",
|
|
137
|
+
},
|
|
138
|
+
project_path: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "Path to project directory (defaults to current directory)",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "list_databases",
|
|
147
|
+
description: "List all D1 databases for a project.",
|
|
148
|
+
inputSchema: {
|
|
149
|
+
type: "object",
|
|
150
|
+
properties: {
|
|
151
|
+
project_path: {
|
|
152
|
+
type: "string",
|
|
153
|
+
description: "Path to project directory (defaults to current directory)",
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
110
158
|
],
|
|
111
159
|
};
|
|
112
160
|
});
|
|
@@ -195,7 +243,15 @@ export function registerTools(server: McpServer, _options: McpServerOptions, deb
|
|
|
195
243
|
const wrappedGetProjectStatus = withTelemetry(
|
|
196
244
|
"get_project_status",
|
|
197
245
|
async (name?: string, projectPath?: string) => {
|
|
198
|
-
|
|
246
|
+
const status = await getProjectStatus(name, projectPath);
|
|
247
|
+
if (status === null) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
// Add available_services to tell agents what services can be created
|
|
251
|
+
return {
|
|
252
|
+
...status,
|
|
253
|
+
available_services: ["d1", "kv", "r2"],
|
|
254
|
+
};
|
|
199
255
|
},
|
|
200
256
|
{ platform: "mcp" },
|
|
201
257
|
);
|
|
@@ -259,6 +315,80 @@ export function registerTools(server: McpServer, _options: McpServerOptions, deb
|
|
|
259
315
|
};
|
|
260
316
|
}
|
|
261
317
|
|
|
318
|
+
case "create_database": {
|
|
319
|
+
const args = CreateDatabaseSchema.parse(request.params.arguments ?? {});
|
|
320
|
+
const projectPath = args.project_path ?? process.cwd();
|
|
321
|
+
|
|
322
|
+
const wrappedCreateDatabase = withTelemetry(
|
|
323
|
+
"create_database",
|
|
324
|
+
async (projectDir: string, name?: string) => {
|
|
325
|
+
const result = await createDatabase(projectDir, {
|
|
326
|
+
name,
|
|
327
|
+
interactive: false,
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// Track business event
|
|
331
|
+
track(Events.SERVICE_CREATED, {
|
|
332
|
+
service_type: "d1",
|
|
333
|
+
platform: "mcp",
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
return {
|
|
337
|
+
database_name: result.databaseName,
|
|
338
|
+
database_id: result.databaseId,
|
|
339
|
+
binding_name: result.bindingName,
|
|
340
|
+
created: result.created,
|
|
341
|
+
deploy_required: true,
|
|
342
|
+
};
|
|
343
|
+
},
|
|
344
|
+
{ platform: "mcp" },
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
const result = await wrappedCreateDatabase(projectPath, args.name);
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
content: [
|
|
351
|
+
{
|
|
352
|
+
type: "text",
|
|
353
|
+
text: JSON.stringify(formatSuccessResponse(result, startTime), null, 2),
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
case "list_databases": {
|
|
360
|
+
const args = ListDatabasesSchema.parse(request.params.arguments ?? {});
|
|
361
|
+
const projectPath = args.project_path ?? process.cwd();
|
|
362
|
+
|
|
363
|
+
const wrappedListDatabases = withTelemetry(
|
|
364
|
+
"list_databases",
|
|
365
|
+
async (projectDir: string) => {
|
|
366
|
+
const databases = await listDatabases(projectDir);
|
|
367
|
+
return {
|
|
368
|
+
databases: databases.map((db) => ({
|
|
369
|
+
name: db.name,
|
|
370
|
+
binding: db.binding,
|
|
371
|
+
id: db.id,
|
|
372
|
+
size_bytes: db.sizeBytes,
|
|
373
|
+
num_tables: db.numTables,
|
|
374
|
+
})),
|
|
375
|
+
};
|
|
376
|
+
},
|
|
377
|
+
{ platform: "mcp" },
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
const result = await wrappedListDatabases(projectPath);
|
|
381
|
+
|
|
382
|
+
return {
|
|
383
|
+
content: [
|
|
384
|
+
{
|
|
385
|
+
type: "text",
|
|
386
|
+
text: JSON.stringify(formatSuccessResponse(result, startTime), null, 2),
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
|
|
262
392
|
default:
|
|
263
393
|
throw new Error(`Unknown tool: ${toolName}`);
|
|
264
394
|
}
|