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

mcp-server-context-search-dcd222

v0.1.0

Published

MCP Server for codebase context search and retrieval

Readme

MCP Server Context Search

一个强大的 Model Context Protocol (MCP) 服务器,提供代码库上下文搜索和分析功能。

功能特性

  • 🔍 语义搜索: 基于向量的代码语义搜索
  • 🌳 AST 分析: 抽象语法树分析和查询
  • 📊 关系分析: 代码依赖关系和调用图分析
  • 🗂️ 项目管理: 多项目隔离和管理
  • 📡 SSE 支持: Server-Sent Events 实时通信
  • 🔧 丰富工具: 25+ 种代码分析工具

安装和使用

作为 MCP 服务器使用

在你的 MCP 客户端配置中添加:

{
  "mcpServers": {
    "context-search": {
      "command": "npx",
      "args": ["-y", "mcp-server-context-search"],
      "env": {
        "PORT": "8888",
        "NEO4J_URI": "bolt://localhost:7687",
        "NEO4J_USERNAME": "neo4j",
        "NEO4J_PASSWORD": "my-password",
        "LITELLM_PROXY_API_KEY": "your_api_key_here",
        "LITELLM_PROXY_API_BASE": "your_api_base_url",
        "EMBEDDING_MODEL": "your_embedding_model"
      }
    }
  }
}

本地开发

# 安装依赖
npm install

# 开发模式运行
npm run start:dev

# 构建项目
npm run build

# 生产模式运行
npm run start:prod

# CLI 模式运行
npm run start:cli

环境变量

| 变量名 | 描述 | 默认值 | |--------|------|--------| | PORT | 服务器端口 | 8888 | | NEO4J_URI | Neo4j 数据库连接地址 | bolt://localhost:7687 | | NEO4J_USERNAME | Neo4j 用户名 | neo4j | | NEO4J_PASSWORD | Neo4j 密码 | my-password | | LITELLM_PROXY_API_KEY | LiteLLM API 密钥 | - | | LITELLM_PROXY_API_BASE | LiteLLM API 基础URL | - | | EMBEDDING_MODEL | 嵌入模型名称 | - | | RERANK_MODEL | 重排序模型名称 | - |

API 端点

  • GET / - 健康检查
  • GET /see - SSE 连接端点
  • GET /mcp/tools - 获取可用工具列表
  • POST /mcp/tools/call - 调用 MCP 工具

可用工具

项目管理

  • create-project - 创建新项目
  • list-projects - 列出所有项目
  • get-project-info - 获取项目信息
  • delete-project - 删除项目
  • add-documents-to-project - 向项目添加文档
  • clear-project-documents - 清空项目文档

代码搜索

  • retrieve-codebase-context - 检索代码库上下文
  • search-code-semantically - 语义搜索代码
  • initialize-codebase-index - 初始化代码库索引
  • get-retrieval-service-status - 获取服务状态
  • clear-vector-store - 清空向量存储

AST 分析

  • ast-find-nodes-by-type - 按类型查找 AST 节点
  • ast-find-function-calls - 查找函数调用关系
  • ast-find-inheritance - 查找继承关系
  • ast-find-circular-dependencies - 查找循环依赖
  • ast-query-relationships - 查询节点关系
  • ast-find-related-nodes - 查找相关节点
  • ast-find-file-nodes - 查找文件节点
  • ast-find-dependency-path - 查找依赖路径
  • ast-get-project-stats - 获取项目统计
  • ast-search-nodes - 搜索节点
  • ast-custom-query - 自定义 Cypher 查询

自定义解析器

  • parse-project-with-custom-parser - 解析项目
  • parse-single-file-custom - 解析单个文件
  • get-custom-parser-stats - 获取解析器统计
  • find-function-definition - 查找函数定义

代码编辑

  • apply-diff-edit - 应用差异补丁

查看完整工具列表和使用方法请访问 /mcp/tools 端点。

使用示例

1. 创建项目并索引代码库

# 通过 MCP 客户端调用
{
  "tool": "create-project",
  "arguments": {
    "projectId": "my-project",
    "name": "My Project",
    "description": "项目描述"
  }
}

{
  "tool": "initialize-codebase-index",
  "arguments": {
    "projectId": "my-project",
    "workspacePath": "/path/to/your/project"
  }
}

2. 搜索代码

{
  "tool": "retrieve-codebase-context",
  "arguments": {
    "projectId": "my-project",
    "query": "用户认证相关的代码"
  }
}

3. AST 分析

{
  "tool": "ast-find-function-calls",
  "arguments": {
    "projectId": "my-project",
    "functionName": "authenticate"
  }
}

支持的文件类型

  • TypeScript/JavaScript: .ts, .js, .tsx, .jsx
  • Python: .py
  • Java: .java
  • C/C++: .cpp, .c, .h, .hpp
  • 其他语言和配置文件

许可证

MIT License