Documentation
thai-mcp is a Model Context Protocol server with seven deterministic Thai tools. Use the hosted endpoint, or run the same code locally over stdio.
Quick start
Zero install: point a Streamable-HTTP-capable client at https://thaimcp.pages.dev/mcp. No key, no account.
claude mcp add --transport http thai https://thaimcp.pages.dev/mcp{
"mcpServers": {
"thai": { "url": "https://thaimcp.pages.dev/mcp" }
}
}Local stdio: the package is not on npm yet, so npx thai-mcp does not work today. Download thai-mcp-0.1.0.tgz and install it, or run from a source checkout:
npm install -g ./thai-mcp-0.1.0.tgz
# then in your client config: { "command": "thai-mcp" }
# or from source
npm install
node /absolute/path/to/thai-mcp/src/server.js{
"mcpServers": {
"thai": { "command": "node", "args": ["/absolute/path/to/thai-mcp/src/server.js"] }
}
}Remote endpoint
POST https://thaimcp.pages.dev/mcp implements the MCP Streamable HTTP transport statelessly, in plain JavaScript without the SDK:
- JSON-RPC 2.0 methods:
initialize,notifications/initialized(→ 202, empty body),ping,tools/list,tools/call. Other methods return-32601. - Protocol versions:
2025-06-18(latest), and the earlier2025-03-26and2024-11-05are accepted and echoed ininitialize. Any other requested version gets2025-06-18back. An unsupportedMCP-Protocol-Versionheader is a 400. - Responses are always
application/json; there is no SSE stream, no sessions, noMcp-Session-Id.GET /mcpreturns 405 with a small JSON description. JSON-RPC batches (older revisions) are accepted, up to 20 messages. - Limits: request body ≤ 32 KB (413 beyond that). Tool inputs are validated; oversized strings are rejected. CORS is open (
*) so browser clients and the demo on this site can call it. - No authentication, no AI, no storage. Inputs are processed in memory; request bodies are not logged.
curl -s https://thaimcp.pages.dev/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2025-06-18",
"capabilities": {
"tools": {
"listChanged": false
}
},
"serverInfo": {
"name": "thai-mcp",
"title": "Thai Toolkit",
"version": "0.1.0"
},
"instructions": "…"
}
}curl -s -o /dev/null -w '%{http_code}\n' https://thaimcp.pages.dev/mcp \
-H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
# 202curl -s https://thaimcp.pages.dev/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"thai_baht_text","arguments":{"amount":500}}}'{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "text",
"text": "500.00 THB = ห้าร้อยบาทถ้วน"
}
],
"structuredContent": {
"amount": "500.00",
"currency": "THB",
"thai_text": "ห้าร้อยบาทถ้วน"
}
}
}Errors: malformed JSON → -32700 (HTTP 400); not a JSON-RPC 2.0 object → -32600; unknown method → -32601; unknown tool or missing name → -32602. Invalid tool arguments are not protocol errors: you get a normal result with isError: true and a message the model can act on.
Local (stdio)
src/server.js uses the official @modelcontextprotocol/sdk over stdio. Tool logic is imported from src/lib/tools.js, the same module the remote function uses, so both transports give identical answers. Nothing is written to stdout except protocol messages, and nothing is logged. Requires Node.js 18+.
Result format
Every tools/call result contains:
content: one text block, concise and readable, written for an LLM to quote;structuredContent: the same facts as JSON (strings for money such as"1070.00", so nothing is lost to float formatting);isError: truewhen the input was invalid, with the reason in the text.
All tools are annotated read-only, idempotent and closed-world (they never touch the outside world).
From code
const res = await fetch("https://thaimcp.pages.dev/mcp", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0", id: 1, method: "tools/call",
params: { name: "thai_vat", arguments: { amount: 1000 } },
}),
});
const { result } = await res.json();
console.log(result.structuredContent); // { net: "1000.00", vat: "70.00", gross: "1070.00", … }import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const client = new Client({ name: "demo", version: "1.0.0" });
await client.connect(new StreamableHTTPClientTransport(new URL("https://thaimcp.pages.dev/mcp")));
const r = await client.callTool({ name: "thai_baht_text", arguments: { amount: 500 } });Self-hosting
The remote endpoint is one Cloudflare Pages Function, functions/mcp.js, importing the pure modules in src/lib/. To host your own copy, deploy the repository as a Pages project with output directory site. The D1 binding used for the anonymous page-view counter is optional; the endpoint works without any binding or secret. Or just run the stdio server.
Reusing the logic
The files in src/lib/*.js are pure ES modules with zero dependencies (plus one vendored MIT QR encoder), so they run in Node, browsers and edge runtimes:
import { callTool, listTools } from "thai-mcp/tools";
const r = callTool("thai_wht", { amount: 1000, payment_type: "service", include_vat: true });
r.structuredContent.net_payable; // "1040.00"Testing
npm test runs the node:test suite: unit tests for each tool (including satang rounding sweeps and PromptPay payloads cross-checked against the sibling BizThai implementation), QR images decoded with zbarimg back to the exact payload, a stdio protocol test (raw JSON-RPC and the official SDK client), and a test of the Pages Function handler (initialize, 202 for notifications, errors, size limits).
Verify the download
thai-mcp-0.1.0.tgz: 33,664 bytes, SHA-256:
69ab6320d12f64beea9cf4719188de2b179d76a2e3a567bb4dde955586a8d5b5