Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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="rmp"
ENVECTOR_ENCRYPTED_QUERY="false"

# Embedding mode
EMBEDDING_MODE="hf"
EMBEDDING_MODEL="sentence-transformers/all-MiniLM-L6-v2"
63 changes: 57 additions & 6 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ MANUAL.md # User Manual

- Environment Variable Set-Up

1. Use `.env` file
1. Use `.env` file to set environmental variables

```bash
source .env
```

2. CLI overrides (Recommended)
2. CLI Options

Every setting has default value, but, you can check option with `python srcs/server.py --help` and overwrite each value with CLI.

Expand Down Expand Up @@ -98,6 +94,60 @@ python srcs/server.py \
Note that,
- `stdio` mode communicate with standard I/O only, so log might not be seen. Please connect to MCP Host.

## 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. Recommend to use `rmp` (default) mode for more flexible usage.
- `--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 `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="rmp"
ENVECTOR_ENCRYPTED_QUERY="false"

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


## Connect MCP Server (Client)

Expand Down Expand Up @@ -217,6 +267,7 @@ Basic format is `JSON-RPC 2.0`
}'
```


## Fast Trouble Shooting
### Error List
- 404/405:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pydantic[email]>=2.11.7
python-dotenv>=1.2.1
fastmcp>=2.2.0
pyenvector>=1.2.0
pytest>=7.0.0
Expand Down
9 changes: 7 additions & 2 deletions srcs/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import json
from pydantic import Field

# load environment variables from .env file if present
from dotenv import load_dotenv
load_dotenv()

# Ensure current directory is in sys.path for module imports
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
if CURRENT_DIR not in sys.path:
Expand Down Expand Up @@ -333,6 +337,7 @@ def run_stdio_service(self) -> None:
parser.add_argument(
"--encrypted-query",
action="store_true",
default=os.getenv("ENVECTOR_ENCRYPTED_QUERY", "false").lower() in ("true", "1", "yes"),
help="Encrypt the query vectors."
)
parser.add_argument(
Expand All @@ -342,13 +347,13 @@ def run_stdio_service(self) -> None:
)
parser.add_argument(
"--embedding-mode",
default="hf",
default=os.getenv("EMBEDDING_MODE", "hf"),
choices=("sbert", "hf", "openai"),
help="Embedding model name for enVector. 'sbert' for SBERT, 'hf' for HuggingFace, 'openai' for OpenAI API.",
)
parser.add_argument(
"--embedding-model",
default="sentence-transformers/all-MiniLM-L6-v2",
default=os.getenv("EMBEDDING_MODEL", "sentence-transformers/all-MiniLM-L6-v2"),
help="Embedding model name for enVector.",
)
args = parser.parse_args()
Expand Down