@backwrite/mcp 0.1.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/README.md +72 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +422 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# `@backwrite/mcp`
|
|
2
|
+
|
|
3
|
+
Official **Model Context Protocol (MCP)** server for **Backwrite** — the programmable backend infrastructure platform.
|
|
4
|
+
|
|
5
|
+
Connect AI tools such as **Lovable**, **Cursor**, **Windsurf**, and **Claude Code** directly to your Backwrite database to create and inspect tables, run migrations, enforce RLS policies, generate TypeScript types, and introspect database schemas autonomously.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
### 1. Run with `npx` (zero install)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @backwrite/mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 2. Configure in Cursor (`~/.cursor/mcp.json` or project `.cursor/mcp.json`)
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"backwrite": {
|
|
23
|
+
"command": "npx",
|
|
24
|
+
"args": ["-y", "@backwrite/mcp"],
|
|
25
|
+
"env": {
|
|
26
|
+
"BACKWRITE_URL": "https://api.backwrite.dev",
|
|
27
|
+
"BACKWRITE_SERVICE_KEY": "bwk_service_...",
|
|
28
|
+
"BACKWRITE_PROJECT_ID": "bw_proj_...",
|
|
29
|
+
"BACKWRITE_BRANCH_ID": "br_..."
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 3. Configure in Claude Desktop (`claude_desktop_config.json`)
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"backwrite": {
|
|
42
|
+
"command": "npx",
|
|
43
|
+
"args": ["-y", "@backwrite/mcp"],
|
|
44
|
+
"env": {
|
|
45
|
+
"BACKWRITE_URL": "https://api.backwrite.dev",
|
|
46
|
+
"BACKWRITE_SERVICE_KEY": "bwk_service_...",
|
|
47
|
+
"BACKWRITE_PROJECT_ID": "bw_proj_..."
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Exposed Tools
|
|
57
|
+
|
|
58
|
+
| Tool | Description |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `backwrite_execute_sql` | Execute arbitrary SQL queries, multi-statement DDL/DML, migrations, and RLS policies. |
|
|
61
|
+
| `backwrite_get_database_schema` | 1-roundtrip complete relational schema introspection (tables, columns, types, nullability, defaults, primary keys, foreign keys, indexes, RLS policies). |
|
|
62
|
+
| `backwrite_list_tables` | List user tables with column counts and primary keys. |
|
|
63
|
+
| `backwrite_describe_table` | Detailed inspection of a specific table. |
|
|
64
|
+
| `backwrite_list_branches` | List project branches (production, preview, development). |
|
|
65
|
+
| `backwrite_get_connection_string` | Direct wire (`5432`) and pooler (`6543`) connection coordinates. |
|
|
66
|
+
| `backwrite_generate_types` | Generate TypeScript interfaces, Prisma schema, or Drizzle schema. |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
Apache-2.0 © Backwrite
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @backwrite/mcp — Official Model Context Protocol (MCP) server for Backwrite.
|
|
4
|
+
* Connects AI tools (Lovable, Cursor, Claude Code, Windsurf) directly to Backwrite databases.
|
|
5
|
+
*/
|
|
6
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
7
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
const BACKWRITE_URL = (process.env.BACKWRITE_URL ||
|
|
10
|
+
process.env.BACKWRITE_API_URL ||
|
|
11
|
+
"https://api.backwrite.dev").replace(/\/$/, "");
|
|
12
|
+
const BACKWRITE_API_KEY = process.env.BACKWRITE_SERVICE_KEY ||
|
|
13
|
+
process.env.BACKWRITE_SECRET_KEY ||
|
|
14
|
+
process.env.BACKWRITE_API_KEY ||
|
|
15
|
+
process.env.BW_KEY ||
|
|
16
|
+
"";
|
|
17
|
+
const DEFAULT_PROJECT_ID = process.env.BACKWRITE_PROJECT_ID || "";
|
|
18
|
+
const DEFAULT_BRANCH_ID = process.env.BACKWRITE_BRANCH_ID || "";
|
|
19
|
+
async function apiRequest(path, method = "GET", body) {
|
|
20
|
+
const url = `${BACKWRITE_URL}${path}`;
|
|
21
|
+
const headers = {
|
|
22
|
+
Accept: "application/json",
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
};
|
|
25
|
+
if (BACKWRITE_API_KEY) {
|
|
26
|
+
headers["apikey"] = BACKWRITE_API_KEY;
|
|
27
|
+
headers["Authorization"] = `Bearer ${BACKWRITE_API_KEY}`;
|
|
28
|
+
}
|
|
29
|
+
const response = await fetch(url, {
|
|
30
|
+
method,
|
|
31
|
+
headers,
|
|
32
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
33
|
+
});
|
|
34
|
+
const json = await response.json().catch(() => ({}));
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const errorMsg = json.error?.message || json.message || `HTTP ${response.status} ${response.statusText}`;
|
|
37
|
+
throw new Error(`Backwrite API error: ${errorMsg}`);
|
|
38
|
+
}
|
|
39
|
+
return json.data ?? json;
|
|
40
|
+
}
|
|
41
|
+
function resolveProject(projectId) {
|
|
42
|
+
const p = projectId || DEFAULT_PROJECT_ID;
|
|
43
|
+
if (!p) {
|
|
44
|
+
throw new Error("No project_id specified and BACKWRITE_PROJECT_ID environment variable is not set.");
|
|
45
|
+
}
|
|
46
|
+
return p;
|
|
47
|
+
}
|
|
48
|
+
function resolveBranch(branchId) {
|
|
49
|
+
return branchId || DEFAULT_BRANCH_ID || undefined;
|
|
50
|
+
}
|
|
51
|
+
// ── Codegen Utilities ────────────────────────────────────────────────────────
|
|
52
|
+
function pgToTs(ty, nullable) {
|
|
53
|
+
const lower = ty.toLowerCase();
|
|
54
|
+
const isArray = lower.endsWith("[]") || lower.startsWith("_");
|
|
55
|
+
const clean = lower.replace(/\[\]$/, "").replace(/^_/, "");
|
|
56
|
+
let base = "string";
|
|
57
|
+
if (clean.includes("int") ||
|
|
58
|
+
clean.includes("serial") ||
|
|
59
|
+
clean.includes("float") ||
|
|
60
|
+
clean.includes("double") ||
|
|
61
|
+
clean.includes("numeric") ||
|
|
62
|
+
clean.includes("decimal") ||
|
|
63
|
+
clean.includes("real") ||
|
|
64
|
+
clean === "money") {
|
|
65
|
+
base = "number";
|
|
66
|
+
}
|
|
67
|
+
else if (clean.includes("bool")) {
|
|
68
|
+
base = "boolean";
|
|
69
|
+
}
|
|
70
|
+
else if (clean.includes("json")) {
|
|
71
|
+
base = "Record<string, unknown> | unknown[]";
|
|
72
|
+
}
|
|
73
|
+
else if (clean.includes("bytea")) {
|
|
74
|
+
base = "Uint8Array";
|
|
75
|
+
}
|
|
76
|
+
else if (clean.includes("timestamp") || clean.includes("date") || clean.includes("time")) {
|
|
77
|
+
base = "string | Date";
|
|
78
|
+
}
|
|
79
|
+
const typeStr = isArray ? `${base}[]` : base;
|
|
80
|
+
return nullable ? `${typeStr} | null` : typeStr;
|
|
81
|
+
}
|
|
82
|
+
function toPascalCase(s) {
|
|
83
|
+
return s
|
|
84
|
+
.split(/[-_ ]+/)
|
|
85
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
86
|
+
.join("");
|
|
87
|
+
}
|
|
88
|
+
function toCamelCase(s) {
|
|
89
|
+
const p = toPascalCase(s);
|
|
90
|
+
return p.charAt(0).toLowerCase() + p.slice(1);
|
|
91
|
+
}
|
|
92
|
+
function generateTypescript(schema) {
|
|
93
|
+
let out = "/**\n * Generated by Backwrite MCP Server\n */\n\n";
|
|
94
|
+
for (const table of schema.tables ?? []) {
|
|
95
|
+
const ifaceName = toPascalCase(table.name);
|
|
96
|
+
out += `export interface ${ifaceName} {\n`;
|
|
97
|
+
for (const col of table.columns ?? []) {
|
|
98
|
+
const opt = col.nullable ? "?" : "";
|
|
99
|
+
out += ` ${col.name}${opt}: ${pgToTs(col.data_type, col.nullable)};\n`;
|
|
100
|
+
}
|
|
101
|
+
out += `}\n\n`;
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function generatePrisma(schema) {
|
|
106
|
+
let out = `// Generated by Backwrite MCP Server\ndatasource db {\n provider = "postgresql"\n url = env("DATABASE_URL")\n directUrl = env("DIRECT_URL")\n}\n\ngenerator client {\n provider = "prisma-client-js"\n}\n\n`;
|
|
107
|
+
for (const table of schema.tables ?? []) {
|
|
108
|
+
const modelName = toPascalCase(table.name);
|
|
109
|
+
out += `model ${modelName} {\n`;
|
|
110
|
+
for (const col of table.columns ?? []) {
|
|
111
|
+
const isPk = col.is_pk ? " @id" : "";
|
|
112
|
+
const isUnique = col.is_unique && !col.is_pk ? " @unique" : "";
|
|
113
|
+
const nullSuffix = col.nullable && !col.is_pk ? "?" : "";
|
|
114
|
+
const ptype = col.data_type.includes("int")
|
|
115
|
+
? "Int"
|
|
116
|
+
: col.data_type.includes("bool")
|
|
117
|
+
? "Boolean"
|
|
118
|
+
: col.data_type.includes("time") || col.data_type.includes("date")
|
|
119
|
+
? "DateTime"
|
|
120
|
+
: "String";
|
|
121
|
+
out += ` ${col.name.padEnd(16)} ${ptype}${nullSuffix}${isPk}${isUnique}\n`;
|
|
122
|
+
}
|
|
123
|
+
out += `\n @@map("${table.name}")\n}\n\n`;
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
function generateDrizzle(schema) {
|
|
128
|
+
let out = `/**\n * Generated by Backwrite MCP Server for Drizzle ORM\n */\nimport { pgTable, text, integer, boolean, timestamp, jsonb } from "drizzle-orm/pg-core";\n\n`;
|
|
129
|
+
for (const table of schema.tables ?? []) {
|
|
130
|
+
const varName = toCamelCase(table.name);
|
|
131
|
+
out += `export const ${varName} = pgTable("${table.name}", {\n`;
|
|
132
|
+
for (const col of table.columns ?? []) {
|
|
133
|
+
const helper = col.data_type.includes("int")
|
|
134
|
+
? "integer"
|
|
135
|
+
: col.data_type.includes("bool")
|
|
136
|
+
? "boolean"
|
|
137
|
+
: col.data_type.includes("time")
|
|
138
|
+
? "timestamp"
|
|
139
|
+
: col.data_type.includes("json")
|
|
140
|
+
? "jsonb"
|
|
141
|
+
: "text";
|
|
142
|
+
const pk = col.is_pk ? ".primaryKey()" : "";
|
|
143
|
+
const notNull = !col.nullable && !col.is_pk ? ".notNull()" : "";
|
|
144
|
+
out += ` ${col.name}: ${helper}("${col.name}")${pk}${notNull},\n`;
|
|
145
|
+
}
|
|
146
|
+
out += `});\n\n`;
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
// ── MCP Tools Definitions ───────────────────────────────────────────────────
|
|
151
|
+
const TOOLS = [
|
|
152
|
+
{
|
|
153
|
+
name: "backwrite_execute_sql",
|
|
154
|
+
description: "Execute arbitrary SQL queries, DDL (CREATE TABLE, ALTER TABLE, CREATE POLICY), or DML (INSERT, SELECT, UPDATE, DELETE) on the Backwrite database.",
|
|
155
|
+
inputSchema: {
|
|
156
|
+
type: "object",
|
|
157
|
+
properties: {
|
|
158
|
+
sql: {
|
|
159
|
+
type: "string",
|
|
160
|
+
description: "The raw SQL statement(s) to execute.",
|
|
161
|
+
},
|
|
162
|
+
project_id: {
|
|
163
|
+
type: "string",
|
|
164
|
+
description: "Optional project ID. Defaults to BACKWRITE_PROJECT_ID.",
|
|
165
|
+
},
|
|
166
|
+
branch_id: {
|
|
167
|
+
type: "string",
|
|
168
|
+
description: "Optional branch ID. Defaults to BACKWRITE_BRANCH_ID.",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
required: ["sql"],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "backwrite_get_database_schema",
|
|
176
|
+
description: "Retrieve the complete relational database schema in a single call, including all tables, columns, data types, nullability, primary keys, foreign keys, indexes, and RLS policies.",
|
|
177
|
+
inputSchema: {
|
|
178
|
+
type: "object",
|
|
179
|
+
properties: {
|
|
180
|
+
project_id: {
|
|
181
|
+
type: "string",
|
|
182
|
+
description: "Optional project ID. Defaults to BACKWRITE_PROJECT_ID.",
|
|
183
|
+
},
|
|
184
|
+
branch_id: {
|
|
185
|
+
type: "string",
|
|
186
|
+
description: "Optional branch ID. Defaults to BACKWRITE_BRANCH_ID.",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "backwrite_list_tables",
|
|
193
|
+
description: "List all user tables in the database with their schemas, column counts, and primary keys.",
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: "object",
|
|
196
|
+
properties: {
|
|
197
|
+
project_id: {
|
|
198
|
+
type: "string",
|
|
199
|
+
description: "Optional project ID. Defaults to BACKWRITE_PROJECT_ID.",
|
|
200
|
+
},
|
|
201
|
+
branch_id: {
|
|
202
|
+
type: "string",
|
|
203
|
+
description: "Optional branch ID. Defaults to BACKWRITE_BRANCH_ID.",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "backwrite_describe_table",
|
|
210
|
+
description: "Get detailed schema information for a specific table, including columns, data types, constraints, foreign keys, and RLS policies.",
|
|
211
|
+
inputSchema: {
|
|
212
|
+
type: "object",
|
|
213
|
+
properties: {
|
|
214
|
+
table_name: {
|
|
215
|
+
type: "string",
|
|
216
|
+
description: "The name of the table to inspect.",
|
|
217
|
+
},
|
|
218
|
+
schema_name: {
|
|
219
|
+
type: "string",
|
|
220
|
+
description: "Optional schema name (defaults to 'public').",
|
|
221
|
+
},
|
|
222
|
+
project_id: {
|
|
223
|
+
type: "string",
|
|
224
|
+
description: "Optional project ID. Defaults to BACKWRITE_PROJECT_ID.",
|
|
225
|
+
},
|
|
226
|
+
branch_id: {
|
|
227
|
+
type: "string",
|
|
228
|
+
description: "Optional branch ID. Defaults to BACKWRITE_BRANCH_ID.",
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
required: ["table_name"],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "backwrite_list_branches",
|
|
236
|
+
description: "List all branches (production, preview, development) for a Backwrite project.",
|
|
237
|
+
inputSchema: {
|
|
238
|
+
type: "object",
|
|
239
|
+
properties: {
|
|
240
|
+
project_id: {
|
|
241
|
+
type: "string",
|
|
242
|
+
description: "Optional project ID. Defaults to BACKWRITE_PROJECT_ID.",
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "backwrite_get_connection_string",
|
|
249
|
+
description: "Retrieve direct PostgreSQL wire connection (port 5432) and connection pooler string (port 6543) for the project or branch.",
|
|
250
|
+
inputSchema: {
|
|
251
|
+
type: "object",
|
|
252
|
+
properties: {
|
|
253
|
+
project_id: {
|
|
254
|
+
type: "string",
|
|
255
|
+
description: "Optional project ID. Defaults to BACKWRITE_PROJECT_ID.",
|
|
256
|
+
},
|
|
257
|
+
branch_id: {
|
|
258
|
+
type: "string",
|
|
259
|
+
description: "Optional branch ID. Defaults to BACKWRITE_BRANCH_ID.",
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "backwrite_generate_types",
|
|
266
|
+
description: "Generate TypeScript interfaces, Prisma schema, or Drizzle schema for the database.",
|
|
267
|
+
inputSchema: {
|
|
268
|
+
type: "object",
|
|
269
|
+
properties: {
|
|
270
|
+
format: {
|
|
271
|
+
type: "string",
|
|
272
|
+
enum: ["typescript", "prisma", "drizzle"],
|
|
273
|
+
description: "The output format to generate ('typescript', 'prisma', or 'drizzle').",
|
|
274
|
+
},
|
|
275
|
+
project_id: {
|
|
276
|
+
type: "string",
|
|
277
|
+
description: "Optional project ID. Defaults to BACKWRITE_PROJECT_ID.",
|
|
278
|
+
},
|
|
279
|
+
branch_id: {
|
|
280
|
+
type: "string",
|
|
281
|
+
description: "Optional branch ID. Defaults to BACKWRITE_BRANCH_ID.",
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
required: ["format"],
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
// ── MCP Server Startup ──────────────────────────────────────────────────────
|
|
289
|
+
async function main() {
|
|
290
|
+
const server = new Server({
|
|
291
|
+
name: "backwrite-mcp",
|
|
292
|
+
version: "0.1.0",
|
|
293
|
+
}, {
|
|
294
|
+
capabilities: {
|
|
295
|
+
tools: {},
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
299
|
+
tools: TOOLS,
|
|
300
|
+
}));
|
|
301
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
302
|
+
const { name, arguments: args } = request.params;
|
|
303
|
+
const a = args || {};
|
|
304
|
+
try {
|
|
305
|
+
switch (name) {
|
|
306
|
+
case "backwrite_execute_sql": {
|
|
307
|
+
const project = resolveProject(a.project_id);
|
|
308
|
+
const branch = resolveBranch(a.branch_id);
|
|
309
|
+
const path = branch
|
|
310
|
+
? `/v1/projects/${encodeURIComponent(project)}/branches/${encodeURIComponent(branch)}/query`
|
|
311
|
+
: `/v1/projects/${encodeURIComponent(project)}/query`;
|
|
312
|
+
const res = await apiRequest(path, "POST", { sql: a.sql, view: "raw" });
|
|
313
|
+
return {
|
|
314
|
+
content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
case "backwrite_get_database_schema": {
|
|
318
|
+
const project = resolveProject(a.project_id);
|
|
319
|
+
const branch = resolveBranch(a.branch_id);
|
|
320
|
+
const path = branch
|
|
321
|
+
? `/v1/projects/${encodeURIComponent(project)}/branches/${encodeURIComponent(branch)}/schema`
|
|
322
|
+
: `/v1/projects/${encodeURIComponent(project)}/schema`;
|
|
323
|
+
const res = await apiRequest(path, "GET");
|
|
324
|
+
return {
|
|
325
|
+
content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
case "backwrite_list_tables": {
|
|
329
|
+
const project = resolveProject(a.project_id);
|
|
330
|
+
const branch = resolveBranch(a.branch_id);
|
|
331
|
+
const path = branch
|
|
332
|
+
? `/v1/projects/${encodeURIComponent(project)}/branches/${encodeURIComponent(branch)}/schema`
|
|
333
|
+
: `/v1/projects/${encodeURIComponent(project)}/schema`;
|
|
334
|
+
const res = await apiRequest(path, "GET");
|
|
335
|
+
const tables = (res.tables || []).map((t) => ({
|
|
336
|
+
schema: t.schema,
|
|
337
|
+
name: t.name,
|
|
338
|
+
column_count: t.columns?.length ?? 0,
|
|
339
|
+
primary_key: t.primary_key ?? [],
|
|
340
|
+
}));
|
|
341
|
+
return {
|
|
342
|
+
content: [{ type: "text", text: JSON.stringify(tables, null, 2) }],
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
case "backwrite_describe_table": {
|
|
346
|
+
const project = resolveProject(a.project_id);
|
|
347
|
+
const branch = resolveBranch(a.branch_id);
|
|
348
|
+
const path = branch
|
|
349
|
+
? `/v1/projects/${encodeURIComponent(project)}/branches/${encodeURIComponent(branch)}/schema`
|
|
350
|
+
: `/v1/projects/${encodeURIComponent(project)}/schema`;
|
|
351
|
+
const res = await apiRequest(path, "GET");
|
|
352
|
+
const targetSchema = a.schema_name || "public";
|
|
353
|
+
const table = (res.tables || []).find((t) => t.name === a.table_name &&
|
|
354
|
+
(t.schema === targetSchema || (!a.schema_name && t.schema === "public")));
|
|
355
|
+
if (!table) {
|
|
356
|
+
throw new Error(`Table '${a.table_name}' not found.`);
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
content: [{ type: "text", text: JSON.stringify(table, null, 2) }],
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
case "backwrite_list_branches": {
|
|
363
|
+
const project = resolveProject(a.project_id);
|
|
364
|
+
const res = await apiRequest(`/v1/projects/${encodeURIComponent(project)}/branches`, "GET");
|
|
365
|
+
return {
|
|
366
|
+
content: [{ type: "text", text: JSON.stringify(res.branches ?? res, null, 2) }],
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
case "backwrite_get_connection_string": {
|
|
370
|
+
const project = resolveProject(a.project_id);
|
|
371
|
+
const branch = resolveBranch(a.branch_id);
|
|
372
|
+
const path = branch
|
|
373
|
+
? `/v1/projects/${encodeURIComponent(project)}/branches/${encodeURIComponent(branch)}/connection`
|
|
374
|
+
: `/v1/projects/${encodeURIComponent(project)}/connection`;
|
|
375
|
+
const res = await apiRequest(path, "GET");
|
|
376
|
+
return {
|
|
377
|
+
content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
case "backwrite_generate_types": {
|
|
381
|
+
const project = resolveProject(a.project_id);
|
|
382
|
+
const branch = resolveBranch(a.branch_id);
|
|
383
|
+
const path = branch
|
|
384
|
+
? `/v1/projects/${encodeURIComponent(project)}/branches/${encodeURIComponent(branch)}/schema`
|
|
385
|
+
: `/v1/projects/${encodeURIComponent(project)}/schema`;
|
|
386
|
+
const res = await apiRequest(path, "GET");
|
|
387
|
+
let code = "";
|
|
388
|
+
if (a.format === "typescript") {
|
|
389
|
+
code = generateTypescript(res);
|
|
390
|
+
}
|
|
391
|
+
else if (a.format === "prisma") {
|
|
392
|
+
code = generatePrisma(res);
|
|
393
|
+
}
|
|
394
|
+
else if (a.format === "drizzle") {
|
|
395
|
+
code = generateDrizzle(res);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
throw new Error(`Unsupported format: ${a.format}`);
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
content: [{ type: "text", text: code }],
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
default:
|
|
405
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
catch (err) {
|
|
409
|
+
return {
|
|
410
|
+
isError: true,
|
|
411
|
+
content: [{ type: "text", text: `Error: ${err.message || String(err)}` }],
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
const transport = new StdioServerTransport();
|
|
416
|
+
await server.connect(transport);
|
|
417
|
+
}
|
|
418
|
+
main().catch((error) => {
|
|
419
|
+
console.error("Fatal error in Backwrite MCP server:", error);
|
|
420
|
+
process.exit(1);
|
|
421
|
+
});
|
|
422
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,aAAa,GAAG,CACpB,OAAO,CAAC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IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backwrite/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Model Context Protocol (MCP) server for Backwrite — connect Lovable, Cursor, Windsurf, and Claude Code directly to your programmable backend infrastructure",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"backwrite-mcp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"start": "node dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"backwrite",
|
|
21
|
+
"mcp",
|
|
22
|
+
"model-context-protocol",
|
|
23
|
+
"ai",
|
|
24
|
+
"lovable",
|
|
25
|
+
"cursor",
|
|
26
|
+
"database",
|
|
27
|
+
"postgres"
|
|
28
|
+
],
|
|
29
|
+
"author": "Backwrite <backwrite@backwrite.dev>",
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.6.1",
|
|
33
|
+
"zod": "^3.24.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^22.13.9",
|
|
37
|
+
"typescript": "^5.7.3"
|
|
38
|
+
}
|
|
39
|
+
}
|