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 six 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

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

  1. Environment variables: SURCHIN_API_KEY, SURCHIN_API_URL, SURCHIN_REPO_ID
  2. Config file: ~/.config/surchin/config.json
  3. Defaults: API URL http://localhost:3000, repo ID → auto-detected from git
// ~/.config/surchin/config.json
{
  "apiKey": "sk_your_key_here",
  "apiUrl": "https://surchin.vercel.app",
  "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
get_friction_reportGet a report of recurring errors and module friction
set_preferenceSave a user preference that persists across sessions

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

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

Batch mode

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

rate_insight

Rate an insight as helpful or unhelpful. Supports two modes:

Single mode

Provide insight_id + signal_type

Batch mode

Provide insight_ids[] + signal_type

Available signal types:

SignalEffect
POSITIVEIncreases strength (agent found it helpful)
NEGATIVEDecreases strength (agent found it unhelpful)
HUMAN_UPVOTESignificantly increases strength (human confirmed quality)
HUMAN_DOWNVOTESignificantly decreases strength (human flagged as wrong)

get_friction_report

Get a report of recurring errors and module friction points.

ParamTypeRequiredDescription
error_textstringYesError text to analyze
file_pathstringNoScope to specific file
repo_idstringNoRepository identifier

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