Skip to main content
Glama
op-enny
by op-enny

fakestore_update_user

Modify user details in a simulated e-commerce environment by providing user ID and updated information like email, address, or username for testing and development purposes.

Instructions

Update an existing user (simulation - does not persist)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUser ID to update
emailNoNew email address
usernameNoNew username
passwordNoNew password
firstnameNoNew first name
lastnameNoNew last name
cityNoNew city
streetNoNew street name
numberNoNew street number
zipcodeNoNew ZIP code
latNoNew latitude
longNoNew longitude
phoneNoNew phone number

Implementation Reference

  • Core execution logic for updating a user. Validates input, constructs partial update object for name and address fields, and sends PUT request to `/users/${id}`.
    export async function updateUser(args: { id: number; email?: string; username?: string; password?: string; firstname?: string; lastname?: string; city?: string; street?: string; number?: number; zipcode?: string; lat?: string; long?: string; phone?: string; }): Promise<User> { const { id, email, username, password, firstname, lastname, city, street, number, zipcode, lat, long, phone, } = args; validatePositiveInteger(id, 'User ID'); const updateData: Record<string, unknown> = {}; if (email !== undefined) { validateEmail(email); updateData.email = email; } if (username !== undefined) updateData.username = username; if (password !== undefined) updateData.password = password; if (phone !== undefined) { validatePhone(phone); updateData.phone = phone; } // Handle name updates if (firstname !== undefined || lastname !== undefined) { updateData.name = {}; if (firstname !== undefined) (updateData.name as Record<string, unknown>).firstname = firstname; if (lastname !== undefined) (updateData.name as Record<string, unknown>).lastname = lastname; } // Handle address updates if (city !== undefined || street !== undefined || number !== undefined || zipcode !== undefined || lat !== undefined || long !== undefined) { updateData.address = {}; if (city !== undefined) (updateData.address as Record<string, unknown>).city = city; if (street !== undefined) (updateData.address as Record<string, unknown>).street = street; if (number !== undefined) (updateData.address as Record<string, unknown>).number = number; if (zipcode !== undefined) (updateData.address as Record<string, unknown>).zipcode = zipcode; if (lat !== undefined || long !== undefined) { (updateData.address as Record<string, unknown>).geolocation = {}; if (lat !== undefined) ((updateData.address as Record<string, unknown>).geolocation as Record<string, unknown>).lat = lat; if (long !== undefined) ((updateData.address as Record<string, unknown>).geolocation as Record<string, unknown>).long = long; } } return put<User>(`/users/${id}`, updateData); }
  • Input schema and metadata for the fakestore_update_user tool, part of the userTools array.
    { name: 'fakestore_update_user', description: 'Update an existing user (simulation - does not persist)', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'User ID to update', }, email: { type: 'string', description: 'New email address', }, username: { type: 'string', description: 'New username', }, password: { type: 'string', description: 'New password', }, firstname: { type: 'string', description: 'New first name', }, lastname: { type: 'string', description: 'New last name', }, city: { type: 'string', description: 'New city', }, street: { type: 'string', description: 'New street name', }, number: { type: 'number', description: 'New street number', }, zipcode: { type: 'string', description: 'New ZIP code', }, lat: { type: 'string', description: 'New latitude', }, long: { type: 'string', description: 'New longitude', }, phone: { type: 'string', description: 'New phone number', }, }, required: ['id'], }, },
  • src/index.ts:40-44 (registration)
    Tool registration via ListToolsRequestSchema handler, including userTools which defines fakestore_update_user.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });
  • Dispatch logic in CallToolRequestSchema handler that calls the updateUser function for this tool.
    if (name === 'fakestore_update_user') { const result = await updateUser(args as { id: number; email?: string; username?: string; password?: string; firstname?: string; lastname?: string; city?: string; street?: string; number?: number; zipcode?: string; lat?: string; long?: string; phone?: string; }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • User type definition used as return type for the updateUser handler.
    export interface User { id: number; email: string; username: string; password: string; name: UserName; address: Address; phone: string; }

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/op-enny/mcp-server-fakestore'

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