Skip to content

Commit fb2d19f

Browse files
committed
Update list-sections.ts
1 parent 8328a35 commit fb2d19f

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed
Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
import type { SvelteMcp } from '../../index.js';
2+
import { get_sections, fetch_with_timeout } from '../../utils.js';
23

3-
export function list_sections(server: SvelteMcp) {
4-
server.resource(
5-
{
6-
name: 'list-sections',
7-
enabled: () => false,
8-
description:
9-
'The list of all the available Svelte 5 and SvelteKit documentation sections in a structured format.',
10-
uri: 'svelte://list-sections',
11-
title: 'Svelte Documentation Section',
12-
},
13-
async (uri) => {
14-
return {
15-
contents: [
16-
{
17-
uri,
18-
type: 'text',
19-
text: 'resource list-sections called',
20-
},
21-
],
22-
};
23-
},
24-
);
4+
export async function list_sections(server: SvelteMcp) {
5+
const sections = await get_sections();
6+
7+
sections.forEach((section) => {
8+
const resource_name = section.title.toLowerCase().replace(/\s+/g, '-');
9+
const resource_uri = `svelte://docs/${resource_name}`;
10+
11+
server.resource(
12+
{
13+
name: resource_name,
14+
enabled: () => true,
15+
description: section.use_cases,
16+
uri: resource_uri,
17+
title: section.title,
18+
},
19+
async (uri) => {
20+
const response = await fetch_with_timeout(section.url);
21+
const content = await response.text();
22+
return {
23+
contents: [
24+
{
25+
uri,
26+
type: 'text',
27+
text: content,
28+
},
29+
],
30+
};
31+
},
32+
);
33+
});
2534
}

0 commit comments

Comments
 (0)