Skip to main content

MCP Server

The Surchin MCP server gives any AI coding agent access to your team's shared knowledge substrate. It works the same way in every editor — stdio transport, one npm package, no extra config.

Automatic Install

The fastest way to get started. Run this in your project root:

npx @surchin/surchin init

This authenticates via your browser, then auto-detects your installed editors and configures each one:

EditorWhat it writes
Claude Code.mcp.json + .claude/settings.json + hooks + CLAUDE.md
Cursor.cursor/mcp.json
ChatGPT Codex.codex/config.toml
Windsurf.windsurf/mcp.json

Options

--scope userInstall globally for all projects (writes to ~/.claude.json + ~/.claude/settings.json)
--agents claude,cursorOnly configure specific editors (comma-separated)
--api-url <url>Self-hosted Surchin instance
--remoteConfigure the hosted stateless MCP endpoint and let the MCP client complete OAuth; no access token is written locally
--token <key>Non-interactive auth (CI, headless environments)

Remote MCP with OAuth

For MCP clients that support HTTP transport and OAuth discovery, use the hosted stateless endpoint instead of a local stdio bridge:

npx @surchin/surchin init --remote

This writes only the MCP URL, typically https://getsurch.in/api/mcp. Access and refresh tokens are not stored in project files or in the Surchin CLI config; your MCP client follows Surchin's OAuth metadata and manages authentication like Linear or Supabase MCP integrations.

{
  "mcpServers": {
    "surchin": {
      "url": "https://getsurch.in/api/mcp"
    }
  }
}

URL API key compatibility

Some Streamable HTTP MCP clients only accept a single server URL and cannot send OAuth credentials or custom headers. For those clients, admins can create an MCP API key in Settings → API Keys and use it in the endpoint URL:

https://getsurch.in/api/mcp?api_key=surchin_mcp_YOUR_KEY

Treat URL keys as compatibility mode. They can appear in local MCP config files, logs, screenshots, and support bundles. Prefer OAuth when your client supports it, set expirations, and revoke unused keys.

Manual Install

For editors that init doesn't auto-detect, or when you prefer to configure things yourself. Every MCP client needs the same three values:

Universal MCP Config

Transportstdio
Commandnpx -y @surchin/surchin@latest
Env varsNone required

Some editors split this into separate “Command” and “Arguments” fields. If yours does, enter npx as the command and -y @surchin/surchin@latest as the arguments.

Authentication is automatic. The first time you use any Surchin tool, the server opens your browser to sign in. Credentials are saved to ~/.config/surchin/config.json and refreshed automatically. No tokens to copy, no env vars to set.

Per-Editor Instructions

The command is always the same — only where you enter it changes.

Claude Code

Add to .mcp.json in your project root:

{
  "mcpServers": {
    "surchin": {
      "command": "npx",
      "args": ["-y", "@surchin/surchin@latest"]
    }
  }
}

Full Claude Code guide — hooks, permissions, CLAUDE.md managed block

ChatGPT Codex

MCP server panel → Add server. Fill in the form:

Server namesurchin
Transportstdio(not Streamable HTTP)
Commandnpx -y @surchin/surchin@latest
Env varsLeave empty

Or add to .codex/config.toml:

[mcp_servers.surchin]
command = "npx"
args = ["-y", "@surchin/surchin@latest"]

Full Codex guide

Cursor

Settings → MCP → Add new MCP server. Select stdio, enter npx -y @surchin/surchin@latest as the command. Or add to .cursor/mcp.json:

{
  "mcpServers": {
    "surchin": {
      "command": "npx",
      "args": ["-y", "@surchin/surchin@latest"]
    }
  }
}

Full Cursor guide

Windsurf

Cascade → MCP icon → Configure → Add Server. Or add to .windsurf/mcp.json:

{
  "mcpServers": {
    "surchin": {
      "command": "npx",
      "args": ["-y", "@surchin/surchin@latest"]
    }
  }
}

Full Windsurf guide

Cline

Cline sidebar → MCP Servers → Configure. Or add to VS Code settings (JSON) under cline.mcpServers:

{
  "cline.mcpServers": {
    "surchin": {
      "command": "npx",
      "args": ["-y", "@surchin/surchin@latest"]
    }
  }
}

Full Cline guide

Claude Desktop

Settings → Developer → Edit Config. Add to claude_desktop_config.json:

{
  "mcpServers": {
    "surchin": {
      "command": "npx",
      "args": ["-y", "@surchin/surchin@latest"]
    }
  }
}

Any other MCP client

If your editor has an “Add MCP Server” form, fill in the values from the reference card above. If it takes a JSON config file, paste:

{
  "mcpServers": {
    "surchin": {
      "command": "npx",
      "args": ["-y", "@surchin/surchin@latest"]
    }
  }
}

Configuration

Run surchin init to authenticate via your browser. Session tokens are saved to ~/.config/surchin/config.json and refreshed automatically.

