create-key
Generate API keys with specific permissions and expiration for managing Meilisearch indexes, ensuring controlled access and security.
Instructions
Create a new API key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| actions | Yes | ||
| description | No | ||
| expiresAt | No | ||
| indexes | Yes |
Implementation Reference
- src/meilisearch_mcp/server.py:653-664 (handler)Executes the 'create-key' tool by calling KeyManager.create_key with parsed arguments and returns the result.elif name == "create-key": key = self.meili_client.keys.create_key( { "description": arguments.get("description"), "actions": arguments["actions"], "indexes": arguments["indexes"], "expiresAt": arguments.get("expiresAt"), } ) return [ types.TextContent(type="text", text=f"Created API key: {key}") ]
- src/meilisearch_mcp/server.py:314-328 (registration)Registers the 'create-key' tool in the MCP server's list_tools handler, defining its name, description, and input schema.types.Tool( name="create-key", description="Create a new API key", inputSchema={ "type": "object", "properties": { "description": {"type": "string"}, "actions": {"type": "array", "items": {"type": "string"}}, "indexes": {"type": "array", "items": {"type": "string"}}, "expiresAt": {"type": "string"}, }, "required": ["actions", "indexes"], "additionalProperties": False, }, ),
- src/meilisearch_mcp/keys.py:26-31 (helper)KeyManager helper method that wraps the Meilisearch client's create_key method to create a new API key.def create_key(self, options: Dict[str, Any]) -> Dict[str, Any]: """Create a new API key""" try: return self.client.create_key(options) except Exception as e: raise Exception(f"Failed to create key: {str(e)}")