> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lambdadb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Use the MCP server

> Connect coding agents through the LambdaDB CLI or configure MCP clients like Claude Desktop directly to search and manage a project.

LambdaDB can be used from any **Model Context Protocol (MCP)** client through the **LambdaDB MCP server**. This makes data stored in LambdaDB available to AI assistants that need to inspect collections, list documents, fetch records, or run search queries against a project.

For a guided first search with a coding agent, see [Start with an AI agent](https://docs.lambdadb.ai/guides/get-started/with-an-agent.md). Use the [CLI setup](#connect-with-the-cli) to connect supported coding agents, or follow the manual steps below for another MCP client, such as Claude Desktop.

The MCP server works with one project per process and exposes 8 read tools, or 22 tools when writes are enabled, covering collections, documents, search, branches, tags, and aliases. Organization listing, project creation and selection, and usage reports are [CLI account commands](https://docs.lambdadb.ai/guides/get-started/use-with-cli.md#manage-your-account-and-projects), not MCP tools.

## Before you start

Both connection methods require Node.js **22.14.0 or later**, npm, and an MCP client. Account-based CLI setup also requires access to the OS credential store. For direct package setup, obtain:

* A LambdaDB **project API key**
* Your project's **base URL**
* Your **project name**

> [!NOTE]
>
> The MCP package is **read-only by default**. Guided CLI `init` defaults to enabling write tools in its generated connection; disable them under **Change options** if you want read-only access.

## Connect with the CLI

Install the [LambdaDB CLI](https://docs.lambdadb.ai/guides/get-started/use-with-cli.md#install), then run:

```bash theme={null}
lambdadb init
```

Choose account login to select or create a project and explicitly issue a key, or reuse an existing connection. Select the agents, review the scope and write-tool setting, and approve the file plan. Supported agents include Codex, Claude Code, Cursor, VS Code, Gemini CLI, OpenCode, GitHub Copilot CLI, Kiro, and the Cline VS Code extension; see [agent setup](https://docs.lambdadb.ai/guides/get-started/use-with-cli.md#connect-coding-agents) for their scope restrictions and non-interactive examples. Claude Desktop uses the manual steps below.

CLI `0.4.1` generates a launch command pinned to that CLI version, which runs MCP `0.5.0` through `lambdadb mcp`. The bridge reads the selected OS credential or environment variable and forwards the project's base URL, name, and key to the MCP process. It adds no account-management tools and stores no key value in generated agent files. A saved OS credential needs the same OS user and access to the unlocked store; an environment-held key must be available to the agent process.

| Launch method | Write-tool control |
| :- | :- |
| Guided `lambdadb init` | Enabled by default in the reviewed agent setup; disable under **Change options** |
| `lambdadb init --non-interactive` | Disabled unless `--write-tools` is supplied |
| `lambdadb mcp` | Disabled unless `--write-tools` is supplied; the bridge overrides the inherited MCP write-tools environment variable |
| Direct MCP package | Disabled unless `LAMBDADB_MCP_ENABLE_WRITE_TOOLS=true` |

Restart or reload the agent and [verify the connection](#step-4-verify-the-connection). After upgrading the CLI or changing its selected project, rerun `init` for the same agents and scope to update their pinned settings. Existing agent connections do not automatically follow `projects use`.

The numbered steps below describe direct package setup, which supplies connection details through the MCP environment rather than the CLI bridge.

## Step 1: Get your LambdaDB connection details

From **[LambdaDB Cloud](https://app.lambdadb.ai)**, collect the following values for the project you want to expose to your MCP client:

* **Base URL**
* **Project name**
* **Project API key**

Project creation does not automatically issue an API key. In the project's **API Keys** tab, an organization Owner or Admin must select **Create key** and save the full value when it is shown. Use that saved value for the MCP configuration; it cannot be revealed again from the key list. See [API key management](https://docs.lambdadb.ai/guides/get-started/quickstart.md#manage-api-keys).

> [!WARNING]
>
> Store your project API key securely. Do not commit it to source control or share it in screenshots, prompts, or logs.

## Step 2: Choose the published package

The npm package is `@functional-systems/lambdadb-mcp`. This guide covers version `0.5.0`; the commands below use the latest stable release. No source checkout or build is required.

```bash theme={null}
node --version
npm view @functional-systems/lambdadb-mcp@latest version engines
```

With the required environment variables supplied, an MCP client can launch:

```bash theme={null}
npx --yes @functional-systems/lambdadb-mcp@latest
```

This is a **stdio server**: when launched in a terminal it waits for MCP protocol input, rather than showing an interactive prompt. It has no CLI `--help` or `--version` mode; use npm metadata to check the package version. Protocol messages use stdout and diagnostics use stderr.

Alternatively, install globally with `npm install --global @functional-systems/lambdadb-mcp@latest` and configure your client to run `lambdadb-mcp` with no arguments. Installed copies do not update themselves; run the same install command to update or `npm uninstall --global @functional-systems/lambdadb-mcp` to remove it. The client configuration below pins version `0.5.0` for reproducible launches. Review [releases](https://github.com/lambdadb/lambdadb-mcp/releases) and update the version explicitly.

### Transport limit

The [documented MCP server release](https://docs.lambdadb.ai/reference/sdk/introduction.md#supported-sdk-versions) has a **10 MiB** stdio receive-buffer limit (10,485,760 bytes). Exceeding it closes the connection. Split large tool inputs into smaller calls; bulk tools accept document arrays, not local paths or URLs. This transport limit does not increase LambdaDB's [API request limits](https://docs.lambdadb.ai/guides/get-started/limits.md#requests-and-documents).

### Environment variables

| Variable | Meaning |
| :- | :- |
| `LAMBDADB_BASE_URL` | Required region-specific API base URL from LambdaDB Cloud |
| `LAMBDADB_PROJECT_NAME` | Required existing project name |
| `LAMBDADB_PROJECT_API_KEY` | Required project API key |
| `LAMBDADB_MCP_ENABLE_WRITE_TOOLS` | Optional; defaults to `false`. Set `true` to expose write tools. |

When launched directly, the installed package reads the process environment. It does not read the general CLI's config file or automatically load `.env` or `.env.local`; the [CLI bridge](#connect-with-the-cli) resolves CLI credentials and supplies this environment for you. `LAMBDADB_ENV_FILE` is only for the source repository's development launchers. Set secrets through your client's protected local configuration or environment forwarding; do not put the key in command arguments.

## Step 3: Add the server to your MCP client

For **Claude Desktop**, open **Settings → Developer → Edit Config** and merge this entry into `claude_desktop_config.json`, preserving existing servers. This uses the [official local-server configuration format](https://modelcontextprotocol.io/docs/develop/connect-local-servers).

```json theme={null}
{
  "mcpServers": {
    "lambdadb": {
      "command": "npx",
      "args": ["--yes", "@functional-systems/lambdadb-mcp@0.5.0"],
      "env": {
        "LAMBDADB_BASE_URL": "YOUR_REGION_BASE_URL",
        "LAMBDADB_PROJECT_NAME": "YOUR_PROJECT_NAME",
        "LAMBDADB_PROJECT_API_KEY": "YOUR_PROJECT_API_KEY",
        "LAMBDADB_MCP_ENABLE_WRITE_TOOLS": "false"
      }
    }
  }
}
```

Replace each placeholder locally. This file contains a credential once filled in: keep it private and out of source control. Do not assume a desktop application inherits variables exported in a terminal.

Fully quit and restart Claude Desktop. Other MCP clients can use the same command, arguments, and environment values, but their configuration schema can differ.

## Step 4: Verify the connection

Open your client's server/tool list (in Claude Desktop, **Manage connectors → lambdadb**). A read-only connection should advertise these eight tools:

* `lambdadb_list_collections`
* `lambdadb_get_collection`
* `lambdadb_query_collection`
* `lambdadb_list_docs`
* `lambdadb_fetch_docs`
* `lambdadb_list_branches`
* `lambdadb_list_tags`
* `lambdadb_list_aliases`

Tool discovery confirms the local MCP connection; it does not authenticate to LambdaDB. To check project access:

1. Call `lambdadb_list_collections` with `{ "size": 1 }` to confirm the project connection.
2. Call `lambdadb_get_collection` for a known collection. Its `indexConfigs` include each field's [`description`](https://docs.lambdadb.ai/guides/collections/index-types#field-descriptions) when one is set, which helps an assistant choose fields.
3. Run `lambdadb_query_collection` with a small query against that collection.

Query, fetch, and list tools accept an optional `ref` such as `{ "kind": "tag", "name": "release" }`; omitting it reads from `main`. Use `lambdadb_list_branches`, `lambdadb_list_tags`, and `lambdadb_list_aliases` to discover refs when `main` is not the intended target. Query and fetch accept `consistentRead: true` with a branch ref, including the default `main` branch, or an alias that currently targets a branch; a tag ref or an alias that targets a tag rejects it. List does not support `consistentRead`. See [Data versioning](https://docs.lambdadb.ai/guides/data-versioning/branches-tags-aliases.md).

Query, fetch, and list follow the [service result and ID limits](https://docs.lambdadb.ai/guides/get-started/limits.md#search-and-reads). List also accepts optional `filter`, `fields`, `includeVectors`, and `partitionFilter`. Keep `size` small while exploring and use `fields` to leave out large stored fields.

For example, pass these arguments to `lambdadb_query_collection` for the sample collection created in the [CLI guide](https://docs.lambdadb.ai/guides/get-started/use-with-cli.md):

```json theme={null}
{
  "collectionName": "cli-demo-docs",
  "size": 10,
  "query": { "queryString": { "query": "serverless", "defaultField": "text" } },
  "ref": { "kind": "branch", "name": "main" },
  "consistentRead": false
}
```

The MCP server also accepts [keyword facets](https://docs.lambdadb.ai/guides/search/facets.md), an omitted `query` for match-all, and `size: 0` with nonempty facets for counts only.

### Native reranking

The MCP server accepts optional `rerank` on `lambdadb_query_collection`. For the sample collection above, pass:

```json theme={null}
{
  "collectionName": "cli-demo-docs",
  "size": 2,
  "query": { "queryString": { "query": "serverless", "defaultField": "text" } },
  "ref": { "kind": "branch", "name": "main" },
  "rerank": {
    "provider": "typesafe",
    "model": "jev-1.13.0",
    "queryText": "Which documents explain serverless search?",
    "fields": ["text"]
  }
}
```

LambdaDB manages the provider credentials. Omitting `rerank` or passing null keeps existing search behavior. Applied results preserve the final `score`, envelope `retrievalScore`, server order, and top-level rerank metadata, including `docsUrl` downloads. Check `rerank.status` before interpreting scores; fallback uses original search scores and exposes no partial reranking scores. See [Native reranking](https://docs.lambdadb.ai/guides/search/native-reranking.md) for custom criteria, candidate depth, and failure/query restrictions. Reranking is available through the read tool and does not require enabling write tools.

### Bayesian hybrid search

The MCP server accepts the [Bayesian request](https://docs.lambdadb.ai/guides/search/hybrid.md#bayesian-hybrid-query) through `lambdadb_query_collection`. Add `collectionName` for a collection with the example's `body` and `bodyEmbedding` fields. Without reranking, pass top-level `candidateSize`; with reranking, omit it and use `rerank.candidateSize`. The read tool preserves result scores and rerank metadata, including downloaded results.

## Optional: Enable write tools

The LambdaDB MCP server can also expose write operations:

| Area | Tools |
| :- | :- |
| Collections | `lambdadb_create_collection`, `lambdadb_update_collection`, `lambdadb_delete_collection` |
| Documents | `lambdadb_upsert_docs`, `lambdadb_update_docs`, `lambdadb_bulk_upsert_docs`, `lambdadb_delete_docs` |
| Data versioning | `lambdadb_create_branch`, `lambdadb_delete_branch`, `lambdadb_create_tag`, `lambdadb_delete_tag`, `lambdadb_create_alias`, `lambdadb_retarget_alias`, `lambdadb_delete_alias` |

The MCP server accepts all 49 [fixed text analyzer presets](https://docs.lambdadb.ai/guides/collections/choose-text-analyzers.md) when creating collections.

The create and update tools accept an `embedding` block in `indexConfigs` for [native embeddings](https://docs.lambdadb.ai/guides/collections/native-embeddings.md#collection-schema); schema updates follow the [collection update rules](https://docs.lambdadb.ai/guides/collections/manage-collections.md#configure-a-collection). Their `indexConfigs` schemas also accept an optional [`description`](https://docs.lambdadb.ai/guides/collections/index-types#field-descriptions) on every field, including nested `objectIndexConfigs` children; on update, omitting it or passing `null` keeps the stored description and `""` clears it.

Every tool takes `collectionName`. The other inputs are:

| Tool | Inputs and behavior |
| :- | :- |
| `lambdadb_create_collection` | Nonempty `indexConfigs`; optional `description`, metadata `tags`, `partitionConfig`, and `snapshotRetentionInDays` (see [collection limits](https://docs.lambdadb.ai/guides/get-started/limits.md#collections-and-schema)) |
| `lambdadb_update_collection` | At least one non-null `indexConfigs`, `description`, `tags`, or `snapshotRetentionInDays`. Omitted or `null` values leave settings unchanged; use `description: ""` or `tags: {}` to clear those fields. Retention must fit the [supported range](https://docs.lambdadb.ai/guides/get-started/limits.md#collections-and-schema) and cannot be cleared. Index changes are additive, except that a field `description` can be changed or cleared |
| `lambdadb_delete_collection` | Deletes the collection with its documents, branches, tags, and aliases |
| `lambdadb_upsert_docs`, `lambdadb_update_docs`, `lambdadb_bulk_upsert_docs` | `docs` and optional `branch`. Update rows need existing IDs and merge into stored documents; bulk runs the SDK upload workflow and never generates native embeddings |
| `lambdadb_delete_docs` | Exactly one of a nonempty `ids` array or a `filter`, plus optional `partitionFilter` and `branch` |
| `lambdadb_create_branch` | `branchName`; optional `source: { "kind": "branch", "name": "...", "asOf"?: <epoch ms> }`, default `main`. Copies committed state only |
| `lambdadb_create_tag` | `tagName`; optional branch source as above or `{ "kind": "tag", "name": "..." }`, default `main` |
| `lambdadb_create_alias`, `lambdadb_retarget_alias` | `aliasName` and `target: { "kind": "branch" \| "tag", "name": "..." }`. Retargeting changes future alias reads, not write targets |
| `lambdadb_delete_branch`, `lambdadb_delete_tag`, `lambdadb_delete_alias` | `branchName`, `tagName`, or `aliasName`. Deleting an alias does not delete its target |

A typical versioning workflow creates a branch from `main`, writes and evaluates on it, pins a tag once the intended data is committed, and then retargets the serving alias:

```json theme={null}
{ "collectionName": "memories", "branchName": "candidate", "source": { "kind": "branch", "name": "main" } }
```

```json theme={null}
{ "collectionName": "memories", "tagName": "reviewed", "source": { "kind": "branch", "name": "candidate" } }
```

```json theme={null}
{ "collectionName": "memories", "aliasName": "serving", "target": { "kind": "tag", "name": "reviewed" } }
```

Document writes without `branch` go to `main`. `asOf` is an integer Unix epoch millisecond cutoff. Branch sources cannot be tags or aliases, and alias targets cannot be aliases. `main` cannot be deleted, and a branch or tag still referenced by an alias cannot be deleted until the alias is retargeted or removed. Accepted writes do not establish committed search visibility, so a branch or tag created right after a write may not include it. Bulk inputs must fit the [transport limit](#transport-limit); the tool does not accept local paths or URLs.

For direct package setup, enable them by changing the environment value and restarting the MCP server:

```bash theme={null}
LAMBDADB_MCP_ENABLE_WRITE_TOOLS=true
```

For CLI-generated connections, use the write-tool setting in `init` and restart the agent; `lambdadb mcp` uses its `--write-tools` flag rather than an inherited environment setting.

> [!WARNING]
>
> Enable write tools only in environments where document creation, updates, and deletion are intended. Start with a non-production project when testing write access from an MCP client.

Successful writes are accepted before committed search visibility is verified. Confirm expected documents with subsequent reads; tool success alone is not an indexing readiness check.

## Troubleshooting

If the server starts but tools fail:

* Verify that **base URL**, **project name**, and **project API key** all belong to the same LambdaDB project.
* Confirm that the project API key is still valid.
* Check the MCP client logs for startup or tool-call errors.
* Run the server locally first to make sure the process starts with the expected environment variables.

If tools are missing:

* Confirm that the client launches the pinned npm package or the intended installed executable.
* Restart the MCP client after editing its configuration.
* If you expect write tools, make sure `LAMBDADB_MCP_ENABLE_WRITE_TOOLS=true` is set.

If the server cannot start:

* Check that the Node executable visible to the client is version 22.14.0 or newer, and that `npx` is on its PATH. For `ENOENT`, use the absolute path returned by `command -v npx` on macOS/Linux or `where npx` on Windows, and ensure Node is also reachable.
* A missing-variable error means the required values were not supplied to the child process. Editing a checkout's `.env.local` does not configure an npm-launched server.
* Use `true` or `false` for write opt-in; an invalid boolean fails startup.
* Check npm/network errors if the pinned package cannot be downloaded. Check JSON syntax and restart the server after configuration changes.
* On macOS, Claude Desktop logs are under `~/Library/Logs/Claude`; on Windows, `%APPDATA%\Claude\logs`. Inspect `mcp.log` and `mcp-server-lambdadb.log` locally, without sharing credentials or document data.

## Optional: Build from source

For development, use a release tag and Node.js 22.14.0 or later:

```bash theme={null}
git clone --branch v0.5.0 https://github.com/lambdadb/lambdadb-mcp
cd lambdadb-mcp
npm ci
npm run build
cp .env.example .env.local
```

Fill in `.env.local` locally, then run `npm run start:env`. The source launcher selects `LAMBDADB_ENV_FILE` when set, otherwise `.env.local` if present, otherwise `.env`. Exported values take precedence. Direct `node dist/index.js` does not load these files. See the [repository README](https://github.com/lambdadb/lambdadb-mcp#readme) for development and Inspector usage.

## Next steps

* Learn how to create collections in [Create a collection](https://docs.lambdadb.ai/guides/collections/create-a-collection.md)
* Learn how to list documents in [List data](https://docs.lambdadb.ai/guides/documents/list-data.md)
* Learn how to search collections in [Search overview](https://docs.lambdadb.ai/guides/search/search-overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.