createHighlight
Create a new highlight for a bookmark in Raindrop.io by specifying the text and bookmark ID. Add optional color and notes to organize and customize your highlights.
Instructions
Create a new highlight for a bookmark
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color | No | Color for the highlight (e.g., "yellow", "#FFFF00") | |
| note | No | Additional note for the highlight | |
| raindropId | Yes | Bookmark ID | |
| text | Yes | Highlighted text |
Implementation Reference
- Core helper function implementing the Raindrop.io API call to create a highlight (POST /highlights). This is the exact API integration logic for creating highlights.async createHighlight(bookmarkId: number, highlight: { text: string; note?: string; color?: string; }): Promise<Highlight> { const { data } = await this.client.POST('/highlights', { body: { ...highlight, raindrop: { $id: bookmarkId }, color: (highlight.color as any) || 'yellow' } }); if (!data?.item) throw new Error('Failed to create highlight'); return data.item; }
- MCP handler function for the 'highlight_manage' tool. The 'create' operation invokes the createHighlight helper with prepared payload from tool arguments.async function handleHighlightManage(args: z.infer<typeof HighlightManageInputSchema>, { raindropService }: ToolHandlerContext) { switch (args.operation) { case 'create': if (!args.bookmarkId || !args.text) throw new Error('bookmarkId and text required for create'); const createPayload: Record<string, unknown> = { text: args.text }; setIfDefined(createPayload, 'note', args.note); setIfDefined(createPayload, 'color', args.color); return await raindropService.createHighlight(args.bookmarkId, createPayload as any); case 'update': if (!args.id) throw new Error('id required for update'); const updatePayload: Record<string, unknown> = {}; setIfDefined(updatePayload, 'text', args.text); setIfDefined(updatePayload, 'note', args.note); setIfDefined(updatePayload, 'color', args.color); return await raindropService.updateHighlight(args.id, updatePayload as any); case 'delete': if (!args.id) throw new Error('id required for delete'); await raindropService.deleteHighlight(args.id); return { deleted: true }; default: throw new Error(`Unsupported operation: ${String(args.operation)}`); } }
- Input schema validation for highlight management tool, extending base HighlightInputSchema with operation type and optional ID.const HighlightManageInputSchema = HighlightInputSchema.extend({ operation: z.enum(['create', 'update', 'delete']), id: z.number().optional(), });
- src/services/raindropmcp.service.ts:432-438 (registration)Tool configuration and registration definition for 'highlight_manage', which handles create/update/delete including createHighlight logic.const highlightManageTool = defineTool({ name: 'highlight_manage', description: 'Creates, updates, or deletes highlights. Use the operation parameter to specify the action.', inputSchema: HighlightManageInputSchema, outputSchema: HighlightOutputSchema, handler: handleHighlightManage, });
- Base Zod schema for highlight input parameters (bookmarkId, text, note, color), used by HighlightManageInputSchema.export const HighlightInputSchema = z.object({ bookmarkId: z.number(), text: z.string(), note: z.string().optional(), color: z.string().optional(), });