Skip to content

Commit fc2f721

Browse files
committed
Add llms.json API endpoint for MCP
1 parent 5c79e0a commit fc2f721

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { docs } from '$lib/server/content';
2+
import { json } from '@sveltejs/kit';
3+
4+
export const prerender = true;
5+
6+
export async function GET() {
7+
return json(await getLlmDocuments());
8+
}
9+
10+
async function getLlmDocuments() {
11+
const documents = [];
12+
13+
for (const [slug, document] of Object.entries(docs.pages)) {
14+
// Extract the topic and path from the slug (format: docs/topic/path)
15+
const parts = slug.split('/');
16+
if (parts.length < 3 || parts[0] !== 'docs') continue;
17+
18+
const topic = parts[1];
19+
const path = parts.slice(2).join('/');
20+
21+
documents.push({
22+
title: document.metadata.title,
23+
url: `https://svelte.dev/docs/${topic}/${path}/llms.txt`,
24+
use_cases: document.metadata.use_cases || undefined
25+
});
26+
}
27+
28+
return documents;
29+
}

0 commit comments

Comments
 (0)