datamgr
Enables AI assistants to discover and inspect research datasets via a read-only MCP server, offering search, variable listing, and metadata retrieval without reading data files.
README
datamgr — dataset registry for empirical research
A lightweight registry that catalogs your research datasets so an AI (or you)
can discover them without reading every file. Each dataset is one folder with a
manifest.yaml; a flat index (_registry.json) makes search cheap no matter
how many datasets you have.
Architecture: one copy of logic in
datamgr.core; thedmCLI and the MCP server are both thin front-ends over it.
Install (editable)
cd data-manage
pip install -e .
Quick start
# 1. point datamgr at a central warehouse (created if missing)
dm init-root D:/datasets
# 2a. import a raw data folder -- harvests variable names + labels from a .dta,
# copies the file into a new clean-id folder under the warehouse
dm import "原始数据包" --id csmar_annual --name "CSMAR 上市公司年度财务"
# 2b. (or) scaffold an empty dataset and fill the manifest by hand
dm init csmar_annual --name "CSMAR 上市公司年度财务"
# 3. rebuild the index
dm refresh
# 4. discover
dm list # all datasets, one line each
dm show csmar_annual # full manifest, rendered
dm search 资产负债率 # fuzzy-search across all variables/labels
dm variables --role control # list all control variables available
dm variables --label 占比 # filter variables by label
dm stats csmar_annual --refresh # compute rows/cols/n_firms, cache to manifest
dm verify # validate manifests + check file paths exist
# 5. pull data into an analysis working directory (backup + provenance)
dm export csmar_annual control_vars --to D:/my_paper
# -> D:/my_paper/data/*.dta (copied files, ready for `use "data/xxx.dta"`)
# -> D:/my_paper/data_sources.txt (where each file came from, for traceability)
Commands
| command | purpose |
|---|---|
dm init-root [PATH] |
set / show the central warehouse location |
dm init <id> |
scaffold an empty dataset folder + manifest template |
dm import [<folder>] [--id X] |
build a manifest by harvesting variables from a .dta/.csv; with --id it copies data into a clean-id folder |
dm refresh |
rebuild the _registry.json index (reads manifests only, never data files) |
dm list [--tag T] |
list all datasets, one line each |
dm show <id> |
print a dataset's full manifest |
dm search <query> [--tag T] |
fuzzy-search datasets by variable name/label, name, description, tag |
dm variables [--role R] [--label L] |
list all variables across the index (for picking controls/instruments) |
dm stats <id> [--refresh] |
show cached stats, or recompute from the data file |
dm export <id...> --to <dir> |
copy dataset files into a working dir + record provenance |
dm verify |
validate manifests + check referenced files exist |
The manifest (manifest.yaml)
This is the heart of the system. Fields:
| field | purpose |
|---|---|
id |
dataset id, must equal the folder name |
name |
human-readable name |
description |
free text — searchable |
version, source |
provenance |
unit_of_observation |
granularity, e.g. 公司-年 |
time_span |
[start, end] years |
identifiers |
{id, time} — fed straight to Stata xtset |
variables |
list; each has name/label/type/role |
tags, dependencies |
search facets & lineage |
files |
relpaths for raw/ pipeline/ processed |
stats |
cached summary (rows, cols, ...), computed at refresh |
notes |
any gotchas /口径变更 |
variables[].role ∈ {id, time, x, y, control, weight, instrument, other}
is the key signal that lets an AI judge "can this dataset run the regression I
want", which plain variable names can't convey.
Why it stays fast as datasets grow
- Search reads the in-memory index, never the folder tree at query time.
- The index stores only search-relevant fields (names, roles, tags, spans) — KB
per dataset. A full manifest is loaded only by
dm show/get_dataset. - Dataset files (
.dta, etc.) are read only when you explicitly refresh stats.list/search/shownever touch them.
Layout
src/datamgr/
config.py warehouse root resolution
core/
manifest.py schema + load/validate/save
registry.py scan -> _registry.json index
search.py fuzzy search over the index (rapidfuzz)
stats.py compute rows/cols/n_firms from a .dta/.csv (explicit --refresh only)
importing.py harvest variables from a .dta/.csv -> manifest scaffold
exporting.py copy data files to a working dir + provenance txt
cli/main.py `dm` command
mcp/server.py read-only MCP server for AI discovery (stdio)
MCP server (AI discovery)
A read-only MCP server lets an AI client (e.g. zcode) discover and inspect datasets without touching data files. Exposes 5 tools over stdio:
| tool | purpose |
|---|---|
list_datasets(tag) |
all datasets (id/name/vars/rows/span/tags) |
search_datasets(query) |
fuzzy search across variables/labels/names |
list_variables(role, label) |
flat variable list for picking controls |
get_dataset(id) |
full manifest incl. absolute file paths (locate the .dta on disk) |
get_dataset_stats(id) |
cached stats only (never reads data files) |
Run it directly, or register with an MCP-aware client:
# direct
python -m datamgr.mcp.server
# or via entry point
datamgr-mcp
ZCode workspace registration (.zcode/config.json):
{
"mcp": {
"servers": {
"datamgr": {
"command": "python",
"args": ["-m", "datamgr.mcp.server"],
"env": { "DATAMGR_ROOT": "D:/datasets" }
}
}
}
}
The server is deliberately read-only: importing data and recomputing stats are
done from the dm CLI by a human, never by the AI.
Deployment & daily use
See DEPLOYMENT.md for:
- deploying to another machine or MCP client (zcode / Claude / Cursor)
- daily workflow when new data arrives (double-click
.batscripts, no CLI needed) - troubleshooting and a full migration checklist
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。