Skip to content

Add delete-index tool #24

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

Closed
wants to merge 1 commit into from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ npx @modelcontextprotocol/inspector python -m src.meilisearch_mcp
### Index Management
- `create-index`: Create a new index with optional primary key
- `list-indexes`: List all available indexes
- `delete-index`: Delete an existing index
- `get-index-metrics`: Get detailed metrics for a specific index

### Document Operations
Expand Down
18 changes: 18 additions & 0 deletions src/meilisearch_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ async def handle_list_tools() -> list[types.Tool]:
description="List all Meilisearch indexes",
inputSchema={"type": "object", "properties": {}},
),
types.Tool(
name="delete-index",
description="Delete a Meilisearch index",
inputSchema={
"type": "object",
"properties": {"uid": {"type": "string"}},
"required": ["uid"],
},
),
types.Tool(
name="get-documents",
description="Get documents from an index",
Expand Down Expand Up @@ -317,6 +326,15 @@ async def handle_call_tool(
)
]

elif name == "delete-index":
await self.meili_client.indexes.delete_index(arguments["uid"])
return [
types.TextContent(
type="text",
text=f"Successfully deleted index: {arguments['uid']}",
)
]

elif name == "get-documents":
documents = await self.meili_client.documents.get_documents(
arguments["indexUid"],
Expand Down
5 changes: 5 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import importlib
import pytest

if importlib.util.find_spec("mcp") is None: # pragma: no cover - dependency missing
pytest.skip("mcp dependency not installed", allow_module_level=True)

from src.meilisearch_mcp.server import create_server


Expand Down