> For the complete documentation index, see [llms.txt](https://docs.envector.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.envector.io/1.4.x/integrations/mcp/mcp-guide.md).

# MCP Guide

## Introduction

The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) 🔌 is a protocol for communicating with LLMs, primarily used for exchanging information (context) or performing actions.

🚀 **enVector** supports using MCP with various AI applications. You can interact with your LLMs like Claude through natural language inputs.

This guide supports how to start enVector MCP in details.

## Prerequisites

* Python version >= 3.10
* A running enVector instance: [Docker Compose](https://github.com/CryptoLabInc/envector-docs/tree/v1.4.6/gitbook/en/integrations/installation/README.md) or [enVector Cloud](https://envector.io/)
* Cloned GitHub Repository of enVector MCP server: <https://github.com/CryptoLabInc/envector-mcp-server>

> **Note**: The base MCP library requires Python 3.10+ while pyenvector supports 3.9+.

## Supporting tools

1. `get_index_list` : Get the list of indexes in enVector.
2. `get_index_info` : Get information about a specific index in enVector.
3. `create_index` : Create an index in enVector.
4. `insert` : Insert vectors and the corresponding metadata into enVector index. Supports to specify embedding model to get embedding vectors to insert.
5. `search` : Perform vector search and Retrieve Metadata from enVector. Supports to specify embedding model to get embedding vectors to search.

## Getting Started

1. Run enVector server via [Docker Compose](https://github.com/CryptoLabInc/envector-docs/tree/v1.4.6/gitbook/en/integrations/installation/README.md) or [enVector Cloud](https://envector.io/).
2. Clone the [envector-mcp-server](https://github.com/CryptoLabInc/envector-mcp-server) and setting up the Python environment.

   ```bash
   python -m venv .venv
   source .venv/bin/activate
   pip install -r requirements.txt
   ```

   See more details in [envector-mcp-server manuals](https://github.com/CryptoLabInc/envector-mcp-server/blob/main/MANUAL.md).
3. (Optional) Run MCP server with the following example command:

   ```bash
   python srcs/server.py \
       --envector-address "your-ev-address" \
       --envector-cloud-access-token "your-ev-access-token"
   ```

   This is optional when you run MCP server via AI application (e.g. Claude Desktop). See more details in [Run MCP Server](#run-mcp-server).
4. Connect your AI application (e.g. Claude) to the MCP server by configuring settings and Chat with enVector 🚀

   ```json
   "envector-mcp-server": {
       "url": "http://MCPHOST:MCPPORT/mcp",
       "description": "enVector MCP Server"
   }
   ```

   See more details in [Connect MCP Server](#connect-mcp-server).

## Connect MCP Server

### Connect to Remote MCP Server

1. Run MCP server on your Python environment with the following example command:

   ```bash
   python srcs/server.py \
       --envector-address "your-ev-address" \
       --envector-cloud-access-token "your-ev-access-token"
   ```

   See more CLI options on [CLI Options](#cli-options) for running MCP server.
2. Configure your MCP settings `.some-mcp-config.json` in your application.

   ```json
   {
       "mcpServers": {
           "envector-mcp-server": {
               "url": "http://MCPHOST:MCPPORT/mcp",
               "description": "enVector MCP Server"
           }
       }
   }
   ```

### Run MCP Server via AI application

Some AI applications support to run MCP server on their applications directly, e.g. Claude Desktop. Configure your MCP settings `.some-mcp-config.json` in your application.

```json
{
    "mcpServers": {
        "enVectorMCP": {
            "command": ".venv/bin/python3",
            "args": [ 
                "srcs/server.py",
                "--envector-address",
                "your-ev-address",
                "--envector-cloud-access-token",
                "your-ev-access-token"
            ],
            "cwd": "/path/to/envector-mcp-server",
            "description": "enVector MCP Server"
        },
    }
}
```

## MCP Server Options

### CLI Options

Arguments to run Python scripts:

* 💻 MCP execution
  * `--mode`: MCP execution mode, supporting `http` (default) and `stdio` transports.
  * `--host`: MCP HTTP bind host. The default is `127.0.0.1`.
  * `--port`: MCP HTTP bind port. The default is `8000`.
  * `--address`: MCP HTTP bind address. Overrides `--host` and `--port` if provided.
  * `--server-name`: MCP server name. The default is `envector_mcp_server`.
* 🔌 enVector connection
  * `--envector-address`: enVector endpoint address (`{host}:{port}` or enVector Cloud endpoint ends with `.clusters.envector.io`).
  * `--envector-cloud-access-token`: access token of enVector Cloud.
* 🔑 enVector options

  * `--envector-key-id`: enVector key id (identifier).

  * `--envector-key-path`: path to enVector key files.

  * `--envector-eval-mode`: enVector FHE evaluation mode.

  * `--encrypted-query`: whether to encrypt the query vectors. The index is encrypted by default.

  > ⚠️ **Note**: MCP server holds the key for homomorphic encryption as MCP server is a enVector Client.
* ⚙️ Embedding options
  * `--embedding-mode`: Mode of the embedding model. Supports `femb` (FastEmb; by default), `hf` (huggingface), `sbert` (SBERT; sentence-transformers), and `openai` (OpenAI API). For `openai`, required to set environmental variable `OPENAI_API_KEY`.
  * `--embedding-model`: Embedding model name to use enVector. The `sentence-transformers/all-MiniLM-L6-v2` set as default, which dimension is 384.

### Use environment variables

Copy `.env.example` to `.env` and configure `.env` as you want.

```bash
# MCP execution
MCP_SERVER_MODE="http"
MCP_SERVER_ADDRESS="127.0.0.1:8000"
MCP_SERVER_NAME="envector_mcp_server"

# enVector connection
ENVECTOR_ADDRESS="localhost:50050"
ENVECTOR_CLOUD_ACCESS_TOKEN=""

# enVector options
ENVECTOR_KEY_ID="mcp_key"
ENVECTOR_KEY_PATH="./keys"
ENVECTOR_EVAL_MODE="mm"
ENVECTOR_ENCRYPTED_QUERY="false"

# Embedding mode
EMBEDDING_MODE="femb"
EMBEDDING_MODEL="sentence-transformers/all-MiniLM-L6-v2"
```

The detailed description of each options can be found in [CLI Options](#cli-options).

## Next Steps

* [🔌 MCP Integration](/1.4.x/integrations/mcp/integration.md): How to integrate your AI applications
  * [Claude](/1.4.x/integrations/mcp/integration/mcp-claude.md)
  * [Cursor](/1.4.x/integrations/mcp/integration/mcp-cursor.md)
  * [Gemini](/1.4.x/integrations/mcp/integration/mcp-gemini.md)
  * [Codex](/1.4.x/integrations/mcp/integration/mcp-codex.md)
  * [Cline](/1.4.x/integrations/mcp/integration/mcp-cline.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.envector.io/1.4.x/integrations/mcp/mcp-guide.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
