Token导航 LogoToken导航TokenDH.com
250908 Html MCP Server Go logo
浏览器工具stdio官方级别未说明来源级核验

250908 Html MCP Server Go

MCP Server

一个高性能的Go实现MCP服务器,用于从网页(包括JavaScript渲染内容和Docsify文档站点)中提取内容,支持JSON-RPC和REST API双模式。

工具数

1

提示词数

0

GitHub Stars

0

资源数

0
浏览器自动化Go内容提取

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

MauricioZapata00

提供方

MauricioZapata00

最后核验

2026/5/17 20:23

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -p 8085:8085 html-mcp-server-go

详细介绍

HTML MCP服务器Go

MCP(模型上下文协议)服务器的高性能Go实现,用于从网页中获取和提取内容,包括JavaScript渲染的内容和Docsify文档网站。使用Go Fiber v2的清洁架构原则构建。

特性

  • 双模式操作:同时用作MCP服务器(JSON-RPC)和REST API服务器
  • HTML内容提取:从静态HTML页面提取文本内容
  • JavaScript渲染:支持SPA和使用Chrome/Chromium动态渲染的内容
  • 文档支持:Docsify文档网站的专业解析
  • 清洁建筑:具有独立关注点的领域驱动设计
  • 高性能:使用Go Fiber v2和异步处理构建
  • Docker就绪:带有健康检查的容器化部署
  • CORS支持:为API模式启用交叉原始请求

快速开始

先决条件

  • 转到1.21或更高版本
  • Chrome/Chromium(用于JavaScript渲染)
  • Docker(可选,用于容器化部署)

地方发展

  1. 克隆和构建:
   git clone 
   cd html-mcp-server-go
   go mod download
   go build -o html-mcp-server ./cmd
  1. 作为REST API服务器运行:
   ./html-mcp-server -mode=api -port=8085
  1. 测试API:
   # Health check
   curl http://localhost:8085/health

   # Fetch regular webpage
   curl -X POST http://localhost:8085/api/fetch \
     -H "Content-Type: application/json" \
     -d '{"url": "https://example.com"}'

   # Fetch with JavaScript rendering
   curl -X POST http://localhost:8085/api/fetch \
     -H "Content-Type: application/json" \
     -d '{"url": "https://docs.example.com", "use_js_rendering": true}'

   # Fetch Docsify site
   curl -X POST http://localhost:8085/api/fetch \
     -H "Content-Type: application/json" \
     -d '{"url": "https://docsify.js.org", "use_js_rendering": true, "parse_docsify": true}'
  1. 以MCP服务器运行:
   ./html-mcp-server -mode=mcp

Docker部署

  1. 使用Docker构建和运行:
   docker build -t html-mcp-server-go .
   docker run -p 8085:8085 html-mcp-server-go
  1. 或者使用Docker Compose:
   docker-compose up -d

api参考

REST API

GET/健康

返回服务器运行状况。

答复:

{
  "status": "healthy",
  "version": "1.0.0"
}

POST/api/fetch

从网页中获取和提取内容。

请求正文:

{
  "url": "https://example.com",
  "extract_text_only": true,
  "use_js_rendering": false,
  "parse_docsify": false,
  "timeout_seconds": 30,
  "wait_for_selector": ".content"
}

参数:

  • url (必填):要获取的URL
  • extract_text_only:仅提取文本内容(默认值:true)
  • use_js_rendering:使用Chrome进行JavaScript渲染(默认值:false)
  • parse_docsify:解析Docsify特定内容(默认:自动检测)
  • timeout_seconds:请求超时(默认值:30,最大值:300)
  • wait_for_selector:要等待的CSS选择器(仅限JS渲染)

答复:

{
  "url": "https://example.com",
  "title": "Example Domain",
  "text_content": "Example Domain This domain is for use...",
  "raw_html": "...",
  "metadata": {
    "content_type": "text/html; charset=utf-8",
    "status_code": 200,
    "content_length": 1256,
    "is_js_rendered": false,
    "is_docsify": false
  },
  "docsify_data": {
    "sidebar_content": "...",
    "navbar_content": "...",
    "main_content": "...",
    "config_data": {...}
  }
}

MCP协议

服务器使用以下工具实现MCP(模型上下文协议):

fetch_html

从网页中提取内容。

参数:

  • url (必填):要获取的URL
  • extract_text_only:仅提取文本内容
  • use_js_rendering:使用JavaScript渲染
  • parse_docsify:解析Docsify内容
  • timeout_seconds:请求超时
  • wait_for_selector:要等待的CSS选择器

MCP客户端配置

将以下配置之一添加到MCP客户端设置中:

本地开发(已安装Go)

