polarity_record_preference
Record user preferences, likes, dislikes, or working-style rules into a persistent knowledge graph for future sessions.
Instructions
Record a stated preference in the user's graph. Convenience wrapper over polarity_observe with kind='preference'. Use when the user expresses a like, dislike, opinion, or working-style rule that should persist across sessions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| source | No | ||
| tags | No | ||
| confidence | No |
Implementation Reference
- src/tools/index.ts:98-99 (handler)The handler for polarity_record_preference – a convenience wrapper that calls client.observe() with kind='preference'.
handler: async (input, client) => client.observe({ ...(input as { text: string }), kind: "preference" }), - src/tools/index.ts:90-97 (schema)Input schema for polarity_record_preference: text (required), optional source, tags, and confidence.
inputSchema: z .object({ text: z.string().min(1).max(4000), source: z.string().max(64).optional(), tags: z.array(z.string().max(32)).max(8).optional(), confidence: z.number().min(0).max(1).optional(), }) .strict(), - src/tools/index.ts:86-100 (registration)Registration of the polarity_record_preference tool in the TOOLS array, including name, description, inputSchema, and handler.
{ name: "polarity_record_preference", description: "Record a stated preference in the user's graph. Convenience wrapper over polarity_observe with kind='preference'. Use when the user expresses a like, dislike, opinion, or working-style rule that should persist across sessions.", inputSchema: z .object({ text: z.string().min(1).max(4000), source: z.string().max(64).optional(), tags: z.array(z.string().max(32)).max(8).optional(), confidence: z.number().min(0).max(1).optional(), }) .strict(), handler: async (input, client) => client.observe({ ...(input as { text: string }), kind: "preference" }), }, - src/client/cosmos.ts:88-100 (helper)CosmosClient.observe() method which the handler delegates to; sends a POST to /api/polarity/observe.
observe(input: { text: string; source?: string; tags?: string[]; kind?: "observation" | "event" | "preference"; confidence?: number; }) { return this.request<ObserveResponse>({ method: "POST", path: "/api/polarity/observe", body: { polarity_user_id: this.config.polarityUserId, ...input }, }); } - src/server.ts:38-44 (registration)Server registration: tools are listed via ListToolsRequestSchema and dispatched via CallToolRequestSchema which calls findTool() and invokes the handler.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS.map((t) => ({ name: t.name, description: t.description, inputSchema: zodToJsonSchema(t.inputSchema), })), }));