Skip to content

Commit 8064a4f

Browse files
committed
remove docs/ prefix
1 parent 005b9d4 commit 8064a4f

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

packages/mcp-server/src/mcp/handlers/tools/get-documentation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export function get_documentation(server: SvelteMcp) {
88
{
99
name: 'get-documentation',
1010
description:
11-
'Retrieves full documentation content for Svelte 5 or SvelteKit sections. Supports flexible search by title (e.g., "$state", "routing") or file path (e.g., "docs/svelte/state.md"). Can accept a single section name or an array of sections. Before running this, make sure to analyze the users query, as well as the output from list-sections (which should be called first). Then ask for ALL relevant sections the user might require. For example, if the user asks to build anything interactive, you will need to fetch all relevant runes, and so on.',
11+
'Retrieves full documentation content for Svelte 5 or SvelteKit sections. Supports flexible search by title (e.g., "$state", "routing") or file path (e.g., "cli/overview"). Can accept a single section name or an array of sections. Before running this, make sure to analyze the users query, as well as the output from list-sections (which should be called first). Then ask for ALL relevant sections the user might require. For example, if the user asks to build anything interactive, you will need to fetch all relevant runes, and so on.',
1212
schema: v.object({
1313
section: v.pipe(
1414
v.union([v.string(), v.array(v.string())]),
1515
v.description(
16-
'The section name(s) to retrieve. Can search by title (e.g., "$state", "load functions") or file path (e.g., "docs/svelte/state.md"). Supports single string and array of strings',
16+
'The section name(s) to retrieve. Can search by title (e.g., "$state", "load functions") or file path (e.g., "cli/overview"). Supports single string and array of strings',
1717
),
1818
),
1919
}),
@@ -51,6 +51,7 @@ export function get_documentation(server: SvelteMcp) {
5151
const matched_section = available_sections.find(
5252
(s) =>
5353
s.title.toLowerCase() === requested_section.toLowerCase() ||
54+
s.slug === requested_section ||
5455
s.url === requested_section,
5556
);
5657

packages/mcp-server/src/mcp/utils.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,21 @@ export async function get_sections() {
2525
).then((res) => res.json());
2626
const validated_sections = v.safeParse(documentation_sections_schema, sections);
2727
if (!validated_sections.success) return [];
28-
return Object.entries(validated_sections.output).map(([, section]) => ({
29-
title: section.metadata.title,
30-
use_cases: section.metadata.use_cases ?? summaries[section.slug] ?? '',
31-
slug: section.slug,
32-
url: `https://svelte.dev/${section.slug}/llms.txt`,
33-
}));
28+
return Object.entries(validated_sections.output).map(([, section]) => {
29+
const original_slug = section.slug;
30+
const cleaned_slug = original_slug.startsWith('docs/')
31+
? original_slug.slice('docs/'.length)
32+
: original_slug;
33+
34+
return {
35+
title: section.metadata.title,
36+
use_cases:
37+
section.metadata.use_cases ?? summaries[original_slug] ?? summaries[cleaned_slug] ?? '',
38+
slug: cleaned_slug,
39+
// Use original slug in URL to ensure it still works
40+
url: `https://svelte.dev/${original_slug}/llms.txt`,
41+
};
42+
});
3443
}
3544

3645
export async function format_sections_list(): Promise<string> {

0 commit comments

Comments
 (0)