Add MCP support (#1028)

This commit is contained in:
Will Chen
2025-09-19 15:43:39 -07:00
committed by GitHub
parent 7b160b7d0b
commit 6d3c397d40
39 changed files with 3865 additions and 650 deletions

View File

@@ -172,3 +172,43 @@ export const versionsRelations = relations(versions, ({ one }) => ({
references: [apps.id],
}),
}));
// --- MCP (Model Context Protocol) tables ---
export const mcpServers = sqliteTable("mcp_servers", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name").notNull(),
transport: text("transport").notNull(),
command: text("command"),
// Store typed JSON for args and environment variables
args: text("args", { mode: "json" }).$type<string[] | null>(),
envJson: text("env_json", { mode: "json" }).$type<Record<
string,
string
> | null>(),
url: text("url"),
enabled: integer("enabled", { mode: "boolean" })
.notNull()
.default(sql`0`),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
updatedAt: integer("updated_at", { mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
});
export const mcpToolConsents = sqliteTable(
"mcp_tool_consents",
{
id: integer("id").primaryKey({ autoIncrement: true }),
serverId: integer("server_id")
.notNull()
.references(() => mcpServers.id, { onDelete: "cascade" }),
toolName: text("tool_name").notNull(),
consent: text("consent").notNull().default("ask"), // ask | always | denied
updatedAt: integer("updated_at", { mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
},
(table) => [unique("uniq_mcp_consent").on(table.serverId, table.toolName)],
);