Skip to main content
Glama

create-user

Add new users to the system by providing required details like name, email, address, age, and phone number for user management operations.

Instructions

Create a new user in the system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
emailYes
addressYes
ageYes
phoneYes

Implementation Reference

  • The main handler function for the 'create-user' tool. It calls the createUser helper with the input params, handles success/error responses, and returns formatted content.
    async (params) => { try { const userId = await createUser(params); return { content: [ { type: "text", text: `User created successfully with ID: ${userId}`, }, ], }; } catch (error) { console.error("Error creating user:", error); return { content: [ { type: "text", text: `Failed to create user`, }, ], }; } }
  • Input schema using Zod for validating parameters: name, email, address, age, phone.
    { name: z.string(), email: z.string().email(), address: z.string(), age: z.number().int().min(0), phone: z.string(), },
  • src/server.ts:81-121 (registration)
    Registration of the 'create-user' tool using server.tool, including name, description, input schema, metadata, and inline handler.
    server.tool( "create-user", "Create a new user in the system", { name: z.string(), email: z.string().email(), address: z.string(), age: z.number().int().min(0), phone: z.string(), }, { title: "Create User", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true, }, async (params) => { try { const userId = await createUser(params); return { content: [ { type: "text", text: `User created successfully with ID: ${userId}`, }, ], }; } catch (error) { console.error("Error creating user:", error); return { content: [ { type: "text", text: `Failed to create user`, }, ], }; } } );
  • Helper function that loads existing users from JSON, appends a new user with incremented ID, writes back to file, and returns the new ID.
    async function createUser(params: { name: string; email: string; address: string; age: number; phone: string }) { const users = await import("./data/users.json", { with: { type: "json" } }).then((m) => m.default); const newId = users.length + 1; const newUsers = [...users, { id: newId, ...params }]; writeFileSync("./src/data/users.json", JSON.stringify(newUsers, null, 2)); return newId; }

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SufyaanKhateeb/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server