npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

jdi-codex

v1.0.0

Published

MCP (Model Context Protocol) 服务

Readme

JDI Codex

这是一个用于访问 coding.jd.com API 的 MCP (Model Context Protocol) 服务器。

登录 jnpm

在发布或使用包之前,需要先登录京东内部的 npm(jnpm):

# 1. 配置 registry(必须)
npm config set registry=http://registry.m.jd.com

# 2. 验证 registry 配置
npm config get registry
# 应该显示: http://registry.m.jd.com

# 3. 登录(使用京东内部账号)
# 方式一:使用 npm adduser(推荐)
npm adduser --registry=http://registry.m.jd.com

# 方式二:使用 npm login(需要先设置 registry)
npm login

重要提示

  • 必须确保 registry 设置为 http://registry.m.jd.com,否则会登录到公共 npm
  • 如果 npm adduser 还是跳转到公共 npm,请使用 --registry 参数显式指定

按提示输入:

  • Username: 你的京东账号用户名(通常是工号或邮箱)
  • Password: 你的密码
  • Email: 你的邮箱地址

登录成功后,可以使用以下命令验证:

npm whoami --registry=http://registry.m.jd.com

常见登录问题

错误:No credentials to set

这个错误通常表示:

  1. 账号未注册:你的账号可能还没有在京东内部 npm 中注册,需要先联系管理员注册账号
  2. 账号或密码错误:请确认输入的账号和密码正确
  3. 需要先注册:如果是新账号,可能需要先访问京东内部 npm 的 Web 界面进行注册

解决方案

  • 确认你的京东内部账号是否有 npm 发布权限
  • 联系京东内部 npm 管理员确认账号状态
  • 尝试使用邮箱而不是用户名登录
  • 如果账号是新创建的,可能需要等待一段时间才能使用

错误:每次发布都需要重新登录

如果登录信息没有持久化,检查 ~/.npmrc 文件是否包含:

//registry.m.jd.com/:_authToken=YOUR_TOKEN

如果没有,可能需要手动配置 token 或重新登录。

安装

方式一:使用 npx(推荐)

无需安装,直接使用 npx 运行:

# 确保已配置 jnpm registry
npm config set registry=http://registry.m.jd.com

方式二:全局安装

npm install -g jdi-codex --registry=http://registry.m.jd.com

方式三:本地安装

npm install jdi-codex --registry=http://registry.m.jd.com

配置

在 MCP 配置文件中(通常是 ~/.cursor/mcp.json~/.config/cursor/mcp.json),添加以下配置:

使用 npx(推荐)

{
  "mcpServers": {
    "jdi-codex": {
      "command": "npx",
      "args": [
        "--registry=http://registry.m.jd.com",
        "jdi-codex"
      ],
      "env": {
        "CODING_TOKEN": "your-token-here"
      },
      "disabled": false
    }
  }
}

使用全局安装

{
  "mcpServers": {
    "jdi-codex": {
      "command": "jdi-codex",
      "env": {
        "CODING_TOKEN": "your-token-here"
      },
      "disabled": false
    }
  }
}

使用本地安装

{
  "mcpServers": {
    "jdi-codex": {
      "command": "node",
      "args": ["./node_modules/jdi-codex/dist/index.js"],
      "env": {
        "CODING_TOKEN": "your-token-here"
      },
      "disabled": false
    }
  }
}

获取 CODING_TOKEN

  1. 登录 coding.jd.com
  2. 进入个人设置 → 访问令牌
  3. 创建新的访问令牌
  4. 将令牌复制到配置文件的 CODING_TOKEN 字段中

开发

# 开发模式运行(使用 tsx)
npm run dev

# 编译 TypeScript
npm run build

# 运行编译后的代码
npm start

# 监听模式编译
npm run watch

使用

配置完成后,重启 Cursor 或重新加载 MCP 服务器,即可在 AI 对话中使用以下工具:

可用工具

  • encode_uri_component: 对指定的URL或字符串进行encodeURIComponent编码
  • fetch_projects: 请求 coding.jd.com API 获取项目列表
    • 支持搜索、分页、排序等功能
  • fetch_file_content: 获取代码文件内容
    • 支持指定分支、项目ID或仓库路径
  • fetch_repository_tree: 获取文件树
    • 支持递归查询、指定路径、分支等

使用示例

在 Cursor 的 AI 对话中,你可以直接说:

  • "帮我获取项目列表"
  • "查看某个项目的文件树"
  • "读取某个文件的代码内容"

AI 会自动调用相应的工具来完成你的请求。

故障排查

  1. 无法连接服务器

    • 检查 CODING_TOKEN 是否正确配置
    • 确认网络可以访问 coding.jd.com
    • 查看 Cursor 的 MCP 日志
  2. 包未找到

    • 确认已配置 jnpm registry:npm config set registry=http://registry.m.jd.com
    • 检查包名是否正确:jdi-codex
  3. 权限错误

    • 确认 CODING_TOKEN 有足够的权限访问项目
    • 检查项目访问权限设置