Skip to main content
Glama
pashaydev

Terminal.shop MCP Server

by pashaydev

get-product-details

Retrieve detailed product information from Terminal.shop using a product ID for browsing, shopping cart management, and order placement.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdYes

Implementation Reference

  • The handler function for the 'get-product-details' tool. It fetches product details from the Terminal.shop API using the provided productId, formats the information including name, description, variants, subscription options, and tags, and returns it as formatted text.
    async ({ productId }) => { try { const response = await terminalApi.get(`/product/${productId}`); const product = response.data.data; // Format the product details let formattedText = `# ${product.name}\n\n`; formattedText += `ID: ${product.id}\n\n`; formattedText += `## Description\n${product.description}\n\n`; // Add variants section formattedText += `## Available Variants\n`; product.variants.forEach((variant) => { formattedText += `### ${variant.name}\n`; formattedText += `- Price: $${variant.price / 100}\n`; formattedText += `- ID: ${variant.id}\n\n`; }); // Add subscription info if available if (product.subscription) { formattedText += `## Subscription Options\n`; formattedText += `This product ${product.subscription === "required" ? "requires" : "allows"} subscription.\n\n`; } // Add tags if available if (product.tags && Object.keys(product.tags).length > 0) { formattedText += `## Product Tags\n`; Object.entries(product.tags).forEach(([key, value]) => { formattedText += `- ${key}: ${value}\n`; }); formattedText += "\n"; } return { content: [ { type: "text", text: formattedText, }, ], }; } catch (error) { console.error(`Error fetching product ${productId}:`, error); return { content: [ { type: "text", text: `Error fetching product details: ${error.message}`, }, ], isError: true, }; } },
  • The input schema for the 'get-product-details' tool, requiring a 'productId' string parameter validated with Zod.
    { productId: z.string(), },
  • server.js:502-561 (registration)
    The registration of the 'get-product-details' tool on the MCP server using server.tool(), specifying the tool name, input schema, and inline handler function.
    server.tool( "get-product-details", { productId: z.string(), }, async ({ productId }) => { try { const response = await terminalApi.get(`/product/${productId}`); const product = response.data.data; // Format the product details let formattedText = `# ${product.name}\n\n`; formattedText += `ID: ${product.id}\n\n`; formattedText += `## Description\n${product.description}\n\n`; // Add variants section formattedText += `## Available Variants\n`; product.variants.forEach((variant) => { formattedText += `### ${variant.name}\n`; formattedText += `- Price: $${variant.price / 100}\n`; formattedText += `- ID: ${variant.id}\n\n`; }); // Add subscription info if available if (product.subscription) { formattedText += `## Subscription Options\n`; formattedText += `This product ${product.subscription === "required" ? "requires" : "allows"} subscription.\n\n`; } // Add tags if available if (product.tags && Object.keys(product.tags).length > 0) { formattedText += `## Product Tags\n`; Object.entries(product.tags).forEach(([key, value]) => { formattedText += `- ${key}: ${value}\n`; }); formattedText += "\n"; } return { content: [ { type: "text", text: formattedText, }, ], }; } catch (error) { console.error(`Error fetching product ${productId}:`, error); return { content: [ { type: "text", text: `Error fetching product details: ${error.message}`, }, ], isError: true, }; } }, );

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/pashaydev/terminal.shop.mcp'

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