Skip to content

Commit 3ad9d99

Browse files
authored
feat: complete agent readiness with full A2A, MCP discovery, OpenAPI schemas, and RFC 9457 errors (#694)
1 parent f93352b commit 3ad9d99

8 files changed

Lines changed: 550 additions & 121 deletions

File tree

‎apps/site/baseline/robots.txt‎

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,42 @@ Disallow: /dashboard/
1515

1616
User-Agent: GPTBot
1717
Allow: /
18-
Allow: /api/search
19-
Allow: /api/mcp
20-
Allow: /.well-known/
21-
Allow: /llms.txt
22-
Allow: /llms-full.txt
23-
Allow: /auth.md
18+
19+
User-Agent: ChatGPT-User
20+
Allow: /
21+
22+
User-Agent: OAI-SearchBot
23+
Allow: /
2424

2525
User-Agent: ClaudeBot
2626
Allow: /
27-
Allow: /api/search
28-
Allow: /api/mcp
29-
Allow: /.well-known/
30-
Allow: /llms.txt
31-
Allow: /llms-full.txt
32-
Allow: /auth.md
27+
28+
User-Agent: Claude-User
29+
Allow: /
30+
31+
User-Agent: Claude-SearchBot
32+
Allow: /
33+
34+
User-Agent: Google-Extended
35+
Allow: /
36+
37+
User-Agent: Amazonbot
38+
Allow: /
39+
40+
User-Agent: Bytespider
41+
Allow: /
42+
43+
User-Agent: CCBot
44+
Allow: /
3345

3446
User-Agent: PerplexityBot
3547
Allow: /
36-
Allow: /api/search
37-
Allow: /api/mcp
38-
Allow: /.well-known/
39-
Allow: /llms.txt
40-
Allow: /llms-full.txt
41-
Allow: /auth.md
4248

4349
User-Agent: Applebot-Extended
4450
Allow: /
45-
Allow: /api/search
46-
Allow: /api/mcp
47-
Allow: /.well-known/
48-
Allow: /llms.txt
49-
Allow: /llms-full.txt
50-
Allow: /auth.md
51+
52+
User-Agent: meta-externalagent
53+
Allow: /
5154

5255
Host: https://codingcat.dev
5356
Sitemap: https://codingcat.dev/sitemap.xml

‎apps/site/src/middleware.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ export const onRequest = defineMiddleware(async (context, next) => {
5757
response = await next();
5858
}
5959

60+
// API error hygiene: structured JSON error responses (RFC 9457 Problem Details) for all /api/ paths
61+
if (pathname.startsWith("/api/") && response.status === 404) {
62+
const problemDetails = {
63+
type: "https://codingcat.dev/errors/not-found",
64+
title: "Not Found",
65+
status: 404,
66+
detail: `The requested API endpoint ${pathname} was not found on this server.`,
67+
instance: pathname,
68+
};
69+
const headers = new Headers(response.headers);
70+
headers.set("content-type", "application/problem+json; charset=utf-8");
71+
response = new Response(JSON.stringify(problemDetails, null, 2), {
72+
status: 404,
73+
statusText: "Not Found",
74+
headers,
75+
});
76+
}
77+
6078
if (context.locals.sanity.preview.enabled) {
6179
// Not cosmetic: without this a response containing unpublished drafts can
6280
// be written to the edge cache and served to the public.

‎apps/site/src/pages/.well-known/agent-card.json.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ export const GET: APIRoute = async ({ locals }) => {
1515
url: origin,
1616
version: "1.0.0",
1717
protocol: "a2a",
18+
supportedInterfaces: [
19+
{
20+
url: `${origin}/api/mcp`,
21+
protocolBinding: "JSONRPC",
22+
protocolVersion: "2.0",
23+
},
24+
{
25+
url: `${origin}/api/search`,
26+
protocolBinding: "HTTP+JSON",
27+
protocolVersion: "1.0",
28+
},
29+
],
1830
endpoints: {
1931
mcp: `${origin}/api/mcp`,
2032
search: `${origin}/api/search`,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GET, prerender } from "./agent-card.json";

0 commit comments

Comments
 (0)