dimctx
dimctx = dimensional modeling context provider 一个本地 MCP server,让你的 AI 编码助手在写数仓代码时拥有维度建模的判断力。
它解决什么
AI 写 SQL/DDL 时会瞎编建模决策:分不清事实和维度、猜不准粒度、不知道哪些维度该跨表一致。
dimctx 把这些判断交给确定性引擎 + 你自己的方法论语料。
五个工具:
| 工具 | 作用 |
|---|---|
analyze_table |
判定表角色(fact/dimension)、粒度键、SCD 建议(按原典 Type 2 三列签名)、总线矩阵格值;事实表用了可更新键模型时附类型债检查(见下) |
search_canon |
检索你自备的建模语料(本地 markdown,可配多个目录) |
bus_matrix |
总线矩阵查询(单表格值 / 单维度实现 / 全库概览) |
measure_sql |
度量下游取数复杂度(CASE WHEN / JOIN 深度 / 子查询 / 聚合嵌套) |
check_conformed_facts |
一致性事实检查:同名度量在多张事实表出现时,定义/单位/过滤/时间口径必须完全一致;不兼容则按原典须改名 |
analyze_table 遇到「事实表 + 可更新键模型(Doris UNIQUE / PRIMARY KEY)」时多给一项 upsert_check。
原典:三型事实表里只有累积快照的行应被更新,判据是每个关键里程碑有一个日期外键——所以只看键外的业务时间列:
| verdict | 含义 |
|---|---|
accumulating_snapshot |
有起止里程碑对 → 行随流程改写属合法更新 |
periodic_snapshot |
业务时间列全在键内 → 按键重写通常只是幂等重算 |
type_debt_risk |
其余 → 若行是事务粒度事件,同键重写会无声明地抹掉历史(同时写入 signals) |
out_of_scope |
贴源 / 汇总 / 维度 / 系统表(按图谱 layer 关键字或表名前缀)→ 不作类型判定 |
三步接入
# 1) 配置(可选,缺省也能跑:只是语料检索为空)
export DIMCTX_ATLAS=/path/to/atlas.json # 工程表图谱(可选)
export DIMCTX_CANON_DIR=/path/to/markdown # 你自备的建模语料(可选;多个目录用 os.pathsep 分隔:macOS/Linux ':',Windows ';')
export DIMCTX_ANALYSIS_DIR=/path/to/notes # 你自己的分析笔记(可选;同样可多目录,结果以 source 字段区分)
# 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 # 24 passed, 14 skipped(图谱相关用例跳过)
# 有工程表图谱时可全跑:
DIMCTX_TEST_ATLAS=/path/to/atlas.json uv run --with pytest --with pydantic python -m pytest tests/ -q # 38 passed
许可
代码 AGPL-3.0-or-later(见 LICENSE)。本项目与 Kimball Group 无关联、未获其背书; 文档中提及 Kimball 方法论属指名性合理使用(nominative fair use)。
Metadata
Release files for dimctx 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dimctx-0.3.0.tar.gz | 43.6 kB | Without provenance | Details for dimctx-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dimctx-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for dimctx-0.3.0-py3-none-any.whl |
Total release size: 85.1 kB
Release files / dimctx-0.3.0.tar.gz
| Download URL | dimctx-0.3.0.tar.gz |
|---|---|
| Size | 43.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9aa6705f2f6687b392a5b629592a10683eac8adbd82f23b46a9b56cbecfbc850
|
|
BLAKE2b-256 checksum How to use checksums |
be45277f97c0638083e8832d995bc6e6cd4d35f03da0e1ed3bd80a4b7932e456
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / dimctx-0.3.0-py3-none-any.whl
| Download URL | dimctx-0.3.0-py3-none-any.whl |
|---|---|
| Size | 41.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcb03ece80185177075425d28a6c62c5927aec636d190568a78e5a82b847b923
|
|
BLAKE2b-256 checksum How to use checksums |
306b5169a35a69af9542991e741843fddce838161ebabac857fd3870afb3857d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for dimctx 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.