checkout
Complete purchases and place orders for items in your Terminal.shop shopping cart using the Terminal.shop MCP Server.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "checkout"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:716-773 (handler)The handler function for the 'checkout' tool. It calls the Terminal.shop API to convert the current cart into an order (/cart/convert), formats the order details including shipping, tracking, items, and totals, and returns a text response. Includes error handling with console.error and error message response.
server.tool("checkout", {}, async () => { try { const response = await terminalApi.post("/cart/convert"); const order = response.data.data; let formattedText = "# Order Placed Successfully!\n\n"; formattedText += `Order ID: ${order.id}\n`; // Shipping information formattedText += "\n## Shipping Information\n"; formattedText += `Name: ${order.shipping.name}\n`; formattedText += `Address: ${order.shipping.street1}${order.shipping.street2 ? `, ${order.shipping.street2}` : ""}\n`; formattedText += `${order.shipping.city}, ${order.shipping.province || ""} ${order.shipping.zip}\n`; formattedText += `Country: ${order.shipping.country}\n`; if (order.shipping.phone) formattedText += `Phone: ${order.shipping.phone}\n`; // Tracking information if available if (order.tracking) { formattedText += "\n## Tracking Information\n"; formattedText += `Service: ${order.tracking.service}\n`; formattedText += `Tracking Number: ${order.tracking.number}\n`; formattedText += `Tracking URL: ${order.tracking.url}\n`; } // Order details formattedText += "\n## Order Details\n"; order.items.forEach((item) => { formattedText += `- Quantity: ${item.quantity}, Amount: $${item.amount / 100}, Variant ID: ${item.productVariantID}\n`; }); // Totals formattedText += "\n## Order Totals\n"; formattedText += `Subtotal: $${order.amount.subtotal / 100}\n`; formattedText += `Shipping: $${order.amount.shipping / 100}\n`; formattedText += `Total: $${(order.amount.subtotal + order.amount.shipping) / 100}\n`; return { content: [ { type: "text", text: formattedText, }, ], }; } catch (error) { console.error("Error during checkout:", error); return { content: [ { type: "text", text: `Error during checkout: ${error.message}`, }, ], isError: true, }; } }); - server.js:716-773 (registration)The registration of the 'checkout' tool using server.tool with empty input schema ({}). The handler is inline.
server.tool("checkout", {}, async () => { try { const response = await terminalApi.post("/cart/convert"); const order = response.data.data; let formattedText = "# Order Placed Successfully!\n\n"; formattedText += `Order ID: ${order.id}\n`; // Shipping information formattedText += "\n## Shipping Information\n"; formattedText += `Name: ${order.shipping.name}\n`; formattedText += `Address: ${order.shipping.street1}${order.shipping.street2 ? `, ${order.shipping.street2}` : ""}\n`; formattedText += `${order.shipping.city}, ${order.shipping.province || ""} ${order.shipping.zip}\n`; formattedText += `Country: ${order.shipping.country}\n`; if (order.shipping.phone) formattedText += `Phone: ${order.shipping.phone}\n`; // Tracking information if available if (order.tracking) { formattedText += "\n## Tracking Information\n"; formattedText += `Service: ${order.tracking.service}\n`; formattedText += `Tracking Number: ${order.tracking.number}\n`; formattedText += `Tracking URL: ${order.tracking.url}\n`; } // Order details formattedText += "\n## Order Details\n"; order.items.forEach((item) => { formattedText += `- Quantity: ${item.quantity}, Amount: $${item.amount / 100}, Variant ID: ${item.productVariantID}\n`; }); // Totals formattedText += "\n## Order Totals\n"; formattedText += `Subtotal: $${order.amount.subtotal / 100}\n`; formattedText += `Shipping: $${order.amount.shipping / 100}\n`; formattedText += `Total: $${(order.amount.subtotal + order.amount.shipping) / 100}\n`; return { content: [ { type: "text", text: formattedText, }, ], }; } catch (error) { console.error("Error during checkout:", error); return { content: [ { type: "text", text: `Error during checkout: ${error.message}`, }, ], isError: true, }; } }); - server.js:716-716 (schema)Empty input schema for the 'checkout' tool (no parameters required).
server.tool("checkout", {}, async () => {