Compare commits

22 Commits

Author SHA1 Message Date
jcabillot 33f2ee388f Merge pull request 'chore(deps): update dependency python to 3.14' (#14) from renovate/python-3.x into main
Docker Build and Push / test (push) Successful in 1m32s
Docker Build and Push / integration-test (push) Successful in 1m58s
Docker Build and Push / build (push) Successful in 4m5s
Reviewed-on: #14
2026-06-12 10:54:18 -04:00
jcabillot 0d88ec0354 Merge pull request 'chore(deps): pin dependencies' (#13) from renovate/pin-dependencies into main
Docker Build and Push / test (push) Successful in 14s
Docker Build and Push / integration-test (push) Failing after 32s
Docker Build and Push / build (push) Has been skipped
Reviewed-on: #13
2026-06-12 09:05:13 -04:00
renovate b20a96f2c4 chore(deps): update dependency python to 3.14
Docker Build and Push / test (pull_request) Successful in 1m20s
Docker Build and Push / integration-test (pull_request) Successful in 2m4s
Docker Build and Push / build (pull_request) Successful in 3m48s
2026-06-12 12:56:43 +00:00
renovate f06a391e7d chore(deps): pin dependencies
Docker Build and Push / test (pull_request) Successful in 47s
Docker Build and Push / integration-test (pull_request) Successful in 1m1s
Docker Build and Push / build (pull_request) Successful in 1m14s
2026-06-12 12:56:29 +00:00
jcabillot 482e97fd2d Merge pull request 'chore: add unit tests for pure functions + CI test job' (#11) from chore/add-tests into main
Docker Build and Push / integration-test (push) Failing after 7s
Docker Build and Push / test (push) Successful in 17s
Docker Build and Push / build (push) Has been skipped
Reviewed-on: #11
2026-06-12 08:50:30 -04:00
cloudix_mcp_server 30ac4ae9ca fix: correct integration test assertions for semantic search
Docker Build and Push / test (pull_request) Successful in 14s
Docker Build and Push / integration-test (pull_request) Successful in 1m44s
Docker Build and Push / build (pull_request) Successful in 1m12s
- test_search_by_content: format_search_result() does not include
  body_text, so check for the expected message_id instead.
- test_search_no_results: vector cosine similarity always returns
  nearest neighbors; use a date filter far in the future to
  guarantee zero results instead.
2026-06-12 08:25:52 -04:00
cloudix_mcp_server d784cd9fba fix: share job container network with Qdrant
Docker Build and Push / test (pull_request) Successful in 13s
Docker Build and Push / integration-test (pull_request) Failing after 1m49s
Docker Build and Push / build (pull_request) Has been skipped
docker run -d publishes ports to the Docker bridge network, but the
job container runs on a different Gitea Actions network. This causes
Connection refused when tests try http://localhost:6333.

Use --network container:$(hostname) so Qdrant shares the job container's
network stack, making localhost reachable.
2026-06-12 08:14:35 -04:00
cloudix_mcp_server 14650619ad fix: replace Gitea services container with manual docker run for Qdrant
Docker Build and Push / test (pull_request) Successful in 1m33s
Docker Build and Push / integration-test (pull_request) Failing after 2m23s
Docker Build and Push / build (pull_request) Has been skipped
The Gitea Actions runner v1.0.8 fails to start the Qdrant service container
with 'exec: ./entrypoint.sh: no such file or directory'. This is a runner bug
with how it handles service container entrypoints/CMD.

Bypass the service container mechanism by starting Qdrant manually with
docker run -d and a health check wait loop.
2026-06-12 08:10:51 -04:00
cloudix_mcp_server 655af15121 fix: replace Gitea services container with manual docker run for Qdrant
The Gitea Actions runner v1.0.8 fails to start the Qdrant service container
with 'exec: ./entrypoint.sh: no such file or directory'. This is a runner bug
with how it handles service container entrypoints/CMD.

Bypass the service container mechanism by starting Qdrant manually with
docker run -d and a health check wait loop.
2026-06-12 08:08:18 -04:00
jcabillot e19a9515ca Merge pull request 'chore(deps): update dependency starlette to v1.3.1' (#12) from renovate/starlette-1.x into main
Docker Build and Push / build (push) Successful in 2m20s
Reviewed-on: #12
2026-06-12 07:32:39 -04:00
renovate 6c1e092bb4 chore(deps): update dependency starlette to v1.3.1
Docker Build and Push / build (pull_request) Successful in 1m10s
2026-06-12 09:35:42 +00:00
opencodecabilloteu 07e7de2811 chore: add integration tests with real Qdrant instance
Docker Build and Push / test (pull_request) Successful in 13s
Docker Build and Push / integration-test (pull_request) Failing after 8s
Docker Build and Push / build (pull_request) Has been skipped
- Integration tests for search_emails and read_email against live Qdrant
- Indexes 3 test emails, tests search by content/participant/date
- CI: new 'integration-test' job with qdrant service, runs before build
- Unit test job ignores integration test file
2026-06-11 12:30:59 +00:00
opencodecabilloteu 78ce84f4ff fix: set QDRANT_URL/COLLECTION_NAME env vars for test import
Docker Build and Push / test (pull_request) Successful in 1m30s
Docker Build and Push / build (pull_request) Successful in 1m11s
2026-06-11 12:24:46 +00:00
opencodecabilloteu 1700877918 chore: add unit tests for pure functions + CI test job
Docker Build and Push / test (pull_request) Failing after 1m35s
Docker Build and Push / build (pull_request) Has been skipped
- Unit tests for normalize_email_address, payload_matches_participant,
  format_search_result (9 test cases across 3 test classes)
- New 'test' job in CI workflow (runs before build)
- pytest.ini for pythonpath config
2026-06-11 12:18:20 +00:00
jcabillot 02eacb340e Merge pull request 'chore(deps): update dependency uvicorn to v0.49.0' (#10) from renovate/uvicorn-0.x into main
Docker Build and Push / build (push) Successful in 2m0s
Reviewed-on: #10
2026-06-11 08:01:43 -04:00
renovate 0346a69b4c chore(deps): update dependency uvicorn to v0.49.0
Docker Build and Push / build (pull_request) Successful in 1m10s
2026-06-11 11:58:27 +00:00
jcabillot ddb801a1e8 Merge pull request 'chore(deps): update dependency starlette to v1.3.0' (#9) from renovate/starlette-1.x into main
Docker Build and Push / build (push) Successful in 1m59s
Reviewed-on: #9
2026-06-11 07:46:20 -04:00
jcabillot 6347071a07 Merge pull request 'chore(config): migrate Renovate config' (#6) from renovate/migrate-config into main
Docker Build and Push / build (push) Successful in 1m57s
Reviewed-on: #6
2026-06-11 07:41:42 -04:00
jcabillot 3f51d7d559 Merge pull request 'chore(deps): update dependency mcp to v1.27.2' (#8) from renovate/mcp-1.x into main
Docker Build and Push / build (push) Successful in 2m26s
Reviewed-on: #8
2026-06-11 07:10:02 -04:00
renovate a837e58376 chore(deps): update dependency starlette to v1.3.0
Docker Build and Push / build (pull_request) Successful in 1m8s
2026-06-11 08:15:30 +00:00
renovate 29d69c589e chore(config): migrate config renovate.json
Docker Build and Push / build (pull_request) Successful in 1m18s
2026-06-11 03:14:03 +00:00
renovate f14bb778b8 chore(deps): update dependency mcp to v1.27.2
Docker Build and Push / build (pull_request) Successful in 1m25s
2026-06-11 03:13:38 +00:00
6 changed files with 356 additions and 14 deletions
+47 -6
View File
@@ -9,11 +9,55 @@ on:
- cron: '0 0 * * *'
jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14"
- name: Install dependencies
run: |
pip install -r requirements.txt pytest
- name: Run unit tests
run: pytest tests/ -v --ignore=tests/test_integration.py
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Start Qdrant
run: |
docker run -d --name qdrant \
--network "container:$(hostname)" \
docker.io/qdrant/qdrant:latest
- name: Wait for Qdrant
run: |
for i in $(seq 1 30); do
curl -s http://localhost:6333/healthz && echo "QDRANT ready" && break
echo "Waiting for Qdrant... ($i/30)"
sleep 1
done
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14"
- name: Install dependencies
run: |
pip install -r requirements.txt pytest
- name: Run integration tests
run: pytest tests/test_integration.py -v
env:
QDRANT_URL: http://localhost:6333
COLLECTION_NAME: test_mcp_maildir
build:
runs-on: ubuntu-latest
needs: [test, integration-test]
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
@@ -31,9 +75,6 @@ jobs:
with:
images: jcabillot/mcp-maildir
tags: |
#type=ref,event=branch
#type=ref,event=pr
#type=sha
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Build and push
+3
View File
@@ -0,0 +1,3 @@
[pytest]
testpaths = tests
pythonpath = src
+4 -5
View File
@@ -1,12 +1,11 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"regexManagers": [
"customManagers": [
{
"customType": "regex",
"description": "Track qdrant/qdrant Docker image from docker-compose.yml (native manager missed it)",
"fileMatch": ["^docker-compose\\.ya?ml$"],
"matchStrings": [
"image:\\s*(?:docker\\.io/)?qdrant/qdrant:(?<currentValue>[^\\s]+)"
],
"managerFilePatterns": ["/^docker-compose\\.ya?ml$/"],
"matchStrings": ["image:\\s*(?:docker\\.io/)?qdrant/qdrant:(?<currentValue>[^\\s]+)"],
"depNameTemplate": "qdrant/qdrant",
"datasourceTemplate": "docker"
}
+3 -3
View File
@@ -1,9 +1,9 @@
mcp==1.26.0
mcp==1.27.2
fastmcp==3.4.2
qdrant-client==1.18.0
fastembed==0.8.0
python-dotenv==1.2.2
uvicorn==0.41.0
starlette==1.2.1
uvicorn==0.49.0
starlette==1.3.1
beautifulsoup4==4.15.0
python-dateutil==2.9.0.post0
+189
View File
@@ -0,0 +1,189 @@
"""Integration tests for mcp-maildir with a real Qdrant instance."""
import os
import uuid
import pytest
os.environ["QDRANT_URL"] = "http://localhost:6333"
os.environ["COLLECTION_NAME"] = "test_mcp_maildir"
os.environ["EMBEDDING_MODEL_NAME"] = "BAAI/bge-small-en-v1.5"
from server import get_qdrant_client, get_embedding_model, search_emails, read_email
from qdrant_client.http import models
TEST_EMAILS = [
{
"message_id": "<test-001@example.com>",
"date": "2026-01-15T10:00:00",
"sender": "alice@example.com",
"sender_raw": "Alice <alice@example.com>",
"receiver": "bob@example.com",
"receiver_raw": "Bob <bob@example.com>",
"subject": "Hello World",
"body_text": "This is a test email about Python programming and vector databases.",
"attachments": [],
},
{
"message_id": "<test-002@example.com>",
"date": "2026-01-16T14:30:00",
"sender": "carol@other.com",
"sender_raw": "Carol <carol@other.com>",
"receiver": "alice@example.com",
"receiver_raw": "Alice <alice@example.com>",
"subject": "Qdrant setup help",
"body_text": "Can you help me set up Qdrant for semantic email search?",
"attachments": ["screenshot.png"],
},
{
"message_id": "<test-003@example.com>",
"date": "2026-02-01T09:00:00",
"sender": "bob@example.com",
"sender_raw": "Bob <bob@example.com>",
"receiver": "alice@example.com",
"receiver_raw": "Alice <alice@example.com>",
"subject": "Meeting next week",
"body_text": "Let's discuss the project roadmap and data pipeline.",
"attachments": [],
},
]
@pytest.fixture(scope="module")
def qdrant_setup():
"""Create collection and index test emails once per test run."""
client = get_qdrant_client()
model = get_embedding_model()
collection_name = os.environ["COLLECTION_NAME"]
# Clean up from previous runs
try:
client.delete_collection(collection_name)
except Exception:
pass
# Create collection
probe = next(iter(model.embed(["dimension_probe"])))
client.create_collection(
collection_name=collection_name,
vectors_config=models.VectorParams(
size=len(probe), distance=models.Distance.COSINE
),
)
# Index test emails
for email in TEST_EMAILS:
vector_text = (
f"Date: {email['date']}\n"
f"From: {email['sender']}\n"
f"To: {email['receiver']}\n"
f"Subject: {email['subject']}\n\n"
f"{email['body_text']}\n\n"
f"Attachments: {', '.join(email['attachments']) if email['attachments'] else 'None'}"
)
vector = list(model.embed([vector_text]))[0].tolist()
# Create payload indexes on first upsert
client.create_payload_index(
collection_name=collection_name,
field_name="sender",
field_schema=models.PayloadSchemaType.KEYWORD,
)
client.create_payload_index(
collection_name=collection_name,
field_name="receiver",
field_schema=models.PayloadSchemaType.KEYWORD,
)
client.create_payload_index(
collection_name=collection_name,
field_name="date",
field_schema=models.PayloadSchemaType.DATETIME,
)
client.upsert(
collection_name=collection_name,
points=[
models.PointStruct(
id=str(uuid.uuid5(uuid.NAMESPACE_OID, email["message_id"])),
vector=vector,
payload={
"message_id": email["message_id"],
"date": email["date"],
"sender": email["sender"],
"sender_raw": email["sender_raw"],
"receiver": email["receiver"],
"receiver_raw": email["receiver_raw"],
"subject": email["subject"],
"body_text": email["body_text"],
"attachments": email["attachments"],
},
)
],
)
yield client
# Cleanup
try:
client.delete_collection(collection_name)
except Exception:
pass
class TestSearchEmails:
def test_search_by_content(self, qdrant_setup):
"""Semantic search returns the most relevant email first.
Searching for 'Python programming' should match email 001
which discusses Python and vector databases.
"""
result = search_emails(query="Python programming")
assert result["count"] >= 1
assert "results" in result
# The top result should be email 001 (most semantically relevant)
messages = [r["message_id"] for r in result["results"]]
assert "<test-001@example.com>" in messages
def test_search_with_participant_filter(self, qdrant_setup):
"""Search emails sent by alice."""
result = search_emails(query="help", participant="alice@example.com")
assert result["count"] >= 1
messages = [r["message_id"] for r in result["results"]]
assert "<test-001@example.com>" in messages
def test_search_with_date_filter(self, qdrant_setup):
"""Search emails after a specific date."""
result = search_emails(query="meeting", start_date="2026-02-01")
assert result["count"] >= 1
for r in result["results"]:
date = r.get("date", "")
assert date >= "2026-02-01"
def test_search_no_results_by_date(self, qdrant_setup):
"""Search with a filter that matches no emails returns empty results.
With semantic (vector) search, any text query always has nearest
neighbors, so we use a date filter that matches nothing instead.
"""
result = search_emails(
query="anything",
start_date="2099-01-01",
end_date="2099-12-31",
)
assert result["count"] == 0
assert result["results"] == []
class TestReadEmail:
def test_read_existing_email(self, qdrant_setup):
"""Read an email by its message_id."""
result = read_email(message_id="<test-001@example.com>")
assert "error" not in result
assert result["message_id"] == "<test-001@example.com>"
assert "This is a test email" in result.get("body_text", "")
def test_read_nonexistent_email(self, qdrant_setup):
"""Read an email that doesn't exist."""
result = read_email(message_id="<nonexistent@ghost.com>")
assert "error" in result
assert "No email found" in result["error"]
+110
View File
@@ -0,0 +1,110 @@
"""Unit tests for mcp-maildir server pure functions."""
import os
os.environ["QDRANT_URL"] = "http://localhost:6333"
os.environ["COLLECTION_NAME"] = "test"
from server import (
normalize_email_address,
payload_matches_participant,
format_search_result,
)
class TestNormalizeEmailAddress:
def test_empty_value(self):
assert normalize_email_address("") == ""
assert normalize_email_address(None) == ""
def test_simple_email(self):
assert normalize_email_address("user@example.com") == "user@example.com"
def test_display_name_with_email(self):
assert normalize_email_address("John Doe <john@example.com>") == "john@example.com"
def test_whitespace_and_case(self):
assert normalize_email_address(" USER@Example.COM ") == "user@example.com"
def test_invalid_email_fallback(self):
result = normalize_email_address("not-an-email")
# Returns stripped lowercase version of the input
assert result == "not-an-email"
class TestPayloadMatchesParticipant:
def test_sender_match_normalized(self):
payload = {"sender": "alice@example.com"}
assert payload_matches_participant(payload, "alice@example.com") is True
def test_receiver_match_normalized(self):
payload = {"receiver": "bob@example.com"}
assert payload_matches_participant(payload, "bob@example.com") is True
def test_sender_raw_match(self):
payload = {"sender_raw": "alice@other.com"}
assert payload_matches_participant(payload, "alice@other.com") is True
def test_no_match(self):
payload = {"sender": "alice@example.com", "receiver": "bob@example.com"}
assert payload_matches_participant(payload, "carol@example.com") is False
def test_display_name_in_sender(self):
payload = {"sender": "Alice <alice@example.com>"}
assert payload_matches_participant(payload, "alice@example.com") is True
def test_display_name_in_receiver(self):
payload = {"receiver": "Bob Smith <bob@example.com>"}
assert payload_matches_participant(payload, "bob@example.com") is True
def test_empty_payload(self):
assert payload_matches_participant({}, "someone@example.com") is False
def test_case_insensitive(self):
payload = {"sender": "ALICE@EXAMPLE.COM"}
assert payload_matches_participant(payload, "alice@example.com") is True
class TestFormatSearchResult:
def test_basic_formatting(self):
class MockPoint:
payload = {
"message_id": "<abc@def>",
"date": "2026-01-15T10:00:00",
"sender": "alice@example.com",
"receiver": "bob@example.com",
"subject": "Hello",
"attachments": ["file.pdf"],
}
score = 0.95
result = format_search_result(MockPoint())
assert result["message_id"] == "<abc@def>"
assert result["date"] == "2026-01-15T10:00:00"
assert result["sender"] == "alice@example.com"
assert result["receiver"] == "bob@example.com"
assert result["subject"] == "Hello"
assert result["attachments"] == ["file.pdf"]
assert result["score"] == 0.95
def test_empty_payload(self):
class MockPoint:
payload = None
score = None
result = format_search_result(MockPoint())
assert result["message_id"] is None
assert result["score"] is None
assert result["attachments"] == []
def test_missing_fields(self):
class MockPoint:
payload = {"message_id": "<123>"}
score = 0.5
result = format_search_result(MockPoint())
assert result["message_id"] == "<123>"
assert result["date"] is None
assert result["sender"] is None
assert result["receiver"] is None
assert result["subject"] is None
assert result["attachments"] == []