VS Code Copilot MCP服务

一个可扩展的模型上下文协议(MCP)服务器,为VS Code Copilot提供GitHub Issues管理、GitHub Projects V2工具和图书目录REST API等功能。

  • by bryan-debaun
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 bryan-debaun/mcp-server

使用说明

@bryan debaun/mcp服务器

使用GitHub Issues工具为VS代码副本提供可扩展的模型上下文协议(MCP)服务器。

特性

  • GitHub问题工具:通过VS Code Copilot聊天直接列出、查看、创建、更新和关闭GitHub问题
  • GitHub项目V2工具:管理GitHub Projects V2中的自定义字段和值(字段CRUD、批量值更新、动态选项解析)
  • 图书目录REST API:使用完整的CRUD操作管理书籍、作者和评级
  • OpenAPI 3.0规范:带有Swagger UI的自动生成API文档,位于 /docs
  • 可扩展架构:无需进行重大重构即可轻松添加新的工具类别
  • Zod验证:所有工具输入都使用zod模式进行验证
  • 错误处理:优雅的错误处理,信息清晰
  • HTTP流和SSE传输:主机MCP POST /mcp (NDJSON流)和SSE回退 GET /mcp 和 POST /mcp/events 用于活动交付。通过以下方式保护端点 MCP_API_KEY 使用 Authorization: Bearer <MCP_API_KEY>.

可用工具

GitHub问题

工具 说明 参数
get-open-issues 列出存储库中的未解决问题 repo, labels?, limit?
get-issue 获取特定问题的完整详细信息 repo, issueNumber
create-issue 创建新问题 repo, title, body?, labels?, assignees?, milestone?
update-issue 更新问题或添加评论 repo, issueNumber, title?, body?, labels?, removeLabels?, assignees?, milestone?, state?, stateReason?, comment?
close-issue 使用可选注释关闭问题 repo, issueNumber, comment?
list-labels 列出存储库中定义的所有标签 repo

GitHub项目V2

管理GitHub Projects V2板——列出项目,设置字段值,并直接在板上自动创建问题。需要一个GitHub令牌 project 范围。

板和项目

工具 说明 参数
list-project-items 按状态分组列出板上的所有项目 owner, projectNumber
get-project-status-options 获取“状态”字段的可用选项 owner, projectNumber
create-issue-in-project 创建一个问题,并在一次通话中将其添加到板上 owner, repo, projectNumber, title, body?, labels?, status?

现场管理

工具 说明 参数
get-project-fields 列出所有具有类型和选项的自定义字段 owner, projectNumber
create-project-field 创建新的自定义字段 owner, projectNumber, name, dataType, options?
update-project-field 更新字段名或SINGLE_SELECT选项 owner, projectNumber, fieldName, newName?, addOptions?, removeOptions?
delete-project-field 删除自定义字段 owner, projectNumber, fieldName

价值运营

工具 说明 参数
set-project-field-value 为问题设置单个字段值 owner, repo, projectNumber, issueNumber, fieldName, value
bulk-set-project-field-values 在多个问题上设置多个字段 owner, repo, projectNumber, updates[]

支持的字段类型:

  • TEXT -自由形式文本值
  • NUMBER -数值(例如,故事点、工作量估算)
  • DATE -ISO 8601日期字符串(例如“2024-12-31”)
  • SINGLE_SELECT -从预定义选项中选择(从字段元数据自动解析)
  • ITERATION -迭代/冲刺参考

特性:

  • ✅ 字段元数据缓存(减少API调用)
  • ✅ 动态SINGLE_SELECT选项解析(无硬编码)
  • ✅ 批量操作,并提供详细的成功/失败报告
  • ✅ 权限问题的可操作错误消息

示例用法:

User: In Project #2, set the "Status" field to "In Progress" and "Priority" to "High" for issues #73 and #42
Copilot: [Uses bulk-set-project-field-values to update both issues]

数据库-书籍

工具 说明 参数
list-books 列出带有可选过滤器的书籍 limit?, offset?, search?, authorId?, minRating?
get-book 获取作者和评级的书籍详细信息 id
create-book 创建新书(管理员) title, description?, isbn?, publishedAt?, authorIds?, createdBy?
update-book 更新图书详细信息(管理员) id, title?, description?, isbn?, publishedAt?, authorIds?
delete-book 删除一本书(管理员) id

