One thing I've never liked about the whole MCP thing is the fact that you have to build a server and host it yourself.
So ever since hearing about this, I've been looking for a self-contained solution where I could basically just describe the functionality that I want and the infrastructure could be handled itself.
It turns out Cloudflare actually has a solution for doing this, and I just love this about Cloudflare. I've actually talked about this elsewhere how they're doing all sorts of one-off services really well, and just kind of eating the internet.
Model Context Protocol (MCP) servers are a way to extend AI assistants with custom tools and data sources. They let you give your AI assistant access to specific capabilities—like querying databases, calling APIs, or performing specialized tasks. The problem is, traditionally you need to:
This is a lot of overhead when you just want to add a simple capability to your AI workflow.
Cloudflare Workers provides the perfect platform for MCP servers because:
Let's build an actual MCP server that I can use. I'll create a simple "website analyzer" that can fetch and analyze any website's content.
mkdir cloudflare-mcp-analyzer
cd cloudflare-mcp-analyzer
bun init -y
bun add @modelcontextprotocol/sdk wrangler
Create src/index.js
:
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
// CORS headers
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
};
if (request.method === "OPTIONS") {
return new Response(null, { headers: corsHeaders });
}
// Root endpoint - server info
if (url.pathname === "/") {
return new Response(
JSON.stringify(
{
name: env.MCP_SERVER_NAME || "website-analyzer",
version: env.MCP_SERVER_VERSION || "1.0.0",
description: "Website analysis MCP server",
endpoints: ["/tools", "/call"],
},
null,
2,
),
{
headers: { "Content-Type": "application/json", ...corsHeaders },
},
);
}
// List available tools
if (url.pathname === "/tools") {
return new Response(
JSON.stringify(
{
tools: [
{
name: "analyze_website",
description: "Analyze a website and extract key information",
inputSchema: {
type: "object",
properties: {
url: { type: "string", description: "The URL to analyze" },
},
required: ["url"],
},
},
],
},
null,
2,
),
{
headers: { "Content-Type": "application/json", ...corsHeaders },
},
);
}
// Execute tool
if (url.pathname === "/call" && request.method === "POST") {
const body = await request.json();
const { name, arguments: args } = body;
if (name === "analyze_website") {
try {
const response = await fetch(args.url);
const html = await response.text();
// Extract basic info
const titleMatch = html.match(/<title>(.*?)<\/title>/i);
const title = titleMatch ? titleMatch[1] : "No title found";
const linkCount = (html.match(/<a\s/gi) || []).length;
const imageCount = (html.match(/<img\s/gi) || []).length;
return new Response(
JSON.stringify({
content: [
{
type: "text",
text: JSON.stringify(
{
url: args.url,
title,
stats: {
links: linkCount,
images: imageCount,
contentLength: html.length,
},
},
null,
2,
),
},
],
}),
{
headers: { "Content-Type": "application/json", ...corsHeaders },
},
);
} catch (error) {
return new Response(
JSON.stringify({
content: [
{
type: "text",
text: `Error: ${error.message}`,
},
],
}),
{
headers: { "Content-Type": "application/json", ...corsHeaders },
},
);
}
}
}
return new Response("Not Found", { status: 404 });
},
};
Create wrangler.toml
:
name = "mcp-website-analyzer"
main = "src/index.js"
compatibility_date = "2024-01-01"
[vars]
MCP_SERVER_NAME = "website-analyzer"
MCP_SERVER_VERSION = "1.0.0"
# Test your worker locally
wrangler dev
# Login to Cloudflare
wrangler login
# Deploy the worker
wrangler deploy
That's it! Your MCP server is now live on Cloudflare's global network.
Add to your MCP configuration:
{
"mcpServers": {
"website-analyzer": {
"url": "https://mcp-website-analyzer.YOUR-SUBDOMAIN.workers.dev",
"description": "Analyzes websites and extracts key information"
}
}
}
To use the public HTTPX MCP server (or any Cloudflare Worker MCP) with OpenCode or Claude Desktop:
.opencode/settings.json
in your project:{
"mcpServers": {
"httpx": {
"url": "https://mcp-httpx-server.danielmiessler.workers.dev"
}
}
}
mcp_httpx_httpx_scan
- Scan multiple URLsmcp_httpx_httpx_tech_stack
- Get technology stack{
"mcpServers": {
"httpx": {
"url": "https://mcp-httpx-server.danielmiessler.workers.dev"
}
}
}
Once connected, you can ask your AI assistant to:
The AI will automatically use the MCP server tools to fetch this information.
What I love about this is:
This is exactly what I've been looking for—a way to extend AI capabilities without the infrastructure overhead.
I've created a working example that provides HTTP reconnaissance capabilities inspired by Project Discovery's httpx. It's live at:
https://mcp-httpx-server.danielmiessler.workers.dev
This server provides two powerful tools:
Quick HTTP scanning for multiple targets at once:
{
"targets": ["example.com", "test.com", "demo.com"]
}
Comprehensive technology stack detection that analyzes:
Example usage:
{
"target": "danielmiessler.com"
}
The entire implementation is a single JavaScript file that runs on Cloudflare's edge network, providing instant global availability without managing servers.