
用于HTML文件预览和分析的MCP服务器——操作系统上有点奇怪,但Cline上运行良好,正在进行中
概览
一个模型上下文协议(MCP)服务器,提供HTML文件的预览和分析功能。该服务器支持捕捉本地HTML文件的全页截图并分析其结构。 - : 以正确的 CSS 样式截取 HTML 文件的全页截图 - : 分析 HTML 结构(标题、段落、图片、链接) - : 处理本地文件路径和资源 - : 将截图保存到专用目录 将服务器添加到你的Claude或Cline MCP设置中: 添加到 ~/Library/Application Support/Claude/claude_desktop_config.json: 截图并返回HTML内容: 截图会保存到项目文件夹的截图/目录中。 返回计数:- 标题 - 段落 - 图片 - 链接 服务器使用MCP SDK的服务器类,初始化为正确:
概述(AI 翻译)
一个模型上下文协议(MCP)服务器,提供HTML文件的预览和分析功能。该服务器支持捕捉本地HTML文件的全页截图并分析其结构。
特色
- 文件预览:以正确的CSS样式捕捉HTML文件的全页截图
- 内容分析:分析HTML结构(标题、段落、图片、链接)
- 本地文件支持:处理本地文件路径和资源
- 截图管理:将截图保存到专用目录
安装
-
克隆仓库:
-
安装依赖:
-
建设项目:
配置
将服务器添加到你的Claude或Cline MCP设置中:
Claude桌面应用
加到~/Library/Application Support/Claude/claude_desktop_config.json:
克莱恩VSCode扩展
添加到VSCode的MCP设置中:
用途
服务器提供两个主要工具:
preview_file
截图并返回HTML内容:
截图保存在项目文件夹的 screenshots/ 目录中。
analyze_content
分析HTML结构:
回报计入:
- 标题
- 段落
- 图片
- 链接
发展
-
安装依赖:
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 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
- Clone the repository:
git clone https://github.com/your-username/mcp-file-preview.git
cd mcp-file-preview
- Install dependencies:
npm install
- 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:
file-preview
preview_file
{
"filePath": "/path/to/file.html",
"width": 1024, // optional
"height": 768 // optional
}
Screenshots are saved to screenshots/ directory in the project folder.
analyze_content
Analyzes HTML structure:
file-preview
analyze_content
{
"filePath": "/path/to/file.html"
}
Returns counts of:
- Headings
- Paragraphs
- Images
- Links
Development
- Install dependencies:
npm install @modelcontextprotocol/sdk puppeteer typescript @types/node @types/puppeteer
- Make changes in
src/ - Build:
npm run build
- 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
安装
npx @modelcontextprotocol/inspector配置
{
"mcpServers": {
"file-preview": {
"command": "node",
"args": ["/path/to/mcp-file-preview/build/index.js"]
}
}
}