Skip to main content
Glama
ckan-thaigdc-mcp

ckan-thaigdc-mcp

by nungsatick

ckan-thaigdc-mcp

MCP server สำหรับค้นหาและอ่านข้อมูลจาก CKAN โดยออกแบบมาสำหรับระบบบัญชีข้อมูลภาครัฐของไทยที่ใช้ ckanext-thai_gdc และใช้กับ CKAN ทั่วไปได้ด้วย

เวอร์ชันนี้อ่านอย่างเดียว ไม่ส่ง token และเห็นเฉพาะข้อมูลสาธารณะ

สิ่งที่ทำได้

Tool

หน้าที่

ckan_list_sites

แสดงไซต์ที่ตั้งค่าไว้

ckan_site_info

เวอร์ชัน ประเภท catalog จำนวนชุดข้อมูล และความสามารถของไซต์

ckan_search_datasets

ค้นชุดข้อมูล พร้อมตัวกรองและการนับตามหมวด

ckan_get_dataset

ดู metadata และรายการไฟล์ของชุดข้อมูล

ckan_get_resource

ดูรายละเอียดไฟล์ คอลัมน์ และจำนวนแถว

ckan_query_data

ดึงข้อมูลในตาราง กรอง เรียง และหาค่าที่ไม่ซ้ำ

ckan_list_organizations

แสดงหรือค้นหน่วยงาน

ckan_list_groups

แสดงหรือค้นกลุ่ม

ckan_search_tags

ค้นแท็กและคำค้นที่ระบบแนะนำ

ckan_get_schema

ดูฟิลด์ metadata ฟิลด์บังคับ และค่าที่เลือกได้

ckan_find_federated_copies

หาชุดข้อมูลที่ส่งต่อไปยัง catalog อื่นด้วย reference_url_catalog

ตัวอย่างคำถาม:

  • "ใน NSO มีชุดข้อมูลเกี่ยวกับประชากรที่มีไฟล์ CSV อะไรบ้าง"

  • "ขอร้อยละครัวเรือนที่มีแท็บเล็ตของภาคเหนือ เรียงจากมากไปน้อย"

  • "จังหวัดกาฬสินธุ์รับชุดข้อมูลอะไรจาก NSO บ้าง"

Related MCP server: CKAN MCP Server

ติดตั้ง

ต้องมี Node.js 20.3 ขึ้นไป

git clone https://github.com/nungsatick/ckan-thaigdc-mcp.git
cd ckan-thaigdc-mcp
npm install

npm install จะ build ให้เองที่ dist/index.js จากนั้นดู path เต็มของไฟล์นี้ไว้ใช้ในขั้นตอนถัดไป

node -e "console.log(require('path').resolve('dist/index.js'))"

ตัวอย่างด้านล่างใช้ C:/path/to/ckan-thaigdc-mcp/dist/index.js ให้เปลี่ยนเป็น path ของคุณ บน Windows ใช้ / ได้เลย

ตั้งค่ากับ AI แต่ละตัว

Claude Code

claude mcp add --env "CKAN_SITES=nso=https://catalog.nso.go.th,gdcatalog=https://gdcatalog.go.th" --transport stdio --scope user ckan-thaigdc-mcp -- node C:/path/to/ckan-thaigdc-mcp/dist/index.js

ตรวจสอบด้วยคำสั่งนี้ หรือพิมพ์ /mcp ใน Claude Code

claude mcp get ckan-thaigdc-mcp
  • --scope user ใช้ได้ทุกโปรเจกต์ ถ้าต้องการแชร์เฉพาะโปรเจกต์ให้ใช้ --scope project ซึ่งจะสร้าง .mcp.json

  • ถ้าจะใช้ไซต์เริ่มต้นทั้งหมด ไม่ต้องใส่ --env

Claude Desktop

  1. เปิด Settings > Developer > Edit Config แล้วเพิ่มส่วนนี้ลงในไฟล์ที่เปิดขึ้นมา

