-
Notifications
You must be signed in to change notification settings - Fork 23
Add custom user agent for Meilisearch MCP server #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __version__ = "0.5.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import pytest | ||
| from unittest.mock import patch, MagicMock | ||
| from src.meilisearch_mcp.client import MeilisearchClient | ||
| from src.meilisearch_mcp.__version__ import __version__ | ||
|
|
||
|
|
||
| def test_meilisearch_client_sets_custom_user_agent(): | ||
| """Test that MeilisearchClient initializes with custom user agent""" | ||
| with patch("src.meilisearch_mcp.client.Client") as mock_client: | ||
| # Create a MeilisearchClient instance | ||
| client = MeilisearchClient(url="http://localhost:7700", api_key="test_key") | ||
|
|
||
| # Verify that Client was called with the correct parameters | ||
| mock_client.assert_called_once_with( | ||
| "http://localhost:7700", | ||
| "test_key", | ||
| client_agents=("meilisearch-mcp", f"v{__version__}"), | ||
| ) | ||
|
|
||
|
|
||
| def test_user_agent_includes_correct_version(): | ||
| """Test that the user agent includes the correct version from __version__.py""" | ||
| with patch("src.meilisearch_mcp.client.Client") as mock_client: | ||
| client = MeilisearchClient() | ||
|
|
||
| # Extract the client_agents parameter from the call | ||
| call_args = mock_client.call_args | ||
| client_agents = call_args[1]["client_agents"] | ||
|
|
||
| # Verify format and version | ||
| assert client_agents[0] == "meilisearch-mcp" | ||
| assert client_agents[1] == "v0.5.0" | ||
| assert client_agents[1] == f"v{__version__}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch target should be the import path actually used by the code
MeilisearchClientlives inmeilisearch_mcp.client, notsrc.meilisearch_mcp.clientonce the package is installed. Patching the real module path avoids import-path-dependent breakage.📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.11.9)
24-24: Local variable
clientis assigned to but never usedRemove assignment to unused variable
client(F841)
🤖 Prompt for AI Agents