Skip to main content
Glama

dimctx

dimctx = dimensional modeling context provider 一个本地 MCP server,让你的 AI 编码助手在写数仓代码时拥有维度建模的判断力。

License: AGPL-3.0-or-later

它解决什么

AI 写 SQL/DDL 时会瞎编建模决策:分不清事实和维度、猜不准粒度、不知道哪些维度该跨表一致。 dimctx 把这些判断交给确定性引擎 + 你自己的方法论语料。

五个工具:

工具

作用

analyze_table

判定表角色(fact/dimension)、粒度键、SCD 建议、总线矩阵格值

search_canon

检索你自备的建模语料(本地 markdown)

bus_matrix

总线矩阵查询(单表格值 / 单维度实现 / 全库概览)

measure_sql

度量下游取数复杂度(CASE WHEN / JOIN 深度 / 子查询 / 聚合嵌套)

check_conformed_facts

一致性事实检查:同名度量在多张事实表出现时,定义/单位/过滤/时间口径必须完全一致;不兼容则按原典须改名

Related MCP server: Grounded Code MCP

三步接入

# 1) 配置(可选,缺省也能跑:只是语料检索为空)
export DIMCTX_ATLAS=/path/to/atlas.json      # 工程表图谱(可选)
export DIMCTX_CANON_DIR=/path/to/markdown    # 你自备的建模语料(可选)

# 2) 在 IDE 的 MCP 配置里加一条
#    VS Code (mcp.json) / Cursor (.cursor/mcp.json) / Continue (config.yaml)
{"command": "uvx", "args": ["dimctx"]}

# 3) 让 AI 用它
#    「用 dimctx 看看 dt_batch 是什么表、粒度是什么」

数据边界(重要)

  • 纯本地 stdio:无网络出口、无遥测、无云服务、不做托管;

  • 不打包任何第三方内容:语料由你自备(详见 docs/DATA-POLICY.md 与 NOTICE);

  • 未配置语料时 search_canon 返回空并提示配置,不会报错、不会联网索取。

开发

uv run --with pytest --with pydantic python -m pytest tests/ -q   # 19 passed

许可

代码 AGPL-3.0-or-later(见 LICENSE)。本项目与 Kimball Group 无关联、未获其背书; 文档中提及 Kimball 方法论属指名性合理使用(nominative fair use)。

Available Tools

5 tools
analyze_tableA

判定一张表的角色(fact/dimension)、粒度键、SCD 建议与总线矩阵格值。

Args: table: 图谱中的表名(如 dt_batch)。与 ddl 二选一。 ddl: CREATE TABLE 文本(table 不在图谱时使用)。

Inputs: ddl, table. Returns: result

bus_matrixA

查询总线矩阵:单表全部格值 / 单维度实现表 / 全库概览。

Args: table: 表名(返回该表各维度格值)。 dim: 维度概念名(如 supplier,返回全部实现表+类型一致性)。

Inputs: dim, table. Returns: result

check_conformed_factsA

一致性事实检查:同名度量在多张事实表出现时,定义/单位/过滤/时间口径必须完全一致;不兼容则按原典须改名。

Args: facts: 各处定义列表,每项 {"name","table","definition","unit","filter","time_basis"}。 table: 可选,只看该表。

Inputs: facts (required), table. Returns: result

measure_sqlB

度量下游取数复杂度(CASE WHEN / JOIN 深度 / 子查询层数 / 聚合套聚合)。

Args: sql: 待检查的 SQL 文本。

Inputs: sql. Returns: result

search_canonB

检索本地自备的 Kimball 方法论语料(原典 markdown)。

Args: query: 检索词(中英文均可,如 "slowly changing dimension")。 limit: 返回条数上限(1-20)。

Inputs: limit, query. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: analyze_table for table role/grain/SCD analysis, search_canon for methodology lookup, bus_matrix for querying existing matrix data, check_conformed_facts for fact consistency, and measure_sql for SQL complexity. There is minor overlap between analyze_table (which suggests bus matrix cell values) and bus_matrix (which retrieves them), but the descriptions differentiate them adequately.

    Naming Consistency4/5

    All names use snake_case and four of five follow a verb_noun pattern (analyze_table, search_canon, check_conformed_facts, measure_sql). The exception is bus_matrix, which is noun-only, but the overall convention remains predictable.

    Tool Count5/5

    Five tools is well-scoped for a focused Kimball dimensional modeling assistant. Each tool covers a distinct analytical operation without redundancy or excessive surface area.

    Completeness4/5

    The surface covers core dimensional modeling workflows: table analysis, methodology retrieval, bus matrix queries, conformed fact checks, and SQL complexity measurement. Minor gaps remain, such as explicit conformed dimension checking or SCD implementation guidance beyond what analyze_table provides, but these are manageable workarounds.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers