MCP Context Bank Server

MCP Context Bank Server

Enables AI agents to fetch, search, and retrieve markdown content from remote Git repositories. Supports both public and private repositories with authentication, allowing AI assistants to access documentation and notes stored in Git.

Category
访问服务器

README

MCP Context Bank Server

A Model Context Protocol (MCP) server that provides AI agents with tools to fetch markdown context files from remote Git repositories. This server enables AI assistants like GitHub Copilot to access and search through documentation, notes, and other markdown content stored in Git repositories.

Features

  • Repository Access: Clone and access any public Git repository (supports both HTTPS and SSH URLs)
  • Markdown File Discovery: Automatically find and list all markdown files in a repository
  • File Content Retrieval: Get the content of specific markdown files
  • Content Search: Search for specific terms within markdown files across the repository
  • Branch Support: Work with any branch in the repository
  • Path Filtering: Filter files by path patterns (e.g., only files in docs/ directory)
  • Security: Built-in protection against path traversal attacks
  • Cleanup: Automatic cleanup of temporary cloned repositories

Installation

From NPM (Recommended)

npm install -g mcp-context-bank-server

From Source

git clone <this-repository>
cd mcp-context-bank-server
yarn install
yarn build

Usage

Environment Configuration

The server supports configurable repositories and authentication through environment variables:

# Set default repository (optional)
export MCP_DEFAULT_REPOSITORY="https://github.com/your-org/your-context-repo.git"

# Set access token for private repositories (optional)
export MCP_ACCESS_TOKEN="ghp_your_github_personal_access_token"

If no default repository is configured, you must provide repository_url in each tool call.

VS Code with GitHub Copilot

1. Install the MCP Server

npm install -g mcp-context-bank-server

2. Configure VS Code Settings

Add the MCP server to your VS Code settings. Open VS Code settings (JSON) and add:

{
  "github.copilot.advanced": {
    "mcp": {
      "servers": {
        "context-bank": {
          "command": "mcp-context-bank-server",
          "env": {
            "MCP_DEFAULT_REPOSITORY": "https://github.com/your-org/your-docs.git",
            "MCP_ACCESS_TOKEN": "ghp_your_token_here"
          }
        }
      }
    }
  }
}

3. Using with Copilot Chat

Once configured, you can ask GitHub Copilot to use the context from your repository:

@workspace Can you help me understand the API documentation? Please check the context repository for the latest API specs.

Copilot will automatically use the MCP server to fetch relevant markdown files from your configured repository.

VS Code with Amazon Q Developer

1. Install the MCP Server

npm install -g mcp-context-bank-server

2. Configure Amazon Q

Create or update your MCP configuration file (typically ~/.config/amazon-q/mcp-servers.json):

{
  "servers": {
    "context-bank": {
      "command": "mcp-context-bank-server",
      "env": {
        "MCP_DEFAULT_REPOSITORY": "https://github.com/your-org/your-context.git",
        "MCP_ACCESS_TOKEN": "ghp_your_github_token"
      }
    }
  }
}

3. Using with Amazon Q

Ask Amazon Q to access your context repository:

Can you search our documentation repository for information about deployment procedures?

Claude Desktop Configuration

For Claude Desktop, add to your configuration file:

{
  "mcpServers": {
    "context-bank": {
      "command": "mcp-context-bank-server",
      "env": {
        "MCP_DEFAULT_REPOSITORY": "git@github.com:your-org/context-bank.git",
        "MCP_ACCESS_TOKEN": "your_token_if_needed"
      }
    }
  }
}

Authentication for Private Repositories

GitHub Personal Access Token (PAT)

  1. Go to GitHub Settings → Developer settings → Personal access tokens
  2. Generate a new token with repo scope for private repositories
  3. Set the token as an environment variable or pass it in tool calls:

Option 1: Environment Variable (Recommended)

export MCP_ACCESS_TOKEN="ghp_your_token_here"

Option 2: Per-request Token

{
  "name": "get_markdown_files",
  "arguments": {
    "repository_url": "https://github.com/your-org/private-repo.git",
    "access_token": "ghp_your_token_here"
  }
}

SSH Keys

For SSH URLs (git@github.com:...), ensure your SSH keys are properly configured:

# Test SSH access
ssh -T git@github.com

# If needed, add your key to ssh-agent
ssh-add ~/.ssh/id_rsa

Repository Configuration Examples

Public Repository

{
  "repository_url": "https://github.com/microsoft/vscode.git",
  "branch": "main"
}

Private Repository with HTTPS + PAT

{
  "repository_url": "https://github.com/your-org/private-docs.git",
  "access_token": "ghp_your_token",
  "branch": "main"
}

