Metadata-Version: 2.4
Name: dimctx
Version: 0.1.0
Summary: dimctx = dimensional modeling context provider — MCP server giving AI coding assistants Kimball modeling judgement, bus-matrix truth, and SQL complexity checks.
Author: wagic
License: AGPL-3.0-or-later
Project-URL: Homepage, https://github.com/SeekerGalahad/dimctx
Keywords: mcp,dimensional-modeling,data-warehouse,kimball,semantic-layer
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Topic :: Database
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: mcp>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pydantic>=2; extra == "dev"
Dynamic: license-file

# dimctx

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

[![License: AGPL-3.0-or-later](https://img.shields.io/badge/License-AGPL--3.0--or--later-blue.svg)](LICENSE)

## 它解决什么

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

四个工具：

| 工具 | 作用 |
|---|---|
| `analyze_table` | 判定表角色（fact/dimension）、粒度键、SCD 建议、总线矩阵格值 |
| `search_canon` | 检索**你自备**的建模语料（本地 markdown） |
| `bus_matrix` | 总线矩阵查询（单表格值 / 单维度实现 / 全库概览） |
| `measure_sql` | 度量下游取数复杂度（CASE WHEN / JOIN 深度 / 子查询 / 聚合嵌套） |

## 三步接入

```bash
# 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`](docs/DATA-POLICY.md) 与 [`NOTICE`](NOTICE)）；
- 未配置语料时 `search_canon` 返回空并提示配置，**不会报错、不会联网索取**。

## 开发

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

## 许可

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