Skip to main content
Glama

parse_kindle_clippings

Extract and organize Kindle highlights from HTML or text files into structured book groupings for analysis and review.

Instructions

Parse a Kindle HTML export or My Clippings.txt and return highlights grouped by book. Use this when you only need the raw highlights without generating summaries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rawTextYesFull raw content of the Kindle file

Implementation Reference

  • Main handler function that executes the parse_kindle_clippings tool logic. It validates input using Zod schema, detects format (HTML vs plain text), and delegates to appropriate parser.
    export function parseKindleClippings(
      input: ParseKindleClippingsInput
    ): ParsedClippings {
      const { rawText } = ParseKindleClippingsInputSchema.parse(input);
      return isHtmlExport(rawText)
        ? parseHtmlExport(rawText)
        : parsePlainTextClippings(rawText);
    }
  • Zod input validation schema and TypeScript type definition for the parse_kindle_clippings tool. Validates that rawText is a non-empty string.
    export const ParseKindleClippingsInputSchema = z.object({
      rawText: z.string().min(1, "rawText must not be empty"),
    });
    
    export type ParseKindleClippingsInput = z.infer<
      typeof ParseKindleClippingsInputSchema
    >;
  • src/index.ts:90-104 (registration)
    Tool registration in the MCP server - defines the tool name, description, and input schema for the parse_kindle_clippings tool in the tool list.
    {
      name: "parse_kindle_clippings",
      description:
        "Parse a Kindle HTML export or My Clippings.txt and return highlights grouped by book. Use this when you only need the raw highlights without generating summaries.",
      inputSchema: {
        type: "object",
        properties: {
          rawText: {
            type: "string",
            description: "Full raw content of the Kindle file",
          },
        },
        required: ["rawText"],
      },
    },
  • src/index.ts:150-155 (registration)
    Tool handler registration - the case statement that routes parse_kindle_clippings calls to the actual implementation function.
    case "parse_kindle_clippings": {
      const result = parseKindleClippings(args as { rawText: string });
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    }
  • Helper function that parses plain-text My Clippings.txt format, extracting book titles, authors, and highlights grouped by book using a Map for deduplication.
    // ─── Plain-text My Clippings.txt parser ──────────────────────────────────────
    
    const CLIPPING_SEPARATOR = "==========";
    
    function parseAuthorAndTitle(header: string): { title: string; author: string } {
      const match = header.match(/^(.+?)\s*\((.+)\)\s*$/);
      if (match) {
        return { title: match[1].trim(), author: match[2].trim() };
      }
      return { title: header.trim(), author: "Unknown Author" };
    }
    
    function normalizeKey(title: string, author: string): string {
      return `${title.toLowerCase()}|||${author.toLowerCase()}`;
    }
    
    function parsePlainTextClippings(rawText: string): ParsedClippings {
      const clippings = rawText
        .split(CLIPPING_SEPARATOR)
        .map((block) => block.trim())
        .filter((block) => block.length > 0);
    
      const bookMap = new Map<string, KindleHighlight>();
    
      for (const clipping of clippings) {
        const lines = clipping
          .split("\n")
          .map((l) => l.trim())
          .filter((l) => l.length > 0);
    
        if (lines.length < 3) continue;
    
        const headerLine = lines[0];
        // lines[1] is metadata (location, date) — skip
        const highlightText = lines.slice(2).join(" ").trim();
    
        if (!highlightText) continue;
    
        const { title, author } = parseAuthorAndTitle(headerLine);
        const key = normalizeKey(title, author);
    
        if (!bookMap.has(key)) {
          bookMap.set(key, { title, author, highlights: [] });
        }
    
        bookMap.get(key)!.highlights.push(highlightText);
      }
    
      return { books: Array.from(bookMap.values()) };
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It successfully explains the grouping logic (by book) and the raw/unprocessed nature of the output. It could explicitly state this is a read-only/idempotent operation, but 'Parse' implies this adequately for a single string input tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with zero waste: the first states purpose and I/O, the second provides usage guidance. Information is front-loaded and every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter parsing tool with no output schema, the description is complete. It compensates for the missing output schema by describing the return structure ('highlights grouped by book') and clarifies the input domain despite the schema already documenting the parameter.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, establishing a baseline of 3. The description adds value by specifying the two acceptable file formats ('HTML export' vs 'My Clippings.txt') for the rawText parameter, helping the agent understand what content to provide beyond the generic schema description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Parse') with clear resources ('Kindle HTML export or My Clippings.txt') and output format ('highlights grouped by book'). It effectively distinguishes from sibling 'generate_personal_summary' by explicitly stating this returns 'raw highlights without generating summaries', clarifying its scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use guidance ('Use this when you only need the raw highlights without generating summaries'), implicitly identifying when NOT to use it and naming the alternative (generate_personal_summary). This gives the agent clear decision criteria for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Silcfcr/kindle-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server