数据库-作者

工具 说明 参数
list-authors 使用可选搜索列出作者 limit?, offset?, search?
get-author 通过书籍获取作者详细信息 id
create-author 创建新作者(管理员) name, bio?, website?, createdBy?
update-author 更新作者详细信息(管理员) id, name?, bio?, website?
delete-author 删除作者(管理员) id

数据库-评级

工具 说明 参数
list-ratings 列出带有可选过滤器的评级 limit?, offset?, bookId?, userId?
create-or-update-rating 创建或更新图书评级(经过身份验证) bookId, rating (1-10), review?, userId
delete-rating 删除评级(所有者或管理员) id

REST API和OpenAPI文档

服务器通过自动生成的OpenAPI 3.0文档为所有图书目录操作公开RESTful API。

交互式API文档

访问Swagger UI以进行交互式API探索:

  • 本地: http://localhost:3000/docs
  • 生产: https://your-server.onrender.com/docs

端点

公共端点(无身份验证)

  • GET /api/books -列出带有过滤功能的书籍
  • GET /api/books/:id -获取书籍详细信息
  • GET /api/authors -列出作者
  • GET /api/authors/:id -获取作者详细信息
  • GET /api/ratings -列出评级

管理端点(需要JWT身份验证)

  • POST /api/books -创建书籍
  • PUT /api/books/:id -更新书籍
  • DELETE /api/books/:id -删除书籍
  • POST /api/authors -创建作者
  • PUT /api/authors/:id -更新作者
  • DELETE /api/authors/:id -删除作者

经过身份验证的用户端点(需要JWT)

  • POST /api/ratings -创建/更新评级
  • DELETE /api/ratings/:id -删除自己的评级

开放API规范

下载原始OpenAPI规范:

  • 本地: http://localhost:3000/docs/swagger.json
  • 生产: https://your-server.onrender.com/docs/swagger.json

使用此规范,使用以下工具为任何语言生成客户端SDK OpenAPI生成器.

先决条件

  • Node.js 24(活动LTS):工具链(Docker镜像、CI、, .nvmrc)目标节点24;20+是支持的最低值(engines.node)
  • pnpm:此项目使用 pnpm 作为其包管理器(通过 packageManager 领域 package.json).获取正确版本的最简单方法是Corepack,它附带了Node.js——run corepack enable once和pnpm命令将自动使用固定版本。
  • PostgreSQL数据库:书籍/电影/游戏目录功能需要(仅GitHub工具可选)
  • GITHUB_TOKEN:GitHub个人访问令牌(PAT)或细粒度令牌 repo 和 project 范围。通过设置 GITHUB_TOKEN 环境变量。

环境变量

创建 .env 项目根目录中的文件:

# Required for database features
DATABASE_URL=postgresql://user:password@localhost:5432/dbname

# Required for GitHub Issues and Projects tools
GITHUB_TOKEN=ghp_your_personal_access_token

# Optional: For HTTP MCP transport authentication
# When `MCP_API_KEY` is set, MCP transport endpoints (eg. `/mcp`) and DB-dependent routes (`/api/*` for books/authors/ratings) require `Authorization: Bearer <MCP_API_KEY>`.
MCP_API_KEY=your-secret-key