{
  "mcpServers": {
    "ckan-thaigdc-mcp": {
      "command": "node",
      "args": ["C:/path/to/ckan-thaigdc-mcp/dist/index.js"],
      "env": {
        "CKAN_SITES": "nso=https://catalog.nso.go.th,gdcatalog=https://gdcatalog.go.th"
      }
    }
  }
}
  1. ปิด Claude Desktop ให้สนิทรวมถึงที่ system tray แล้วเปิดใหม่

ไฟล์นี้ปกติอยู่ที่ %APPDATA%\Claude\claude_desktop_config.json แต่ถ้าติดตั้งจาก Microsoft Store อาจอยู่ที่อื่น จึงควรเปิดผ่านเมนู Edit Config ถ้ามี mcpServers อยู่แล้ว ให้เพิ่มเฉพาะ ckan-thaigdc-mcp เข้าไป

Codex (CLI, IDE extension, ChatGPT desktop)

ทั้งสามตัวใช้ไฟล์ตั้งค่าเดียวกันคือ ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml) ให้เพิ่มส่วนนี้

[mcp_servers.ckan-thaigdc-mcp]
command = "node"
args = ["C:/path/to/ckan-thaigdc-mcp/dist/index.js"]

[mcp_servers.ckan-thaigdc-mcp.env]
CKAN_SITES = "nso=https://catalog.nso.go.th,gdcatalog=https://gdcatalog.go.th"

หรือเพิ่มด้วยคำสั่ง

codex mcp add ckan-thaigdc-mcp --env "CKAN_SITES=nso=https://catalog.nso.go.th,gdcatalog=https://gdcatalog.go.th" -- node C:/path/to/ckan-thaigdc-mcp/dist/index.js

ตรวจสอบด้วยคำสั่งนี้ หรือพิมพ์ /mcp ใน Codex

codex mcp list

Google Antigravity

  1. เปิดไฟล์ตั้งค่า

    • IDE: กด … ด้านบนแผง agent > MCP Servers > Manage MCP Servers > View raw config

    • App หรือ CLI: แก้ไฟล์ ~/.gemini/config/mcp_config.json โดยตรง (Windows: %USERPROFILE%\.gemini\config\mcp_config.json)

  2. เพิ่มส่วนนี้

{
  "mcpServers": {
    "ckan-thaigdc-mcp": {
      "command": "node",
      "args": ["C:/path/to/ckan-thaigdc-mcp/dist/index.js"],
      "env": {
        "CKAN_SITES": "nso=https://catalog.nso.go.th,gdcatalog=https://gdcatalog.go.th"
      }
    }
  }
}
  1. โหลดใหม่

    • App: Settings > Customizations > Installed MCP Servers แล้วกดปุ่ม refresh

    • CLI: พิมพ์ /mcp แล้วเลือกโหลดใหม่

    • IDE: ถ้ายังไม่เห็น tools ให้ปิดแล้วเปิดใหม่

Antigravity รุ่นเก่าใช้ไฟล์ ~/.gemini/antigravity/mcp_config.json ถ้าแก้แล้วไม่เห็นผล ให้ใช้เมนู View raw config เพื่อดูว่ารุ่นของคุณอ่านไฟล์ใด

AI อื่น ๆ

โปรแกรมที่รองรับ MCP แบบ stdio ส่วนใหญ่ใช้ค่าเดียวกันนี้: command คือ node, args คือ path ของ dist/index.js และ env คือ CKAN_SITES

เลือกไซต์ด้วย CKAN_SITES

กำหนดในรูปแบบ ชื่อย่อ=URL คั่นด้วยจุลภาค server จะเรียกได้เฉพาะไซต์ในรายการนี้

CKAN_SITES=nso=https://catalog.nso.go.th,kalasin=https://kalasin.gdcatalog.go.th,local=http://localhost:8881
  • ใช้ http:// ได้เฉพาะ localhost ส่วนไซต์อื่นต้องเป็น https://

  • ถ้าไม่กำหนด จะใช้ nso, gdcatalog, datagoth, statprovince, kalasin

