get-ranking-rules
Retrieve the ranking rules configuration for a Meilisearch index to understand how search results are prioritized and sorted.
Instructions
Get the ranking rules setting
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier of the index |
Implementation Reference
- src/tools/settings-tools.ts:155-164 (handler)Handler function implementing the core logic of the 'get-ranking-rules' tool. It makes an API call to retrieve the ranking-rules settings from Meilisearch for the specified index using the endpoint 'ranking-rules'.async ({ indexUid }) => { try { const response = await apiClient.get(`/indexes/${indexUid}/settings/${endpoint}`); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/settings-tools.ts:152-154 (schema)Input schema definition for the 'get-ranking-rules' tool, validating the required 'indexUid' parameter using Zod.{ indexUid: z.string().describe("Unique identifier of the index"), },
- src/tools/settings-tools.ts:110-114 (registration)Configuration object used in the dynamic registration process for the 'get-ranking-rules' tool, specifying its name, API endpoint segment, and description.{ name: "get-ranking-rules", endpoint: "ranking-rules", description: "Get the ranking rules setting", },
- src/tools/settings-tools.ts:147-166 (registration)Dynamic registration loop that registers the 'get-ranking-rules' tool (and other settings getters) on the MCP server using the configuration objects and shared schema/handler template.// Create a tool for each specific setting specificSettingsTools.forEach(({ name, endpoint, description }) => { server.tool( name, description, { indexUid: z.string().describe("Unique identifier of the index"), }, async ({ indexUid }) => { try { const response = await apiClient.get(`/indexes/${indexUid}/settings/${endpoint}`); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } ); });
- src/index.ts:67-67 (registration)Top-level call to register all settings tools, including 'get-ranking-rules', on the MCP server instance.registerSettingsTools(server);