Skip to main content
Glama
codingthailand

xmcp Application

get-today-sales.ts1.95 kB
import { type ToolMetadata } from "xmcp"; const BASE_URL = "https://backend.codingthailand.com"; export const metadata: ToolMetadata = { name: "get_today_sales", description: "ดูสรุปยอดขายประจำวันนี้ แสดงจำนวนออเดอร์ รายได้ ต้นทุน และกำไร", annotations: { title: "Get Today's Sales", readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, }; export default async function getTodaySales() { try { const res = await fetch(`${BASE_URL}/v2/orders/today/summary`); if (!res.ok) { return `ไม่สามารถดึงข้อมูลยอดขายวันนี้ได้: ${res.statusText}`; } const data = await res.json(); const { date, summary } = data; const formattedDate = new Date(date).toLocaleDateString("th-TH", { weekday: "long", year: "numeric", month: "long", day: "numeric", }); return { structuredContent: data, // content: [ // { // type: "text" as const, // text: // `📊 สรุปยอดขายประจำวันนี้\n` + // `📅 วันที่: ${formattedDate}\n\n` + // `🛒 จำนวนออเดอร์: ${summary.totalOrders.toLocaleString("th-TH")} รายการ\n` + // `💰 รายได้รวม: ${summary.totalRevenue.toLocaleString("th-TH")} บาท\n` + // `📦 ต้นทุนรวม: ${summary.totalCost.toLocaleString("th-TH")} บาท\n` + // `✨ กำไรสุทธิ: ${summary.totalProfit.toLocaleString("th-TH")} บาท`, // }, // ], }; } catch (error) { return `เกิดข้อผิดพลาด: ${error instanceof Error ? error.message : "Unknown error"}`; } }

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/codingthailand/mcp-server-app'

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