mult-fetch-mcp-server 标志

mult-fetch-mcp-server

社区
lmcc-dev

A versatile MCP-compliant web content fetching tool that supports multiple modes (browser/node), formats (HTML/JSON/Markdown/Text), and intelligent proxy detection, with bilingual interface (English/Chinese).

发布者lmcc-dev
代码仓库mult-fetch-mcp-server
语言TypeScript
复刻数
9
星标数
15
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    mult-fetch-mcp-server 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 15 个星标和 9 个复刻。

MseeP.ai Security Assessment Badge

mult-fetch-mcp-server

npm version License: MIT Node.js Version TypeScript MCP SDK GitHub Stars GitHub Forks GitHub Issues GitHub Pull Requests npm downloads GitHub last commit GitHub contributors smithery badge codecov CodeFactor

This project implements an MCP-compliant client and server for communication between AI assistants and external tools.

English | 中文文档

Project Structure

fetch-mcp/
├── src/                         # Source code directory
│   ├── lib/                     # Library files
│   │   ├── fetchers/            # Web fetching implementation
│   │   │   ├── browser/         # Browser-based fetching
│   │   │   │   ├── BrowserFetcher.ts      # Browser fetcher implementation
│   │   │   │   ├── BrowserInstance.ts     # Browser instance management
│   │   │   │   └── PageOperations.ts      # Page interaction operations
│   │   │   ├── node/            # Node.js-based fetching
│   │   │   └── common/          # Shared fetching utilities
│   │   ├── utils/               # Utility modules
│   │   │   ├── ChunkManager.ts        # Content chunking
│   │   │   ├── ContentProcessor.ts    # HTML to text conversion
│   │   │   ├── ContentExtractor.ts    # Intelligent content extraction
│   │   │   ├── ContentSizeManager.ts  # Content size limiting
│   │   │   └── ErrorHandler.ts        # Error handling
│   │   ├── server/              # Server-related modules
│   │   │   ├── index.ts         # Server entry
│   │   │   ├── browser.ts       # Browser management
│   │   │   ├── fetcher.ts       # Web fetching logic
│   │   │   ├── tools.ts         # Tool registration and handling
│   │   │   ├── resources.ts     # Resource handling
│   │   │   ├── prompts.ts       # Prompt templates
│   │   │   └── types.ts         # Server type definitions
│   │   ├── i18n/                # Internationalization support
│   │   └── types.ts             # Common type definitions
│   ├── client.ts                # MCP client implementation
│   └── mcp-server.ts            # MCP server main entry
├── index.ts                     # Server entry point
├── tests/                       # Test files
└── dist/                        # Compiled files

MCP Specification

The Model Context Protocol (MCP) defines two main transport methods:

  1. Standard Input/Output (Stdio): The client starts the MCP server as a child process, and they communicate through standard input (stdin) and standard output (stdout).
  2. Server-Sent Events (SSE): Used to pass messages between client and server.

This project implements the Standard Input/Output (Stdio) transport method.

Features

  • Implementation based on the official MCP SDK
  • Support for Standard Input/Output (Stdio) transport
  • Multiple web scraping methods (HTML, JSON, text, Markdown, plain text conversion)
  • Intelligent mode switching: automatic switching between standard requests and browser mode
  • Content size management: automatically splits large content into manageable chunks to solve AI model context size limitations
  • Chunked content retrieval: ability to request specific chunks of large content while maintaining context continuity
  • Detailed debug logging to stderr
  • Bilingual internationalization (English and Chinese)
  • Modular design for easy maintenance and extension
  • Intelligent Content Extraction: Based on Mozilla's Readability library, capable of extracting meaningful content from web pages while filtering out advertisements and navigation elements
  • Metadata Support: Ability to extract webpage metadata such as title, author, publication date, and site information
  • Smart Content Detection: Automatically detects if a page contains meaningful content, filtering out login pages, error pages, and other pages without substantial content
  • Browser Automation Enhancements: Support for page scrolling, cookie management, selector waiting, and other advanced browser interactions

