RK

reyneill/kontxt

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

10 stars 3 forks 质量 58 趋势 18

Codebase indexing MCP server

概览

A Model Context Protocol (MCP) server that tries to solve condebase indexing (until agents can). - Connects to a user-specified local code repository. - Provides the (get_codebase_context) tool for AI clients (like Cursor, Claude Desktop). - Uses Gemini 2.0 Flash's 1M input window internally to analyze the codebase and generate context based on the user's client querry. - Flash itself can use internal tools (list_repository_structure, read_files, grep_codebase) to understand the code. - Supports both SSE (recommended) and stdio transport protocols. - Supports user-attached files/docs/context from client's queries for more targeted analysis. - Tracks token usage and provides detailed analysis of API consumption. - User-configurable token limit for context generation (options: 500k, 800k, or 1M tokens; default: 800k). 1. Get the server code. 2. 3. 4. Ensure the tree command is available on your system.

README

以下为原文 README 节选,完整内容请查看原文。

Marketplace badges

Kontxt MCP Server

A Model Context Protocol (MCP) server that tries to solve condebase indexing (until agents can).

Features

  • Connects to a user-specified local code repository.
  • Provides the (get_codebase_context) tool for AI clients (like Cursor, Claude Desktop).
  • Uses Gemini 2.0 Flash’s 1M input window internally to analyze the codebase and generate context based on the user’s client querry.
  • Flash itself can use internal tools (list_repository_structure, read_files, grep_codebase) to understand the code.
  • Supports both SSE (recommended) and stdio transport protocols.
  • Supports user-attached files/docs/context from client’s queries for more targeted analysis.
  • Tracks token usage and provides detailed analysis of API consumption.
  • User-configurable token limit for context generation (options: 500k, 800k, or 1M tokens; default: 800k).

Setup

  1. Clone/Download: Get the server code.
  2. Create Environment:
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install Dependencies:
    pip install -r requirements.txt
    
  4. Install tree: Ensure the tree command is available on your system.
    • macOS: brew install tree
    • Debian/Ubuntu: sudo apt update && sudo apt install tree
    • Windows: Requires installing a port or using WSL.
  5. Configure API Key:
    • Copy .env.example to .env.
    • Edit .env and add your Google Gemini API Key:
      GEMINI_API_KEY="YOUR_ACTUAL_API_KEY"
      
    • Alternatively, you can provide the key via the --gemini-api-key command-line argument.

By default, the server runs in SSE mode, which allows you to:

  • Start the server independently
  • Connect from multiple clients
  • Keep it running while restarting clients

Run the server:

python kontxt_server.py --repo-path /path/to/your/codebase

PS: you can use pwd to list the project path

The server will start on http://127.0.0.1:8080/sse by default.

For additional options:

python kontxt_server.py --repo-path /path/to/your/codebase --host 0.0.0.0 --port 6900

Shutting Down the Server

The server can be stopped by pressing Ctrl+C in the terminal where it’s running. The server will attempt to close gracefully with a 3-second timeout.

Connecting to the Server from client (Cursor example)

Once your server is running, you can connect Cursor to it by editing your ~/.cursor/mcp.json file:

{
  "mcpServers": {
    "kontxt-server": {
      "serverType": "sse",
      "url": "http://localhost:8080/sse"
    }
  }
}
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "kontxt-server": { "serverType": "sse", "url": "http://localhost:8080/sse" } } }