Kontxt MCP Server logo

Kontxt MCP Server

Community
ReyNeill

Codebase indexing MCP server

PublisherReyNeill
RepositoryKontxt
LanguagePython
Forks
3
Stars
10
Available tools
0
Transport typestdio, streamable-http
Categories
Links
  • Connect tools to AI workflows

    Kontxt MCP Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    10 stars and 3 forks from the linked repository.

Verified on MseeP

Marketplace badges

MseeP.ai Security Assessment Badge

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:
    bash
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Dependencies:
    bash
    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.

Running as a Standalone Server (Recommended)

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:

bash
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:

bash
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:

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

PS: remember to always refresh the MCP server on Cursor Settings or other client to connect to the MCP via sse

Alternative: Running with stdio Transport

If you prefer to have the client start and manage the server process:

bash
python kontxt_server.py --repo-path /path/to/your/codebase --transport stdio

For this mode, configure your ~/.cursor/mcp.json file like this:

json
{
  "mcpServers": {
    "kontxt-server": {
      "serverType": "stdio",
      "command": "python",
      "args": ["/absolute/path/to/kontxt_server.py", "--repo-path", "/absolute/path/to/your/codebase", "--transport", "stdio"],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Command Line Arguments

  • --repo-path PATH: Required. Absolute path to the local code repository to analyze.
  • --gemini-api-key KEY: Google Gemini API Key (overrides .env if provided).
  • --token-threshold NUM: Target maximum token count for the context. Allowed values are:
    • 500000
    • 800000 (default)
    • 1000000
  • --gemini-model NAME: Specific Gemini model to use (default: models/gemini-2.5-flash-preview-04-17).
  • --tokenizer-model NAME: Hugging Face tokenizer id for token estimation (default: google/gemma-7b; override via KONTXT_TOKENIZER_MODEL).
  • --transport {stdio,sse}: Transport protocol to use (default: sse).
  • --host HOST: Host address for the SSE server (default: 127.0.0.1).
  • --port PORT: Port for the SSE server (default: 8080).
  • --cors-origins ORIGINS: Comma-separated list of allowed CORS origins. If omitted, defaults to loopback only.
  • --cors-credentials: Allow credentials for CORS (disabled by default).

CORS Configuration

For security, wildcard CORS is not used. By default, only loopback origins are allowed:

  • http://127.0.0.1, http://localhost, and the bound host:port.

To allow specific web clients during development, pass explicit origins or use an env var:

bash
python kontxt_server.py \
  --repo-path /path/to/your/codebase \
  --cors-origins http://localhost:3000,http://127.0.0.1:5173

# or via environment variable
KONTXT_CORS_ORIGINS="http://localhost:3000,http://127.0.0.1:5173" \
python kontxt_server.py --repo-path /path/to/your/codebase

Notes:

  • Allowed methods: GET, OPTIONS. Headers: all. Credentials: off unless --cors-credentials is set.

Tokenizer (Gemma) Access & Auto-Recovery

This server uses the google/gemma-7b tokenizer to estimate tokens. The model is gated by Google on Hugging Face.

What happens if you don't have access yet:

  • On startup, if the tokenizer cannot be downloaded, the server logs a clear message and auto-opens: https://huggingface.co/google/gemma-7b
  • The server keeps running using a heuristic token estimator (does not crash).
  • It periodically retries loading the tokenizer; once you gain access, it switches automatically (no restart needed).

How to gain access (free, ~2 minutes):

  1. Visit https://huggingface.co/google/gemma-7b and log in (create an account if needed).
  2. Accept Google’s terms on the model page.
  3. If running headless/CI or a container, authenticate the environment: huggingface-cli login (or set HF_TOKEN).

Configuration:

  • --tokenizer-model or KONTXT_TOKENIZER_MODEL: use a different HF tokenizer id if desired.
  • KONTXT_TOKENIZER_RELOAD_INTERVAL (seconds, default 60): how often the server re-attempts tokenizer loading.

Basic Usage

Example queries:

  • "What's this codebase about"
  • "How does the authentication system work?"
  • "Explain the data flow in the application"

PS: you can further specify the agent to use the MCP tool if it's not using it: "What is the last word of the third codeblock of the auth file? Use the MCP tool available."

Context Attachment

Your referenced files/context in your queries are included as context for analysis:

  • "Explain how this file works: @kontxt_server.py"
  • "Find all files that interact with @user_model.py"
  • "Compare the implementation of @file1.js and @file2.js"

The server will mention these files to Gemini but will NOT automatically read or include their contents. Instead, Gemini will decide which files to read using its tools based on the query context.

This approach allows Gemini to only read files that are actually needed and prevents the context from being bloated with irrelevant file content.

Token Usage Tracking

The server tracks token usage across different operations:

  • Repository structure listing
  • File reading
  • Grep searches
  • Attached files from user queries
  • Generated responses

This information is logged during operation, helping you monitor API usage and optimize your queries.

PD: want the tool to improve? PR's are open.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "reyneill-kontxt": {
      "command": "",
      "args": []
    }
  }
}

Use Kontxt MCP Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Kontxt MCP Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Kontxt MCP Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Kontxt MCP Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "reyneill-kontxt": {
      "command": "npx",
      "args": [
        "-y",
        "Kontxt"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Kontxt MCP Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Kontxt MCP Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Kontxt MCP Server to help me with this task?
Kontxt MCP Server
Sure. I read it.
Here is what I found using Kontxt MCP Server.

Option 2: Add an MCP server URL

Use this when Kontxt MCP Server is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter your server URL in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste your server URL into the Server URL field.
  2. Enter a connection name for Kontxt MCP Server.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the Kontxt MCP Server connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the Kontxt MCP Server tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the Kontxt MCP Server tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Kontxt MCP Server to help me with this task?
Kontxt MCP Server
Sure. I read it.
Here is what I found using Kontxt MCP Server.

Frequently asked questions

What is the Kontxt MCP Server MCP server used for?

Kontxt MCP Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Kontxt MCP Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Kontxt MCP Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Kontxt MCP Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Kontxt MCP Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Kontxt MCP Server MCP to TypingMind?

Kontxt MCP Server can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does Kontxt MCP Server MCP provide in TypingMind?

Kontxt MCP Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Kontxt MCP Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Kontxt MCP Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