Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit to ensure consistent formatting #13

Merged
merged 1 commit into from
Mar 5, 2025
Merged
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
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.10

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
autoupdate_schedule: quarterly
# submodules: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-ast
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: "Sort Imports"
args: [ "--profile", "black" ]
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ To use this server with the Claude Desktop app, add the following configuration
"qdrant": {
"command": "uvx",
"args": [
"mcp-server-qdrant",
"--qdrant-url",
"mcp-server-qdrant",
"--qdrant-url",
"http://localhost:6333",
"--qdrant-api-key",
"--qdrant-api-key",
"your_api_key",
"--collection-name",
"your_collection_name"
Expand All @@ -68,8 +68,8 @@ To use this server with the Claude Desktop app, add the following configuration
}
```

Replace `http://localhost:6333`, `your_api_key` and `your_collection_name` with your Qdrant server URL, Qdrant API key
and collection name, respectively. The use of API key is optional, but recommended for security reasons, and depends on
Replace `http://localhost:6333`, `your_api_key` and `your_collection_name` with your Qdrant server URL, Qdrant API key
and collection name, respectively. The use of API key is optional, but recommended for security reasons, and depends on
the Qdrant server configuration.

This MCP server will automatically create a collection with the specified name if it doesn't exist.
Expand All @@ -87,7 +87,7 @@ To use a local mode of Qdrant, you can specify the path to the database using th
"qdrant": {
"command": "uvx",
"args": [
"mcp-server-qdrant",
"mcp-server-qdrant",
"--qdrant-local-path",
"/path/to/qdrant/database",
"--collection-name",
Expand All @@ -113,6 +113,6 @@ You cannot provide `QDRANT_URL` and `QDRANT_LOCAL_PATH` at the same time.

## License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software,
subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software,
subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project
repository.
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = ["pyright>=1.1.389", "pytest>=8.3.3", "ruff>=0.8.0"]
dev-dependencies = [
"pre-commit>=4.1.0",
"pyright>=1.1.389",
"pytest>=8.3.3",
"ruff>=0.8.0",
]

[project.scripts]
mcp-server-qdrant = "mcp_server_qdrant:main"
7 changes: 5 additions & 2 deletions src/mcp_server_qdrant/qdrant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional
from qdrant_client import AsyncQdrantClient, models

from qdrant_client import AsyncQdrantClient


class QdrantConnector:
Expand Down Expand Up @@ -27,7 +28,9 @@ def __init__(
# For the time being, FastEmbed models are the only supported ones.
# A list of all available models can be found here:
# https://qdrant.github.io/fastembed/examples/Supported_Models/
self._client = AsyncQdrantClient(location=qdrant_url, api_key=qdrant_api_key, path=qdrant_local_path)
self._client = AsyncQdrantClient(
location=qdrant_url, api_key=qdrant_api_key, path=qdrant_local_path
)
self._client.set_model(fastembed_model_name)

async def store_memory(self, information: str):
Expand Down
19 changes: 12 additions & 7 deletions src/mcp_server_qdrant/server.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncio
from typing import Optional

from mcp.server import Server, NotificationOptions
from mcp.server.models import InitializationOptions

import click
import mcp.types as types
import asyncio
import mcp
import mcp.types as types
from mcp.server import NotificationOptions, Server
from mcp.server.models import InitializationOptions

from .qdrant import QdrantConnector

Expand All @@ -29,7 +28,11 @@ def serve(
server = Server("qdrant")

qdrant = QdrantConnector(
qdrant_url, qdrant_api_key, collection_name, fastembed_model_name, qdrant_local_path
qdrant_url,
qdrant_api_key,
collection_name,
fastembed_model_name,
qdrant_local_path,
)

@server.list_tools()
Expand Down Expand Up @@ -151,7 +154,9 @@ def main(
):
# XOR of url and local path, since we accept only one of them
if not (bool(qdrant_url) ^ bool(qdrant_local_path)):
raise ValueError("Exactly one of qdrant-url or qdrant-local-path must be provided")
raise ValueError(
"Exactly one of qdrant-url or qdrant-local-path must be provided"
)

async def _run():
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
Expand Down
70 changes: 69 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading