Token导航 LogoToken导航TokenDH.com
D3 MCP Server logo
文档知识stdio官方级别未说明来源级核验

D3 MCP Server

MCP Server

提供D3.js API文档和示例代码的搜索服务,帮助AI代理快速获取D3.js相关资源。

工具数

5

提示词数

0

GitHub Stars

1

资源数

0
API文档PythonClaude搜索工具Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

jakeb-grant

提供方

jakeb-grant

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run fastmcp dev inspector d3_mcp_server/server.py --with-editable .

详细介绍

d3 mcp服务器

MCP服务器,为AI代理提供D3.js API文档和示例代码。从以下位置获取文档 d3js.org 以及来自 可观察的D3画廊,通过可搜索的工具为他们提供服务。

设置

需要Python 3.14+和 紫外线.

克劳德代码

claude mcp add -t stdio -s user d3 -- uvx --from git+https://github.com/jakeb-grant/d3-mcp-server d3-mcp-server

克劳德桌面/光标等。

{
  "mcpServers": {
    "d3": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/jakeb-grant/d3-mcp-server", "d3-mcp-server"]
    }
  }
}

更新中

uvx 缓存已安装的版本。要获取最新数据,请清除缓存并重新运行:

uv cache clean d3-mcp-server

MCP检查员

uv run fastmcp dev inspector d3_mcp_server/server.py --with-editable .

工具

find_module(query?)

探索D3模块。不带查询,列出所有30个模块。通过查询,返回按名称、标签和描述相关性排名的前5个匹配项。

find_module()                → list all modules
find_module("scale")         → modules related to scales
find_module("color")         → d3-color, d3-scale-chromatic, d3-interpolate

get_docs(module_name, page?)

获取模块的文档。默认情况下返回模块概述或特定子页面。

get_docs("d3-scale")              → scale overview + list of sub-pages
get_docs("scale")                 → same (short names work)
get_docs("d3-scale", "linear")    → linear scales sub-page
get_docs("d3-array", "ticks")     → ticks sub-page

search_docs(query, module_name?)

在文档内容中搜索特定主题或方法。可选范围为单个模块。

search_docs("scaleLinear")              → searches across relevant modules
search_docs("domain", "d3-scale")       → searches within d3-scale only

find_example(query?, category?)

从Observable库中浏览和搜索14个类别(条形图、线条、地图、层次结构等)的约170个D3示例。

find_example()                    → list all categories with counts
find_example(query="treemap")     → search examples by keyword
find_example(category="Bars")     → list all examples in a category

get_example(path)

从Observable笔记本中获取示例源代码。从笔记本格式中提取干净、独立的D3代码,以及描述和数据文件URL。

get_example("@d3/bar-chart/2")           → bar chart source code
get_example("@d3/force-directed-graph/2") → force-directed graph source

建筑

d3_mcp_server/
├── __init__.py    # Entry point (main)
├── server.py      # FastMCP server, tools, resource template
├── modules.py     # D3Module model + 30-module registry
├── examples.py    # Observable gallery scraping + notebook code extraction
├── cache.py       # File cache (~/.cache/d3-mcp-server/) + HTML→markdown
├── search.py      # Module scoring + markdown section parsing/search
└── sync.py        # Registry drift detection (see below)
tests/
├── test_examples.py # Gallery parsing, scoring, notebook extraction tests
├── test_search.py   # Search, parsing, module resolution tests
├── test_cache.py    # HTML conversion, caching, fetch error handling
└── test_server.py   # Tool integration tests

文档页面从d3js.org获取,剥离到 `` 内容,通过markdownify转换为markdown,并以24小时TTL缓存到磁盘。

注册表同步

中的模块注册表 modules.py 是硬编码的。如果d3js.org添加、删除或重命名模块或页面,注册表将漂移。同步实用程序检测到这一点。

检查漂移情况

uv run python -m d3_mcp_server.sync

这会抓取d3js.org/api侧边栏,并将其与硬编码的进行比较 D3_MODULES 列表、报告:

  • d3js.org上的新模块不在注册表中
  • 注册表中不再存在于d3js.org上的模块
  • 添加到现有模块的新子页面
  • d3js.org上不再存在的注册表子页

更新注册表

当检测到漂移时,更新 d3_mcp_server/modules.py 遵循这些规则:

D3_MODULES 是要编辑的列表。 每个条目都是一个 D3Module 与:

  • name --模块名称与d3js.org上显示的完全一致(例如。 "d3-array")
  • description --简短摘要(从d3js.org侧栏或模块索引页面复制)
  • tags -用于搜索评分的小写关键字(包括简短名称、API关键术语和相关概念)
  • pages --页面路径的有序列表;第一个条目始终是模块索引页("/d3-array"),后面是子页面("/d3-array/ticks")

对于新模块,添加a D3Module 进入 D3_MODULES。将其按字母顺序放置在现有条目中,或将其与相关模块分组。填充 tags 具有简短的模块名称和来自模块描述和API方法的3-8个相关关键字。

对于已拆卸的模块,删除整个 D3Module 进入。

对于新页面,将页面路径附加到模块的 pages 列表。路径格式为 "/{module_name}/{page_slug}" 其中slug与d3js.org URL匹配。

对于已删除的页面,从模块中删除页面路径 pages 列表。

编辑后,验证:

uv run python -m d3_mcp_server.sync   # should report no drift
uv run pytest tests/ -v               # all tests should pass
uvx ruff check d3_mcp_server/ tests/  # no lint errors

发展

uv run pytest tests/ -v                              # run tests
uvx ruff check d3_mcp_server/ tests/                 # lint
uvx ruff format d3_mcp_server/ tests/                # format
uv run python -m d3_mcp_server.sync                  # check registry drift
uv run fastmcp dev inspector d3_mcp_server/server.py --with-editable .  # MCP inspector

目录标签

目录标签

API文档PythonClaude搜索工具本地部署D3.js示例代码AI辅助

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP