Create an MCP server in Go served with Docker to fetch and process web content for AI applications
The mcp-curl
MCP server allows you to extend the capabilities of your artificial intelligence (AI) applications by integrating external tools seamlessly through a standardized protocol. This Go-based server provides a simple yet powerful way to extend your LLMs' functionality, enabling them to perform tasks such as fetching web content, executing command-line utilities, and more. It leverages the Model Context Protocol (MCP), ensuring compatibility with popular MCP clients like Claude Desktop, Continue, and Cursor.
The mcp-curl
MCP server offers a streamlined interface to integrate external data sources or tools into AI applications. Key features include:
curl
for fetching web content.The following Mermaid diagram illustrates the flow of interactions between an AI application, its MCP client, the mcp-curl
server, and external tools:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[External Tool or Data Source]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
The mcp-curl
server is compatible with various MCP clients, including:
To deploy the mcp-curl
server, start by setting up the necessary prerequisites:
mcp-curl
project source code.Install Go dependencies using go mod
commands in the repository root:
module mcp-curl
go 1.23.4
require github.com/mark3labs/mcp-go v0.8.2
require github.com/google/uuid v1.6.0
Build the Go executable for your server using:
go build -o mcp-curl main.go
Create and push a Docker image that contains the mcp-curl
server.
FROM golang:1.23.4-alpine AS builder
WORKDIR /app
COPY go.mod .
COPY main.go .
RUN go mod tidy && go build
FROM curlimages/curl:8.6.0
WORKDIR /app
COPY --from=builder /app/mcp-curl .
ENTRYPOINT ["./mcp-curl"]
Build the Docker image using:
docker build -t mcp-curl .
Consider a scenario where you need to provide web content summarization or analysis within an AI-driven project. By integrating the mcp-curl
server, your AI application can fetch and analyze live data from websites, enhancing its capabilities.
Using the provided Go code, you can configure the server to accept URL parameters via MCP calls:
package main
import (
"context"
"fmt"
"os/exec"
"github.com/mark3labs/mcp-go/mcp"
"github.com/mark3labs/mcp-go/server"
)
func main() {
s := server.NewMCPServer(
"mcp-curl",
"1.0.0",
)
tool := mcp.NewTool("use_curl",
mcp.WithDescription("fetch this webpage"),
mcp.WithString("url",
mcp.Required(),
mcp.Description("url of the webpage to fetch"),
),
)
s.AddTool(tool, curlHandler)
fmt.Println("🚀 Server started")
if err := server.ServeStdio(s); err != nil {
fmt.Printf("😡 Server error: %v\n", err)
}
fmt.Println("👋 Server stopped")
}
func curlHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
url, _ := request.Params.Arguments["url"].(string)
cmd := exec.Command("curl", "-s", url)
output, err := cmd.Output()
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
content := string(output)
return mcp.NewToolResultText(content), nil
}
Another use case involves automating data processing flows by integrating mcp-curl
into an end-to-end pipeline. This setup enables your AI application to handle web-based data without manual intervention.
To utilize the mcp-curl
server, you need to configure it to be recognized and accessible via an MCP client like mcphost
. For example:
Create a configuration file for mcphost
that includes details about your mcp-curl
deployment using Docker.
{
"mcpServers": {
"mcp-curl-with-docker" :{
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"mcp-curl"
]
}
}
}
Start mcphost
with your configuration:
mcphost --config ./mcp.json --model ollama:qwen2.5-coder:14b
This setup leverages the mcp-curl
server to perform tasks such as fetching web content, which can then be processed by your hosted model.
Here is a compatibility matrix highlighting the support levels for various MCP clients:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ❌ | Full Tool |
Cursor | ❌ | ✅ | ❌ | Tool Only |
You can customize the mcp-curl
server by setting environmental variables. For example, you might want to set an API key for secure access:
API_KEY=your-api-key ./mcp-curl
Ensure that your environment secrets and API keys are stored securely when deploying this server in production.
Can mcp-curl server be used with other MCP clients besides those listed?
How can I troubleshoot connection issues between my AI application and mcp-curl server?
Is it possible to add more tools to mcp-curl apart from curl?
mcp-curl
by adding additional tool integrations through Go and custom code modifications as needed.By leveraging the mcp-curl
server, developers and AI application creators can significantly enhance their projects' functionality and interactivity through seamless tool integrations.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods