Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

mcp-file-preview

MCP.Pizza Chef: seanivore

The mcp-file-preview is an MCP server designed to provide HTML file preview and structural analysis capabilities. It enables capturing full-page screenshots of local HTML files with accurate CSS styling, supporting local file paths and resources. Additionally, it analyzes the HTML content by extracting key elements such as headings, paragraphs, images, and links. Screenshots are saved to a dedicated directory for easy access. This server is useful for developers and AI agents needing to visualize and understand HTML files in real-time within the MCP ecosystem. It integrates with MCP clients like Claude and Cline, enhancing model interactions with local web content.

Use This MCP server To

Capture full-page screenshots of local HTML files Analyze HTML structure for headings, images, and links Preview styled HTML content within AI workflows Save and manage screenshots of HTML files Support local file path handling for web previews

README

MCP File Preview Server

A Model Context Protocol (MCP) server that provides HTML file preview and analysis capabilities. This server enables capturing full-page screenshots of local HTML files and analyzing their structure.

Features

  • File Preview: Capture full-page screenshots of HTML files with proper CSS styling
  • Content Analysis: Analyze HTML structure (headings, paragraphs, images, links)
  • Local File Support: Handle local file paths and resources
  • Screenshot Management: Save screenshots to a dedicated directory

Installation

  1. Clone the repository:
git clone https://github.com/your-username/mcp-file-preview.git
cd mcp-file-preview
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Configuration

Add the server to your Claude or Cline MCP settings:

Claude Desktop App

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "file-preview": {
      "command": "node",
      "args": ["/path/to/mcp-file-preview/build/index.js"]
    }
  }
}

Cline VSCode Extension

Add to VSCode's MCP settings:

{
  "mcpServers": {
    "file-preview": {
      "command": "node",
      "args": ["/path/to/mcp-file-preview/build/index.js"]
    }
  }
}

Usage

The server provides two main tools:

preview_file

Captures a screenshot and returns HTML content:

<use_mcp_tool>
<server_name>file-preview</server_name>
<tool_name>preview_file</tool_name>
<arguments>
{
  "filePath": "/path/to/file.html",
  "width": 1024,  // optional
  "height": 768   // optional
}
</arguments>
</use_mcp_tool>

Screenshots are saved to screenshots/ directory in the project folder.

analyze_content

Analyzes HTML structure:

<use_mcp_tool>
<server_name>file-preview</server_name>
<tool_name>analyze_content</tool_name>
<arguments>
{
  "filePath": "/path/to/file.html"
}
</arguments>
</use_mcp_tool>

Returns counts of:

  • Headings
  • Paragraphs
  • Images
  • Links

Development

  1. Install dependencies:
npm install @modelcontextprotocol/sdk puppeteer typescript @types/node @types/puppeteer
  1. Make changes in src/
  2. Build:
npm run build
  1. Test locally:
npm run dev

Implementation Details

The server uses the MCP SDK's Server class with proper initialization:

this.server = new Server(
  // Metadata object
  {
    name: 'file-preview-server',
    version: '0.1.0'
  },
  // Options object with capabilities
  {
    capabilities: {
      tools: {
        preview_file: {
          description: 'Preview local HTML file and capture screenshot',
          inputSchema: {
            // ... schema definition
          }
        }
      }
    }
  }
);

Key points:

  • Server constructor takes separate metadata and options objects
  • Tools are declared in capabilities.tools
  • Each tool needs a description and inputSchema
  • Screenshots are saved to a local screenshots/ directory

Debugging

  1. Use the MCP Inspector:
npx @modelcontextprotocol/inspector
  1. Connect with:

    • Transport Type: STDIO
    • Command: node
    • Arguments: /path/to/build/index.js
  2. Check Claude OS logs if tools don't appear in the dropdown

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

mcp-file-preview FAQ

How do I install the mcp-file-preview server?
Clone the GitHub repo, install dependencies with npm, then build the project using npm run build.
Can mcp-file-preview handle local HTML files with CSS styling?
Yes, it captures full-page screenshots with proper CSS styling for local HTML files.
Where are screenshots saved when using mcp-file-preview?
Screenshots are saved to a dedicated directory configured by the server.
How do I configure mcp-file-preview with MCP clients like Claude or Cline?
Add the server details to the MCP client configuration files, such as claude_desktop_config.json for Claude.
Does mcp-file-preview analyze HTML content?
Yes, it extracts and analyzes HTML elements like headings, paragraphs, images, and links.
Is mcp-file-preview stable across all operating systems?
It works well on Cline but has some issues on certain OSes; it is a work in progress.
What dependencies are required for mcp-file-preview?
The server requires Node.js and npm to install dependencies and build the project.
Can mcp-file-preview be integrated with multiple LLM providers?
Yes, it can be used with MCP clients that support models from OpenAI, Claude, Gemini, and others.