You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -101,15 +108,26 @@ For more details on environment variable expansion, see: https://docs.claude.com
101
108
102
109
### Supported Environment Variables
103
110
111
+
**Core Settings:**
112
+
-**STORAGE_BACKEND**: Database backend - `sqlite` (default) or `postgresql`
104
113
-**LOG_LEVEL**: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) - defaults to INFO
105
-
-**MCP_CONTEXT_DB**: Database file location - defaults to ~/.mcp/context_storage.db
114
+
-**DB_PATH**: Database file location (SQLite only) - defaults to ~/.mcp/context_storage.db
106
115
-**MAX_IMAGE_SIZE_MB**: Maximum size per image in MB - defaults to 10
107
116
-**MAX_TOTAL_SIZE_MB**: Maximum total request size in MB - defaults to 100
117
+
118
+
**Semantic Search Settings:**
108
119
-**ENABLE_SEMANTIC_SEARCH**: Enable semantic search functionality (true/false) - defaults to false
109
120
-**OLLAMA_HOST**: Ollama API host URL for embedding generation - defaults to http://localhost:11434
110
121
-**EMBEDDING_MODEL**: Embedding model name for semantic search - defaults to embeddinggemma:latest
111
122
-**EMBEDDING_DIM**: Embedding vector dimensions - defaults to 768. **Note**: Changing this after initial setup requires database migration (see [Semantic Search Guide](docs/semantic-search.md#changing-embedding-dimensions))
112
123
124
+
**PostgreSQL Settings** (only when STORAGE_BACKEND=postgresql):
125
+
-**POSTGRESQL_HOST**: PostgreSQL server host - defaults to localhost
126
+
-**POSTGRESQL_PORT**: PostgreSQL server port - defaults to 5432
127
+
-**POSTGRESQL_USER**: PostgreSQL username - defaults to postgres
128
+
-**POSTGRESQL_PASSWORD**: PostgreSQL password - defaults to postgres
129
+
-**POSTGRESQL_DATABASE**: PostgreSQL database name - defaults to mcp_context
130
+
113
131
### Advanced Configuration
114
132
115
133
Additional environment variables are available for advanced server tuning, including:
@@ -125,6 +143,81 @@ For a complete list of all configuration options, see [app/settings.py](app/sett
125
143
126
144
For detailed instructions on enabling optional semantic search with Ollama and EmbeddingGemma, see the [Semantic Search Guide](docs/semantic-search.md).
127
145
146
+
## Database Backends
147
+
148
+
The server supports multiple database backends, selectable via the `STORAGE_BACKEND` environment variable.
149
+
150
+
### SQLite (Default)
151
+
152
+
Zero-configuration local storage, perfect for single-user deployments.
153
+
154
+
**Features:**
155
+
- No installation required - works out of the box
156
+
- Production-grade connection pooling and write queue
157
+
- WAL mode for better concurrency
158
+
- Suitable for single-user and moderate workloads
159
+
160
+
**Configuration:** No configuration needed - just start the server!
161
+
162
+
### PostgreSQL
163
+
164
+
High-performance backend for multi-user and high-traffic deployments.
165
+
166
+
**Features:**
167
+
- 10x+ write throughput vs SQLite via MVCC
168
+
- Native concurrent write support
169
+
- JSONB indexing for fast metadata queries
170
+
- Production-grade connection pooling with asyncpg
171
+
- pgvector extension for semantic search
172
+
173
+
**Quick Start with Docker:**
174
+
175
+
Running PostgreSQL with pgvector is incredibly simple - just 2 commands:
176
+
177
+
```bash
178
+
# 1. Pull and run PostgreSQL with pgvector (all-in-one)
179
+
docker run --name pgvector18 \
180
+
-e POSTGRES_USER=postgres \
181
+
-e POSTGRES_PASSWORD=postgres \
182
+
-e POSTGRES_DB=mcp_context \
183
+
-p 5432:5432 \
184
+
-d pgvector/pgvector:pg18-trixie
185
+
186
+
# 2. Configure the server (minimal setup - just 2 variables)
187
+
export STORAGE_BACKEND=postgresql
188
+
export ENABLE_SEMANTIC_SEARCH=true # Optional: only if you need semantic search
189
+
```
190
+
191
+
**That's it!** The server will automatically:
192
+
- Connect to PostgreSQL on startup
193
+
- Initialize the schema (creates tables and indexes)
194
+
- Enable pgvector extension (comes pre-installed in the Docker image)
195
+
- Apply semantic search migration if enabled
196
+
197
+
**Configuration in .mcp.json:**
198
+
199
+
```json
200
+
{
201
+
"mcpServers": {
202
+
"context-server": {
203
+
"type": "stdio",
204
+
"command": "uvx",
205
+
"args": ["mcp-context-server"],
206
+
"env": {
207
+
"STORAGE_BACKEND": "postgresql",
208
+
"POSTGRESQL_HOST": "localhost",
209
+
"POSTGRESQL_USER": "postgres",
210
+
"POSTGRESQL_PASSWORD": "postgres",
211
+
"POSTGRESQL_DATABASE": "mcp_context",
212
+
"ENABLE_SEMANTIC_SEARCH": "true"
213
+
}
214
+
}
215
+
}
216
+
}
217
+
```
218
+
219
+
**Note:** PostgreSQL settings are only needed when using PostgreSQL. The server uses SQLite by default if `STORAGE_BACKEND` is not set.
220
+
128
221
## API Reference
129
222
130
223
### Tools
@@ -275,11 +368,13 @@ Update specific fields of an existing context entry.
275
368
- List of updated fields
276
369
- Success/error message
277
370
278
-
#### semantic_search_tool
371
+
#### semantic_search_context
279
372
280
373
Perform semantic similarity search using vector embeddings.
281
374
282
-
Note: This tool is only available when semantic search is enabled via `ENABLE_SEMANTIC_SEARCH=true` and all dependencies are installed (ollama, numpy, sqlite-vec packages, and EmbeddingGemma model).
375
+
Note: This tool is only available when semantic search is enabled via `ENABLE_SEMANTIC_SEARCH=true` and all dependencies are installed. The implementation varies by backend:
376
+
-**SQLite**: Uses sqlite-vec extension with embedding model via Ollama
377
+
-**PostgreSQL**: Uses pgvector extension (pre-installed in pgvector Docker image) with embedding model via Ollama
283
378
284
379
**Parameters:**
285
380
-`query` (str, required): Natural language search query
0 commit comments