Skip to main content
Glama

summarize

Generate concise summaries of plain text, web pages, PDF documents, EPUB books, or HTML content. Specify text, desired length, and language for tailored results.

Input Schema

NameRequiredDescriptionDefault
languageNoen
maxLengthNo
textYes

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "language": { "default": "en", "type": "string" }, "maxLength": { "default": 200, "type": "number" }, "text": { "minLength": 1, "type": "string" } }, "required": [ "text" ], "type": "object" }

Implementation Reference

  • The asynchronous handler function that generates a summary of the input text using the Google Gemini model via the 'ai' SDK. It constructs a prompt, calls generateText, and returns the result in MCP format, with error handling.
    async ({ text, maxLength, language }) => { try { const prompt = `Please summarize the following text in ${language}, keeping the summary within ${maxLength} characters:\n\n${text}`; const model = google.chat("gemini-1.5-pro"); const result = await generateText({ model: model, prompt: prompt, maxTokens: maxLength, temperature: 0.5 }); return { content: [{ type: "text", text: result.text }] }; } catch (error) { console.error('Summarization error:', error); throw new Error('Failed to generate summary'); } }
  • Zod schema for the 'summarize' tool inputs: 'text' (required string, min length 1), 'maxLength' (optional number, default 200), 'language' (optional string, default 'en').
    { text: z.string().min(1), maxLength: z.number().optional().default(200), language: z.string().optional().default("en") },
  • src/index.ts:17-46 (registration)
    The server.tool() call that registers the 'summarize' tool, specifying its input schema and handler function.
    server.tool("summarize", { text: z.string().min(1), maxLength: z.number().optional().default(200), language: z.string().optional().default("en") }, async ({ text, maxLength, language }) => { try { const prompt = `Please summarize the following text in ${language}, keeping the summary within ${maxLength} characters:\n\n${text}`; const model = google.chat("gemini-1.5-pro"); const result = await generateText({ model: model, prompt: prompt, maxTokens: maxLength, temperature: 0.5 }); return { content: [{ type: "text", text: result.text }] }; } catch (error) { console.error('Summarization error:', error); throw new Error('Failed to generate summary'); } } );

Other Tools

Related 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/0xshellming/mcp-summarizer'

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