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

fakestore_get_user_carts

Retrieve all shopping carts for a specific user from the Fake Store API to manage e-commerce data for testing or learning purposes.

Instructions

Get all carts belonging to a specific user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdYesUser ID

Implementation Reference

  • Core handler function that validates the userId and fetches the user's carts from the FakeStore API endpoint `/carts/user/${userId}`.
    export async function getUserCarts(args: { userId: number }): Promise<Cart[]> { const { userId } = args; validatePositiveInteger(userId, 'User ID'); return get<Cart[]>(`/carts/user/${userId}`); }
  • MCP server dispatch handler that calls the getUserCarts function and formats the response as MCP content.
    if (name === 'fakestore_get_user_carts') { const result = await getUserCarts(args as { userId: number }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • Tool schema definition including name, description, and inputSchema for validation.
    { name: 'fakestore_get_user_carts', description: 'Get all carts belonging to a specific user', inputSchema: { type: 'object', properties: { userId: { type: 'number', description: 'User ID', }, }, required: ['userId'], },
  • src/index.ts:40-44 (registration)
    Registration of all tools including cartTools (which contains fakestore_get_user_carts) in the MCP server's listTools handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });

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