-
Notifications
You must be signed in to change notification settings - Fork 5
docs: add documentation for svelte.dev #31
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
7 commits
Select commit
Hold shift + click to select a range
216a470
docs: add documentation for svelte.dev
paoloricciuti 3c14872
fix: LLM -> model
paoloricciuti 3106305
chore: apply suggestions from code review
paoloricciuti e9214bc
chore: apply suggestions from code review
paoloricciuti 3b50014
chore: apply suggestions from code review
paoloricciuti dc16a42
chore: apply suggestions from code review
paoloricciuti 9a70fbe
feat: redirect to docs in case someone visits via browser
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
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,44 @@ | ||
--- | ||
title: Overview | ||
--- | ||
|
||
The Svelte MCP ([Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro)) server can help your LLM or agent of choice write better Svelte code. It works by providing documentation relevant to the task at hand, and statically analysing generated code so that it can suggest fixes and best practices. | ||
|
||
## Setup | ||
|
||
The setup varies based on the version of the MCP you prefer — remote or local — and your chosen MCP client (e.g. Claude Code, Codex CLI or GitHub Copilot): | ||
|
||
- [local setup](local-setup) using `@sveltejs/mcp` | ||
- [remote setup](remote-setup) using [mcp.svelte.dev/mcp](https://mcp.svelte.dev/mcp) | ||
|
||
## Usage | ||
|
||
To get the most out of the MCP server we recommend including the following prompt in your `AGENTS.md` (or `CLAUDE.md`, if using Claude Code). This will tell the LLM which tools are available and when it's appropriate to use them. | ||
|
||
```md | ||
You are able to use the Svelte MCP server, where you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively: | ||
|
||
## Available MCP Tools: | ||
|
||
### 1. list-sections | ||
|
||
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths. | ||
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections. | ||
|
||
### 2. get-documentation | ||
|
||
Retrieves full documentation content for specific sections. Accepts single or multiple sections. | ||
After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task. | ||
|
||
### 3. svelte-autofixer | ||
|
||
Analyzes Svelte code and returns issues and suggestions. | ||
You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned. | ||
|
||
### 4. playground-link | ||
|
||
Generates a Svelte Playground link with the provided code. | ||
After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project. | ||
``` | ||
|
||
If your MCP client supports it, we also recommend using the [svelte-task](prompts#svelte-task) prompt to instruct the LLM on the best way to use the MCP server. |
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,3 @@ | ||
--- | ||
title: Introduction | ||
--- |
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,113 @@ | ||
--- | ||
title: Local setup | ||
--- | ||
|
||
The local (or stdio) version of the MCP server is available via the [`@sveltejs/mcp`](https://www.npmjs.com/package/@sveltejs/mcp) npm package. You can either install it globally and then reference it in your configuration or run it with `npx`: | ||
|
||
```bash | ||
npx -y @sveltejs/mcp | ||
``` | ||
|
||
Here's how to set it up in some common MCP clients: | ||
|
||
## Claude Code | ||
|
||
To include the local MCP version in Claude Code, simply run the following command: | ||
|
||
```bash | ||
claude mcp add -t stdio -s [scope] svelte npx -y @sveltejs/mcp | ||
``` | ||
|
||
The `[scope]` must be `user`, `project` or `local`. | ||
|
||
## Claude Desktop | ||
|
||
In the Settings > Developer section, click on Edit Config. It will open the folder with a `claude_desktop_config.json` file in it. Edit the file to include the following configuration: | ||
|
||
```json | ||
{ | ||
"mcpServers": { | ||
"svelte": { | ||
"command": "npx", | ||
"args": ["-y", "@sveltejs/mcp"] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Codex CLI | ||
|
||
Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups): | ||
|
||
```toml | ||
[mcp_servers.svelte] | ||
command = "npx" | ||
args = ["-y", "@sveltejs/mcp"] | ||
``` | ||
|
||
## Gemini CLI | ||
|
||
To include the local MCP version in Gemini CLI, simply run the following command: | ||
|
||
```bash | ||
gemini mcp add -t stdio -s [scope] svelte npx -y @sveltejs/mcp | ||
``` | ||
|
||
The `[scope]` must be `user`, `project` or `local`. | ||
|
||
## OpenCode | ||
|
||
Run the command: | ||
|
||
```bash | ||
opencode mcp add | ||
``` | ||
|
||
and follow the instructions, selecting 'Local' under the 'Select MCP server type' prompt: | ||
|
||
```bash | ||
opencode mcp add | ||
|
||
┌ Add MCP server | ||
│ | ||
◇ Enter MCP server name | ||
│ svelte | ||
│ | ||
◇ Select MCP server type | ||
│ Local | ||
│ | ||
◆ Enter command to run | ||
│ npx -y @sveltejs/mcp | ||
``` | ||
|
||
## VS Code | ||
|
||
- Open the command palette | ||
- Select "MCP: Add Server..." | ||
- Select "Command (stdio)" | ||
- Insert `npx -y @sveltejs/mcp` in the input and press `Enter` | ||
- When prompted for a name, insert `svelte` | ||
- Select if you want to add it as a `Global` or `Workspace` MCP server | ||
|
||
## Cursor | ||
|
||
- Open the command palette | ||
- Select "View: Open MCP Settings" | ||
- Click on "Add custom MCP" | ||
|
||
It will open a file with your MCP servers where you can add the following configuration: | ||
|
||
```json | ||
{ | ||
"mcpServers": { | ||
"svelte": { | ||
"command": "npx", | ||
"args": ["-y", "@sveltejs/mcp"] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Other clients | ||
|
||
If we didn't include the MCP client you are using, refer to their documentation for `stdio` servers and use `npx` as the command and `-y @sveltejs/mcp` as the arguments. |
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,101 @@ | ||||||
--- | ||||||
title: Remote setup | ||||||
--- | ||||||
|
||||||
The remote version of the MCP server is available on `https://mcp.svelte.dev/mcp`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmm since it's not something that the user needs to navigate to but copy into their setup i think it's better if it is a codeblock rather than a link |
||||||
|
||||||
Here's how to set it up in some common MCP clients: | ||||||
|
||||||
## Claude Code | ||||||
|
||||||
To include the remote MCP version in Claude Code, simply run the following command: | ||||||
|
||||||
```bash | ||||||
claude mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp | ||||||
``` | ||||||
|
||||||
You can choose your preferred `scope` (it must be `user`, `project` or `local`) and `name`. | ||||||
|
||||||
## Claude Desktop | ||||||
|
||||||
- Open Settings > Connectors | ||||||
- Click on Add Custom Connector | ||||||
- When prompted for a name, enter `svelte` | ||||||
- Under the Remote MCP server URL input, use `https://mcp.svelte.dev/mcp` | ||||||
- Click Add | ||||||
|
||||||
## Codex CLI | ||||||
|
||||||
Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups): | ||||||
|
||||||
```toml | ||||||
experimental_use_rmcp_client = true | ||||||
[mcp_servers.svelte] | ||||||
url = "https://mcp.svelte.dev/mcp" | ||||||
``` | ||||||
|
||||||
## Gemini CLI | ||||||
|
||||||
To use the remote MCP server with Gemini CLI, simply run the following command: | ||||||
|
||||||
```bash | ||||||
gemini mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp | ||||||
``` | ||||||
|
||||||
The `[scope]` must be `user`, `project` or `local`. | ||||||
|
||||||
## OpenCode | ||||||
|
||||||
Run the command: | ||||||
|
||||||
```bash | ||||||
opencode mcp add | ||||||
``` | ||||||
|
||||||
and follow the instructions, selecting 'Remote' under the 'Select MCP server type' prompt: | ||||||
|
||||||
```bash | ||||||
opencode mcp add | ||||||
|
||||||
┌ Add MCP server | ||||||
│ | ||||||
◇ Enter MCP server name | ||||||
│ svelte | ||||||
│ | ||||||
◇ Select MCP server type | ||||||
│ Remote | ||||||
│ | ||||||
◇ Enter MCP server URL | ||||||
│ https://mcp.svelte.dev/mcp | ||||||
``` | ||||||
|
||||||
## VS Code | ||||||
|
||||||
- Open the command palette | ||||||
- Select "MCP: Add Server..." | ||||||
- Select "HTTP (HTTP or Server-Sent-Events)" | ||||||
- Insert `https://mcp.svelte.dev/mcp` in the input and press `Enter` | ||||||
- Insert your preferred name | ||||||
- Select if you want to add it as a `Global` or `Workspace` MCP server | ||||||
|
||||||
## Cursor | ||||||
|
||||||
- Open the command palette | ||||||
- Select "View: Open MCP Settings" | ||||||
- Click on "Add custom MCP" | ||||||
|
||||||
It will open a file with your MCP servers where you can add the following configuration: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"mcpServers": { | ||||||
"svelte": { | ||||||
"url": "https://mcp.svelte.dev/mcp" | ||||||
} | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
## Other clients | ||||||
|
||||||
If we didn't include the MCP client you are using, refer to their documentation for `remote` servers and use `https://mcp.svelte.dev/mcp` as the URL. |
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,3 @@ | ||
--- | ||
title: Setup | ||
--- |
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,21 @@ | ||
--- | ||
title: Tools | ||
--- | ||
|
||
The following tools are provided by the MCP server to the model, which can decide to call one or more of them during a session: | ||
|
||
## list-sections | ||
|
||
Provides a list of all the available documentation sections. | ||
|
||
## get-documentation | ||
|
||
Allows the model to get the full (and up-to-date) documentation for the requested sections directly from [svelte.dev/docs](/docs). | ||
|
||
## svelte-autofixer | ||
|
||
Uses static analysis to provide suggestions for the generated code. It should be invoked in a loop by the model until all issues and suggestions are resolved. | ||
|
||
## playground-link | ||
|
||
Generates an ephemeral playground link with the generated code. It's useful when the generated code is not written to a file in your project and you want to quickly test the generated solution. The code is not stored anywhere except the URL itself (which will often, as a consequence, be quite large). |
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,9 @@ | ||
--- | ||
title: Resources | ||
--- | ||
|
||
This is the list of available resources provided by the MCP server. Resources are included by the user (not by the LLM) and are useful if you want to include specific knowledge in your session. For example, if you know that the component will need to use transitions you can include the transition documentation directly without asking the LLM to do it for you. | ||
|
||
## doc-section | ||
|
||
This dynamic resource allows you to add every section of the Svelte documentation as a resource. The URI looks like this `svelte://slug-of-the-docs.md` and the returned resource will contain the `llms.txt` version of the specific page you selected. | ||
Rich-Harris marked this conversation as resolved.
Show resolved
Hide resolved
|
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,26 @@ | ||
--- | ||
title: Prompts | ||
--- | ||
|
||
This is the list of available prompts provided by the MCP server. Prompts are selected by the user and are sent as a user message. They can be useful to write repetitive instructions for the LLM on how to properly use the MCP server. | ||
Rich-Harris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## svelte-task | ||
|
||
This prompt should be used whenever you are asking the model to work on some Svelte-related task. It will instruct the LLM on which documentation sections are available, which tool to invoke, when to invoke it, and how to interpret the result. It will ask you for the description of the task and the returned value will look like this: | ||
|
||
``` | ||
You are a Svelte expert tasked to build components and utilities for Svelte developers. If you need documentation for anything related to Svelte you can invoke the tool \`get-documentation\` with one of the following paths: | ||
<available-docs-paths> | ||
[all available docs] | ||
</available-docs-paths> | ||
Every time you write a Svelte component or a Svelte module you MUST invoke the \`svelte-autofixer\` tool providing the code. The tool will return a list of issues or suggestions. If there are any issues or suggestions you MUST fix them and call the tool again with the updated code. You MUST keep doing this until the tool returns no issues or suggestions. Only then you can return the code to the user. | ||
This is the task you will work on: | ||
<task> | ||
[your task here] | ||
</task> | ||
If you are not writing the code into a file, once you have the final version of the code ask the user if they want to generate a playground link to quickly check the code in it and if they answer yes call the \`playground-link\` tool and return the url to the user nicely formatted. The playground link MUST be generated only once you have the final version of the code and you are ready to share it, it MUST include an entry point file called \`App.svelte\` where the main component should live. If you have multiple files to include in the playground link you can include them all at the root. | ||
``` |
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,3 @@ | ||
--- | ||
title: Capabilities | ||
--- |
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,3 @@ | ||
--- | ||
title: MCP | ||
--- |
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.