update_preference
Modify user preferences like resume formats or communication styles to personalize AI assistant behavior and responses.
Instructions
Update a preference in Chen's context. Use when Chen expresses a new preference (e.g. resume format, communication style, tool choice).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Preference key, e.g. 'resumeFormat.style' or 'communication.tone' | |
| value | Yes | The value to set (will be parsed as JSON if possible) |
Implementation Reference
- src/storage/context-store.ts:112-125 (handler)The implementation of updatePreference, which handles updating a nested preference key in preferences.json.
export async function updatePreference(key: string, value: unknown): Promise<void> { const prefs = await loadJson<Record<string, unknown>>("preferences.json", {}); const keys = key.split("."); let target: Record<string, unknown> = prefs; for (let i = 0; i < keys.length - 1; i++) { const k = keys[i]; if (!(k in target) || typeof target[k] !== "object") { target[k] = {}; } target = target[k] as Record<string, unknown>; } target[keys[keys.length - 1]] = value; await saveJson("preferences.json", prefs); } - src/index.ts:156-180 (registration)The request handler logic for 'update_preference' in src/index.ts.
if (name === "update_preference") { const key = safeArgs.key as string; const valueStr = safeArgs.value as string; if (!key || valueStr === undefined) { return { content: [{ type: "text", text: "Error: key and value are required" }], isError: true, }; } let value: unknown = valueStr; try { value = JSON.parse(valueStr); } catch { // Keep as string } await updatePreference(key, value); return { content: [ { type: "text", text: `Updated preference ${key} = ${JSON.stringify(value)}`, }, ], }; } - src/index.ts:62-73 (schema)Tool schema registration for 'update_preference'.
name: "update_preference", description: "Update a preference in Chen's context. Use when Chen expresses a new preference (e.g. resume format, communication style, tool choice).", inputSchema: { type: "object", properties: { key: { type: "string", description: "Preference key, e.g. 'resumeFormat.style' or 'communication.tone'" }, value: { type: "string", description: "The value to set (will be parsed as JSON if possible)" }, }, required: ["key", "value"], }, },