Back to Documentation

GitHub MCP Server for Cursor

This project implements a Model Context Protocol (MCP) server that integrates with GitHub to provide comprehensive functionality for web-based projects in Cursor.

Features

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/github-mcp-server.git
    cd github-mcp-server
  2. Install dependencies:

    npm install
  3. Create a .env file in the root directory with your GitHub credentials:

    GITHUB_TOKEN=your_github_personal_access_token
    GITHUB_OWNER=default_repository_owner
    GITHUB_REPO=default_repository_name
    PORT=3000
    HOST=0.0.0.0
    NODE_ENV=development
    DEFAULT_TRANSPORT=stdio

Usage

Starting the server with stdio transport (local development)

npm run start:stdio

Starting the server with SSE transport (networked access)

npm run start:sse

Configuring Cursor to use the MCP server

Project-specific configuration

Create a .cursor/mcp.json file in your project root:

{
  "servers": [
    {
      "name": "github-mcp-server",
      "command": "npm",
      "args": ["run", "start:stdio"],
      "cwd": "/path/to/github-mcp-server",
      "env": {
        "GITHUB_TOKEN": "your_github_personal_access_token",
        "GITHUB_OWNER": "your_github_username",
        "GITHUB_REPO": "your_repository_name"
      }
    }
  ]
}

Global configuration

Create a ~/.cursor/mcp.json file:

{
  "servers": [
    {
      "name": "github-mcp-server",
      "command": "npm",
      "args": ["run", "start:stdio"],
      "cwd": "/path/to/github-mcp-server",
      "env": {
        "GITHUB_TOKEN": "your_github_personal_access_token",
        "GITHUB_OWNER": "your_github_username",
        "GITHUB_REPO": "your_repository_name"
      }
    }
  ]
}

Using SSE transport

For SSE transport, modify the configuration:

{
  "servers": [
    {
      "name": "github-mcp-server",
      "url": "http://localhost:3000/sse"
    }
  ]
}

Available Tools

The MCP server exposes the following tools to Cursor:

For detailed information about each tool, see the API Reference.

Development

Building the project

npm run build

Running tests

npm test

Linting

npm run lint

Formatting

npm run format

Architecture

The project follows a clean architecture approach with distinct layers:

  1. Domain Layer: Core entities and business logic
  2. Infrastructure Layer: GitHub API integration
  3. Service Layer: Business logic coordination
  4. MCP Layer: Tool definitions and request handling

For more details, see ARCHITECTURE.md.

License

MIT