Skip to main content
Glama
dfine-semantic

dfine-semantic

Official
by dfine-io

@dfine-io-gmbh/semantic-mcp

Semantic code search as an MCP server. It embeds a project's code into a local SQLite vector store and answers natural-language questions that a plain grep cannot match. Everything runs locally once the model is downloaded.

How it works

  • Code is split into chunks and embedded with jinaai/jina-embeddings-v2-base-code (768 dimensions) through @huggingface/transformers.

  • Vectors live in one local SQLite database per project (sqlite-vec).

  • The server speaks MCP over stdio, revision 2026-07-28 and the 2025 revisions, and works with any MCP client, for example Claude Code or Cursor.

  • Each search first re-indexes the files that changed since the last one. If that would take longer than about ten minutes, clients on MCP 2026-07-28 that support forms ask you first. Other clients re-index without asking.

  • Long runs report progress to clients that ask for it. Claude Code and other clients that reset their timeout on progress keep such a call open until it finishes.

Related MCP server: code-memory-rs

Requirements

  • Node.js 22 or newer

  • Git on the PATH. Every indexed root must be inside a git work tree, because files are listed with git ls-files.

  • Network access to download the model (about 640 MB) into ~/.dfine-semantic/models when it is not there yet

  • better-sqlite3 and sqlite-vec ship prebuilt binaries for macOS (arm64, x64), Linux (x64, arm64) and Windows (x64). Other targets build from source and need a C/C++ toolchain.

Use it with an MCP client

No install step is needed: npx fetches and runs the server. Add it to your MCP client config (.mcp.json for Claude Code project scope, or ~/.claude.json for user scope):

{
  "mcpServers": {
    "dfine-semantic": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@dfine-io-gmbh/semantic-mcp"]
    }
  }
}

The server sends short usage instructions to the client when it connects.

Tools

Name

Purpose

semantic_search

Natural-language query, returns ranked file:line references

index_project

Index or refresh a project root, embedding only what changed

index_status

List indexed projects with file, chunk and size counts

find_duplicates

List similar code for files or line ranges (opt-in, see below)

semantic_search and find_duplicates also return their results as structured data, described by each tool's output schema. Its status field tells an agent that duplicate search is off for a project, which is not the same as finding no duplicates.

semantic_search covers .ts and .tsx by default. Pass include (for example [".md", ".vue"]) to search other indexed file types. index_project indexes the allow-listed extensions you pass and keeps that list, so a later call without extensions indexes the same file types.

Duplicate search (opt-in)

find_duplicates is off until you turn it on for a project. It needs a second index of short code windows, and building that index takes time and disk space, so projects that never use it never pay for it.

  1. Ask your agent to run index_project with duplicates: true once for the project. On an indexed repository with about 1,400 TypeScript files, this takes about 50 minutes and 75 MB. A project without a search index yet needs about 35 minutes more.

  2. Ask for duplicates of files or line ranges, for example src/a.ts:10-40, and your agent calls find_duplicates. Searches and index runs keep the windows of edited files current. When a result says windows are missing, run index_project again.

  3. Run index_project with duplicates: false to switch it off and delete the duplicate index.

Each result pairs a range of your file with a similar range in another file. It comes with a similarity score and a band: likely from 0.88, check from 0.80 up to 0.88. The tool only lists candidates, and your agent reads both ranges before it merges anything. The tool description tells the agent what counts as a duplicate: both ranges follow the same rule, or a block repeats with only names, data or texts swapped. A shared call or a short idiom does not count.

In a measured TypeScript project with about 1,400 files, the default threshold of 0.80 listed about three in four of the real duplicates, and about half scored 0.88 or more. Short functions get an entry of their own, so a word-for-word copy of a five-line function is found as well. Pass threshold: 0.88 to list only likely pairs.

The tool covers .ts, .tsx, .js, .jsx and .mjs files and skips tests, specs and .d.ts files. Pass exclude with folders such as src/generated to leave generated or vendored code out.

Configuration

Variable

Default

