-
Notifications
You must be signed in to change notification settings - Fork 3
feat: simplified documentation listing #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e7431e9
Update README.md
khromov dc6c87c
Merge branch 'main' into llms-txt
khromov 972cadc
Update package.json
khromov 917fdf6
enable
khromov 68cf69a
wip
khromov 19cacf7
refactor
khromov e314ab5
Update list-sections.ts
khromov 1bb171c
cleanup
khromov d33a374
Update get-documentation.ts
khromov 6cb97ac
Update get-documentation.ts
khromov c49b24d
wip
khromov b774b46
Update get-documentation.ts
khromov 0f54824
Update get-documentation.ts
khromov bf477a6
Update get-documentation.ts
khromov 7f9ea74
don't lint .claude dir
khromov c05b6c2
eslint
khromov 8328a35
eslint
khromov fb2d19f
Update list-sections.ts
khromov b1a1964
Update list-sections.ts
khromov 77af7eb
Update packages/mcp-server/src/mcp/handlers/tools/get-documentation.ts
khromov 6a6417d
Use Promise.allSettled()
khromov 0366bc7
Merge branch 'llms-txt' of https://github.com/sveltejs/mcp into llms-txt
khromov 01d5803
reduce duplication
khromov 54763e0
Update packages/mcp-server/src/mcp/utils.ts
khromov 76a35f5
format
khromov 5dd83d1
Update utils.ts
khromov ce0861c
chore: use mocked current version of sections
paoloricciuti 8231966
feat: add sections to prompt
paoloricciuti 5bc812e
fix: enable `list-sections` tool
paoloricciuti a281ef4
fix: use `server.template` with list and complete for docs resources
paoloricciuti 70f14bd
feat: use endpoint to get sections
paoloricciuti a36d0d1
fix: validate response and default `use_cases`
paoloricciuti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,7 @@ bun.lockb | |
# Miscellaneous | ||
/static/ | ||
/drizzle/ | ||
/**/.svelte-kit/* | ||
/**/.svelte-kit/* | ||
|
||
# Claude Code | ||
.claude/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 49 additions & 10 deletions
59
packages/mcp-server/src/mcp/handlers/resources/list-sections.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 13 additions & 4 deletions
17
packages/mcp-server/src/mcp/handlers/tools/list-sections.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const SECTIONS_LIST_INTRO = | ||
'List of available Svelte documentation sections and its inteneded uses:'; | ||
|
||
export const SECTIONS_LIST_OUTRO = | ||
'Use the title or path with the get-documentation tool to get more details about a specific section.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as v from 'valibot'; | ||
|
||
export const documentation_sections_schema = v.record( | ||
v.string(), | ||
v.object({ | ||
metadata: v.object({ | ||
title: v.string(), | ||
use_cases: v.optional(v.string()), | ||
}), | ||
slug: v.string(), | ||
}), | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as v from 'valibot'; | ||
import { documentation_sections_schema } from '../mcp/schemas/index.js'; | ||
|
||
export async function fetch_with_timeout( | ||
url: string, | ||
timeout_ms: number = 10000, | ||
): Promise<Response> { | ||
try { | ||
const response = await fetch(url, { signal: AbortSignal.timeout(timeout_ms) }); | ||
return response; | ||
} catch (error) { | ||
if (error instanceof Error && error.name === 'AbortError') { | ||
throw new Error(`Request timed out after ${timeout_ms}ms`); | ||
} | ||
throw error; | ||
} | ||
} | ||
|
||
export async function get_sections() { | ||
const sections = await fetch_with_timeout( | ||
'https://svelte.dev/docs/experimental/sections.json', | ||
).then((res) => res.json()); | ||
const validated_sections = v.safeParse(documentation_sections_schema, sections); | ||
if (!validated_sections.success) return []; | ||
return Object.entries(validated_sections.output).map(([, section]) => ({ | ||
title: section.metadata.title, | ||
use_cases: section.metadata.use_cases ?? 'read document for use cases', | ||
slug: section.slug, | ||
url: `https://svelte.dev/${section.slug}/llms.txt`, | ||
})); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's not add use_cases if it's empty, and put it at the end (so it's title, path, (maybe) use_cases)?