Skip to content

Commit 66b70bb

Browse files
committed
feat(#26): support OpenAI API base URL and model name config
- Added OPENAI_API_BASE support for custom API endpoints - Renamed EMBEDDING_MODEL_NAME to DOCS_MCP_EMBEDDING_MODEL for clarity - Updated documentation with environment variable descriptions
1 parent 8865495 commit 66b70bb

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

.env.example

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
# OpenAI
1+
# OpenAI Configuration
2+
# Required: Your OpenAI API Key
23
OPENAI_API_KEY=your-key-here
34

5+
# Optional: Your OpenAI Organization ID (handled automatically by LangChain if set)
6+
OPENAI_ORG_ID=
7+
8+
# Optional: Custom base URL for OpenAI API (e.g., for Azure OpenAI or compatible APIs)
9+
OPENAI_API_BASE=
10+
11+
# Optional: Embedding model name (defaults to "text-embedding-3-small")
12+
# Must produce vectors with ≤1536 dimensions (smaller dimensions are padded with zeros)
13+
# Examples: text-embedding-3-small (1536), text-embedding-ada-002 (1536)
14+
# Note: text-embedding-3-large (3072) is not supported due to dimension limit
15+
DOCS_MCP_EMBEDDING_MODEL=
16+
417
# Optional: Specify a custom directory to store the SQLite database file (documents.db).
518
# If set, this path takes precedence over the default locations.
619
# Default behavior (if unset):

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ The server exposes MCP tools for:
2626
- Finding appropriate versions (`find_version`).
2727
- Removing indexed documents (`remove_docs`).
2828

29+
## Configuration
30+
31+
The following environment variables are supported to configure the OpenAI API and embedding behavior:
32+
33+
- `OPENAI_API_KEY`: **Required.** Your OpenAI API key for generating embeddings.
34+
- `OPENAI_ORG_ID`: **Optional.** Your OpenAI Organization ID (handled automatically by LangChain if set).
35+
- `OPENAI_API_BASE`: **Optional.** Custom base URL for OpenAI API (e.g., for Azure OpenAI or compatible APIs).
36+
- `DOCS_MCP_EMBEDDING_MODEL`: **Optional.** Embedding model name (defaults to "text-embedding-3-small"). Must produce vectors with ≤1536 dimensions. Smaller dimensions are automatically padded with zeros.
37+
38+
The database schema uses a fixed dimension of 1536 for embedding vectors. Models that produce larger vectors are not supported and will cause an error. Models with smaller vectors (e.g., older embedding models) are automatically padded with zeros to match the required dimension.
39+
40+
These variables can be set regardless of how you run the server (Docker, npx, or from source).
41+
2942
## Running the MCP Server
3043

3144
There are two ways to run the docs-mcp-server:
@@ -76,6 +89,17 @@ This is the recommended approach for most users. It's easy, straightforward, and
7689
- `-e OPENAI_API_KEY`: **Required.** Set your OpenAI API key.
7790
- `-v docs-mcp-data:/data`: **Required for persistence.** Mounts a Docker named volume `docs-mcp-data` to store the database. You can replace with a specific host path if preferred (e.g., `-v /path/on/host:/data`).
7891

92+
Any of the configuration environment variables (see [Configuration](#configuration) above) can be passed to the container using the `-e` flag. For example:
93+
94+
```bash
95+
docker run -i --rm \
96+
-e OPENAI_API_KEY="your-key-here" \
97+
-e DOCS_MCP_EMBEDDING_MODEL="text-embedding-3-large" \
98+
-e OPENAI_API_BASE="http://your-api-endpoint" \
99+
-v docs-mcp-data:/data \
100+
ghcr.io/arabold/docs-mcp-server:latest
101+
```
102+
79103
### Option 2: Using npx
80104

81105
This approach is recommended when you need local file access (e.g., indexing documentation from your local file system). While this can also be achieved by mounting paths into a Docker container, using npx is simpler but requires a Node.js installation.
@@ -122,7 +146,7 @@ docker run --rm \
122146
docs-cli <command> [options]
123147
```
124148

125-
Make sure to use the same volume name (`docs-mcp-data` in this example) as you did for the server.
149+
Make sure to use the same volume name (`docs-mcp-data` in this example) as you did for the server. Any of the configuration environment variables (see [Configuration](#configuration) above) can be passed using `-e` flags, just like with the server.
126150

127151
### Using npx CLI
128152

@@ -339,6 +363,16 @@ This method is useful for contributing to the project or running un-published ve
339363
# Required: Your OpenAI API key for generating embeddings.
340364
OPENAI_API_KEY=your-api-key-here
341365
366+
# Optional: Your OpenAI Organization ID (handled automatically by LangChain if set)
367+
OPENAI_ORG_ID=
368+
369+
# Optional: Custom base URL for OpenAI API (e.g., for Azure OpenAI or compatible APIs)
370+
OPENAI_API_BASE=
371+
372+
# Optional: Embedding model name (defaults to "text-embedding-3-small")
373+
# Examples: text-embedding-3-large, text-embedding-ada-002
374+
DOCS_MCP_EMBEDDING_MODEL=
375+
342376
# Optional: Specify a custom directory to store the SQLite database file (documents.db).
343377
# If set, this path takes precedence over the default locations.
344378
# Default behavior (if unset):

0 commit comments

Comments
 (0)