> Note: The gateway key may also be sent via the `X-Mcp-Api-Key` header. This is a first-class, supported second factor for callers whose `Authorization` header already carries a Supabase user JWT (e.g. the website's admin requests, which send `Authorization: Bearer <SUPABASE_JWT>` + `X-Mcp-Api-Key: <MCP_API_KEY>`). Pure MCP clients may instead send the key directly as `Authorization: Bearer <MCP_API_KEY>`.

# Optional: For admin endpoints
INTERNAL_ADMIN_KEY=your-admin-key
ADMIN_DEBUG_ENABLED=true

# Optional: Sentry error alerting. When SENTRY_DSN is set, unhandled errors and
# every logger.error are reported to Sentry. Unset = disabled (dev/test default).
SENTRY_DSN=https://<key>@o<org>.ingest.sentry.io/<project>
# SENTRY_ENVIRONMENT=production        # defaults to NODE_ENV
# SENTRY_TRACES_SAMPLE_RATE=0          # 0..1; 0 = errors only (no perf tracing)
# SENTRY_RELEASE=mcp-server@0.1.0

安装

  1. C

  2. 数据库设置 (如果使用图书目录功能):

    # Run migrations
    pnpm exec prisma migrate deploy
    

    部署时间种子(推荐)

    # Seed initial data (creates admin user and sample books)
    # NOTE: Run this as a deploy step (CI or Render deploy hook) to avoid re-seeding on cold-starts
    pnpm run prisma:seed
    

    示例GitHub操作代码段(迁移后运行seed):

    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - uses: pnpm/action-setup@v4
          - uses: actions/setup-node@v4
            with:
              node-version: 24
              cache: 'pnpm'
          - run: pnpm install --frozen-lockfile
          - run: pnpm exec prisma migrate deploy
          - run: pnpm run prisma:seed
    

    渲染:您可以在服务设置(渲染UI)中添加部署后命令以运行 pnpm run prisma:seed,或在部署后使用Deploy Hook触发种子设定。

    git clone https://github.com/bryan-debaun/mcp-server.git
    cd mcp-server
    
  3. 安装依赖项:

    pnpm install
    
  4. 构建:

    pnpm run build
    

VS代码配置

选项1:远程(已部署服务器--推荐)

通过HTTP流将任何VS Code安装连接到已部署的Render实例。打开用户MCP配置(命令面板→ MCP:打开用户配置)并添加:

{
  "servers": {
    "bryan-debaun-mcp": {
      "type": "http",
      "url": "https://mcp-server.onrender.com/mcp",
      "headers": {
        "Authorization": "Bearer ${input:mcpApiKey}"
      }
    }
  },
  "inputs": [
    {
      "id": "mcpApiKey",
      "type": "promptString",
      "description": "MCP API Key",
      "password": true
    }
  ]
}

VS Code将提示一次 MCP_API_KEY 服务器首次连接时。密钥安全地存储在VS Code的秘密存储器中,并可用于后续会话。

其他应用程序的注意事项:任何支持HTTP流传输的MCP客户端都可以以相同的方式连接。指向 https://mcp-server.onrender.com/mcp 和 Authorization: Bearer <MCP_API_KEY>.


选项2:本地(stdio-用于开发)

从本地版本运行服务器。在服务器本身迭代时很有用。

创建或更新 .vscode/mcp.json 在您的工作区中,或添加到您的VS Code用户MCP配置中:

{
  "servers": {
    "bryan-debaun-mcp-local": {
      "type": "stdio",
      "command": "node",
      "args": ["C:/path/to/mcp-server/dist/index.js"],
      "env": {
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

选项3:传统用户配置

添加到VS Code用户设置中(使用命令调色板→ “MCP:打开用户配置”):

{
  "servers": {
    "bryan-debaun-mcp": {
### VS Code Copilot

Once configured, the MCP tools are available in VS Code Copilot chat:

1. Open Copilot Chat (`Ctrl+Alt+I`)
2. Enable the MCP server from the Tools picker
3. Ask questions like:
   - "List open issues in bryan-debaun/mcp-server"
   - "Show me issue #2 in bryan-debaun/mcp-server"
   - "Create an issue titled 'Bug fix' in owner/repo"
   - "Close issue #5 in owner/repo with comment 'Fixed in PR #10'"
   - "List all books in the catalog"
   - "Show me books by Brandon Sanderson"

### HTTP API

The server also exposes HTTP endpoints for direct access:

#### Books

```bash
# List books
curl http://localhost:8080/api/books?limit=10

# Get book by ID
curl http://localhost:8080/api/books/1

# Create book (requires admin JWT)
curl -X POST http://localhost:8080/api/books \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "X-INTERNAL-KEY: YOUR_ADMIN_KEY" \
  -d '{
    "title": "New Book",
    "description": "A great book",
    "isbn": "978-1234567890",
    ├── db/
│   │   └── index.ts          # Prisma client initialization
│   ├── http/
│   │   ├── server.ts         # HTTP server setup
│   │   ├── books-route.ts    # Book catalog endpoints
│   │   ├── authors-route.ts  # Author endpoints
│   │   └── ratings-route.ts  # Rating endpoints
│   └── tools/
│       ├── index.ts          # Tool registration aggregator
│       ├── local.ts          # Tool dispatcher for HTTP routes
│       ├── github-issues/    # GitHub Issues tool category
│       │   ├── index.ts      # Registers all issue tools
│       │   ├── schemas.ts    # Zod schemas for inputs
│       │   ├── gh-cli.ts     # GitHub CLI wrapper
│       │   ├── results.ts    # Result helpers
│       │   └── *.ts          # Individual tool implementations
│       └── db/               # Database tool categories
│           ├── books/        # Book CRUD tools
│           ├── authors/      # Author CRUD tools
│           └── ratings/      # Rating CRUD tools
├── prisma/
│   ├── schema.prisma         # Database schema
│   ├── seed.ts               # Initial data seeding
│   └── migrations/           # Database migr
  -H "X-INTERNAL-KEY: YOUR_ADMIN_KEY" \
  -d '{"title": "Updated Title"}'

# Delete book
curl -X DELETE http://localhost:8080/api/books/1 \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "X-INTERNAL-KEY: YOUR_ADMIN_KEY"

作者

# List authors
curl http://localhost:8080/api/authors?limit=10

# Get author by ID (includes their books)
curl http://localhost:8080/api/authors/1

# Create author (requires admin JWT)
curl -X POST http://localhost:8080/api/authors \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "X-INTERNAL-KEY: YOUR_ADMIN_KEY" \
  -d '{
    "name": "New Author",
    "bio": "Author biography",
    "website": "https://example.com"
  }'

评分

# List all ratings
curl http://localhost:8080/api/ratings?limit=10

# Get my ratings (requires JWT)
curl http://localhost:8080/api/users/me/ratings \
  -H "Authorization: Bearer YOUR_JWT"

# Create or update rating (requires JWT)
curl -X POST http://localhost:8080/api/ratings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT" \
  -d '{
    "bookId": 1,
    "rating": 8,
    "review": "Great book!"
  }'

# Delete rating (requires JWT, owner or admin)
curl -X DELETE http://localhost:8080/api/ratings/1 \
  -H "Authorization: Bearer YOUR_JWT"

配置后,MCP工具在VS Code Copilot聊天中可用:

  1. 打开Copilot聊天(Ctrl+Alt+I)
  2. 从工具选择器启用MCP服务器
  3. 问以下问题:
    • “列出bryan debaun/mcp服务器中的未决问题”
    • “显示bryan debaun/mcp服务器中的问题#2”
    • “在所有者/仓库中创建一个标题为“Bug修复”的问题”
    • “关闭所有者/回购中的第5个问题,并评论‘已在PR#10中修复’”

发展

# Build
pnpm run build

# Watch mode (rebuild on changes)
pnpm run dev

# Run tests
pnpm test

# Run tests in watch mode
pnpm run test:watch

# Type check
pnpm run typecheck

项目结构

mcp-server/
├── src/
│   ├── index.ts              # Entry point, stdio transport setup
│   ├── server.ts             # McpServer factory
│   └── tools/
│       ├── index.ts          # Tool registration aggregator
│       └── github-issues/    # GitHub Issues tool category
│           ├── index.ts      # Registers all issue tools
│           ├── schemas.ts    # Zod schemas for inputs
│           ├── gh-cli.ts     # GitHub CLI wrapper
│           ├── results.ts    # Result helpers
│           └── *.ts          # Individual tool implementations
├── test/                     # Tests mirror src structure
├── dist/                     # Compiled output
└── .vscode/
    └── mcp.json              # VS Code MCP configuration

添加新工具

要添加新的工具类别(例如Git操作):

  1. 创建新文件夹: src/tools/git/
  2. 按照中的模式实施工具 github-issues/
  3. 创建注册功能: registerGitTools(server)
  4. 导入并调用它 src/tools/index.ts