Configuration is loaded from the following sources, highest priority first:

  1. Environment variables: SURCHIN_ACCESS_TOKEN, SURCHIN_REFRESH_TOKEN, SURCHIN_TOKEN, SURCHIN_API_URL, SURCHIN_REPO_ID
  2. Config file: ~/.config/surchin/config.json
  3. Defaults: API URL https://getsurch.in, repo ID → auto-detected from git
// ~/.config/surchin/config.json
// Managed by `surchin init` — do not edit manually
{
  "apiUrl": "https://getsurch.in",
  "repoId": "owner/repo",
  "accessToken": "<jwt_access_token>",
  "refreshToken": "<jwt_refresh_token>"
}

Repo ID Auto-Detection

When no explicit repo ID is configured, the MCP server detects it automatically using this priority:

  1. SURCHIN_REPO_ID environment variable
  2. git remote get-url origin → extracts owner/repo
  3. git rev-parse --show-toplevel → uses directory name
  4. Empty string fallback

Available Tools

ToolDescription
query_insightsSearch the knowledge substrate and load user preferences in one call
deposit_insightDeposit a knowledge artifact (solution, pattern, pitfall, etc.)
rate_insightRate an insight as helpful or unhelpful
set_preferenceSave a user preference that persists across sessions
end_sessionEnd the current session with an optional summary and handoff note for the next agent
get_session_historyGet recent session history with summaries and handoff notes
get_skillRetrieve a skill's full instructions by ID or name
create_skillCreate or update a skill with triggers (tags, files, errors)
list_groupsList all groups accessible to the current user
reconnectRe-authenticate when credentials expire (reloads config or opens browser)

query_insights

Search the knowledge substrate for relevant solutions, patterns, and pitfalls. Also returns the user's saved preferences automatically, so there's no need for a separate preferences call.

ParamTypeRequiredDescription
querystringYesNatural-language search query
file_contextstring[]NoFile paths for locality-boosted results
error_signaturestringNoError message text for signature matching
tag_contextstring[]NoTags to filter results by
symbol_contextstring[]NoSymbol names for locality-boosted results
repo_idstringNoRepository identifier
kindsInsightKind[]NoFilter results to specific insight kinds (SOLUTION, PATTERN, PITFALL, CONTEXT, WORKFLOW, DEPENDENCY)
limitintegerNoMaximum number of results to return (1–10, default 5)
depthnumberNoRetrieval depth: 0 = topic summaries only, 1 = top insight per cluster, 2 = full results (default)
cluster_idstringNoFilter results to a specific topic cluster (use with depth=2 to drill into a cluster)
expand_contextbooleanNoWhen true (default) and a local code index exists, automatically expands file_context using the import/call graph to surface insights from related code. Set to false for pure semantic search.
groupsstring[]NoFilter results to specific groups by ID. Omit to search all accessible groups.

deposit_insight

Deposit a knowledge artifact. Supports two modes:

Single mode

Provide content + kind as required parameters, plus optional fields.

ParamTypeRequiredDescription
contentstringYesFull text of the knowledge
kindstringYesSOLUTION, PATTERN, PITFALL, CONTEXT, WORKFLOW, DEPENDENCY
summarystringNoOne-line summary (auto-generated if omitted)
file_patternsstring[]NoFile path patterns to anchor to
symbol_namesstring[]NoSymbol names to anchor to
tagsstring[]NoCategorization tags
error_signaturestringNoError message for fingerprinting
repo_idstringNoRepository identifier
group_idstringNoGroup ID (UUID) to scope the deposit to a specific group. Omit for org-wide deposit.

Batch mode

Provide a deposits array where each item has content + kind plus any optional fields.

rate_insight

Rate one or more insights as helpful or unhelpful. Positive signals strengthen them; negative signals weaken them. Supports two modes:

Single mode

Provide insight_id + rating

Batch mode

Provide insight_ids[] + rating

ParamTypeRequiredDescription
insight_idstringNoID of a single insight to rate
insight_idsstring[]NoIDs of multiple insights to rate. Provide this OR insight_id, not both.
ratingstringYes"helpful" or "unhelpful"
skill_idstringNoID of a skill to provide feedback on
skill_feedbackstringNo"followed" or "dismissed" — feedback on whether the skill's instructions were used

set_preference

Save a persistent preference that carries across sessions. Agents should call this proactively when they detect a preference signal — explicit statements (“I prefer...”), corrections, tool choices, or communication style preferences.

ParamTypeRequiredDescription
categorystringYesOne of approach, communication, values, domain, general
keystringYesPreference name (e.g., complexity_tolerance, verbosity)
valueanyYesThe preference value (string, boolean, object, etc.)
scopestringNopersonal (default) or team

Best Practices

  • Query before starting any task — query_insights returns both knowledge and user preferences in one call
  • Query again with specific context after diagnosis — this second query is the most important
  • Deposit after every non-trivial task — implementations, bug fixes, patterns, architectural decisions. When in doubt, deposit
  • Always include file_context for better locality matching
  • Use batch deposit/rate for multiple items at session end
  • Watch for preference signals during the session and call set_preference immediately when detected — then tell the user what you remembered
  • Users can review and delete preferences from their dashboard at Settings → Preferences