Home / Docs / MCP server

MCP server for exact and regex search

Give your agent the API as tools. StackGrep's MCP server works with Claude, Claude Code, Cursor, Codex and any client that speaks remote MCP.

The server

The MCP server is at https://stackgrep.com/mcp (Streamable HTTP, protocol 2025-06-18; 2025-03-26 and 2024-11-05 clients work too). It signs in two ways: an API key in the Authorization header, or OAuth, where you approve the client in your browser. Every tool only reads, so clients can call them without asking you each time, and each one says what it costs in its description.

Claude Code

Shell
claude mcp add --transport http stackgrep https://stackgrep.com/mcp \
  --header "Authorization: Bearer $STACKGREP_KEY"

Claude.ai and Claude Desktop

Add a custom connector with the URL https://stackgrep.com/mcp. Claude opens a StackGrep page where you sign in and approve it; there's no key to paste. Other clients that support OAuth for remote MCP servers connect the same way (we support dynamic client registration and client metadata documents).

Cursor

~/.cursor/mcp.json
{
  "mcpServers": {
    "stackgrep": {
      "url": "https://stackgrep.com/mcp",
      "headers": { "Authorization": "Bearer gw_..." }
    }
  }
}

Codex

~/.codex/config.toml
[mcp_servers.stackgrep]
url = "https://stackgrep.com/mcp"
bearer_token_env_var = "STACKGREP_KEY"

Tools

ToolWhat it doesCredits
list_collectionsYour collections, with what was written to each.0
search_collectionExact text or regex in one collection: collection, query, regex, filter, limit.1
count_collectionCount every matching document, with a sample of ids: collection, query, regex, filter.5
get_documentRead one document whole: collection, id.1
search_sourceWebsites whose HTML contains some text or matches a pattern, one per site: query, regex, limit, cursor, order.1
count_sitesHow many pages and sites match: query, regex.5
filter_sitesSites by technology stack: filter, limit.5
fetch_pageOne live page as Markdown: url, all, max_age, max_chars.1

Tool results are the same JSON as the REST answers (search, count, web search, fetch). A failed call comes back with isError: true and the error message as its text, so the agent can read why and try again.

Calling it by hand

Shell
curl https://stackgrep.com/mcp -H "Authorization: Bearer $STACKGREP_KEY" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call",
       "params": {"name": "search_collection",
                  "arguments": {"collection": "contracts", "query": "net 30", "filter": "customer:acme"}}}'

The server also gives agents short instructions when they connect: use plain text unless a pattern is needed, count for "how many" questions, and read a whole document with get_document.

Try it on your own documentsExact and regex search for your agents, from one API. Or see the engine on npm's source first.