Fast Context MCP

repository·main·Indexed 43 days ago

https://github.com/sammysnake-d/fast-context-mcp

An AI-driven semantic code search tool implemented as an MCP server. It uses a reverse-engineered Windsurf SWE-grep protocol to enable AI clients like Claude or Cursor to perform natural-language searches across local codebases using bundled tools like ripgrep and tree. Version 1.3.2.

Tokens
6.5K
Snippets
24
Records
30
Agent score
56%

What's inside Fast Context MCP

  1. Install Fast Context MCP via npm

    main

    You can install the latest stable release or the beta/next release using npm. This project has no system-level dependencies as ripgrep and tree are bundled.

    Latest stable release:

    npm install @sammysnake/fast-context-mcp

    Beta/next release:

    npm install @sammysnake/fast-context-mcp@next
  2. Configure Fast Context MCP for Claude Desktop

    main

    Add the server configuration to your claude_desktop_config.json file under the mcpServers key. You must provide your WINDSURF_API_KEY in the env object.

    Stable release configuration:

    {
      "fast-context": {
        "command": "npx",
        "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp"],
        "env": {
          "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
        }
      }
    }

    Beta/next release configuration:

    {
      "fast-context": {
        "command": "npx",
        "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp@next"],
        "env": {
          "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
        }
      }
    }
  3. Configure Fast Context MCP for Claude Code

    main

    Add the server configuration to your ~/.claude.json file under the mcpServers key. You must provide your WINDSURF_API_KEY in the env object.

    Stable release configuration:

    {
      "fast-context": {
        "command": "npx",
        "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp"],
        "env": {
          "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
        }
      }
    }

    Beta/next release configuration:

    {
      "fast-context": {
        "command": "npx",
        "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp@next"],
        "env": {
          "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
        }
      }
    }
  4. Use the `fast_context_search` tool

    main

    Performs AI-driven semantic code search. It maps your project, generates a directory tree, and uses the Windsurf Devstral model to execute local commands (like rg) to find relevant code.

    Parameters:

    • query (string, Required): Natural language search query.
    • project_path (string, Optional): Absolute path to project root. Defaults to cwd.
    • tree_depth (integer, Optional): Directory tree depth for repo map (1-6). Default is 3. Use 1-2 for huge monorepos, 3 for most projects, 4-6 for small projects. Automatically falls back to a lower depth if the tree exceeds 250KB.
    • max_turns (integer, Optional): Search rounds (1-5). Default is 3. Use 1-2 for simple lookups, 3 for most queries, 4-5 for complex analysis.
    • max_results (integer, Optional): Maximum number of files to return (1-30). Default is 10.
    • exclude_paths (string[], Optional): Directory/file patterns excluded from the repository map and search context. Defaults to [].

    Returns:

    1. Relevant files with line ranges.
    2. Suggested search keywords (the rg patterns used).
    3. Diagnostic metadata (e.g., [config] line showing actual tree_depth used and tree size).
  5. Use the `extract_windsurf_key` tool

    main

    Attempts to extract the Windsurf API Key from your local installation (Devin, Deviv, or Windsurf) by reading local SQLite databases. This tool takes no parameters.

    Note: You can hide this tool from the MCP tool list by setting the environment variable FC_HIDE_EXTRACT_WINDSURF_KEY_TOOL=1 at startup.

  6. Configure Fast Context MCP via environment variables

    main

    The server behavior can be tuned using the following environment variables:

    VariableDescriptionDefault
    WINDSURF_API_KEYWindsurf API key (auto-discovered if not set)N/A
    FC_MAX_TURNSSearch rounds per query (clamped 1-5)3
    FC_MAX_COMMANDSMax parallel commands per round (clamped 1-20)8
    FC_TIMEOUT_MSConnect-Timeout-Ms for streaming requests (clamped 1000-300000)30000
    FC_HIDE_EXTRACT_WINDSURF_KEY_TOOLIf true, hides the extract_windsurf_key tool from MCP clientsfalse
  7. Configure output limits via environment variables

    main

    You can control the truncation behavior of the ToolExecutor output by setting the following environment variables. This is useful if you need to increase the amount of context returned to an AI agent.

    VariableDefaultRangeDescription
    FC_RESULT_MAX_LINES501 to 500Maximum number of lines returned in a result.
    FC_LINE_MAX_CHARS25020 to 10000Maximum characters per line before silent truncation.
  8. Reference: Fast Context MCP Environment Variables

    main

    Use these environment variables to tune the behavior of the MCP server.

    VariableDefaultDescription
    WINDSURF_API_KEY(auto-discover)Windsurf API key
    FC_MAX_TURNS3Search rounds per query (more = deeper but slower)
    FC_MAX_COMMANDS8Max parallel commands per round
    FC_TIMEOUT_MS30000Connect-Timeout-Ms for streaming requests
    FC_HIDE_EXTRACT_WINDSURF_KEY_TOOLfalseHide extract_windsurf_key from MCP tools when set to 1, true, yes, or on
    FC_RESULT_MAX_LINES50Max lines per command output (truncation)
    FC_LINE_MAX_CHARS250Max characters per output line (truncation)
    FC_CACHE_DISABLED(unset)Disable the in-memory result cache with 1, true, yes, or on
    FC_CACHE_TTL_MS300000Result-cache TTL; <=0 disables caching
    FC_CACHE_MAX_ENTRIES200Maximum in-memory cache entries
    FC_ALLOW_INSECURE_TLS(unset)Set to 1 only when a trusted corporate proxy requires disabled TLS verification
    WS_MODELMODEL_SWE_1_6_FASTWindsurf model name
    WS_APP_VER1.48.2Windsurf app version (protocol metadata)
    WS_LS_VER1.9544.35Windsurf language server version (protocol metadata)
  9. Use the ToolExecutor class to run codebase commands

    main

    The ToolExecutor class is designed to execute restricted filesystem and search commands (like rg, ls, readfile, tree, and glob) within a specific project root. It is optimized to mimic Windsurf's behavior, including path remapping (converting real paths to /codebase) and output truncation to prevent overwhelming the context.

    To use it, instantiate the class with your project's absolute path. You can then either call specific methods directly or use the execCommand / execToolCall methods to dispatch commands from structured objects.

    import { ToolExecutor } from './src/executor.mjs';
    
    const executor = new ToolExecutor('/absolute/path/to/project');
    
    // Direct method call
    const files = executor.ls('/codebase', true, false);
    
    // Dispatching via command object
    const result = executor.execCommand({
      type: 'rg',
      pattern: 'TODO',
      path: '/codebase'
    });
  10. Extract Windsurf API Key information

    main

    Use extractKeyInfo() to programmatically retrieve information about the discovered Windsurf API key. This is useful for verifying if the user is correctly logged into Windsurf before starting a search.

    import { extractKeyInfo } from '@sammysnake/fast-context-mcp';
    
    try {
      const keyInfo = await extractKeyInfo();
      console.log('API Key found:', keyInfo.api_key);
    } catch (err) {
      console.error('Could not find API key:', err.message);
    }