{
  "mcpServers": {
    "html-mcp-server-go": {
      "command": "go",
      "args": ["run", "./cmd", "-mode=mcp"],
      "cwd": "/path/to/html-mcp-server-go"
    }
  }
}

二进制执行(编译二进制)

{
  "mcpServers": {
    "html-mcp-server-go": {
      "command": "/path/to/html-mcp-server",
      "args": ["-mode=mcp"]
    }
  }
}

Docker容器

{
  "mcpServers": {
    "html-mcp-server-go": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "html-mcp-server-go", "-mode=mcp"]
    }
  }
}

注: 替换 /path/to/html-mcp-server-go/path/to/html-mcp-server 分别显示项目目录和二进制文件的实际路径。

建筑

该项目遵循清洁建筑原则:

├── cmd/                    # Application entry point
├── domain/                 # Core business logic
│   ├── model/             # Domain entities and value objects
│   └── port/              # Interfaces for external dependencies
├── application/           # Business logic and use cases
│   ├── service/           # Application services
│   └── usecase/           # Use case implementations
├── infrastructure/        # External adapters
│   ├── adapter/           # HTML parser adapter
│   ├── api/               # Fiber REST API server
│   ├── client/            # HTTP client with Chrome support
│   └── mcp/               # MCP server implementation
└── docker-compose.yaml   # Container orchestration

配置

环境变量

  • CHROME_BIN:Chrome/Chromium二进制文件的路径
  • CHROME_PATH:Chrome的替代路径

命令行标志

  • -mode:服务器模式(mcp、api、auto)-默认值:auto
  • -port:API服务器端口-默认值:8085

Docker配置

Docker镜像包括:

  • Alpine Linux基础映像
  • Chrome/Chromium浏览器
  • 非root用户安全
  • 健康检查
  • 资源限制(1GB内存,1个CPU核)

发展

添加新功能

  1. 在中定义域模型 domain/model/
  2. 在中创建接口 domain/port/
  3. 在中实现业务逻辑 application/service/
  4. 在中创建适配器 infrastructure/
  5. 导线依赖关系 cmd/main.go

测试

# Run tests
go test ./...

# Run specific package tests
go test ./domain/model
go test ./application/service

# Integration testing with Docker
docker-compose up -d
curl http://localhost:8085/health
docker-compose down

建筑

# Development build
go build -o html-mcp-server ./cmd

# Production build
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o html-mcp-server ./cmd

# Docker build
docker build -t html-mcp-server-go .

文档支持

服务器为Docsify文档站点提供专门支持:

特性

  • 自动检测:自动检测Docsify站点
  • 内容提取:将侧边栏、导航栏和主要内容分开
  • 配置解析:提取Docsify配置数据
  • JavaScript渲染:处理动态内容加载

用法示例

curl -X POST http://localhost:8085/api/fetch \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docsify.js.org/#/quickstart",
    "use_js_rendering": true,
    "parse_docsify": true,
    "wait_for_selector": ".markdown-section"
  }'

Docsify响应结构

{
  "docsify_data": {
    "sidebar_content": "Quick start\nWriting content...",
    "navbar_content": "GitHub\nGitee",
    "main_content": "Quick start\nIt is recommended...",
    "config_data": {
      "name": "docsify",
      "repo": "https://github.com/docsifyjs/docsify/",
      "loadSidebar": true
    }
  }
}

错误处理

服务器提供全面的错误处理:

HTTP状态代码(API模式)

  • 200 OK:请求成功
  • 400 Bad Request:请求参数无效
  • 408 Request Timeout:请求超时
  • 500 Internal Server Error:服务器端错误

错误响应格式

{
  "error": "ERROR_CODE",
  "message": "Human-readable error description"
}

常见错误代码

  • INVALID_URL:URL为空或格式错误
  • FETCH_ERROR:网络或HTTP错误
  • PARSE_ERROR:HTML解析失败
  • TIMEOUT:请求超时
  • JS_RENDERING_ERROR:JavaScript渲染失败
  • DOCSIFY_PARSE_ERROR:文档解析失败

演出

  • 并发处理:基于Goroutine的异步处理
  • 连接池:HTTP客户端重用连接
  • 内存效率高:流式HTML处理
  • 资源限制:可配置的超时和限制
  • 浏览器优化:Chrome以最低的资源使用率推出

安全

  • 非根容器:Docker以非root用户身份运行
  • 资源限制:Docker中的内存和CPU限制
  • 输入验证:URL验证和净化
  • 超时保护:请求和浏览器超时
  • CORS配置:可配置的跨来源政策

许可证

这个项目是开源的,可以在MIT许可证下使用。

目录标签

目录标签

浏览器自动化Go内容提取网页抓取本地部署JavaScript渲染Docsify解析高性能服务器

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP