Token导航 LogoToken导航TokenDH.com
MCP Sourcegraph logo
开发工具stdio官方级别未说明来源级核验

MCP Sourcegraph

MCP Server

一个通过GraphQL API提供Sourcegraph强大代码搜索功能的MCP服务器。

工具数

1

提示词数

0

GitHub Stars

0

资源数

0
代码搜索代码分析PythonClaude开发工具Claude

安装说明

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

作者 / 组织

0xb8001

提供方

0xb8001

最后核验

2026/5/17 20:20

运行时

Python

快速接入

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

命令预览

uvx --from git+https://github.com/0xb8001/mcp-sourcegraph mcp-sourcegraph

详细介绍

MCP源图

![License: MIT](https://opensource.org/licenses/MIT) ![Python 3.8+](https://www.python.org/downloads/)

模型上下文协议(MCP)服务器,通过GraphQL API提供对Sourcegraph强大的代码搜索功能的访问。

特性

  • 🔍 代码搜索:使用Sourcegraph的高级搜索语法跨存储库搜索
  • 🎯 存储库筛选:按特定存储库筛选 repo: 模式
  • 📁 文件筛选:使用搜索特定文件类型 file: 模式
  • 🔤 语言过滤:按编程语言筛选 lang:/language: 模式
  • 🔧 图案类型:支持关键字和正则表达式搜索
  • ⚙️ 搜索修改器:区分大小写、结果限制、超时等
  • 🌐 通用载体:适用于Sourcegraph.com和私有Sourcegraph实例

安装

uvx快速入门(推荐)

# Set your Sourcegraph credentials
export SOURCEGRAPH_URL="https://sourcegraph.com"
export SOURCEGRAPH_TOKEN="your-access-token"

# Run directly from GitHub
uvx --from git+https://github.com/0xb8001/mcp-sourcegraph mcp-sourcegraph

一个衬垫

SOURCEGRAPH_URL="https://sourcegraph.com" SOURCEGRAPH_TOKEN="your-token" uvx --from git+https://github.com/0xb8001/mcp-sourcegraph mcp-sourcegraph

地方发展

# Clone and run locally
git clone https://github.com/0xb8001/mcp-sourcegraph.git
cd mcp-sourcegraph
uvx --from . mcp-sourcegraph

获取源图访问令牌

  1. 首选 源代码图设置>访问令牌
  2. 点击“生成新令牌”
  3. 为其命名并赋予适当的权限
  4. 复制生成的令牌

配置

克劳德代码(CLI)

将MCP服务器添加到Claude代码中:

export SOURCEGRAPH_URL="https://sourcegraph.com"
export SOURCEGRAPH_TOKEN="your-access-token"

claude mcp add sourcegraph -e SOURCEGRAPH_URL="$SOURCEGRAPH_URL" -e SOURCEGRAPH_TOKEN="$SOURCEGRAPH_TOKEN" -- uvx --from git+https://github.com/0xb8001/mcp-sourcegraph mcp-sourcegraph

用法

服务器提供 search 工具具有以下参数:

参数类型默认值说明
query字符串*(必填)*使用Sourcegraph语法搜索查询
pattern_type字符串"keyword""keyword""regexp"
count整数10最大结果数(1-1000)
timeout整数10搜索超时(秒)(5-60)

搜索查询示例

# Basic keyword search
hello world

# Repository filtering  
repo:facebook/react useState

# File filtering by extension
file:\.ts$ interface lang:typescript

# Language filtering
lang:python import requests

# Complex multi-filter query
repo:^github\.com/microsoft/ file:\.cs$ async lang:csharp

# Symbol search
type:symbol main lang:go

# Case-sensitive search
case:yes TODO

# Search with result limit
repo:kubernetes file:\.go$ context count:50

高级搜索语法

Sourcegraph支持许多强大的搜索运算符:

  • 存储库筛选器: repo:pattern, -repo:pattern
  • 文件筛选器: file:pattern, -file:pattern
  • 语言过滤器: lang:name, -lang:name
  • 内容过滤器: content:"text", -content:"text"
  • 符号搜索: type:symbol
  • 区分大小写: case:yes
  • 布尔运算符: AND, OR, NOT
  • 正则表达式模式: patterntype:regexp

有关完整的参考,请参阅 源代码图搜索文档.

发展

测试

运行测试脚本以验证您的设置:

python test_server.py

项目结构

mcp-sourcegraph/
├── mcp_sourcegraph/
│   ├── __init__.py
│   └── server.py          # Main MCP server implementation
├── test_server.py         # Test script
├── pyproject.toml         # Package configuration
├── README.md
├── LICENSE
└── .env.example           # Environment variables template

贡献

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add some amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

致谢

目录标签

目录标签

代码搜索代码分析PythonClaude开发工具本地部署GraphQLMCP

支持客户端

Claude

接入字段

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

stdio

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

token

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdiotoken部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP