Skip to content

Commit 38a794b

Browse files
docs: add mcp to docs (#1585)
* feat: add `mcp` to `sync-docs` * fix: ignore `##` in code blocks for table of content * docs: add mcp docs
1 parent 41b34aa commit 38a794b

File tree

15 files changed

+403
-25
lines changed

15 files changed

+403
-25
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 official Svelte MCP (Model Context Protocol) Server can help your LLM or Agent of choice write better Svelte code by providing it with documentation and tools to get suggestions on the generated code based on static analysis.
7+
8+
## Setup
9+
10+
The setup differs based on the version of the MCP you prefer (either remote or local) and the MCP client of your choice (e.g. Claude Code, Codex CLI, GitHub Copilot etc.). Refer to our documentation to learn how to set those up [locally](./local-setup) and [remotely](./remote-setup) for the most common clients.
11+
12+
## Usage
13+
14+
To get the most out of the MCP we recommend including the following prompt in your `AGENTS.md` or `CLAUDE.md`. This will instruct the LLM on what's available and when it's appropriate to use the MCP.
15+
16+
```md
17+
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:
18+
19+
## Available MCP Tools:
20+
21+
### 1. list-sections
22+
23+
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
24+
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
25+
26+
### 2. get-documentation
27+
28+
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
29+
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.
30+
31+
### 3. svelte-autofixer
32+
33+
Analyzes Svelte code and returns issues and suggestions.
34+
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.
35+
36+
### 4. playground-link
37+
38+
Generates a Svelte Playground link with the provided code.
39+
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.
40+
```
41+
42+
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: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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 STDIO (local) version of the MCP server is available as an `npm` package: `@sveltjs/mcp`. 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] [name] npx -y @sveltejs/mcp
20+
```
21+
22+
You can choose your preferred `scope` (it must be `user`, `project` or `local`) and `name`.
23+
24+
## Claude Desktop
25+
26+
Open the Developer section in settings, 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+
"[name]": {
32+
"command": "npx",
33+
"args": ["-y", "@sveltejs/mcp"]
34+
}
35+
}
36+
}
37+
```
38+
39+
The top level must be `mcpServers` but you can choose your preferred `name`.
40+
41+
## Codex CLI
42+
43+
Add the following to your `config.toml` (defaults to `~/.codex/config.toml`... refer to [the configuration documentation](https://github.com/openai/codex/blob/69cb72f8422f2aa7222bea3a6ce48fd130fa76c4/docs/config.md) for more advanced setups):
44+
45+
```toml
46+
[mcp_servers.name]
47+
command = "npx"
48+
args = ["-y", "@sveltejs/mcp"]
49+
```
50+
51+
The top level must be `mcp_server` but you can choose your preferred `name`.
52+
53+
## Gemini CLI
54+
55+
To include the local MCP version in Gemini CLI, simply run the following command:
56+
57+
```bash
58+
gemini mcp add -t stdio -s [scope] [name] npx -y @sveltejs/mcp
59+
```
60+
61+
You can choose your preferred `scope` (it must be `user`, `project` or `local`) and `name`.
62+
63+
## Opencode
64+
65+
Run the command:
66+
67+
```bash
68+
opencode mcp add
69+
```
70+
71+
and follow the instructions, selecting Local when asked for "Select MCP server type":
72+
73+
```bash
74+
opencode mcp add
75+
76+
┌ Add MCP server
77+
78+
◇ Enter MCP server name
79+
│ [name]
80+
81+
◇ Select MCP server type
82+
│ Local
83+
84+
◆ Enter command to run
85+
│ npx -y @sveltejs/mcp
86+
```
87+
88+
You can choose your preferred `name`.
89+
90+
## VSCode
91+
92+
- Open the command Palette
93+
- Select "MCP: Add Server..."
94+
- Select "Command (stdio)"
95+
- Insert `npx -y @sveltejs/mcp` in the input and press `Enter`
96+
- Insert your preferred name
97+
- Select if you want to add it as a `Global` or `Workspace` MCP server
98+
99+
## Cursor
100+
101+
- Open the command Palette
102+
- Select "View: Open MCP Settings"
103+
- Click on "Add custom MCP"
104+
105+
It will open a file with your MCP servers where you can add the following configuration:
106+
107+
```json
108+
{
109+
"mcpServers": {
110+
"[name]": {
111+
"command": "npx",
112+
"args": ["-y", "@sveltejs/mcp"]
113+
}
114+
}
115+
}
116+
```
117+
118+
The top level must be `mcpServers` but you can choose your preferred `name`.
119+
120+
## Other clients
121+
122+
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: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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] [name] 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+
- Insert the name you prefer most
25+
- Insert `https://mcp.svelte.dev/mcp` as the `Remote MCP server URL`
26+
- Click `Add`
27+
28+
## Codex CLI
29+
30+
Add the following to your `config.toml` (defaults to `~/.codex/config.toml`... refer to [the configuration documentation](https://github.com/openai/codex/blob/69cb72f8422f2aa7222bea3a6ce48fd130fa76c4/docs/config.md) for more advanced setups):
31+
32+
```toml
33+
experimental_use_rmcp_client = true
34+
[mcp_servers.name]
35+
url = "https://mcp.svelte.dev/mcp"
36+
```
37+
38+
To use HTTP servers in Codex you need to enable `experimental_use_rmcp_client` and the top level must be `mcp_server` but you can choose your preferred `name`.
39+
40+
## Gemini CLI
41+
42+
To include the remote MCP version in Gemini CLI, simply run the following command:
43+
44+
```bash
45+
gemini mcp add -t http -s [scope] [name] https://mcp.svelte.dev/mcp
46+
```
47+
48+
You can choose your preferred `scope` (it must be `user`, `project` or `local`) and `name`.
49+
50+
## Opencode
51+
52+
Run the command:
53+
54+
```bash
55+
opencode mcp add
56+
```
57+
58+
and follow the instructions, selecting Remote when asked for "Select MCP server type":
59+
60+
```bash
61+
opencode mcp add
62+
63+
┌ Add MCP server
64+
65+
◇ Enter MCP server name
66+
│ [name]
67+
68+
◇ Select MCP server type
69+
│ Remote
70+
71+
◇ Enter MCP server URL
72+
│ https://mcp.svelte.dev/mcp
73+
```
74+
75+
You can choose your preferred `name`.
76+
77+
## VSCode
78+
79+
- Open the command Palette
80+
- Select "MCP: Add Server..."
81+
- Select "HTTP (HTTP or Server-Sent-Events)"
82+
- Insert `https://mcp.svelte.dev/mcp` in the input and press `Enter`
83+
- Insert your preferred name
84+
- Select if you want to add it as a `Global` or `Workspace` MCP server
85+
86+
## Cursor
87+
88+
- Open the command Palette
89+
- Select "View: Open MCP Settings"
90+
- Click on "Add custom MCP"
91+
92+
It will open a file with your MCP servers where you can add the following configuration:
93+
94+
```json
95+
{
96+
"mcpServers": {
97+
"[name]": {
98+
"url": "https://mcp.svelte.dev/mcp"
99+
}
100+
}
101+
}
102+
```
103+
104+
The top level must be `mcpServers` but you can choose your preferred `name`.
105+
106+
## Other clients
107+
108+
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+
This is the list of available tools provided by the MCP server. The list of tools is given to the model which can decide to call one or more of the tools during a session.
7+
8+
## list-sections
9+
10+
Provides a list of all the available documentation sections and their use cases if available. The titles of the sections will be used by the LLM to get up-to-date documentation directly from the official documentation.
11+
12+
## get-documentation
13+
14+
Allows the model to get the full documentation for the requested sections. The documentation is fetched on the fly from the official Svelte documentation and it will always be up to date.
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, the server uses the `share-with-hash` functionality of the Svelte playground to generate the correct hash on the fly (which is also why it will generate a pretty big link).
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 LLM 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)