Skip to main content
Glama
vurtnec

LanceDB Node

by vurtnec

LanceDB Node.js 向量搜索

使用 LanceDB 和 Ollama 的嵌入模型进行向量搜索的 Node.js 实现。

概述

该项目演示了如何:

  • 连接到 LanceDB 数据库

  • 使用 Ollama 创建自定义嵌入函数

  • 对存储的文档执行向量相似性搜索

  • 处理并显示搜索结果

Related MCP server: MCP Tooling Lab

先决条件

  • Node.js(v14 或更高版本)

  • Ollama 使用nomic-embed-text模型在本地运行

  • 具有读/写权限的 LanceDB 存储位置

安装

  1. 克隆存储库

  2. 安装依赖项:

pnpm install

依赖项

  • @lancedb/lancedb :Node.js 的 LanceDB 客户端

  • apache-arrow :用于处理列式数据

  • node-fetch :用于向 Ollama 发出 API 调用

用法

运行向量搜索测试脚本:

pnpm test-vector-search

或者直接执行:

node test-vector-search.js

配置

该脚本连接到:

  • LanceDB 在配置的路径下

  • Ollama API 位于http://localhost:11434/api/embeddings

MCP 配置

要与 Claude Desktop 作为 MCP 服务集成,请将以下内容添加到您的 MCP 配置 JSON 中:

{
  "mcpServers": {
    "lanceDB": {
      "command": "node",
      "args": [
        "/path/to/lancedb-node/dist/index.js",
        "--db-path",
        "/path/to/your/lancedb/storage"
      ]
    }
  }
}

用您的实际安装路径替换路径:

  • /path/to/lancedb-node/dist/index.js - 已编译 index.js 文件的路径

  • /path/to/your/lancedb/storage - 您的 LanceDB 存储目录的路径

自定义嵌入函数

该项目包括一个自定义的OllamaEmbeddingFunction ,它:

  • 向 Ollama API 发送文本

  • 接收 768 维的嵌入

  • 格式化它们以便与 LanceDB 一起使用

向量搜索示例

该示例在“ai-rag”表中搜索“如何定义成功标准”,并显示其相似度分数的结果。

执照

MIT 许可证

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables semantic search and retrieval of information from technical documentation PDFs using RAG-powered natural language queries with Ollama embeddings and LLMs.
    6
    -
  • F
    license
    B
    quality
    D
    maintenance
    A Node.js-based MCP server that enables AI agents to generate embeddings, index documents, and perform semantic vector searches using OpenAI and Chroma. It facilitates the creation of retrieval-augmented generation (RAG) pipelines for internal knowledge assistants and document-based workflows.
    3
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Local offline semantic search over documents (txt, md, pdf, docx, pptx, csv). Indexes folders into a LanceDB vector database with multilingual embeddings and supports hybrid vector + keyword search via Reciprocal Rank Fusion. No API keys, no cloud, no Docker required.
    29
    AGPL 3.0