update-searchable-attributes
Modify searchable attributes in Meilisearch indexes to refine search functionality and improve query results accuracy using JSON settings.
Instructions
Update the searchable attributes setting
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier of the index | |
| value | Yes | JSON value for the setting |
Implementation Reference
- src/tools/settings-tools.ts:236-248 (handler)The execution handler for the 'update-searchable-attributes' tool (shared with other update tools). Parses the 'value' parameter as JSON and performs a PUT request to `/indexes/{indexUid}/settings/searchable-attributes` using apiClient.async ({ indexUid, value }) => { try { // Parse the value string to ensure it's valid JSON const parsedValue = JSON.parse(value); const response = await apiClient.put(`/indexes/${indexUid}/settings/${endpoint}`, parsedValue); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/settings-tools.ts:232-235 (schema)Zod input schema for the tool parameters: indexUid (string, Meilisearch index UID) and value (string, JSON-serialized value to set for searchable attributes).{ indexUid: z.string().describe("Unique identifier of the index"), value: z.string().describe("JSON value for the setting"), },
- src/tools/settings-tools.ts:227-250 (registration)Dynamic registration loop that calls server.tool for 'update-searchable-attributes' (using endpoint 'searchable-attributes') and other update tools, providing schema and handler.// Create an update tool for each specific setting updateSettingsTools.forEach(({ name, endpoint, description }) => { server.tool( name, description, { indexUid: z.string().describe("Unique identifier of the index"), value: z.string().describe("JSON value for the setting"), }, async ({ indexUid, value }) => { try { // Parse the value string to ensure it's valid JSON const parsedValue = JSON.parse(value); const response = await apiClient.put(`/indexes/${indexUid}/settings/${endpoint}`, parsedValue); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } ); });
- src/tools/settings-tools.ts:170-174 (helper)Configuration object in updateSettingsTools array that defines the tool name, Meilisearch endpoint, and description for 'update-searchable-attributes'.{ name: "update-searchable-attributes", endpoint: "searchable-attributes", description: "Update the searchable attributes setting", },
- src/index.ts:67-67 (registration)Top-level registration call in main server setup that invokes registerSettingsTools(server), thereby registering the 'update-searchable-attributes' tool.registerSettingsTools(server);