แก้ปัญหาเบื้องต้น

อาการ

สิ่งที่ควรตรวจ

ไม่เห็น tools

path ใน args ต้องเป็น path เต็ม และโปรแกรมต้องเริ่มใหม่หลังแก้ค่า

node not found

ใช้ path เต็มของ Node เป็น command ดูได้จาก where node (Windows) หรือ which node

Cannot find module dist/index.js

รัน npm install หรือ npm run build

Unknown site

เพิ่มไซต์นั้นใน CKAN_SITES

ไซต์ไม่ตอบ

ลองใหม่หรือลด limit บางไซต์ เช่น data.go.th อาจตอบช้าเมื่อขอข้อมูลมาก

ทดสอบ server โดยไม่ต้องใช้ AI:

npx @modelcontextprotocol/inspector node dist/index.js

พัฒนาต่อ

npm test
npm run build

npm run smoke เรียก tools ทุกตัวกับไซต์จริง เลือกไซต์ได้ด้วย SMOKE_SITE และ CKAN_SITES

ผลการศึกษา API และแผนเฟสถัดไปอยู่ใน docs/ckan-api-research.md

License

MIT

Available Tools

11 tools
ckan_find_federated_copiesFind Federated Dataset CopiesA
Read-onlyIdempotent

Find datasets on other catalogs that were copied from a source catalog, using their reference_url_catalog field. Searches several sites and reports a per-site result, including sites that fail.

Examples:

Inputs: source_url (required), limit, match, sites, +1 more.

ckan_get_datasetGet CKAN DatasetA
Read-onlyIdempotent

Get one dataset's metadata and its files (resources). Each resource says whether it is queryable: if so, pass its id to ckan_query_data; if not, give the user its url.

Use ckan_search_datasets to find ids. detail="full" returns the catalog's raw record, which is much longer.

Inputs: id (required), site (required), detail, response_format.

ckan_get_resourceGet CKAN ResourceA
Read-onlyIdempotent

Get one file's details. For a queryable resource this also returns its columns, their types and the row count, which ckan_query_data needs for filters and sorting.

Values are often stored as text, including years such as "2565Q2", so check column types before comparing them.

Inputs: site (required), resource_id (required), response_format.

ckan_get_schemaGet CKAN Metadata SchemaA
Read-onlyIdempotent

Get a catalog's metadata fields: their labels, whether they are required, and allowed values.

Use this to learn what a field means, or the exact value to filter on: values are usually Thai and differ from English-looking names (update_frequency_unit is 'ปี', not 'year').

By default choices are only counted. Pass field="objective" or include_choices=true to see them.

Inputs: site (required), field, limit, offset, +3 more.

ckan_list_groupsList CKAN GroupsA
Read-onlyIdempotent

List a catalog's groups with dataset counts, or find them by name. Pass the returned name as the group filter of ckan_search_datasets.

Example: "หน่วยงานที่ชื่อมีคำว่าสถิติ" -> query="สถิติ" (returns matches without dataset counts).

Inputs: site (required), limit, query, offset, +1 more.

ckan_list_organizationsList CKAN OrganizationsA
Read-onlyIdempotent

List a catalog's organizations with dataset counts, or find them by name. Pass the returned name as the organization filter of ckan_search_datasets.

Example: "หน่วยงานที่ชื่อมีคำว่าสถิติ" -> query="สถิติ" (returns matches without dataset counts).

Inputs: site (required), limit, query, offset, +1 more.

ckan_list_sitesList CKAN SitesA
Read-onlyIdempotent

List the CKAN catalogs this server may query, with the aliases other tools take as site. Call this first when you do not know which catalog to use.

Inputs: response_format.

ckan_query_dataQuery CKAN TableA
Read-onlyIdempotent

