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 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude-context-mcp

v1.0.1

Published

MCP server for accessing Claude Code context files (index and resolutions)

Readme

Claude Context MCP Server

一个 MCP (Model Context Protocol) 服务器,用于访问 Claude Code 项目的上下文信息(index 和 resolutions)。

功能特性

此 MCP 服务器提供两个工具:

  1. read_context_index - 读取项目的 .claude/context/index.json,获取上一轮对话的摘要信息
  2. read_context_resolution - 读取特定问题解决方案的详细信息

安装

全局安装(推荐)

npm install -g claude-context-mcp

本地安装

npm install claude-context-mcp

配置

方式 1:全局配置(推荐)

将此 MCP 服务器添加为用户级配置,在所有项目中都可以使用:

claude mcp add --transport stdio --scope user claude-context \
  -- npx -y claude-context-mcp

方式 2:项目配置

在特定项目中配置:

claude mcp add --transport stdio --scope local claude-context \
  -- npx -y claude-context-mcp

方式 3:手动配置

编辑 ~/.claude.json 文件(用户级)或项目的 .mcp.json 文件(项目级):

{
  "mcpServers": {
    "claude-context": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "claude-context-mcp"],
      "env": {}
    }
  }
}

如果您已全局安装,也可以直接使用:

{
  "mcpServers": {
    "claude-context": {
      "type": "stdio",
      "command": "claude-context-mcp",
      "args": [],
      "env": {}
    }
  }
}

使用方法

配置完成后,在 Claude Code 中可以使用以下工具:

1. 查看项目上下文索引

查看之前的实现和决策

> 使用 read_context_index 工具查看当前项目的上下文

MCP 工具会自动读取当前项目的 .claude/context/index.json 文件。

2. 查看具体问题的解决方案

当您从 index 中发现相关的解决方案(例如 res-001),可以获取详细信息:

> 使用 read_context_resolution 工具读取 resolution_id 为 "res-001" 的详细信息

典型工作流程

开发者: 我要实现用户认证功能

Claude: 让我先查看之前有没有相关的实现...
> [调用 read_context_index 工具]

Claude: 我在上下文中找到了一个相关的解决方案 res-003,关于认证流程的实现。
       让我查看详细信息...
> [调用 read_context_resolution 工具,resolution_id: "res-003"]

Claude: 根据之前的实现经验,我建议采用以下方案...

项目结构要求

此 MCP 服务器期望项目中存在以下结构:

your-project/
├── .claude/
│   └── context/
│       ├── index.json          # 上下文索引文件
│       └── resolutions/        # 解决方案详情目录
│           ├── res-001.json
│           ├── res-002.json
│           └── ...

工作原理

  • MCP 服务器通过 stdio 传输与 Claude Code 通信
  • 服务器会自动使用调用时的当前工作目录作为项目路径
  • 哪个项目调用它,它就读取哪个项目下的 .claude/context/ 文件
  • 支持自定义 project_path 参数来指定项目路径(可选)

验证安装

# 查看已配置的 MCP 服务器
claude mcp list

# 查看具体配置
claude mcp get claude-context

故障排查

服务器无法启动

  1. 检查 npx 是否可用:

    npx --version
  2. 检查 MCP 服务器配置:

    claude mcp get claude-context

找不到 context 文件

确保项目中存在 .claude/context/index.json 文件。此文件通常由之前的 Claude Code 会话自动创建。

Windows 用户注意事项

在原生 Windows(非 WSL)上,使用 npx 需要 cmd /c 包装器:

claude mcp add --transport stdio --scope user claude-context \
  -- cmd /c npx -y claude-context-mcp

开发

本地开发

# 克隆仓库
git clone <repository-url>
cd claude-context-mcp

# 安装依赖
npm install

# 构建
npm run build

# 监听模式
npm run watch

本地测试

在本地开发时,可以使用本地路径配置:

claude mcp add --transport stdio --scope local claude-context-dev \
  -- node /path/to/claude-context-mcp/build/index.js

许可证

MIT

贡献

欢迎提交 Issue 和 Pull Request!