Skip to main content

MCP Server

The Surchin MCP server integrates directly with Claude Code, giving your AI agent access to the shared knowledge substrate via ten tools.

Installation

npx @surchin/surchin init

This adds Surchin to your Claude Code MCP configuration and creates a config file at ~/.config/surchin/config.json.

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_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"
}

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