Purpose

SEMANTIC_ALLOWED_ROOTS

cwd, ~/.claude

Extra absolute roots the server may index (comma-separated)

SEMANTIC_DATA_DIR

~/.dfine-semantic

Where the indexes and the model are stored

The working directory counts as a root unless it is / or your home folder. Indexes are keyed by project path and survive upgrades. Run index_project with force: true for a clean rebuild.

Upgrading from 0.1.4

  • In projects with duplicate search on, run index_project once. It rebuilds the duplicate index with the new entries for short functions, which takes about as long as the first build. Until then find_duplicates keeps working with the old index.

  • find_duplicates now lists pairs from 0.80 instead of 0.88. Pass threshold: 0.88 for the shorter list.

Upgrading from 0.1.3 or older

  • Restart every session that still runs 0.1.3 or older. An old server cannot read an upgraded index.

  • The model downloads once more into its new folder. Copies inside old npx caches can be deleted.

  • Files are now split into chunks differently. Searches keep using your existing index, and clients that support forms offer a rebuild. You can also run index_project.

  • find_duplicates is new and stays off until your agent runs index_project with duplicates: true.

Security

See SECURITY.md for the security model and how to report a vulnerability.

Local development

pnpm install
pnpm build        # tsc
pnpm lint:dlint   # dlint, the dfine linter on the TypeScript compiler
pnpm check        # tsc, dlint and prettier
pnpm start

License and support

MIT, see LICENSE. Questions or issues: support@dfine.io or the issue tracker.

Available Tools

4 tools
find_duplicatesFind duplicate codeA
Read-onlyIdempotent

List code in other files that nearly matches the given files or line ranges. Use it in reviews and refactors - pass changed line ranges ("src/a.ts:10-40") for sharper pairs. Treat every pair as a candidate - read both ranges before you call it a duplicate. Expect it to be off per project - ask the user before you turn it on. Turn it on with index_project duplicates: true - the first build can take over an hour on large projects. Covers .ts, .tsx, .js, .jsx, .mjs files; skips tests, specs and .d.ts files.

Inputs: files (required), path, limit, exclude, +1 more. Returns: notes, pairs, status

index_projectIndex a projectA
DestructiveIdempotent

Build or refresh the semantic index of a project root. Embeds only new, edited or outdated files and drops deleted ones. Pass duplicates: true once to enable find_duplicates for this project.

Inputs: path (required), force, duplicates, extensions.

index_statusIndex statusA
Read-onlyIdempotent

List indexed projects with file, chunk and size counts - pass path for one project.

Inputs: path.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: semantic_search retrieves code, index_project builds/refreshes the index, index_status reports state, and find_duplicates detects near-matches. There is no overlap between searching, indexing, status, and duplicate detection.

    Naming Consistency4/5

    All names use snake_case consistently, but the internal pattern varies slightly (adjective_noun, noun_verb, noun_noun, verb_noun). Still highly readable and predictable as a set.

    Tool Count4/5

    Four tools is lean but well-matched to a focused semantic-search-and-indexing server. Each tool earns its place without redundancy, though the surface is on the thin side.

    Completeness4/5

    The core lifecycle (index build, status, search, duplicate detection) is covered. Minor gaps exist, such as removing or clearing an index and per-file reindexing, but agents can work around these via index_project.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables local semantic code search across repositories using natural language, with AST-aware chunking and hybrid vector/FTS5 retrieval.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables semantic and keyword search over a local codebase by chunking source files along function and class boundaries, embedding them offline, and fusing vector and BM25 results. Runs entirely on your machine in a single SQLite file, so AI coding agents can find relevant code with no API keys, telemetry, or cloud calls.
      7
      11 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables coding agents to search a locally indexed repository and get back a token-budgeted deck of ranked code and doc snippets instead of a full-tree grep dump, with lexical, semantic, and prose-answering modes plus index status reporting. Runs fully offline for lexical queries and optionally uses an OpenAI-compatible provider for semantic or ask modes.
      MIT