Installation

Installing via Smithery

To install Mult Fetch MCP Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @lmcc-dev/mult-fetch-mcp-server --client claude

Local Installation

bash
pnpm install

Global Installation

bash
pnpm add -g @lmcc-dev/mult-fetch-mcp-server

Or run directly with npx (no installation required):

bash
npx @lmcc-dev/mult-fetch-mcp-server

Integration with Claude

To integrate this tool with Claude desktop, you need to add server configuration:

Configuration File Location

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

Configuration Examples

Method 1: Using npx (Recommended)

This method is the simplest, doesn't require specifying the full path, and is suitable for global installation or direct use with npx:

json
{
  "mcpServers": {
    "mult-fetch-mcp-server": {
      "command": "npx",
      "args": ["@lmcc-dev/mult-fetch-mcp-server"],
      "env": {
        "MCP_LANG": "en"  // Set language to English, options: "zh" or "en"
      }
    }
  }
}

Method 2: Specifying Full Path

If you need to use a specific installation location, you can specify the full path:

json
{
  "mcpServers": {
    "mult-fetch-mcp-server": {
      "command": "path-to/bin/node",
      "args": ["path-to/@lmcc-dev/mult-fetch-mcp-server/dist/index.js"],
      "env": {
        "MCP_LANG": "en"  // Set language to English, options: "zh" or "en"
      }
    }
  }
}

Please replace path-to/bin/node with the path to the Node.js executable on your system, and replace path-to/@lmcc-dev/mult-fetch-mcp-server with the actual path to this project.

Usage Examples

Below is an example of using this tool in Claude desktop client:

Claude Desktop Client Example

The image shows how Claude can use the fetch tools to retrieve web content and process it according to your instructions.

Usage

After configuration, restart Claude desktop, and you can use the following tools in your conversation:

  • fetch_html: Get HTML content of a webpage
  • fetch_json: Get JSON data
  • fetch_txt: Get plain text content
  • fetch_markdown: Get Markdown formatted content
  • fetch_plaintext: Get plain text content converted from HTML (strips HTML tags)

Build

bash
pnpm run build

Run Server

bash
pnpm run server
# or
node dist/index.js
# if globally installed, you can run directly
@lmcc-dev/mult-fetch-mcp-server
# or use npx
npx @lmcc-dev/mult-fetch-mcp-server

Client Demo Tools

Note: The following client.js functionality is provided for demonstration and testing purposes only. When used with Claude or other AI assistants, the MCP server is driven by the AI, which manages the chunking process automatically.

Command Line Client

The project includes a command-line client for testing and development purposes:

bash
pnpm run client <method> <params_json>
# example
pnpm run client fetch_html '{"url": "https://example.com", "debug": true}'

Demo Client Chunk Control Parameters

When testing with the command-line client, you can use these parameters to demonstrate content chunking capabilities:

  • --all-chunks: Command line flag to automatically fetch all chunks in sequence (demonstration purpose only)
  • --max-chunks: Command line flag to limit the maximum number of chunks to fetch (optional, default is 10)

Real-time Output Demo

The client.js demo tool provides real-time output capabilities:

bash
node dist/src/client.js fetch_html '{"url":"https://example.com", "startCursor": 0, "contentSizeLimit": 500}' --all-chunks --debug

The demo client will automatically fetch all chunks in sequence and display them immediately, showcasing how large content can be processed in real-time.

Run Tests

bash
# Run MCP functionality tests
npm run test:mcp

# Run mini4k.com website tests
npm run test:mini4k

# Run direct client call tests
npm run test:direct

Language Settings

This project supports Chinese and English bilingual internationalization. You can set the language using environment variables:

Using Environment Variables

Set the MCP_LANG environment variable to control the language:

bash
# Set to English
export MCP_LANG=en
npm run server

# Set to Chinese
export MCP_LANG=zh
npm run server

# Windows system
set MCP_LANG=zh
npm run server

Using environment variables ensures that all related processes (including the MCP server) use the same language settings.

Default Language

By default, the system will choose a language according to the following priority:

  1. MCP_LANG environment variable
  2. Operating system language (if it starts with "zh", use Chinese)
  3. English (as the final fallback option)

Debugging

This project follows the MCP protocol specification and does not output any logs by default to avoid interfering with JSON-RPC communication. Debug information is controlled through call parameters:

Using the debug Parameter

Set the debug: true parameter when calling a tool:

json
{
  "url": "https://example.com",
  "debug": true
}

Debug messages are sent to the standard error stream (stderr) using the following format:

[MCP-SERVER] MCP server starting...
[CLIENT] Fetching URL: https://example.com

Debug Log File

When debug mode is enabled, all debug messages are also written to a log file located at:

~/.mult-fetch-mcp-server/debug.log

This log file can be accessed through the MCP resources API:

typescript
// Access the debug log file
const result = await client.readResource({ uri: "file:///logs/debug" });
console.log(result.contents[0].text);

// Clear the debug log file
const clearResult = await client.readResource({ uri: "file:///logs/clear" });
console.log(clearResult.contents[0].text);

Proxy Settings

This tool supports various methods to configure proxy settings:

1. Using the proxy Parameter

The most direct way is to specify the proxy in the request parameters:

json
{
  "url": "https://example.com",
  "proxy": "http://your-proxy-server:port",
  "debug": true
}

2. Using Environment Variables

The tool will automatically detect and use proxy settings from standard environment variables:

bash
# Set proxy environment variables
export HTTP_PROXY=http://your-proxy-server:port
export HTTPS_PROXY=http://your-proxy-server:port

# Run the server
npm run server

3. System Proxy Detection

The tool attempts to detect system proxy settings based on your operating system:

  • Windows: Reads proxy settings from environment variables using the set command
  • macOS/Linux: Reads proxy settings from environment variables using the env command

4. Proxy Troubleshooting

If you're having issues with proxy detection:

  1. Use the debug: true parameter to see detailed logs about proxy detection
  2. Explicitly specify the proxy using the proxy parameter
  3. Ensure your proxy URL is in the correct format: http://host:port or https://host:port
  4. For websites that require browser capabilities, set useBrowser: true to use browser mode

5. Browser Mode and Proxies

When using browser mode (useBrowser: true), the tool will:

  1. First try to use the explicitly specified proxy (if provided)
  2. Then try to use system proxy settings
  3. Finally, proceed without a proxy if none is found

Browser mode is particularly useful for websites that implement anti-scraping measures or require JavaScript execution.

Parameter Handling

This project handles parameters in the following ways:

  • debug: Passed through call parameters, each request can individually control whether to enable debug output
  • MCP_LANG: Retrieved from environment variables, controls the language settings of the entire server

Usage

Creating a Client

typescript
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import path from 'path';
import { fileURLToPath } from 'url';

// Get the directory path of the current file
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// Create client transport layer
const transport = new StdioClientTransport({
  command: 'node',
  args: [path.resolve(__dirname, 'dist/index.js')],
  stderr: 'inherit',
  env: {
    ...process.env  // Pass all environment variables, including MCP_LANG
  }
});

// Create client
const client = new Client({
  name: "example-client",
  version: "1.0.0"
});

// Connect to transport layer
await client.connect(transport);

// Use client
const result = await client.callTool({
  name: 'fetch_html',
  arguments: {
    url: 'https://example.com',
    debug: true  // Control debug output through parameters
  }
});

if (result.isError) {
  console.error('Fetch failed:', result.content[0].text);
} else {
  console.log('Fetch successful!');
  console.log('Content preview:', result.content[0].text.substring(0, 500));
}

