convez.ai
MCP ServerProdutividadeIntermediário
artpar

Past Conversations MCP

artpar/past-conversations-mcp

Indexa e busca conversas do Claude Code com extração automática de conhecimento

Ver no GitHub
InicialPluginScore · de 0 a 100

Servidor MCP que indexa e busca histórico de conversas do Claude Code, extraindo conhecimento estruturado e padrões através de análise de turnos, decisões e erros. Permite reutilizar aprendizados entre sessões com inteligência destilada.

Instalação

$npx convez-ai artpar/past-conversations-mcp

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
28%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Recuperar decisões técnicas e princípios já validados em projetos anteriores
  • Rastrear correções de erros e soluções estruturadas entre sessões
  • Agregar conhecimento de múltiplas sessões por projeto ou contexto de arquivo
  • Buscar padrões de importância em conversas pelo tipo de mensagem e outcome

Veredito

Ferramenta robusta e bem-estruturada para resgate de contexto técnico entre sessões. A análise estrutural (turnos, erros provados, decisões validadas) é superior a regex puro. Recomendado para fluxos intensivos em Claude Code com múltiplos projetos.

README

A tradução para o português deste README ainda está na fila.

past-conversations-mcp

MCP server that indexes and searches your Claude Code and Codex conversation history, providing knowledge transfer across sessions with distilled intelligence.

What it does

Indexes your Claude Code and Codex sessions and extracts structured knowledge:

  • Turn-based conversation model — Groups JSONL records into logical turns (user prompt → assistant response cycle), tracking tool results, errors, commits, and user feedback per turn. This structural context drives all downstream analysis.
  • Message scoring — Every message is scored for importance (0-1) and typed (conclusion, solution, exploration, error_report, question). Scoring uses structural signals (pre-commit position, error→fix resolution, user confirmation) as primary factors, with content patterns as tiebreakers.
  • Decision extraction — Detects generalizable principles ("don't X when Y", "chose X because Z") validated by structural gates: user confrontation before, action taken after, user confirmation, or proximity to commits. Eliminates debugging noise that contains decision-like words.
  • Error-fix detection — Structurally proven: identifies turns where tool results had errors, then finds the resolution turn where tools succeeded. No regex needed for detection — structure proves causality.
  • Session outcomes — Computes whether sessions ended successfully, partially, with errors, or were abandoned.
  • Cross-project references — Detects when one project references another (filesystem paths, "copied from X project").
  • Structural tagging — Tags sessions by what tools were used, what files were touched, and what commands were run — not by content keywords. testing requires actual test files or test runner commands, not the word "test" in text.
  • Importance ranking — Sessions scored by commits, file breadth, outcome, and cross-references.
  • NLP text analysis — Uses compromise for sentence boundary detection and wink-sentiment (AFINN-165 lexicon) for user feedback classification. Both deterministic, pure JS, no native deps.

Installation

As a global MCP server for Claude Code or Codex

Add to ~/.claude.json:

{
  "mcpServers": {
    "past-conversations": {
      "command": "npx",
      "args": ["-y", "past-conversations-mcp"]
    }
  }
}

Restart Claude Code. First startup takes ~17s to build the index. Subsequent startups are <700ms (incremental).

From source

git clone https://github.com/artpar/past-conversations-mcp
cd past-conversations-mcp
npm install
npm run build
node dist/index.js

Tools (11)

Knowledge tools

ToolDescription
search_insightsSearch extracted decisions, error fixes, patterns. Returns distilled knowledge, not raw text.
search_by_contextFind sessions by file path, tool name, outcome, tags, or date range.
get_project_knowledgeAggregated KT for a project: memory files, decisions, cross-refs, recent sessions, tags.

Search tools

ToolDescription
search_conversationsFull-text search with importance ranking, message type filtering, context windows, and session grouping.
search_historyFast search over all user prompts (covers sessions without full transcripts).

Session tools

ToolDescription
list_sessionsBrowse sessions with outcome, importance, and tag filters. Sort by recency or importance.
get_sessionFull conversation transcript with pagination.
get_session_contextRich KT context: prompts, responses, files, tools, insights, tags, cross-refs, outcome.

Project tools

