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 to support shopping decisions and order management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdYes

Implementation Reference

  • The handler function for the 'get-product-details' tool. It fetches product details using the provided productId from the terminalApi, formats the information including name, description, variants, subscription info, and tags into markdown text, and returns it. Handles errors by returning an error message.
    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, }; } },
  • Input schema for the 'get-product-details' tool, defining 'productId' as a required string using Zod validation.
    productId: z.string(), }, async ({ productId }) => {
  • server.js:503-562 (registration)
    Registration of the 'get-product-details' tool using server.tool(), specifying the name, input schema, and inline handler function.
    "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