Supported Tools

  • fetch_html: Get HTML content of a webpage
  • fetch_json: Get JSON data
  • fetch_txt: Get plain text content
  • fetch_markdown: Get Markdown formatted content
  • fetch_plaintext: Get plain text content converted from HTML (strips HTML tags)

Resources Support

The server includes support for the resources/list and resources/read methods, but currently no resources are defined in the implementation. The resource system is designed to provide access to project files and documentation, but this feature is not fully implemented yet.

Resource Usage Example

typescript
// Example: List available resources
const resourcesResult = await client.listResources({});
console.log('Available resources:', resourcesResult);

// Note: Currently this will return empty lists for resources and resourceTemplates

Supported Prompt Templates

The server provides the following prompt templates:

  • fetch-website: Get website content, supporting different formats and browser mode
  • extract-content: Extract specific content from a website, supporting CSS selectors and data type specification
  • debug-fetch: Debug website fetching issues, analyze possible causes and provide solutions

Prompt Template Usage

  1. Use prompts/list to get a list of available prompt templates
  2. Use prompts/get to get specific prompt template content
typescript
// Example: List available prompt templates
const promptsResult = await client.listPrompts({});
console.log('Available prompts:', promptsResult);

// Example: Get website content prompt
const fetchPrompt = await client.getPrompt({
  name: "fetch-website",
  arguments: {
    url: "https://example.com",
    format: "html",
    useBrowser: "false"
  }
});
console.log('Fetch website prompt:', fetchPrompt);

// Example: Debug website fetching issues
const debugPrompt = await client.getPrompt({
  name: "debug-fetch",
  arguments: {
    url: "https://example.com",
    error: "Connection timeout"
  }
});
console.log('Debug fetch prompt:', debugPrompt);

Parameter Options

Each tool supports the following parameters:

Basic Parameters

  • url: URL to fetch (required)
  • headers: Custom request headers (optional, default {})
  • proxy: Proxy server URL in the format http://host:port or https://host:port (optional)

Network Control Parameters

  • timeout: Timeout in milliseconds (optional, default is 30000)
  • maxRedirects: Maximum number of redirects to follow (optional, default is 10)
  • noDelay: Whether to disable random delay between requests (optional, default is false)
  • useSystemProxy: Whether to use system proxy (optional, default is true)

Content Size Control Parameters

  • enableContentSplitting: Whether to split large content into chunks (optional, default is true)
  • contentSizeLimit: Maximum content size in bytes before splitting (optional, default is 50000)
  • startCursor: Starting cursor position in bytes for retrieving content from a specific position (optional, default is 0)

These parameters help manage large content that would exceed AI model context size limits, allowing you to retrieve web content in manageable chunks while maintaining the ability to process the complete information.

Chunk Management

  • chunkId: Unique identifier for a chunk set when content is split (used for requesting subsequent chunks)

When content is split into chunks, the response includes metadata that allows the AI to request subsequent chunks using the chunkId and startCursor parameters. The system uses byte-level chunk management to provide precise control over content retrieval, enabling seamless processing of content from any position.

Mode Control Parameters

  • useBrowser: Whether to use browser mode (optional, default is false)
  • useNodeFetch: Whether to force using Node.js mode (optional, default is false, mutually exclusive with useBrowser)
  • autoDetectMode: Whether to automatically detect and switch to browser mode if standard mode fails with 403/Forbidden errors (optional, default is true). Set to false to strictly use the specified mode without automatic switching.

Browser Mode Specific Parameters

  • waitForSelector: Selector to wait for in browser mode (optional, default is 'body')
  • waitForTimeout: Timeout to wait in browser mode in milliseconds (optional, default is 5000)
  • scrollToBottom: Whether to scroll to the bottom of the page in browser mode (optional, default is false)
  • saveCookies: Whether to save cookies in browser mode (optional, default is true)
  • closeBrowser: Whether to close the browser instance (optional, default is false)

