DevRev集成协议

一个用于DevRev平台集成的模型上下文协议实现,支持AI助手无缝交互,提供搜索、工作项管理、部件管理等功能。

  • by KalshuCodes
  • Python
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 KalshuCodes/devrev-mcp-server

使用说明

DevRev MCP

注: 这是DevRev模型上下文协议的非官方实现。它不是由DevRev,股份有限公司创建、维护或认可的。

用于DevRev集成的游标模型上下文协议(MCP)实现,允许AI助手与DevRev平台无缝交互。

特性

  • 搜索DevRev:跨多个命名空间查找对象(问题、票证、文章等)
  • 管理工作:列出、创建和更新问题、工单和任务
  • 零部件管理:探索产品层次结构、功能、特性等
  • 详细信息:按ID检索全面的对象详细信息
  • 光标集成:已准备好通过SSE传输与Cursor IDE一起使用
  • 稳健的错误处理:全面的日志记录和错误恢复
  • 情境感知协助:内置文档和最佳实践

先决条件

  • Python 3.8+
  • 具有适当权限的DevRev API访问令牌(PAT)
  • 游标IDE,实现最佳集成

安装

快速开始安装脚本

./install.sh

手动安装

# Create virtual environment
python -m venv venv

# Activate virtual environment
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .

配置

设置以下环境变量:

# Required
export DEVREV_API_KEY="your_devrev_personal_access_token"

# Optional (with defaults shown)
export DEVREV_API_BASE_URL="https://api.devrev.ai"
export DEVREV_API_TIMEOUT="30"
export DEVREV_API_RETRIES="3"
export DEVREV_MCP_HOST="127.0.0.1"
export DEVREV_MCP_PORT="8888"
export DEVREV_MCP_LOG_LEVEL="info"  # debug, info, warning, error
export DEVREV_MCP_DEBUG="false"

用法

启动服务器

python -m devrev_mcp

连接光标

在Cursor IDE中,打开设置并添加MCP服务器URL:

http://127.0.0.1:8888/sse

可用工具

综合文档

通过以下方式访问内置文档:

context = devrev_context()

这提供了有关所有工具、支持的名称空间、参数和使用示例的详细信息。

搜索DevRev

# Search for issues with "authentication" in the title or description
results = search(query="authentication", namespace="issue")

# Search for features in a specific product
results = search(query="product:payments api", namespace="feature")

列出作品

# List issues assigned to the current user
works = list_works(work_type="issue", owned_by="self", limit=20)

# List tickets related to a specific feature
works = list_works(work_type="ticket", applies_to_part="FEAT-123", limit=10)

创作作品

# Create a new issue for a specific feature
issue = create_work(
    work_type="issue",
    title="API returns 500 error on large payloads",
    applies_to_part="FEAT-123",
    body="When submitting payloads larger than 1MB, the API consistently returns a 500 error."
)

# Create a new task without part association
task = create_work(
    work_type="task",
    title="Update documentation with new endpoints",
    body="Add the newly created endpoints to our API documentation."
)

更新作品

# Update an issue's title
updated_issue = update_work(
    work_id="ISS-123",
    title="Updated: API returns 500 error on large payloads"
)

# Change an issue's status
updated_issue = update_work(
    work_id="ISS-123",
    status="closed"
)

# Update multiple fields at once
updated_issue = update_work(
    work_id="ISS-123",
    title="Updated title",
    body="Updated description",
    applies_to_part="FEAT-456",
    stage="done"
)

获取对象详细信息

# Get details about an issue
issue = get_object(id="ISS-123")

# Get details about a ticket
ticket = get_object(id="TKT-456")

探索零件

# List all products
products = list_parts(part_type="product")

# List capabilities under a specific product
capabilities = list_parts(part_type="capability", parent_part="PROD-123")

# List features under a capability
features = list_parts(part_type="feature", parent_part="CAP-123")

# Get details about a specific part
part = get_part(id="FEAT-123")

工作流示例

示例1:为功能创建问题

# First, search for the feature or get a list of features
features = list_parts(part_type="feature", parent_part="CAP-123")
feature_id = features["parts"][0]["id"]  # Select the first feature

# Create an issue linked to that feature
new_issue = create_work(
    work_type="issue",
    title="Fix security vulnerability in authentication",
    applies_to_part=feature_id,
    body="Critical security vulnerability in the token validation process."
)

# Verify the issue was created and get full details
created_issue = get_object(id=new_issue["work"]["id"])

示例2:分层产品探索

# Start with listing all products
products = list_parts(part_type="product")
product_id = products["parts"][0]["id"]  # Select a product

# List capabilities for this product
capabilities = list_parts(part_type="capability", parent_part=product_id)
capability_id = capabilities["parts"][0]["id"]  # Select a capability

# List features under this capability
features = list_parts(part_type="feature", parent_part=capability_id)
feature_id = features["parts"][0]["id"]  # Select a feature

# List issues related to this feature
issues = list_works(work_type="issue", applies_to_part=feature_id)

示例3:问题管理工作流

# Search for a specific issue by keyword
issues = search(query="authentication error", namespace="issue")
issue_id = issues["results"][0]["id"]

# Get full details of the issue
issue = get_object(id=issue_id)

# Update the issue with new information
updated_issue = update_work(
    work_id=issue_id,
    title=f"[In Progress] {issue['title']}",
    stage="in_progress"
)

支持的DevRev对象类型

该集成支持各种DevRev对象,包括:

  • 作品:问题、票证、任务
  • 零件:产品、功能、特性、增强、可链接、可运行
  • 用户:开发用户、加速用户、系统用户
  • 沟通:对话、评论、文章
  • 还有更多:项目、标签、工作流等。

有关支持对象及其用法的完整列表,请参阅 devrev_context() 工具输出。

故障排除

如果您在使用MCP工具时遇到问题:

  1. 验证您的API密钥是否有效并且设置正确
  2. 查看日志 ./tmp/logs/devrev_mcp.log
  3. 确保为每个工具使用正确的参数
  4. 检查DevRev API端点是否可以从您的网络访问

发展

项目结构

devrev_mcp/
├── src/
│   └── devrev_mcp/
│       ├── __init__.py
│       ├── __main__.py     # Entry point
│       ├── auth.py         # Authentication
│       ├── client.py       # DevRev API client
│       ├── config.py       # Configuration
│       ├── errors.py       # Error handling
│       └── sse.py          # SSE transport
├── README.md               # This file
└── pyproject.toml          # Project metadata

运行测试

pytest

许可证

麻省理工学院

贡献

欢迎投稿!请随时提交问题或拉取请求,以帮助改进此集成。

致谢

  • DevRev API团队的优秀文档和支持
  • MCP框架的Cursor团队
  • 此项目的所有贡献者