From 5051a573d72aa2efab961b91231cb8f81da01558 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 13:13:37 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`feature?= =?UTF-8?q?/custom-user-agent`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @tpayet. * https://github.com/meilisearch/meilisearch-mcp/pull/45#issuecomment-2980124461 The following files were modified: * `src/meilisearch_mcp/client.py` * `tests/test_user_agent.py` --- src/meilisearch_mcp/client.py | 6 +++++- tests/test_user_agent.py | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/meilisearch_mcp/client.py b/src/meilisearch_mcp/client.py index c7c5b5a..19d0f22 100644 --- a/src/meilisearch_mcp/client.py +++ b/src/meilisearch_mcp/client.py @@ -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 diff --git a/tests/test_user_agent.py b/tests/test_user_agent.py index 9e701a5..ef68170 100644 --- a/tests/test_user_agent.py +++ b/tests/test_user_agent.py @@ -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") @@ -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()