adding an MCP Server 🎉

This commit is contained in:
orangecoding
2026-03-09 15:35:29 +01:00
parent a460b813c1
commit be5c4af3cf
21 changed files with 1374 additions and 51 deletions

View File

@@ -0,0 +1,25 @@
/*
* Copyright (c) 2026 by Christian Kellner.
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
*/
/*
* Copyright (c) 2026 by Christian Kellner.
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
*/
import crypto from 'crypto';
// Migration: Add mcp_token column to users table.
// Each user gets a permanent, non-expiring secret token used for MCP API authentication.
// Tokens are auto-generated for all existing users during this migration.
export function up(db) {
db.exec(`ALTER TABLE users ADD COLUMN mcp_token TEXT`);
// Backfill all existing users that don't have a token yet
const users = db.prepare(`SELECT id FROM users WHERE mcp_token IS NULL`).all();
const update = db.prepare(`UPDATE users SET mcp_token = @token WHERE id = @id`);
for (const user of users) {
const token = `fredy_${crypto.randomBytes(32).toString('hex')}`;
update.run({ id: user.id, token });
}
}