Labsco
seanivore logo

MCP File Preview Server

โ˜… 24

from seanivore

Preview local HTML files and capture screenshots, saving them to a local directory.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

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

Development

  • Install dependencies:
Copy & paste โ€” that's it
npm install @modelcontextprotocol/sdk puppeteer typescript @types/node @types/puppeteer
  • Make changes in src/

  • Build:

Copy & paste โ€” that's it
npm run build
  • Test locally:
Copy & paste โ€” that's it
npm run dev

Implementation Details

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

Copy & paste โ€” that's it
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

  • Use the MCP Inspector:
Copy & paste โ€” that's it
npx @modelcontextprotocol/inspector

Connect with:

  • Transport Type: STDIO

  • Command: node

  • Arguments: /path/to/build/index.js

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.