Logo Session Knowledge

Session Knowledge

Cộng đồng
nameforjt-afk

Turn your Claude Code session history into a searchable local knowledge base — 13 MCP tools, pure stdlib, nothing leaves your machine

Nhà phát hànhnameforjt-afk
Kho mãsession-knowledge
Ngôn ngữPython
Bản fork
12
Sao
335
Công cụ có sẵn
0
Phương thức truyền tảistdio
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Session Knowledge cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    335 sao và 12 bản fork từ kho mã được liên kết.

session-knowledge

Tests Python 3.10+ License: MIT

Claude Code's memory is scoped per project directory. Your history isn't.

Every session you've ever run is already on disk in ~/.claude/projects/**/*.jsonl — every decision, every command that worked, every credential you pasted. But open a session in a different directory and none of it is reachable. You re-ask questions you already answered, and re-implement integrations you already wrote.

This indexes all of it and hands Claude 13 MCP tools to search it. You just ask normally.

What was the retry logic in that deploy script? Which DATABASE_URL did I actually use for staging? Before I write the Stripe integration — has anyone here already done payment auth?

Pure Python standard library. No third-party dependencies, no embeddings, no API calls, nothing leaves your machine.

bash
git clone https://github.com/nameforjt-afk/session-knowledge.git
cd session-knowledge
bash install.sh

Restart Claude Code. Done.


⚠️ Read this before installing

The index lives in ~/.claude/session-index/ and it contains plaintext credentials scraped from your sessions. That is the precondition for "which key did I use here" to work at all.

Never commit that directory, never sync it to cloud storage, never send it to anyone. This repo's .gitignore covers the default location, but if you relocate it that's on you.

The full-text index itself is redacted: common credential shapes (API keys, Bearer tokens, JWTs, GitHub PATs, passwords inside connection strings) are replaced with ⟦SECRET:fingerprint⟧ before they are written. Plaintext lives only in vault.db at mode 0600, and only an explicit creds get returns it.

The transcript and code indexes still contain sensitive local context even after redaction. The index directory is restricted to mode 0700; every generated SQLite database, WAL/SHM sidecar, and refresh log is restricted to mode 0600.

Redaction is pattern matching, not magic. Custom-format secrets can slip through. verify-redaction spot-checks for leaks.


What it actually solves

Four things, in rough order of how often they save you:

