Skip to content

Commit b1fab1f

Browse files
Add mcp docs (#1587)
* feat: add `mcp` to `sync-docs` * fix: ignore `##` in code blocks for table of content * docs: add mcp docs * fix: push new change * docs: new sync
1 parent 578df6c commit b1fab1f

File tree

15 files changed

+392
-25
lines changed

15 files changed

+392
-25
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Overview
4+
---
5+
6+
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.
7+
8+
## Setup
9+
10+
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):
11+
12+
- [local setup](local-setup) using `@sveltejs/mcp`
13+
- [remote setup](remote-setup) using [mcp.svelte.dev/mcp](https://mcp.svelte.dev/mcp)
14+
15+
## Usage
16+
17+
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.
18+
19+
```md
20+
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:
21+
22+
## Available MCP Tools:
23+
24+
### 1. list-sections
25+
26+
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
27+
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
28+
29+
### 2. get-documentation
30+
31+
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
32+
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.
33+
34+
### 3. svelte-autofixer
35+
36+
Analyzes Svelte code and returns issues and suggestions.
37+
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.
38+
39+
### 4. playground-link
40+
41+
Generates a Svelte Playground link with the provided code.
42+
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.
43+
```
44+
45+
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.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Introduction
4+
---
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Local setup
4+
---
5+
6+
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`:
7+
8+
```bash
9+
npx -y @sveltejs/mcp
10+
```
11+
12+
Here's how to set it up in some common MCP clients:
13+
14+
## Claude Code
15+
16+
To include the local MCP version in Claude Code, simply run the following command:
17+
18+
```bash
19+
claude mcp add -t stdio -s [scope] svelte npx -y @sveltejs/mcp
20+
```
21+
22+
The `[scope]` must be `user`, `project` or `local`.
23+
24+
## Claude Desktop
25+
26+
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:
27+
28+
```json
29+
{
30+
"mcpServers": {
31+
"svelte": {
32+
"command": "npx",
33+
"args": ["-y", "@sveltejs/mcp"]
34+
}
35+
}
36+
}
37+
```
38+
39+
## Codex CLI
40+
41+
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):
42+
43+
```toml
44+
[mcp_servers.svelte]
45+
command = "npx"
46+
args = ["-y", "@sveltejs/mcp"]
47+
```
48+
49+
## Gemini CLI
50+
51+
To include the local MCP version in Gemini CLI, simply run the following command:
52+
53+
```bash
54+
gemini mcp add -t stdio -s [scope] svelte npx -y @sveltejs/mcp
55+
```
56+
57+
The `[scope]` must be `user`, `project` or `local`.
58+
59+
## OpenCode
60+
61+
Run the command:
62+
63+
```bash
64+
opencode mcp add
65+
```
66+
67+
and follow the instructions, selecting 'Local' under the 'Select MCP server type' prompt:
68+
69+
```bash
70+
opencode mcp add
71+
72+
┌ Add MCP server
73+
74+
◇ Enter MCP server name
75+
│ svelte
76+
77+
◇ Select MCP server type
78+
│ Local
79+
80+
◆ Enter command to run
81+
│ npx -y @sveltejs/mcp
82+
```
83+
84+
## VS Code
85+
86+
- Open the command palette
87+
- Select "MCP: Add Server..."
88+
- Select "Command (stdio)"
89+
- Insert `npx -y @sveltejs/mcp` in the input and press `Enter`
90+
- When prompted for a name, insert `svelte`
91+
- Select if you want to add it as a `Global` or `Workspace` MCP server
92+
93+
## Cursor
94+
95+
- Open the command palette
96+
- Select "View: Open MCP Settings"
97+
- Click on "Add custom MCP"
98+
99+
It will open a file with your MCP servers where you can add the following configuration:
100+
101+
```json
102+
{
103+
"mcpServers": {
104+
"svelte": {
105+
"command": "npx",
106+
"args": ["-y", "@sveltejs/mcp"]
107+
}
108+
}
109+
}
110+
```
111+
112+
## Other clients
113+
114+
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.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Remote setup
4+
---
5+
6+
The remote version of the MCP server is available on `https://mcp.svelte.dev/mcp`.
7+
8+
Here's how to set it up in some common MCP clients:
9+
10+
## Claude Code
11+
12+
To include the remote MCP version in Claude Code, simply run the following command:
13+
14+
```bash
15+
claude mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp
16+
```
17+
18+
You can choose your preferred `scope` (it must be `user`, `project` or `local`) and `name`.
19+
20+
## Claude Desktop
21+
22+
- Open Settings > Connectors
23+
- Click on Add Custom Connector
24+
- When prompted for a name, enter `svelte`
25+
- Under the Remote MCP server URL input, use `https://mcp.svelte.dev/mcp`
26+
- Click Add
27+
28+
## Codex CLI
29+
30+
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):
31+
32+
```toml
33+
experimental_use_rmcp_client = true
34+
[mcp_servers.svelte]
35+
url = "https://mcp.svelte.dev/mcp"
36+
```
37+
38+
## Gemini CLI
39+
40+
To use the remote MCP server with Gemini CLI, simply run the following command:
41+
42+
```bash
43+
gemini mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp
44+
```
45+
46+
The `[scope]` must be `user`, `project` or `local`.
47+
48+
## OpenCode
49+
50+
Run the command:
51+
52+
```bash
53+
opencode mcp add
54+
```
55+
56+
and follow the instructions, selecting 'Remote' under the 'Select MCP server type' prompt:
57+
58+
```bash
59+
opencode mcp add
60+
61+
┌ Add MCP server
62+
63+
◇ Enter MCP server name
64+
│ svelte
65+
66+
◇ Select MCP server type
67+
│ Remote
68+
69+
◇ Enter MCP server URL
70+
│ https://mcp.svelte.dev/mcp
71+
```
72+
73+
## VS Code
74+
75+
- Open the command palette
76+
- Select "MCP: Add Server..."
77+
- Select "HTTP (HTTP or Server-Sent-Events)"
78+
- Insert `https://mcp.svelte.dev/mcp` in the input and press `Enter`
79+
- Insert your preferred name
80+
- Select if you want to add it as a `Global` or `Workspace` MCP server
81+
82+
## Cursor
83+
84+
- Open the command palette
85+
- Select "View: Open MCP Settings"
86+
- Click on "Add custom MCP"
87+
88+
It will open a file with your MCP servers where you can add the following configuration:
89+
90+
```json
91+
{
92+
"mcpServers": {
93+
"svelte": {
94+
"url": "https://mcp.svelte.dev/mcp"
95+
}
96+
}
97+
}
98+
```
99+
100+
## Other clients
101+
102+
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.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Setup
4+
---
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Tools
4+
---
5+
6+
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:
7+
8+
## list-sections
9+
10+
Provides a list of all the available documentation sections.
11+
12+
## get-documentation
13+
14+
Allows the model to get the full (and up-to-date) documentation for the requested sections directly from [svelte.dev/docs](/docs).
15+
16+
## svelte-autofixer
17+
18+
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.
19+
20+
## playground-link
21+
22+
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).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Resources
4+
---
5+
6+
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.
7+
8+
## doc-section
9+
10+
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.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Prompts
4+
---
5+
6+
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.
7+
8+
## svelte-task
9+
10+
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:
11+
12+
```
13+
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:
14+
<available-docs-paths>
15+
[all available docs]
16+
</available-docs-paths>
17+
18+
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.
19+
20+
This is the task you will work on:
21+
22+
<task>
23+
[your task here]
24+
</task>
25+
26+
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.
27+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Capabilities
4+
---
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: MCP
4+
---

0 commit comments

Comments
 (0)