Skip to content

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 .mdx endpoint for AI agents

Sushmithamallesh78a8af6001d0
diff --git a/docs/app/llms.mdx/docs/[[...slug]]/route.ts b/docs/app/llms.mdx/docs/[[...slug]]/route.ts
new file mode 100644
index 000000000..912b0af34
--- /dev/null
+++ b/docs/app/llms.mdx/docs/[[...slug]]/route.ts
@@ -0,0 +1,23 @@
+import { getLLMText, source } from '@/lib/source';
+import { notFound } from 'next/navigation';
+
+export const revalidate = false;
+
+export async function GET(
+ _req: Request,
+ { params }: { params: Promise<{ slug?: string[] }> }
+) {
+ const { slug } = await params;
+ const page = source.getPage(slug);
+ if (!page) notFound();
+
+ return new Response(await getLLMText(page), {
+ headers: {
+ 'Content-Type': 'text/markdown; charset=utf-8',
+ },
+ });
+}
+
+export function generateStaticParams() {
+ return source.generateParams();
+}
diff --git a/docs/lib/source.ts b/docs/lib/source.ts
index c40d77abd..b24069dd6 100644
--- a/docs/lib/source.ts
+++ b/docs/lib/source.ts
@@ -58,7 +58,7 @@ export function getPageImage(page: InferPageType<typeof source>) {
export async function getLLMText(page: InferPageType<typeof source>) {
const processed = await page.data.getText('processed');
- return `# ${page.data.title}
+ return `# ${page.data.title} (${page.url})
${processed}`;
}
diff --git a/docs/next.config.mjs b/docs/next.config.mjs
index 2d022e1be..1a32badb7 100644
--- a/docs/next.config.mjs
+++ b/docs/next.config.mjs
@@ -11,6 +11,14 @@ const config = {
turbopack: {
root: __dirname,
},
+ async rewrites() {
+ return [
+ {
+ source: '/docs/:path*.mdx',
+ destination: '/llms.mdx/docs/:path*',
+ },
+ ];
+ },
async redirects() {
return [
{