GoFetch
HTTP-SSE基于Go的网页内容获取MCP服务器
基于Go的网页内容获取MCP服务器
An SSE Go implementation of the gofetch MCP server that retrieves web content.
mcp/fetch?This Go implementation provides similar functionality as the original Python MCP fetch server but has the following benefits:
Clone the repository:
git clone https://github.com/StacklokLabs/gofetch.git cd gofetch
Install dependencies:
task install
Build the server:
task build
To run the server with the default StreamableHTTP transport:
./build/gofetch
The server will start and expose endpoints as mandated by the MCP specification:
Streamable HTTP Transport (default):
http://localhost:8080/mcp (for streaming responses and commands)SSE Transport:
http://localhost:8080/ssehttp://localhost:8080/messages--transport: Transport type: sse or streamable-http (default)--port: Port number for HTTP-based transports (default: 8080)--user-agent: Custom User-Agent string (default: "Mozilla/5.0 (compatible;
MCPGoFetchBot/1.0)")--ignore-robots-txt: Ignore robots.txt rules--proxy-url: Proxy URL for requests# Basic server on port 8080 ./build/gofetch --transport=streamable-http --port 8080 # Custom port with user agent ./build/gofetch --port 8080 --user-agent "MyBot/1.0" # Ignore robots.txt on custom port ./build/gofetch --port 8080 --ignore-robots-txt # Use proxy ./build/gofetch --port 8080 --proxy-url "http://proxy.example.com:8080" # Use environment variable for port MCP_PORT=9090 ./build/gofetch
For using the gofetch server, you can follow the usage guide for curl commands:
The server provides a single tool called fetch with the following parameters:
fetchFetches a URL from the internet and optionally extracts its contents as markdown.
url (required): The URL to fetchmax_length (optional): Maximum number of characters to return (default:
5000, max: 1000000)start_index (optional): Starting character index for content extraction
(default: 0)raw (optional): Return raw HTML content without simplification (default:
false){ "name": "fetch", "arguments": { "url": "https://example.com" } }
{ "name": "fetch", "arguments": { "url": "https://example.com", "max_length": 1000, "raw": false } }
Requires yardstick client to be installed for integration tests.
task test
task fmt
task lint
task deps
gofetch can be run as a Model Context Protocol (MCP) server using ToolHive, which simplifies the deployment and management of MCP servers.
The easiest way to run gofetch is using the packaged version available in ToolHive's registry:
# Register a supported client so ToolHive can auto-configure your environment thv client setup # Run the fetch server thv run fetch --transport streamable-http --target-port 8080 # List running servers thv list # Get detailed information about the server thv registry info fetch
For advanced users who need custom configuration, you can also run fetch using the container image directly:
# Run the fetch server using the published container image thv run --name fetch --transport streamable-http --target-port 8080 ghcr.io/stackloklabs/gofetch/server:latest
This command:
To use a specific version instead of the latest:
thv run --name fetch --transport sse --target-port 8080 ghcr.io/stackloklabs/gofetch/server:v0.0.1
To verify that the gofetch server is running:
thv list
This will show all running MCP servers managed by ToolHive, including the gofetch server.
To stop the gofetch server:
# For custom named version thv stop fetch
To remove the server instance completely:
# For custom named version thv rm fetch
We welcome contributions to this MCP server! If you'd like to contribute, please review the CONTRIBUTING guide for details on how to get started.
If you run into a bug or have a feature request, please
open an issue in the repository
or join us in the #mcp-servers channel on our
community Discord server.
This project is licensed under the Apache v2 License - see the LICENSE file for details.