1. "Have I already built this?" — Search by external service, not by function name. grep only works if you already know the string to search for (you need to know it's tenant_access_token before you can grep for Feishu auth). Capability tags don't require that.

2. "How did we decide this?" — The rationale is buried in thousands of past instructions. Full-text search over them, filterable to just your own instructions.

3. "How did that command go again?" — Every Bash and MCP call, with arguments and results. Filter to only the ones that failed, to recall the traps.

4. "Which value does this key take?" — Same variable name routinely has several real values (multiple apps, dev vs prod, two tables). It returns all candidates ranked, with the call site each came from, rather than silently picking one.


Usage

Day to day: nothing

A hook refreshes the index incrementally on each Claude Code start (async, non-blocking, usually 1–2s). Ask questions normally; Claude reaches for the tools on its own.

Deleting a transcript removes its searchable text, tool calls, metadata, and session-only credential observations on the next refresh. Credentials that still occur in another live transcript remain available.

CLI

bash
python3 -m sessionmcp.cli index                     # incremental refresh
python3 -m sessionmcp.cli stats                     # index health check

python3 -m sessionmcp.cli search "deploy timeout"   # full text (multi-word = AND)
python3 -m sessionmcp.cli search "pricing" --kind user_instruction
python3 -m sessionmcp.cli tool "docker build"       # past commands and API calls
python3 -m sessionmcp.cli tool "stripe" --errors    # only the ones that failed
python3 -m sessionmcp.cli timeline "that migration" # reconstruct how it unfolded
python3 -m sessionmcp.cli synth "rate limiting"     # cross-session material pack
python3 -m sessionmcp.cli evolution "auth design"   # how a decision changed over time

python3 -m sessionmcp.cli code find --capability stripe   # who implemented payment auth
python3 -m sessionmcp.cli code find send_message          # by symbol name
python3 -m sessionmcp.cli code dup                        # duplicate-implementation report

python3 -m sessionmcp.cli creds list                 # variable names only, never values
python3 -m sessionmcp.cli creds get DATABASE_URL     # all candidates, ranked
python3 -m sessionmcp.cli creds get X --masked       # masked form only
python3 -m sessionmcp.cli verify-redaction           # confirm no plaintext in the index

Search is AND. More words means fewer hits. Use the 2–3 words you would actually have typed back then, not a sentence.

The fake-credential problem

Not every "credential" in your history is real. Doc examples, error snippets, values someone made up mid-discussion — all get extracted, and they look exactly like the real thing. A fake in your candidate list is worse than no record at all: it looks perfectly plausible, so you use it.

Blacklist it permanently:

bash
python3 -m sessionmcp.cli creds forget --fingerprint <fp> --reason "doc example"

Deleting alone does nothing — the index re-scans daily and the value comes right back. forget is delete plus blacklist.


The 13 MCP tools

search_sessionsfull-text search across every session
get_sessionpage through one session's full transcript
list_sessionssession metadata (title, project, date, turns)
get_timelinechronological reconstruction of one topic
synthesize_topiccurated excerpts across sessions, for summarizing
track_evolutionhow a decision or standard changed, bucketed by month
find_tool_callpast Bash/MCP calls with arguments; errors_only to recall traps
find_implementationexisting code by symbol or by external-service tag
list_duplicationwhat got implemented N times, and which "projects" are forks
list_credentialsvariable-name registry — never returns values
get_credentialthe actual values, all candidates ranked by trustworthiness
lookup_secretresolve a ⟦SECRET:fp⟧ fingerprint back to its variable name
index_statscoverage and freshness

How it works

~/.claude/projects/**/*.jsonl      transcripts Claude Code already writes
            ↓  single pass
   ┌────────┴────────┐
 index side        credential side
 redacted → FTS5   KEY=VALUE → vault.db (0600)
   ↓                  ↓
index.db          vault.db          code.db
full text         credential        symbols +
                  registry          capability tags

CJK search uses bigram pre-tokenization. FTS5's built-in trigram cannot match two-character Chinese words (measured: common two-char terms returned nothing), and unicode61 doesn't segment CJK at all. So CJK text is expanded into adjacent character pairs at write time and the query is expanded the same way — exact matches work, still on the FTS5 index, BM25 ranking preserved.


Configuration

Most of it needs none. To tune, edit sessionmcp/config.py:

SettingWhat it does
CODE_CAPABILITY_PATTERNSThe one worth editing. Service tags that drive "find existing implementations by service". Drop the ones you don't use, add yours
PRIVATE_TITLESSession titles to exclude from the index, exact match
_PRIVATE_KEYWORDSHeuristic for personal content; sessions that hit enough of these are skipped
CODE_PROJECT_*Which directories the code index scans (auto-derived by default)

Which directories get code-indexed

Auto-derived: working directories with ≥2 sessions in the last 45 days, top 30 by session count. Not hard-coding a list is deliberate — a hard-coded list goes stale silently as projects come and go, and is entirely wrong on a new machine.

If you're new to Claude Code and every project has exactly one session, this derives an empty list and the code index scans nothing. Override:

bash
export SESSION_KNOWLEDGE_PROJECT_DIRS="~/proj-a:~/proj-b"

Claiming a canonical implementation

~/.claude/knowledge/canonical.json lets you declare which file is the canonical implementation of a capability. The generator reads it and never overwrites it, so daily refreshes won't clobber your call. When the same logic shows up a third time, claiming one beats copying it a fourth.


Uninstall

bash
bash uninstall.sh            # remove MCP + hook, keep the index
bash uninstall.sh --purge    # remove the index too

Known limits

  • Claude Code transcripts only (~/.claude/projects/**/*.jsonl). Not Cursor, not Copilot.
  • Redaction is pattern matching. Common shapes are covered; custom formats can leak. Run verify-redaction periodically.
  • Code index reads Python/JS/TS only (.py .js .ts .tsx .mjs .jsx).
  • First full index of a few hundred sessions takes 1–3 minutes. Incremental after that is 1–2s.
  • Python 3.10+, with FTS5 compiled into the bundled sqlite3. The system Python on macOS sometimes lacks it — install from python.org or brew install python.

中文文档

Contributing and security

See CONTRIBUTING.md before opening an issue or pull request. Never include real transcripts or credentials in public reports. Potential vulnerabilities should be reported privately according to SECURITY.md.

Release history is recorded in CHANGELOG.md.

License

MIT — see LICENSE.

Dùng MCP Session Knowledge với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Session Knowledge, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Session Knowledge làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Session Knowledge.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "session-knowledge": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Session Knowledge, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Session Knowledge.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Session Knowledge giúp tôi làm việc này không?
Session Knowledge
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Session Knowledge.

Câu hỏi thường gặp

Máy chủ MCP Session Knowledge dùng để làm gì?

Session Knowledge là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Session Knowledge với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Session Knowledge với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Session Knowledge với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Session Knowledge, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Session Knowledge với TypingMind?

Session Knowledge hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Session Knowledge cung cấp những công cụ nào trong TypingMind?

Session Knowledge cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Session Knowledge không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Session Knowledge yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