ToolDescription
list_projectsAll projects with stats, top tags, decision counts, cross-ref counts, avg importance.
get_project_memoryRead curated memory files (.claude/projects/*/memory/*.md).

Admin tools

ToolDescription
rebuild_indexForce complete re-index from scratch.

Architecture

src/
├── index.ts                 Entry point, MCP server setup
├── types.ts                 All TypeScript interfaces
├── db/
│   ├── Database.ts          sql.js wrapper (better-sqlite3-compatible API)
│   ├── schema.ts            SQLite schema + migrations
│   ├── indexer.ts            Build/incremental index pipeline
│   └── queries.ts           All query functions
├── parser/
│   ├── jsonl.ts             Turn-based JSONL parsing with structural enrichment
│   ├── history.ts           history.jsonl streaming
│   ├── project.ts           Project/session discovery
│   ├── subagent.ts          Subagent file parsing
│   └── extractor.ts         Principle detection + structural tag extraction
├── tools/
│   ├── search.ts            search_conversations, search_history
│   ├── sessions.ts          list_sessions, get_session, get_session_context
│   ├── projects.ts          list_projects, get_project_memory
│   ├── insights.ts          search_insights, search_by_context, get_project_knowledge
│   └── admin.ts             rebuild_index
└── utils/
    ├── paths.ts             Path/slug utilities
    ├── text.ts              Text extraction helpers
    ├── nlp.ts               NLP utilities (compromise + wink-sentiment)
    └── scoring.ts           Turn-based importance scoring

Extraction pipeline

JSONL records
  → Group by message.id into logical messages
  → Pair user prompts with assistant responses into turns
  → Track tool result errors/successes per turn
  → Classify user feedback via sentiment analysis
  → Build errorFixPairs (structural error→resolution sequences)
  → Build commitTurnIndices (turns containing git commits)
  → Score turns using structural context (pre-commit, error-fix, user confirmation)
  → Extract decisions via principle patterns + structural validation gates
  → Extract error-fixes from structural pairs (no regex for detection)
  → Compute structural tags from tool usage, file paths, bash commands

Database

SQLite via sql.js (pure WASM — no native modules, works in any Node/Bun runtime).

Tables:

  • sessions — Session metadata + computed fields (outcome, importance_score, error_count, commit_count)
  • messages — User/assistant text with importance scores and message types
  • messages_fts — FTS4 full-text search on messages
  • tool_usage — Tool calls with file paths
  • history / history_fts — All user prompts from history.jsonl
  • session_insights / insights_fts — Extracted decisions, error fixes, patterns
  • session_tags — Auto-generated tags per session
  • cross_references — Cross-project links

Data sources

  • ~/.claude/projects/ — Claude Code conversation JSONL files, subagent files, memory files
  • ~/.claude/history.jsonl — Claude Code user prompts across all sessions
  • ~/.codex/sessions/ — Codex rollout JSONL files
  • ~/.codex/history.jsonl — Codex user prompts across all sessions

Indexing

  • Full build: ~17s for ~1700 sessions on a typical machine
  • Incremental: <700ms (mtime-based, only re-indexes changed files)
  • Index stored at ~/.claude/past-conversations-index.db

Key design choices

  • Turn-based model over flat messages — Conversations are trees of records linked by parentUuid. Grouping into turns captures tool result context, user feedback, and stop_reason that flat message lists lose.
  • Structural signals over content patterns — Scoring and extraction use conversation structure (what happened before/after, did tools succeed, did user confirm) as primary signals. Content regex patterns are tiebreakers, not drivers.
  • Principle detection over keyword matching — Decision extraction requires co-occurrence of a directive AND scope/rationale in the same text, plus at least one structural validation gate. Eliminates debugging traces that contain decision-like words.
  • Structural tags over content keywords — Tags derived from what tools were used and what files were touched, not from keywords in text. "testing" requires test files or test runner commands.
  • sql.js over better-sqlite3 — Pure WASM avoids native module ABI mismatches when Claude Code (Bun-based) spawns MCP servers
  • FTS4 over FTS5 — sql.js doesn't ship FTS5; standalone FTS4 tables (not content-linked) avoid transaction conflicts
  • NLP for text analysis — compromise for sentence boundaries (handles abbreviations, code, URLs), wink-sentiment for user feedback classification (AFINN-165 lexicon). Both deterministic and pure JS.
  • Connect before index — MCP stdio transport connects immediately; incremental indexing runs in background

Dependencies

PackagePurposeSize
@modelcontextprotocol/sdkMCP server protocol—
sql.jsSQLite via WASM—
zodSchema validation—
compromiseSentence splitting, POS tagging2.6 MB
wink-sentimentAFINN-165 sentiment analysis332 KB

License

MIT

Ver o original no GitHub

Bom para

Relacionados