Private Repository with SSH

{
  "repository_url": "git@github.com:your-org/private-docs.git",
  "branch": "develop"
}

As an MCP Server

The server communicates via stdio and provides three main tools:

  1. get_markdown_files - List all markdown files in a repository
  2. get_file_content - Get content of a specific file
  3. search_markdown_content - Search for text within markdown files

Development

# Install dependencies
yarn install

# Run in development mode
yarn dev

# Build for production
yarn build

# Start built version
yarn start

Tools Documentation

get_markdown_files

Lists all markdown files in the specified Git repository.

Parameters:

  • repository_url (optional): Git repository URL (uses default if not provided)
  • branch (optional): Git branch to fetch from (default: "main")
  • path_filter (optional): Path pattern to filter files (e.g., "docs/", "*.md")
  • access_token (optional): Personal Access Token for private repositories

Example Response:

{
  "repository": "https://github.com/your-org/context-repo.git",
  "branch": "main",
  "files": ["README.md", "docs/api.md", "docs/guide.md"],
  "total_files": 3
}

get_file_content

Retrieves the content of a specific markdown file from the repository.

Parameters:

  • repository_url (optional): Git repository URL (uses default if not provided)
  • file_path (required): Path to the file within the repository
  • branch (optional): Git branch to fetch from (default: "main")
  • access_token (optional): Personal Access Token for private repositories

Example Response:

{
  "repository": "https://github.com/your-org/context-repo.git",
  "branch": "main",
  "file_path": "docs/api.md",
  "content": "# API Documentation\n\nThis is the API documentation...",
  "size": 1234
}

search_markdown_content

Searches for specific content within markdown files in the repository.

Parameters:

  • repository_url (optional): Git repository URL (uses default if not provided)
  • search_term (required): Text to search for
  • branch (optional): Git branch to fetch from (default: "main")
  • case_sensitive (optional): Whether search should be case sensitive (default: false)
  • access_token (optional): Personal Access Token for private repositories

Example Response:

{
  "repository": "https://github.com/your-org/context-repo.git",
  "branch": "main",
  "search_term": "API",
  "case_sensitive": false,
  "results": [
    {
      "file_path": "docs/api.md",
      "matches": [
        {
          "line_number": 1,
          "line_content": "# API Documentation"
        }
      ],
      "total_matches": 1
    }
  ],
  "total_files_with_matches": 1,
  "total_matches": 1
}

Repository Requirements

The server can work with any Git repository that contains markdown files. The repository can be configured in multiple ways:

Default Repository Configuration

Set a default repository using environment variables:

export MCP_DEFAULT_REPOSITORY="https://github.com/your-org/your-context-repo.git"
export MCP_ACCESS_TOKEN="ghp_your_token_if_private"

Repository Access Methods

  • Public repositories: Work with both HTTPS and SSH URLs without authentication
  • Private repositories with HTTPS: Use Personal Access Token (PAT) authentication
  • Private repositories with SSH: Use SSH key authentication
  • Per-request repositories: Override default by providing repository_url in each tool call

Supported Repository Types

  • GitHub (public and private)
  • GitLab (public and private)
  • Bitbucket (public and private)
  • Any Git repository accessible via HTTPS or SSH

Branch Support

  • Default branch: Uses "main" by default but can work with any branch
  • Branch specification: Override default by providing branch parameter
  • Multiple branches: Each tool call can target a different branch

Authentication Methods

Personal Access Token (PAT)

For private repositories, create a PAT with appropriate permissions:

  1. GitHub: Settings → Developer settings → Personal access tokens → Generate new token

    • Required scopes: repo (for private repos) or public_repo (for public repos)
  2. GitLab: User Settings → Access Tokens → Add a personal access token

    • Required scopes: read_repository
  3. Bitbucket: Personal Bitbucket settings → App passwords → Create app password

    • Required permissions: Repositories: Read

SSH Key Authentication

For SSH URLs, ensure proper SSH key setup:

# Test SSH access to GitHub
ssh -T git@github.com

# Add SSH key to agent if needed
ssh-add ~/.ssh/id_rsa

Security Considerations

  • Path Traversal Protection: The server prevents access to files outside the repository directory
  • Temporary Files: All cloned repositories are stored in temporary directories and cleaned up automatically
  • Input Validation: All inputs are validated using Zod schemas
  • Branch Isolation: Each operation clones only the specific branch with depth 1 for efficiency

Error Handling

The server provides detailed error messages for common issues:

  • Invalid repository URLs
  • Non-existent files or branches
  • Network connectivity issues
  • Permission problems

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

For issues and questions, please use the GitHub issue tracker.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选