Skip to content

Commit 5051a57

Browse files
📝 Add docstrings to feature/custom-user-agent
Docstrings generation was requested by @tpayet. * #45 (comment) The following files were modified: * `src/meilisearch_mcp/client.py` * `tests/test_user_agent.py`
1 parent 07c3af4 commit 5051a57

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/meilisearch_mcp/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ class MeilisearchClient:
1818
def __init__(
1919
self, url: str = "http://localhost:7700", api_key: Optional[str] = None
2020
):
21-
"""Initialize Meilisearch client"""
21+
"""
22+
Initializes a MeilisearchClient instance for interacting with a Meilisearch server.
23+
24+
Creates an internal client with a custom user agent and sets up managers for indexes, documents, settings, tasks, keys, and monitoring.
25+
"""
2226
self.url = url
2327
self.api_key = api_key
2428
# Add custom user agent to identify this as Meilisearch MCP

tests/test_user_agent.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66

77
def test_meilisearch_client_sets_custom_user_agent():
8-
"""Test that MeilisearchClient initializes with custom user agent"""
8+
"""
9+
Verifies that MeilisearchClient sets a custom user agent string during initialization.
10+
11+
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.
12+
"""
913
with patch("src.meilisearch_mcp.client.Client") as mock_client:
1014
# Create a MeilisearchClient instance
1115
client = MeilisearchClient(url="http://localhost:7700", api_key="test_key")
@@ -19,7 +23,11 @@ def test_meilisearch_client_sets_custom_user_agent():
1923

2024

2125
def test_user_agent_includes_correct_version():
22-
"""Test that the user agent includes the correct version from __version__.py"""
26+
"""
27+
Verifies that MeilisearchClient sets the user agent to include the correct version string.
28+
29+
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.
30+
"""
2331
with patch("src.meilisearch_mcp.client.Client") as mock_client:
2432
client = MeilisearchClient()
2533

0 commit comments

Comments
 (0)