Skip to main content
Glama

ASCII Table MCP Server

+------------+------------------+------+---------------+
| คำบาลี      | Roman            | หมวด | ความหมาย      |
+------------+------------------+------+---------------+
| ปฏิจจสมุปฺปาท | paṭiccasamuppāda | ธรรม | เหตุปัจจัยต่อเนื่อง |
| กามจฺฉนฺท    | kāmacchanda      | นิวรณ์ | ความพอใจในกาม |
| อวิชฺชา      | avijjā           | กิเลส | ความไม่รู้       |
+------------+------------------+------+---------------+

ตารางภาษาไทย + Roman + ตัวเลข → alignment ตรงทุกบรรทัด

MCP server สำหรับสร้างตาราง (ASCII grid / Unicode box-drawing) ที่รองรับภาษาไทย บาลี โรมัน และ CJK อย่างถูกต้อง — ใช้ wcwidth ในการวัดความกว้างตัวอักษร ไม่ใช้ len() ที่นับผิด


Features

  • 3 formats: grid (ASCII +---+), box (Unicode ┌─┬─┐), pipe (Markdown | | |)

  • Thai/Pali/CJK: zero-width combining marks (พินทุ, สระบน/ล่าง) alignment ไม่เพี้ยน

  • Safe mode: char-count padding สำหรับ platform ที่ zero-width ≠ 0

  • 5 MCP tools: make_table, make_table_from_csv, make_table_from_json, make_table_preview, debug_table

  • Validation: validate_table_text ตรวจสอบโครงสร้างตาราง, analyze_table วิเคราะห์ alignment

  • Zero external dependencies (beyond mcp + wcwidth)


Related MCP server: WebforAI Text Extractor

Quick Start

uvx (no install)

uvx --from git+https://github.com/dhammawatthumpra-coder/ascii-table-mcp ascii-table-mcp

pip install

git clone https://github.com/dhammawatthumpra-coder/ascii-table-mcp.git
cd ascii-table-mcp
pip install -e .
python -m ascii_table_mcp

Register with Claude Desktop

{
  "mcpServers": {
    "ascii-table": {
      "command": "python",
      "args": ["-m", "ascii_table_mcp"]
    }
  }
}

Register with Hermes

# หลังจาก pip install -e . แล้ว
hermes mcp add ascii-table --command "python -m ascii_table_mcp"

MCP Tools

make_table

สร้างตารางจาก headers + rows

Parameter

Type

Default

Description

headers

list[str]

หัวตาราง

rows / data

list[list[str]]

แถวข้อมูล

fmt

str

"box"

"grid", "box", "pipe", "safe"

{
  "headers": ["ชื่อไฟล์", "หน้าที่", "สถานะ"],
  "rows": [
    ["generate_table.py", "core rendering engine", "✅"],
    ["server.py", "MCP wrapper", "✅"],
    ["README.md", "documentation", "✅"]
  ],
  "fmt": "grid"
}

ผลลัพธ์:

+-------------------+-----------------------+-------+
| ชื่อไฟล์             | หน้าที่                  | สถานะ |
+-------------------+-----------------------+-------+
| generate_table.py | core rendering engine | ✅    |
| server.py         | MCP wrapper           | ✅    |
| README.md         | documentation         | ✅    |
+-------------------+-----------------------+-------+

make_table_from_csv

{
  "csv_text": "คำบาลี,Roman,หมวด,ความหมาย\\nกมฺม,kamma,นาม,กรรม",
  "fmt": "grid"
}

make_table_from_json

{
  "json_data": "[ [\"คำ\",\"แปล\"], [\"กมฺม\",\"kamma\"], [\"อวิชฺชา\",\"avijjā\"] ]",
  "fmt": "grid"
}

debug_table

แสดงตำแหน่ง char@pos และ drift analysis สำหรับ debugging alignment:

┌───────┬───────┐
│ คำบาลี │ Roman │ ← │@char9 vs ┬@char8 ❌ drift=1
├───────┼───────┤
│ กมฺม   │ kamma │ ← ✅ align
└───────┴───────┘

analyze_table

วิเคราะห์ column positions ของ +--+ table และ validate | alignment

validate_table_text

ตรวจสอบโครงสร้างตาราง: column count, border alternation, format detection


Why wcwidth?

ภาษาไทยและบาลีมีอักขระ zero-width combining marks เช่น:

  • พินทุ ( ฺ ) — 0-width ในพจนานุกรม

  • สระบน ( ิ ี ึ ื ั ) — 0-width ติดพยัญชนะ

  • สระล่าง ( ุ ู ) — 0-width

  • ไม้หันอากาศ ( ั ) — 0-width

len() ใน Python นับผิด:

len("กมฺม")  → 4   ❌ (นับพินทุเป็นตัวอักษร)
wcswidth("กมฺม") → 3  ✅ (พินทุ width 0)

ถ้าใช้ len() ในการจัดตาราง:

+----------+-----------+   ← border ยาว 8
| คำบาลี    | Roman     |   ← "กมฺม" = 4 char → padding 4 → len=9 ❌ drift!
+----------+-----------+

ของเราใช้ wcwidth.wcswidth() แทน len() → alignment ตรงทุก platform


Format Comparison

Format

Example

เหมาะกับ

grid

+----+----+

Default — terminal, code review, GitHub

box

┌────┬────┐

presentation, formal doc

safe

┌────┬────┐

Browser/Discord ที่ zero-width ≠ 0

pipe

| | |

Markdown, ไม่แนะนำสำหรับตารางไทย


CLI Usage

# CSV args → grid
python -m ascii_table_mcp.generate_table --grid 'ชื่อ,อายุ' 'สมชาย,30' 'สมหญิง,25'

# TSV pipe → grid
printf 'ชื่อ\tอายุ\nสมชาย\t30\n' | python -m ascii_table_mcp.generate_table --tsv --grid

# JSON
python -m ascii_table_mcp.generate_table --json '{"headers":["A","B"],"rows":[["1","2"]]}' --grid

# ASCII/Pipe Table → auto-convert
cat table.txt | python -m ascii_table_mcp.generate_table --ascii
+-------+-----+
| ชื่อ    | อายุ |
+-------+-----+
| สมชาย | 30  |
| สมหญิง | 25  |
+-------+-----+

Architecture

ascii-table-mcp/
├── ascii_table_mcp/
│   ├── __init__.py      # MCP server (FastMCP)
│   └── generate_table.py # Core rendering engine
├── server.py            # Thin wrapper for `python server.py`
├── requirements.txt     # mcp + wcwidth
├── pyproject.toml        # uv / pip install
├── ascii-table-mcp.bat  # Windows wrapper
├── LICENSE              # MIT
└── README.md            # เอกสารนี้

Core rendering (render_table, render_ascii_grid, render_pipe_table, render_table_safe) อยู่ใน generate_table.py — server.py import มาใช้ ไม่มี code ซ้ำ



License

MIT — แจกฟรี ใช้ได้ทั้งส่วนตัวและพาณิชย์

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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/dhammawatthumpra-coder/ascii-table-mcp'

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