Skip to main content
Glama
seanivore

MCP File Preview Server

analyze_content

Parse and evaluate the structure of HTML files to identify elements, hierarchy, and layout. Use this tool to extract meaningful insights from local HTML content for debugging or analysis.

Instructions

Analyze HTML content structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to local HTML file

Implementation Reference

  • Core handler function in FilePreviewWrapper that reads the HTML file and uses regex to count structural elements: headings (h1-h6), paragraphs, images, and links.
    async analyzeContent(filePath: string) { if (!fs.existsSync(filePath)) { throw new McpError(ErrorCode.InvalidRequest, `File not found: ${filePath}`); } const content = fs.readFileSync(filePath, 'utf-8'); return { headings: (content.match(/<h[1-6][^>]*>.*?<\/h[1-6]>/g) || []).length, paragraphs: (content.match(/<p[^>]*>.*?<\/p>/g) || []).length, images: (content.match(/<img[^>]*>/g) || []).length, links: (content.match(/<a[^>]*>.*?<\/a>/g) || []).length, }; }
  • Tool object definition including name, description, and input schema specifying the required 'filePath' parameter.
    const analyzeContentTool: Tool = { name: 'analyze_content', description: 'Analyze HTML content structure', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to local HTML file' } }, required: ['filePath'] } };
  • src/index.ts:166-169 (registration)
    Registration of the analyze_content tool (along with preview_file) in the server's capabilities for tools.
    tools: { preview_file: previewFileTool, analyze_content: analyzeContentTool }
  • src/index.ts:241-243 (registration)
    Tool listing handler that returns the registered tools including analyze_content.
    return { tools: [previewFileTool, analyzeContentTool], };
  • Dispatch handler in CallToolRequestSchema that validates input, calls the analyzeContent method, and formats the response as JSON text.
    case "analyze_content": { const args = request.params.arguments as { filePath: string }; if (!args.filePath) { throw new Error("Missing required argument: filePath"); } const analysis = await filePreview.analyzeContent(args.filePath); return { content: [ { type: "text", text: JSON.stringify(analysis, null, 2) } ], }; }

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/seanivore/mcp-file-preview'

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