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 initThis authenticates via your browser, then auto-detects your installed editors and configures each one:
| Editor | What 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 user | Install globally for all projects (writes to ~/.claude.json + ~/.claude/settings.json) |
--agents claude,cursor | Only configure specific editors (comma-separated) |
--api-url <url> | Self-hosted Surchin instance |
--remote | Configure 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 --remoteThis 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_KEYTreat 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
stdionpx -y @surchin/surchin@latestSome 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 name | surchin |
| Transport | stdio(not Streamable HTTP) |
| Command | npx -y @surchin/surchin@latest |
| Env vars | Leave empty |
Or add to .codex/config.toml:
[mcp_servers.surchin]
command = "npx"
args = ["-y", "@surchin/surchin@latest"]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"]
}
}
}Windsurf
Cascade → MCP icon → Configure → Add Server. Or add to .windsurf/mcp.json:
{
"mcpServers": {
"surchin": {
"command": "npx",
"args": ["-y", "@surchin/surchin@latest"]
}
}
}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"]
}
}
}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:
- Environment variables:
SURCHIN_ACCESS_TOKEN,SURCHIN_REFRESH_TOKEN,SURCHIN_TOKEN,SURCHIN_API_URL,SURCHIN_REPO_ID - Config file:
~/.config/surchin/config.json - 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:
SURCHIN_REPO_IDenvironment variablegit remote get-url origin→ extractsowner/repogit rev-parse --show-toplevel→ uses directory name- Empty string fallback
Available Tools
| Tool | Description |
|---|---|
query_insights | Search the knowledge substrate and load user preferences in one call |
deposit_insight | Deposit a knowledge artifact (solution, pattern, pitfall, etc.) |
rate_insight | Rate an insight as helpful or unhelpful |
set_preference | Save a user preference that persists across sessions |
end_session | End the current session with an optional summary and handoff note for the next agent |
get_session_history | Get recent session history with summaries and handoff notes |
get_skill | Retrieve a skill's full instructions by ID or name |
create_skill | Create or update a skill with triggers (tags, files, errors) |
list_groups | List all groups accessible to the current user |
reconnect | Re-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.
| Param | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Natural-language search query |
file_context | string[] | No | File paths for locality-boosted results |
error_signature | string | No | Error message text for signature matching |
tag_context | string[] | No | Tags to filter results by |
symbol_context | string[] | No | Symbol names for locality-boosted results |
repo_id | string | No | Repository identifier |
kinds | InsightKind[] | No | Filter results to specific insight kinds (SOLUTION, PATTERN, PITFALL, CONTEXT, WORKFLOW, DEPENDENCY) |
limit | integer | No | Maximum number of results to return (1–10, default 5) |
depth | number | No | Retrieval depth: 0 = topic summaries only, 1 = top insight per cluster, 2 = full results (default) |
cluster_id | string | No | Filter results to a specific topic cluster (use with depth=2 to drill into a cluster) |
expand_context | boolean | No | When 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. |
groups | string[] | No | Filter 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.
| Param | Type | Required | Description |
|---|---|---|---|
content | string | Yes | Full text of the knowledge |
kind | string | Yes | SOLUTION, PATTERN, PITFALL, CONTEXT, WORKFLOW, DEPENDENCY |
summary | string | No | One-line summary (auto-generated if omitted) |
file_patterns | string[] | No | File path patterns to anchor to |
symbol_names | string[] | No | Symbol names to anchor to |
tags | string[] | No | Categorization tags |
error_signature | string | No | Error message for fingerprinting |
repo_id | string | No | Repository identifier |
group_id | string | No | Group 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
| Param | Type | Required | Description |
|---|---|---|---|
insight_id | string | No | ID of a single insight to rate |
insight_ids | string[] | No | IDs of multiple insights to rate. Provide this OR insight_id, not both. |
rating | string | Yes | "helpful" or "unhelpful" |
skill_id | string | No | ID of a skill to provide feedback on |
skill_feedback | string | No | "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.
| Param | Type | Required | Description |
|---|---|---|---|
category | string | Yes | One of approach, communication, values, domain, general |
key | string | Yes | Preference name (e.g., complexity_tolerance, verbosity) |
value | any | Yes | The preference value (string, boolean, object, etc.) |
scope | string | No | personal (default) or team |
Best Practices
- Query before starting any task —
query_insightsreturns 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_contextfor better locality matching - Use batch deposit/rate for multiple items at session end
- Watch for preference signals during the session and call
set_preferenceimmediately when detected — then tell the user what you remembered - Users can review and delete preferences from their dashboard at Settings → Preferences