code-failures-mcp

code-failures-mcp

MCP server that indexes a knowledge base of past bugs and fixes, making them searchable via BM25 from Claude Code or any MCP client.

Category
访问服务器

README

code-failures-mcp

MCP server that indexes your code_failures/ knowledge base and makes it searchable from Claude Code (or any MCP client). Uses BM25 via MiniSearch for fast, relevant keyword search with fuzzy matching.

Why

Every bug you debug for hours becomes institutional knowledge. This MCP server makes that knowledge automatically available to Claude Code so it searches your past fixes before attempting a new solution.

Tools

Tool Purpose
search_past_bugs Search bugs by symptom, error message, or library name
search_references Search canonical working patterns and version guides
search_all_knowledge Search everything with relevance scores
get_document Retrieve full content of a specific document
list_documents List all indexed documents

Setup

cd /Users/tk/Desktop/code-failures-mcp
npm install
npm run build

Configure Claude Code

CLI + Manual Config (recommended)

The claude mcp add CLI doesn't support environment variables via flags, so you need to add the server first, then manually edit the config:

# Step 1: Add the server (global)
claude mcp add code-failures -- node /Users/tk/Desktop/code-failures-mcp/dist/index.js

# Step 2: Edit ~/.claude.json and add the env object to the code-failures server config:
# "env": {
#   "BRAIN_PATH": "/Users/tk/Desktop/brain/code_failures"
# }

# For project-scoped:
claude mcp add -s project code-failures -- node /Users/tk/Desktop/code-failures-mcp/dist/index.js
# Then edit the project's section in ~/.claude.json

Verify with:

claude mcp list

JSON config (alternative)

Manually add to ~/.claude.json (find your project section):

{
  "projects": {
    "/your/project/path": {
      "mcpServers": {
        "code-failures": {
          "type": "stdio",
          "command": "node",
          "args": ["/Users/tk/Desktop/code-failures-mcp/dist/index.js"],
          "env": {
            "BRAIN_PATH": "/Users/tk/Desktop/brain/code_failures"
          }
        }
      }
    }
  }
}

Or for Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "code-failures": {
      "command": "node",
      "args": ["/Users/tk/Desktop/code-failures-mcp/dist/index.js"],
      "env": {
        "BRAIN_PATH": "/Users/tk/Desktop/brain/code_failures"
      }
    }
  }
}

CLAUDE.md Integration

Add this to your project's CLAUDE.md to make Claude Code automatically use the knowledge base:

# Global Preferences

- Implement only what's explicitly requested. Prefer minimal changes. No unnecessary features, files, or abstractions.
- Check all related functionality before modifying code — update or verify dependents.
- Before writing a script, check what tools are available via MCP or plugins. Prefer existing tools over bash scripts.
- Always use Context7 MCP (resolve-library-id → get-library-docs) before writing code involving external libraries or frameworks.
- ALWAYS call `search_past_bugs` before debugging any error. Call `search_references` before writing integration code. These check your verified fixes first — prioritize over Context7 and web search.
- After solving a bug that took >15 min: draft Symptom/Root Cause/Fix/Prevention, show me for review, then call `file_bug` to save it.

## Git Workflow

- Commit after each logical unit of work with conventional commit messages (feat:, fix:, refactor:, chore:).
- Do not push unless explicitly asked.
- Work on feature branches, never commit directly to main.

## Self-Improving Project CLAUDE.md

When I correct you on something that represents a recurring pattern or architectural decision (not a one-off typo), propose an update to the project's CLAUDE.md. Follow these rules:

**Before writing, check the existing file.** If a similar rule exists, replace or refine it — never duplicate. If the file exceeds 80 lines, identify a lower-value rule to remove before adding.

**How to write rules:**
1. Use absolute directives — start with NEVER or ALWAYS when appropriate
2. Lead with why (1 sentence max), then the concrete rule
3. Include actual commands or file:line references, not abstract descriptions
4. One code example max per rule. No example if the rule is obvious
5. Bullets over paragraphs. No "Warning Signs" sections for trivial rules

**When to update:** Only for corrections that would apply to future sessions — patterns, conventions, architectural decisions, recurring tool preferences. Not for one-off fixes, typos, or task-specific context.

**Two-tier structure:** If the project CLAUDE.md has a summary section at the top, add a one-line summary there and the detailed rule in the appropriate section below.

If the correction is about a library bug or integration pattern (not project-specific), use `file_bug` or `file_reference` instead of updating CLAUDE.md.

After proposing the update, wait for my approval before writing to the file.

Test with MCP Inspector

npm run inspect

This opens the MCP Inspector UI where you can test each tool interactively.

How Indexing Works

On startup, the server:

  1. Recursively finds all .md files under BRAIN_PATH
  2. Parses YAML frontmatter for metadata (type, library, tags, severity, status)
  3. Extracts structured sections (Symptom, Root Cause, Fix, Prevention) from bug files
  4. Builds a BM25 index with field boosting:
    • symptom × 3.0 (highest — you search by what you see)
    • title × 2.5
    • library × 2.0
    • rootCause × 1.5
    • tags × 1.5
    • fix × 1.0
    • fullText × 1.0 (fallback for anything else)
  5. Enables fuzzy matching (0.2 edit distance) and prefix search
  6. Watches the directory for changes and auto-rebuilds

Adding New Bugs

Follow the format in your existing knowledge base:

# Create a new bug file
touch /Users/tk/Desktop/brain/code_failures/bugs/<library>-<short-description>.md

Template:

---
type: bug
library: <library name>
versions_affected: "<version range>"
status: confirmed
severity: critical|high|medium|low
tags:
  - tag1
  - tag2
---

# BUG: Short Description

## Symptom
What you see (error messages, behavior)

## Root Cause
Why it happens

## Fix
Working code

## Prevention
How to avoid it

The index auto-rebuilds when files change.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选