Content Extraction Parameters

  • extractContent: Whether to use the Readability algorithm to extract main content (optional, default false)
  • includeMetadata: Whether to include metadata in the extracted content (optional, default false, only works when extractContent is true)
  • fallbackToOriginal: Whether to fall back to the original content when extraction fails (optional, default true, only works when extractContent is true)

Debug Parameters

  • debug: Whether to enable debug output (optional, default false)

Content Extraction Feature

Use the content extraction feature to get the core content of a webpage, filtering out navigation bars, advertisements, sidebars, and other distracting elements:

json
{
  "url": "https://example.com/article",
  "extractContent": true,
  "includeMetadata": true
}

The extracted content will include the following metadata (if available):

  • Title
  • Byline (author)
  • Site name
  • Excerpt
  • Content length
  • Readability flag (isReaderable)

Special Usage

Content Extraction Examples

To extract only the meaningful content from an article webpage:

json
{
  "url": "https://example.com/news/article",
  "extractContent": true,
  "includeMetadata": true
}

For websites where content extraction might fail, you can use fallbackToOriginal to ensure you get some content:

json
{
  "url": "https://example.com/complex-layout",
  "extractContent": true,
  "fallbackToOriginal": true
}

Closing Browser Without Fetching

To close the browser instance without performing any fetch operation:

json
{
  "url": "about:blank",
  "closeBrowser": true
}

Proxy Priority

The proxy is determined in the following order:

  1. Command line specified proxy
  2. proxy parameter in the request
  3. Environment variables (if useSystemProxy is true)
  4. Git configuration (if useSystemProxy is true)

If proxy is set, useSystemProxy will be automatically set to false.

Debug Output

When debug: true is set, logs will be output to stderr with the following prefixes:

  • [MCP-SERVER]: Logs from the MCP server
  • [NODE-FETCH]: Logs from the Node.js fetcher
  • [BROWSER-FETCH]: Logs from the browser fetcher
  • [CLIENT]: Logs from the client
  • [TOOLS]: Logs from the tool implementation
  • [FETCHER]: Logs from the main fetcher interface
  • [CONTENT]: Logs related to content handling
  • [CONTENT-PROCESSOR]: Logs from the HTML content processor
  • [CONTENT-SIZE]: Logs related to content size management
  • [CHUNK-MANAGER]: Logs related to content chunking operations
  • [ERROR-HANDLER]: Logs related to error handling
  • [BROWSER-MANAGER]: Logs from the browser instance manager
  • [CONTENT-EXTRACTOR]: Logs from the content extractor

License

MIT


Updated by lmcc-dev

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "lmcc-dev-mult-fetch-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@lmcc-dev/mult-fetch-mcp-server"
      ]
    }
  }
}

将 mult-fetch-mcp-server MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 mult-fetch-mcp-server 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 mult-fetch-mcp-server 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 mult-fetch-mcp-server MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "lmcc-dev-mult-fetch-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@lmcc-dev/mult-fetch-mcp-server"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 mult-fetch-mcp-server MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 mult-fetch-mcp-server MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 mult-fetch-mcp-server 帮我完成这项任务吗?
mult-fetch-mcp-server
当然,我看过了。
以下是我使用 mult-fetch-mcp-server 得到的结果。

常见问题

mult-fetch-mcp-server MCP 服务器有什么用途?

mult-fetch-mcp-server 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 mult-fetch-mcp-server MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 mult-fetch-mcp-server。

为什么在 TypingMind 中使用 mult-fetch-mcp-server MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 mult-fetch-mcp-server 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 mult-fetch-mcp-server MCP 连接到 TypingMind?

mult-fetch-mcp-server 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

mult-fetch-mcp-server MCP 在 TypingMind 中提供哪些工具?

mult-fetch-mcp-server 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 mult-fetch-mcp-server MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 mult-fetch-mcp-server 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