From 1f887507152590da0313de5718b2fa691ded1054 Mon Sep 17 00:00:00 2001 From: Erik Thorelli Date: Wed, 7 Oct 2026 11:14:57 -0700 Subject: [PATCH] Remove the stdio MCP's administrator tools and their scripts --- app/scripts/add-user-to-admins.ts | 24 -------- app/scripts/functions.ts | 74 ------------------------ app/scripts/list-admins.ts | 27 --------- app/scripts/mcp-server.ts | 80 -------------------------- app/scripts/remove-user-from-admins.ts | 19 ------ 5 files changed, 224 deletions(-) delete mode 100644 app/scripts/add-user-to-admins.ts delete mode 100644 app/scripts/list-admins.ts delete mode 100644 app/scripts/remove-user-from-admins.ts diff --git a/app/scripts/add-user-to-admins.ts b/app/scripts/add-user-to-admins.ts deleted file mode 100644 index a0523960..00000000 --- a/app/scripts/add-user-to-admins.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { addUserToAdmins } from "./functions"; - -// Replace with the actual user ID from the neon_auth.users_sync table -const userId = "your-user-id-here"; - -async function main() { - try { - const result = await addUserToAdmins(userId); - console.log("✅ User added to administrators successfully!"); - console.log("Admin record:", result.admin); - console.log("User info:", { - id: result.user.id, - name: result.user.name, - email: result.user.email, - }); - } catch (error) { - console.error( - "❌ Error adding user to admins:", - error instanceof Error ? error.message : error, - ); - } -} - -await main(); diff --git a/app/scripts/functions.ts b/app/scripts/functions.ts index 65abbbf7..b0eaea6f 100644 --- a/app/scripts/functions.ts +++ b/app/scripts/functions.ts @@ -614,80 +614,6 @@ export async function addImagesToEvent( return results; } -// Administrator functions -export async function addUserToAdmins(userId: string) { - // First check if user exists in neon_auth.users_sync table - const { usersSync } = await import("drizzle-orm/neon"); - const userExists = await db - .select() - .from(usersSync) - .where(eq(usersSync.id, userId)) - .then((users) => users[0]); - - if (!userExists) { - throw new Error(`User with ID ${userId} not found in users_sync table`); - } - - // Check if user is already an admin - const { administratorsTable } = await import("../src/lib/schema"); - const existingAdmin = await db - .select() - .from(administratorsTable) - .where(eq(administratorsTable.userId, userId)) - .then((admins) => admins[0]); - - if (existingAdmin) { - throw new Error( - `User ${userExists.name || userId} is already an administrator`, - ); - } - - // Add user to administrators table - const result = await db - .insert(administratorsTable) - .values({ userId }) - .returning(); - - return { - admin: result[0], - user: userExists, - }; -} - -export async function removeUserFromAdmins(userId: string) { - const { administratorsTable } = await import("../src/lib/schema"); - - const result = await db - .delete(administratorsTable) - .where(eq(administratorsTable.userId, userId)) - .returning(); - - if (!result[0]) { - throw new Error(`User ${userId} is not an administrator`); - } - - return result[0]; -} - -export async function listAdmins() { - const { administratorsTable } = await import("../src/lib/schema"); - const { usersSync } = await import("drizzle-orm/neon"); - - const admins = await db - .select({ - id: administratorsTable.id, - userId: administratorsTable.userId, - createdAt: administratorsTable.createdAt, - updatedAt: administratorsTable.updatedAt, - userName: usersSync.name, - userEmail: usersSync.email, - }) - .from(administratorsTable) - .leftJoin(usersSync, eq(administratorsTable.userId, usersSync.id)); - - return admins; -} - // Luma functions export async function getLumaEvent(eventId: string) { const lumaClient = createLumaClient(); diff --git a/app/scripts/list-admins.ts b/app/scripts/list-admins.ts deleted file mode 100644 index 60f63b7e..00000000 --- a/app/scripts/list-admins.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { listAdmins } from "./functions"; - -async function main() { - try { - const admins = await listAdmins(); - console.log(`📋 Found ${admins.length} administrator(s):`); - - if (admins.length === 0) { - console.log("No administrators found."); - return; - } - - admins.forEach((admin, index) => { - console.log(`\n${index + 1}. ${admin.userName || "Unknown Name"}`); - console.log(` User ID: ${admin.userId}`); - console.log(` Email: ${admin.userEmail || "No email"}`); - console.log(` Added: ${admin.createdAt?.toISOString()}`); - }); - } catch (error) { - console.error( - "❌ Error listing admins:", - error instanceof Error ? error.message : error, - ); - } -} - -await main(); diff --git a/app/scripts/mcp-server.ts b/app/scripts/mcp-server.ts index 331181e4..b438fcee 100644 --- a/app/scripts/mcp-server.ts +++ b/app/scripts/mcp-server.ts @@ -46,9 +46,6 @@ import { deleteEventImages, deleteOrphanedImage, addImagesToEvent, - addUserToAdmins, - removeUserFromAdmins, - listAdmins, getLumaEvent, } from "./functions.js"; @@ -782,44 +779,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => { draftReadinessTool, ...lumaToolDefinitions, ...socialToolDefinitions, - // Administrator tools - { - name: "add_user_to_admins", - description: "Add a user to administrators by user ID", - inputSchema: { - type: "object", - properties: { - userId: { - type: "string", - description: "User ID from neon_auth.users_sync table", - }, - }, - required: ["userId"], - }, - }, - { - name: "remove_user_from_admins", - description: "Remove a user from administrators by user ID", - inputSchema: { - type: "object", - properties: { - userId: { - type: "string", - description: "User ID to remove from administrators", - }, - }, - required: ["userId"], - }, - }, - { - name: "list_admins", - description: "List all administrators with user details", - inputSchema: { - type: "object", - properties: {}, - required: [], - }, - }, ], }; }); @@ -1142,33 +1101,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { }; } - // Administrator tools - case "add_user_to_admins": { - const { userId } = args as { userId: string }; - const result = await addUserToAdmins(userId); - return { - content: [ - { - type: "text", - text: JSON.stringify(result, null, 2), - }, - ], - }; - } - - case "remove_user_from_admins": { - const { userId } = args as { userId: string }; - const result = await removeUserFromAdmins(userId); - return { - content: [ - { - type: "text", - text: JSON.stringify(result, null, 2), - }, - ], - }; - } - case "get_completeness_report": { const { slug } = (args ?? {}) as { slug?: string }; const result = await completenessReport(slug); @@ -1272,18 +1204,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { return { content: [{ type: "text", text }] }; } - case "list_admins": { - const result = await listAdmins(); - return { - content: [ - { - type: "text", - text: JSON.stringify(result, null, 2), - }, - ], - }; - } - default: throw new Error(`Unknown tool: ${toolName}`); } diff --git a/app/scripts/remove-user-from-admins.ts b/app/scripts/remove-user-from-admins.ts deleted file mode 100644 index f46c58c8..00000000 --- a/app/scripts/remove-user-from-admins.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { removeUserFromAdmins } from "./functions"; - -// Replace with the actual user ID to remove from administrators -const userId = "your-user-id-here"; - -async function main() { - try { - const result = await removeUserFromAdmins(userId); - console.log("✅ User removed from administrators successfully!"); - console.log("Removed admin record:", result); - } catch (error) { - console.error( - "❌ Error removing user from admins:", - error instanceof Error ? error.message : error, - ); - } -} - -await main();