Skip to content

Commit b336d72

Browse files
authored
feat: serve MCP Server Card (#30202)
* feat: serve MCP Server Card at /.well-known/mcp/server-card.json * fix: serve server card from worker to handle dot-prefixed path * fix: use MIDDLECACHE R2 binding instead of fetch() for server card * fix: correct comment explaining why server card is in the worker * fix: remove manual Cache-Control header, let Cloudflare handle caching * chore: remove redundant server card comment
1 parent 7913831 commit b336d72

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

public/_headers

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818

1919
/.well-known/skills/index.json
2020
Content-Type: application/json; charset=utf-8
21+
22+
/.well-known/mcp/server-card.json
23+
Content-Type: application/json; charset=utf-8

worker/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ export default class extends WorkerEntrypoint<Env> {
9292
});
9393
}
9494

95+
if (pathname === "/.well-known/mcp/server-card.json") {
96+
const object = await this.env.MIDDLECACHE.get(
97+
"v1/cloudflare-mcps/server-card.json",
98+
);
99+
if (!object) {
100+
return new Response("server-card.json not found", { status: 404 });
101+
}
102+
return new Response(object.body, {
103+
headers: {
104+
"Content-Type": "application/json; charset=utf-8",
105+
},
106+
});
107+
}
108+
95109
if (pathname === "/openapi.json") {
96110
const object = await this.env.MIDDLECACHE.get(
97111
"v1/cloudflare-api-schemas/openapi.json",

0 commit comments

Comments
 (0)