Skip to content
Closed
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
6 changes: 5 additions & 1 deletion src/meilisearch_mcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class MeilisearchClient:
def __init__(
self, url: str = "http://localhost:7700", api_key: Optional[str] = None
):
"""Initialize Meilisearch client"""
"""
Initializes a MeilisearchClient instance for interacting with a Meilisearch server.

Creates an internal client with a custom user agent and sets up managers for indexes, documents, settings, tasks, keys, and monitoring.
"""
self.url = url
self.api_key = api_key
# Add custom user agent to identify this as Meilisearch MCP
Expand Down
12 changes: 10 additions & 2 deletions tests/test_user_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@


def test_meilisearch_client_sets_custom_user_agent():
"""Test that MeilisearchClient initializes with custom user agent"""
"""
Verifies that MeilisearchClient sets a custom user agent string during initialization.

This test ensures that the internal Client is instantiated with the correct URL, API key, and a client_agents tuple containing the package name and version.
"""
with patch("src.meilisearch_mcp.client.Client") as mock_client:
# Create a MeilisearchClient instance
client = MeilisearchClient(url="http://localhost:7700", api_key="test_key")
Expand All @@ -19,7 +23,11 @@ def test_meilisearch_client_sets_custom_user_agent():


def test_user_agent_includes_correct_version():
"""Test that the user agent includes the correct version from __version__.py"""
"""
Verifies that MeilisearchClient sets the user agent to include the correct version string.

This test ensures that the internal client is initialized with a user agent tuple containing the package name and the version string from the __version__ module.
"""
with patch("src.meilisearch_mcp.client.Client") as mock_client:
client = MeilisearchClient()

Expand Down