Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ jobs:
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

50 changes: 25 additions & 25 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
version_changed: ${{ steps.check_version.outputs.version_changed }}
current_version: ${{ steps.get_version.outputs.current_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Get current version
id: get_version
run: |
CURRENT_VERSION=$(grep "version = " pyproject.toml | cut -d'"' -f2)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT

- name: Check if version changed
id: check_version
run: |
Expand All @@ -40,23 +40,23 @@ jobs:
url: https://pypi.org/p/meilisearch-mcp
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build

- name: Build package
run: python -m build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand All @@ -65,24 +65,24 @@ jobs:

build-and-publish-docker-latest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push latest Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
Expand All @@ -95,28 +95,28 @@ jobs:
needs: check-version
if: needs.check-version.outputs.version_changed == 'true'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push versioned Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: getmeili/meilisearch-mcp:${{ needs.check-version.outputs.current_version }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max
20 changes: 10 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
jobs:
test:
runs-on: ubuntu-latest

services:
meilisearch:
image: getmeili/meilisearch:v1.6
image: getmeili/meilisearch:v1.16
ports:
- 7700:7700
env:
Expand All @@ -23,30 +23,30 @@ jobs:
--health-interval 30s
--health-timeout 10s
--health-retries 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -e .

- name: Format code with black
run: |
black src/
black tests/

- name: Wait for Meilisearch to be ready
run: |
timeout 60 bash -c 'until curl -f http://localhost:7700/health; do sleep 2; done'

- name: Run tests
env:
MEILI_HTTP_ADDR: http://localhost:7700
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Use Python 3.12 slim image for smaller size
FROM python:3.12-slim
FROM python:3.13-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get dist-upgrade -y && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*

# Install uv for faster Python package management
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
Expand All @@ -25,4 +25,4 @@ ENV MEILI_HTTP_ADDR=http://meilisearch:7700
ENV MEILI_MASTER_KEY=""

# Run the MCP server
CMD ["python", "-m", "src.meilisearch_mcp"]
CMD ["uv", "run", "python", "-m", "src.meilisearch_mcp"]
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ version = "0.5.0"
description = "MCP server for Meilisearch"
requires-python = ">=3.10"
dependencies = [
"meilisearch>=0.33.0",
"mcp>=0.1.0",
"httpx>=0.24.0",
"pydantic>=2.0.0"
"meilisearch>=0.36.0",
"mcp>=1.12.4",
"httpx>=0.28.1",
"pydantic>=2.11.7",
]

[build-system]
Expand Down
8 changes: 4 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest>=7.0.0
pytest-asyncio>=0.25.0
black>=23.0.0
mcp>=1.2.1
pytest>=8.4.1
pytest-asyncio>=1.1.0
black>=25.1.0
mcp>=1.12.4
18 changes: 10 additions & 8 deletions src/meilisearch_mcp/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@ def get_documents(
params["limit"] = limit
if fields is not None:
params["fields"] = fields

result = index.get_documents(params if params else {})

# Convert meilisearch model objects to JSON-serializable format
if hasattr(result, '__dict__'):
if hasattr(result, "__dict__"):
result_dict = result.__dict__.copy()
# Convert individual document objects in results if they exist
if 'results' in result_dict and isinstance(result_dict['results'], list):
if "results" in result_dict and isinstance(
result_dict["results"], list
):
serialized_results = []
for doc in result_dict['results']:
if hasattr(doc, '__dict__'):
for doc in result_dict["results"]:
if hasattr(doc, "__dict__"):
# Extract the actual document data
doc_dict = doc.__dict__.copy()
# Look for private attributes that might contain the actual data
for key, value in doc_dict.items():
if key.startswith('_') and isinstance(value, dict):
if key.startswith("_") and isinstance(value, dict):
# Use the dict content instead of the wrapper
serialized_results.append(value)
break
Expand All @@ -50,7 +52,7 @@ def get_documents(
serialized_results.append(doc_dict)
else:
serialized_results.append(doc)
result_dict['results'] = serialized_results
result_dict["results"] = serialized_results
return result_dict
else:
return result
Expand Down
4 changes: 1 addition & 3 deletions src/meilisearch_mcp/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class KeyManager:
def __init__(self, client: Client):
self.client = client

def get_keys(
self, parameters: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
def get_keys(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
"""Get list of API keys"""
try:
return self.client.get_keys(parameters)
Expand Down
4 changes: 2 additions & 2 deletions src/meilisearch_mcp/logging.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import sys
import json
from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path
from typing import Optional, Dict, Any
import threading
Expand Down Expand Up @@ -97,7 +97,7 @@ def _setup_logger(self, log_dir: Optional[str]):
def _log(self, level: str, msg: str, **kwargs):
"""Create structured log entry"""
log_entry = {
"timestamp": datetime.utcnow().isoformat(),
"timestamp": datetime.now(timezone.utc).isoformat(),
"level": level,
"message": msg,
**kwargs,
Expand Down
2 changes: 1 addition & 1 deletion src/meilisearch_mcp/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_health_status(self) -> HealthStatus:
"""Get comprehensive health status"""
try:
# Get various stats to build health picture
stats = self.client.get_stats()
stats = self.client.get_all_stats()
indexes = self.client.get_indexes()

indexes_info = []
Expand Down
4 changes: 1 addition & 3 deletions src/meilisearch_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,7 @@ async def handle_call_tool(
]

elif name == "delete-index":
result = self.meili_client.indexes.delete_index(
arguments["uid"]
)
result = self.meili_client.indexes.delete_index(arguments["uid"])
return [
types.TextContent(
type="text",
Expand Down
4 changes: 1 addition & 3 deletions src/meilisearch_mcp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def get_task(self, task_uid: int) -> Dict[str, Any]:
except Exception as e:
raise Exception(f"Failed to get task: {str(e)}")

def get_tasks(
self, parameters: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
def get_tasks(self, parameters: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
"""Get list of tasks with optional filters"""
try:
tasks = self.client.get_tasks(parameters)
Expand Down
Loading