Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
feat(docs): add .md support and Accept header for AI agents
Following Lee Robinson's Agent-Ready principles: - Add .md URL extension support (in addition to .mdx) - Add proxy.ts for Accept: text/markdown header support - Same URL serves HTML to browsers, Markdown to AI agents Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sushmithamallesh committed
Jan 19, 2026 at 14:12 UTC
121691e970ee1eaf16a0d89a8cf4e5d3a23f885b
2 files changed
+39
docs/next.config.mjs
+5
@@ -13,10 +13,15 @@ const config = {
13
},
14
async rewrites() {
15
return [
16
+ // Support both .md and .mdx extensions for AI agents
17
{
18
source: '/docs/:path*.mdx',
19
destination: '/llms.mdx/docs/:path*',
20
},
21
+ {
22
+ source: '/docs/:path*.md',
23
+ destination: '/llms.mdx/docs/:path*',
24
+ },
25
];
26
},
27
async redirects() {
docs/proxy.ts
new
+34
@@ -0,0 +1,34 @@
1
+import { NextRequest, NextResponse } from 'next/server';
2
+
3
+/**
4
+ * Proxy that serves Markdown content when AI agents request it via Accept header.
5
+ * This follows Lee Robinson's "Agent-Ready" principle:
6
+ * "Serve Markdown files when Accept: text/markdown is requested"
7
+ */
8
+export function proxy(request: NextRequest) {
9
+ const acceptHeader = request.headers.get('accept') || '';
10
+
11
+ // Check if the request prefers markdown (AI agents)
12
+ const prefersMarkdown =
13
+ acceptHeader.includes('text/markdown') ||
14
+ acceptHeader.includes('text/plain');
15
+
16
+ // Only apply to /docs pages (not already .md or .mdx)
17
+ const pathname = request.nextUrl.pathname;
18
+ if (
19
+ prefersMarkdown &&
20
+ pathname.startsWith('/docs') &&
21
+ !pathname.endsWith('.md') &&
22
+ !pathname.endsWith('.mdx')
23
+ ) {
24
+ // Rewrite to the markdown endpoint
25
+ const mdUrl = new URL(`${pathname}.md`, request.nextUrl.origin);
26
+ return NextResponse.rewrite(mdUrl);
27
+ }
28
+
29
+ return NextResponse.next();
30
+}
31
+
32
+export const config = {
33
+ matcher: ['/docs/:path*'],
34
+};