Skip to content

Enhance environment variable parsing - #77

Closed
MH0386 wants to merge 3 commits into
qdrant:masterfrom
MH0386:env-parse-none-str
Closed

MH0386 wants to merge 3 commits into
qdrant:masterfrom
MH0386:env-parse-none-str

Conversation

@MH0386

@MH0386 MH0386 commented Jul 25, 2025 •

Copy link
Copy Markdown

By default, environment variables are parsed verbatim, so this pull request updates the QdrantSettings configuration in src/mcp_server_qdrant/settings.py to enhance environment variable parsing and improve maintainability. The key changes include importing SettingsConfigDict and adding a model_config attribute for handling None string values in environment variables.

Changes to environment variable parsing:

  • src/mcp_server_qdrant/settings.py: Added SettingsConfigDict to the imports and introduced a model_config attribute in the QdrantSettings class to ensure that the string "None" is parsed as None for environment variables.

Before:

$ QDRANT_URL="http://localhost:6333" COLLECTION_NAME="my-collection" QDRANT_LOCAL_PATH=None uv run mcp-server-qdrant --transport sse
Traceback (most recent call last):
  File "/mnt/d/Sync/Development/mcp-server-qdrant/.venv/bin/mcp-server-qdrant", line 10, in <module>
    sys.exit(main())
  File "/mnt/d/Sync/Development/mcp-server-qdrant/src/mcp_server_qdrant/main.py", line 22, in main
    from mcp_server_qdrant.server import mcp
  File "/mnt/d/Sync/Development/mcp-server-qdrant/src/mcp_server_qdrant/server.py", line 10, in <module>
    qdrant_settings=QdrantSettings(),
  File "/mnt/d/Sync/Development/mcp-server-qdrant/.venv/lib/python3.10/site-packages/pydantic_settings/main.py", line 176, in __init__
    super().__init__(
  File "/mnt/d/Sync/Development/mcp-server-qdrant/.venv/lib/python3.10/site-packages/pydantic/main.py", line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for QdrantSettings
  Value error, If 'local_path' is set, 'location' and 'api_key' must be None. [type=value_error, input_value={'QDRANT_URL': 'http://lo...ANT_LOCAL_PATH': 'None'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error

After

$ QDRANT_URL="http://localhost:6333" COLLECTION_NAME="my-collection" QDRANT_LOCAL_PATH=None uv run
mcp-server-qdrant --transport sse
[07/25/25 21:47:25] INFO     Starting MCP server 'mcp-server-qdrant' with transport 'sse' on http://127.0.0.1:8000/sse                               server.py:1210
INFO:FastMCP.fastmcp.server.server:Starting MCP server 'mcp-server-qdrant' with transport 'sse' on http://127.0.0.1:8000/sse
INFO:     Started server process [10725]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

Why?

I plan to add Qdrant MCP to Docker MCP Registry. The problem is that the Docker MCP Registry's server configuration file server.yaml needs to specify all environment variables (options) for that MCP (Qdrant MCP).

@MH0386
MH0386 marked this pull request as ready for review July 25, 2025 20:16
@MH0386 MH0386 changed the title Add _env_parse_none_str configuration to QdrantSettings Add env_parse_none_str configuration to QdrantSettings Jul 31, 2025
@MH0386 MH0386 changed the title Add env_parse_none_str configuration to QdrantSettings Enhance environment variable parsing Jul 31, 2025
mahmoudimus pushed a commit to mahmoudimus/mcp-server-qdrant that referenced this pull request Nov 17, 2025
This commit consolidates changes from PRs qdrant#92, qdrant#75, qdrant#77, qdrant#90, qdrant#20, qdrant#89, qdrant#78, qdrant#76, and qdrant#68:

Infrastructure & Configuration (PR qdrant#75, qdrant#77):
- Upgrade Dockerfile to Python 3.13-slim
- Use UV 0.8.3 from official image
- Add FASTMCP_HOST="0.0.0.0" for container networking
- Add SettingsConfigDict for proper None value parsing

New Embedding Providers (PR qdrant#76, qdrant#92):
- Add Model2Vec support for fast, lightweight embeddings
- Add OpenAI-compatible API support (oai_compat)
- New settings: OAI_COMPAT_ENDPOINT, OAI_COMPAT_API_KEY, OAI_COMPAT_VEC_SIZE

Unnamed Vectors & Multiple Collections (PR qdrant#78):
- Add support for Qdrant unnamed vectors
- Create UnnamedVectorProvider wrapper
- Add USE_UNNAMED_VECTORS and COLLECTION_NAMES settings
- Update qdrant.py to handle both named and unnamed vectors
- Add __main__.py for python -m execution

Hybrid Search (PR qdrant#90):
- Implement hybrid search combining dense and sparse vectors
- Add find_hybrid() method with RRF and DBSF fusion methods
- New tool: qdrant-hybrid-find
- Add SPARSE_EMBEDDING_MODEL setting
- Support configurable limits for dense, sparse, and final results

Optional Collection Names (PR qdrant#89):
- Make collection_name parameter optional in store() and find()
- Use default collection when not specified
- Simplify tool usage with fallback to COLLECTION_NAME env var

Additional Tools (PR qdrant#68):
- Add qdrant-get-point: Retrieve point by ID
- Add qdrant-delete-point: Delete point by ID
- Add qdrant-update-point-payload: Update point metadata
- Add qdrant-get-collections: List all collections
- Add qdrant-get-collection-details: Get collection info
- Implement corresponding methods in QdrantConnector

Documentation:
- Update README with all new features
- Document new embedding providers
- Add examples for unnamed vectors and multiple collections
- Update environment variables table
- Document hybrid search functionality
- Expand tools documentation

Dependencies:
- Add model2vec==0.6.0
- Add openai>=1.109.1
mahmoudimus added a commit to mahmoudimus/mcp-server-qdrant that referenced this pull request Nov 17, 2025
This commit consolidates changes from PRs qdrant#92, qdrant#75, qdrant#77, qdrant#90, qdrant#20, qdrant#89, qdrant#78, qdrant#76, and qdrant#68:

Infrastructure & Configuration (PR qdrant#75, qdrant#77):
- Upgrade Dockerfile to Python 3.13-slim
- Use UV 0.8.3 from official image
- Add FASTMCP_HOST="0.0.0.0" for container networking
- Add SettingsConfigDict for proper None value parsing

New Embedding Providers (PR qdrant#76, qdrant#92):
- Add Model2Vec support for fast, lightweight embeddings
- Add OpenAI-compatible API support (oai_compat)
- New settings: OAI_COMPAT_ENDPOINT, OAI_COMPAT_API_KEY, OAI_COMPAT_VEC_SIZE

Unnamed Vectors & Multiple Collections (PR qdrant#78):
- Add support for Qdrant unnamed vectors
- Create UnnamedVectorProvider wrapper
- Add USE_UNNAMED_VECTORS and COLLECTION_NAMES settings
- Update qdrant.py to handle both named and unnamed vectors
- Add __main__.py for python -m execution

Hybrid Search (PR qdrant#90):
- Implement hybrid search combining dense and sparse vectors
- Add find_hybrid() method with RRF and DBSF fusion methods
- New tool: qdrant-hybrid-find
- Add SPARSE_EMBEDDING_MODEL setting
- Support configurable limits for dense, sparse, and final results

Optional Collection Names (PR qdrant#89):
- Make collection_name parameter optional in store() and find()
- Use default collection when not specified
- Simplify tool usage with fallback to COLLECTION_NAME env var

Additional Tools (PR qdrant#68):
- Add qdrant-get-point: Retrieve point by ID
- Add qdrant-delete-point: Delete point by ID
- Add qdrant-update-point-payload: Update point metadata
- Add qdrant-get-collections: List all collections
- Add qdrant-get-collection-details: Get collection info
- Implement corresponding methods in QdrantConnector

Documentation:
- Update README with all new features
- Document new embedding providers
- Add examples for unnamed vectors and multiple collections
- Update environment variables table
- Document hybrid search functionality
- Expand tools documentation

Dependencies:
- Add model2vec==0.6.0
- Add openai>=1.109.1

Co-authored-by: Claude <noreply@anthropic.com>
@chadha-sridi

Copy link
Copy Markdown
Contributor

Thanks @MH0386. The empty QDRANT_URL and QDRANT_API_KEY came from the Dockerfile, which set them to "". #214 stops setting them, so local mode works in Docker without changing how settings are read. Closing in favor of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants