Skip to main content
Glama
czottmann

kagi-kan-mcp

by czottmann

Kagi Summarizer

kagi_summarizer

Summarize content from any URL, choosing between paragraph summary or bulleted takeaways, with optional language targeting.

Instructions

Summarize content from a URL using the Kagi.com Summarizer API. The Summarizer can summarize any document type (text webpage, video, audio, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesA URL to a document to summarize.
summary_typeNoType of summary to produce. Options are 'summary' for paragraph prose and 'takeaway' for a bulleted list of key points.summary
target_languageNoDesired output language using language codes (e.g., 'EN' for English). If not specified, the document's original language influences the output.

Implementation Reference

  • The main handler function `kagiSummarizer` that implements the tool logic. It takes URL, summary_type, and target_language arguments, calls the `kagi-ken` summarize() function, extracts the summary text from the response, and returns an MCP-formatted content response.
    export async function kagiSummarizer(
      { url, summary_type = "summary", target_language },
    ) {
      try {
        if (!url) {
          throw new Error("Summarizer called with no URL.");
        }
    
        const { token, engine } = getEnvironmentConfig();
    
        // Validate summary type
        if (!["summary", "takeaway"].includes(summary_type)) {
          throw new Error(
            `Invalid summary_type: ${summary_type}. Must be 'summary' or 'takeaway'.`,
          );
        }
    
        // Set default language if not provided
        const language = target_language || "EN";
    
        // Validate language if provided
        if (
          target_language && SUPPORTED_LANGUAGES &&
          !SUPPORTED_LANGUAGES.includes(language)
        ) {
          console.warn(
            `Warning: Language '${language}' may not be supported. Supported languages: ${
              SUPPORTED_LANGUAGES.join(", ")
            }`,
          );
        }
    
        // Note about engine compatibility
        if (engine && engine !== "default") {
          console.warn(
            `Note: Engine selection (${engine}) from KAGI_SUMMARIZER_ENGINE may not be supported by kagi-ken. Using default behavior.`,
          );
        }
    
        // Prepare options for kagi-ken
        const options = {
          type: summary_type,
          language: language,
          isUrl: true,
        };
    
        // Call kagi-ken summarize function
        const result = await summarize(url, token, options);
    
        // Extract the summary text from the result
        // The structure may vary, so we'll try different possible response formats
        let summaryText;
        if (typeof result === "string") {
          summaryText = result;
        } else if (result && result.summary) {
          summaryText = result.summary;
        } else if (result && result.data && result.data.output) {
          summaryText = result.data.output;
        } else if (result && result.output) {
          summaryText = result.output;
        } else {
          // Fallback: stringify the result if it's not in expected format
          summaryText = JSON.stringify(result, null, 2);
        }
    
        return {
          content: [
            {
              type: "text",
              text: summaryText,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: formatError(error),
            },
          ],
        };
      }
    }
  • Input validation schema `summarizerInputSchema` using Zod, defining url (string.url), summary_type (enum: summary/takeaway, default: summary), and target_language (optional string).
    export const summarizerInputSchema = {
      url: z.string().url().describe("A URL to a document to summarize."),
      summary_type: z.enum(["summary", "takeaway"]).default("summary").describe(
        "Type of summary to produce. Options are 'summary' for paragraph prose and 'takeaway' for a bulleted list of key points.",
      ),
      target_language: z.string().optional().describe(
        "Desired output language using language codes (e.g., 'EN' for English). If not specified, the document's original language influences the output.",
      ),
    };
  • Tool registration configuration `summarizerToolConfig` with name 'kagi_summarizer', description, and inputSchema reference.
    export const summarizerToolConfig = {
      name: "kagi_summarizer",
      description: `
        Summarize content from a URL using the Kagi.com Summarizer API. The Summarizer can summarize any
        document type (text webpage, video, audio, etc.)
        `.replace(/\s+/gs, " ").trim(),
      inputSchema: summarizerInputSchema,
    };
  • src/index.js:43-52 (registration)
    Registration of the summarizer tool in the MCP server via `this.server.registerTool()` with the name 'kagi_summarizer', title, description, inputSchema, and the handler callback that awaits `kagiSummarizer(args)`.
    // Register summarizer tool
    this.server.registerTool(
      summarizerToolConfig.name,
      {
        title: "Kagi Summarizer",
        description: summarizerToolConfig.description,
        inputSchema: summarizerToolConfig.inputSchema,
      },
      async (args) => await kagiSummarizer(args),
    );
  • Helper function `getEnvironmentConfig()` that resolves the Kagi session token via `resolveToken()` and reads the engine from the `KAGI_SUMMARIZER_ENGINE` environment variable.
    export function getEnvironmentConfig() {
      const token = resolveToken();
    
      // Note: kagi-ken might not support engine selection like the official API
      // We'll keep this for compatibility but may not use it
      const engine = process.env.KAGI_SUMMARIZER_ENGINE || "default";
    
      return { token, engine };
    }
Behavior3/5

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

With no annotations, the description must bear full burden. It mentions the API and broad document support but does not disclose rate limits, auth needs, or error scenarios. Basic behavior is covered but lacks depth.

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, front-loaded with core purpose, no redundant information. Efficient and to the point.

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

Completeness4/5

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

For a tool with 3 parameters and no output schema, the description covers purpose and capability well. Lacks output format hint or limitations, but overall adequate given simplicity.

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%, so baseline is 3. The description adds value by stating the tool handles any document type (webpage, video, audio), providing context beyond the schema's parameter descriptions.

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 clearly states the tool summarizes content from a URL using Kagi API, specifying support for any document type. It differentiates from the sibling tool 'kagi_search_fetch' which likely retrieves search results.

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

Usage Guidelines3/5

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

The description implies general usage ('summarize any document type') but provides no explicit guidance on when to use this tool versus the sibling 'kagi_search_fetch', nor exclusions or prerequisites.

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/czottmann/kagi-ken-mcp'

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