Read rows from a queryable resource, with filters, full-text search, column selection, sorting and distinct values. Only works where ckan_get_dataset shows the resource as queryable.

Call ckan_get_resource first for the column names: an unknown column is an error.

Examples:

  • Rows for one region -> filters={"region": "ภาคเหนือ"}

  • Several values -> filters={"region": ["ภาคเหนือ", "ภาคใต้"]}

  • Which regions exist -> fields=["region"], distinct=true

  • Highest values first -> sort="Per_HH_Tablet desc", limit=5

Inputs: site (required), resource_id (required), q, sort, +6 more.

ckan_search_datasetsSearch CKAN DatasetsA
Read-onlyIdempotent

Search one catalog's public datasets, with optional filters and counts per category (facets). Returns compact summaries; use ckan_get_dataset for full metadata and the file list.

Examples:

  • "ชุดข้อมูลเกี่ยวกับประชากร" -> query="ประชากร"

  • Words that must be in the title -> title="ประชากร อายุ"

  • "สถิติที่มีไฟล์ CSV" -> query="สถิติ", format="CSV", data_type="stat"

  • "มีหน่วยงานไหนบ้างและชุดข้อมูลละกี่ชุด" -> limit=0, facets=["organization"]

Use names returned by facets, ckan_list_organizations or ckan_list_groups for the organization and group filters.

Inputs: site (required), fq, tag, sort, +10 more.

ckan_search_tagsSearch CKAN TagsA
Read-onlyIdempotent

Find tags containing some text, plus search terms the catalog suggests where available. Pass a returned tag as the tag filter of ckan_search_datasets.

Example: query="ประชากร".

Inputs: site (required), query (required), limit, offset, +1 more.

ckan_site_infoGet CKAN Site InfoA
Read-onlyIdempotent

Get a catalog's CKAN and Thai GDC versions, catalog type, dataset count and features.

Use this to check whether a site supports something before relying on it: capabilities.datastore means tabular data may be queryable with ckan_query_data, capabilities.scheming means ckan_get_schema works.

Inputs: site (required), response_format.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 11 tools

    Disambiguation4/5

    Most tools target clearly distinct resources and actions (search datasets vs get dataset vs query data vs get resource). The main potential confusions are ckan_list_sites vs ckan_site_info (both about catalogs) and ckan_list_organizations vs ckan_list_groups, but the descriptions clarify the boundaries reasonably well.

    Naming Consistency4/5

    All names share a ckan_ prefix and predominantly follow verb_noun (list_sites, search_datasets, get_dataset, query_data, get_schema). Minor deviations like ckan_site_info (noun-only, not get_site_info) and ckan_find_federated_copies (find instead of get/search) are small inconsistencies.

    Tool Count5/5

    11 tools is well within the ideal 3-15 range and each tool covers a distinct facet of CKAN exploration. Nothing feels redundant or missing at the count level.

    Completeness4/5

    The surface covers discovery (sites, orgs, groups, tags), search, metadata retrieval, schema inspection, and tabular data querying, plus federated copy lookup — comprehensive for a read-only catalog client. There are no write/CRUD operations and no direct resource download tool (users are told to use the URL), but these are minor gaps for the apparent read-only purpose.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      Not graded
      maintenance
      Enables AI assistants and CLI tools to explore and analyze datasets from 600+ global CKAN open-data portals. Provides comprehensive tools for dataset discovery, datastore queries, metadata analysis, and local downloads without writing custom CKAN integrations.
      14
      MIT
    • A
      license
      A
      quality
      A
      maintenance
      Enables AI assistants to search, explore, and query any CKAN open data portal through natural language, making public datasets accessible without requiring knowledge of the portal's API.
      20
      1,648 npm
      82
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to search and read Thailand's official open-government data from data.go.th, providing tools to search datasets, retrieve full records, and browse categories without API keys.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to search, retrieve metadata, and query tabular resources from Latvia's Open Data portal (data.gov.lv) via CKAN.
      76 npm
      MIT