Skip to content

Commit 23bc092

Browse files
authored
feat(docs): adds plugin to generate MCP server artifacts and CloudFlare MCP worker script (#1274)
1 parent 7b3492a commit 23bc092

5 files changed

Lines changed: 485 additions & 43 deletions

File tree

cloudflare-mcp/src/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { createCloudflareHandler } from "docusaurus-plugin-mcp-server/adapters";
2+
import docs from "../../build/mcp/docs.json";
3+
import searchIndexData from "../../build/mcp/search-index.json";
4+
5+
let cachedHandler = null;
6+
let cachedBaseUrl = null;
7+
8+
export default {
9+
async fetch(request, env) {
10+
const url = new URL(request.url);
11+
12+
if (!url.pathname.startsWith("/mcp")) {
13+
return new Response("Not found", { status: 404 });
14+
}
15+
16+
const baseUrl = env?.DOCS_BASE_URL ?? "https://dev.flare.network/";
17+
18+
if (!cachedHandler || cachedBaseUrl !== baseUrl) {
19+
cachedBaseUrl = baseUrl;
20+
21+
cachedHandler = createCloudflareHandler({
22+
docs,
23+
searchIndexData,
24+
name: env?.MCP_SERVER_NAME ?? "flare-devhub",
25+
version: env?.MCP_SERVER_VERSION ?? "1.0.0",
26+
baseUrl,
27+
});
28+
}
29+
30+
const newRequest = new Request(
31+
request.url.replace("/mcp", "") || "/",
32+
request,
33+
);
34+
35+
return cachedHandler(newRequest);
36+
},
37+
};

cloudflare-mcp/wrangler.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name = "flare-devhub-mcp"
2+
main = "src/index.ts"
3+
compatibility_date = "2026-01-01"
4+
compatibility_flags = ["nodejs_compat"]
5+
preview_urls = false
6+
7+
routes = [
8+
{ pattern = "dev.flare.network/mcp*", zone_name = "flare.network" }
9+
]
10+
11+
[vars]
12+
DOCS_BASE_URL = "https://dev.flare.network/"
13+
MCP_SERVER_NAME = "flare-devhub"
14+
MCP_SERVER_VERSION = "1.0.0"
15+

docusaurus.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@ const config: Config = {
359359
],
360360
},
361361
],
362+
[
363+
"docusaurus-plugin-mcp-server",
364+
{
365+
server: {
366+
name: "flare-devhub",
367+
version: "1.0.0",
368+
},
369+
},
370+
],
362371
],
363372
scripts: [
364373
// Defer cookie script loading until after page load

0 commit comments

Comments
 (0)