Skip to content

Commit 273c780

Browse files
Merge branch 'main' into llms-txt
2 parents 891fae8 + 7ada706 commit 273c780

File tree

27 files changed

+978
-13
lines changed

27 files changed

+978
-13
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "sveltejs/mcp" }],
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup pnpm
1919
uses: pnpm/action-setup@v4
2020
with:
21-
version: 10
21+
version: 10.17.1
2222

2323
- name: Setup Node.js
2424
uses: actions/setup-node@v4

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup pnpm
1919
uses: pnpm/action-setup@v4
2020
with:
21-
version: 10
21+
version: 10.17.1
2222

2323
- name: Setup Node.js
2424
uses: actions/setup-node@v4

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
permissions: {}
8+
9+
jobs:
10+
release:
11+
permissions:
12+
contents: write # to create release (changesets/action)
13+
id-token: write # OpenID Connect token needed for provenance
14+
pull-requests: write # to create pull request (changesets/action)
15+
# prevents this action from running on forks
16+
if: github.repository == 'sveltejs/mcp'
17+
name: Release
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
# pseudo-matrix for convenience, NEVER use more than a single combination
22+
node: [24]
23+
os: [ubuntu-latest]
24+
steps:
25+
- name: checkout
26+
uses: actions/checkout@v5
27+
with:
28+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
29+
fetch-depth: 0
30+
- uses: actions/setup-node@v5
31+
with:
32+
node-version: ${{ matrix.node }}
33+
package-manager-cache: false # pnpm is not installed yet
34+
- name: install pnpm
35+
shell: bash
36+
run: |
37+
PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json)
38+
echo installing pnpm version $PNPM_VER
39+
npm i -g pnpm@$PNPM_VER
40+
- uses: actions/setup-node@v5
41+
with:
42+
node-version: ${{ matrix.node }}
43+
package-manager-cache: true # caches pnpm via packageManager field in package.json
44+
- name: install
45+
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
46+
- name: build
47+
run: pnpm run --filter ./packages/mcp-stdio/ build
48+
49+
- name: Create Release Pull Request or Publish to npm
50+
id: changesets
51+
# pinned for security, always review third party action code before updating
52+
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
53+
with:
54+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
55+
publish: pnpm release
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
NPM_CONFIG_PROVENANCE: true

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup pnpm
1919
uses: pnpm/action-setup@v4
2020
with:
21-
version: 10
21+
version: 10.17.1
2222

2323
- name: Setup Node.js
2424
uses: actions/setup-node@v4

apps/mcp-remote/src/hooks.server.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import { http_transport } from '$lib/mcp/index.js';
22
import { db } from '$lib/server/db/index.js';
3+
import { redirect } from '@sveltejs/kit';
34

45
export async function handle({ event, resolve }) {
6+
if (event.request.method === 'GET') {
7+
const accept = event.request.headers.get('accept');
8+
if (accept) {
9+
const accepts = accept.split(',');
10+
if (!accepts.includes('text/event-stream')) {
11+
// the request it's a browser request, not an MCP client request
12+
// it means someone probably opened it from the docs...we should redirect to the docs
13+
redirect(302, 'https://svelte.dev/docs/mcp/overview');
14+
}
15+
}
16+
}
517
const mcp_response = await http_transport.respond(event.request, {
618
db,
719
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Overview
3+
---
4+
5+
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.
6+
7+
## Setup
8+
9+
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):
10+
11+
- [local setup](local-setup) using `@sveltejs/mcp`
12+
- [remote setup](remote-setup) using `https://mcp.svelte.dev/mcp`
13+
14+
## Usage
15+
16+
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.
17+
18+
```md
19+
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:
20+
21+
## Available MCP Tools:
22+
23+
### 1. list-sections
24+
25+
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
26+
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
27+
28+
### 2. get-documentation
29+
30+
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
31+
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.
32+
33+
### 3. svelte-autofixer
34+
35+
Analyzes Svelte code and returns issues and suggestions.
36+
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.
37+
38+
### 4. playground-link
39+
40+
Generates a Svelte Playground link with the provided code.
41+
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.
42+
```
43+
44+
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Introduction
3+
---
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: Local setup
3+
---
4+
5+
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`:
6+
7+
```bash
8+
npx -y @sveltejs/mcp
9+
```
10+
11+
Here's how to set it up in some common MCP clients:
12+
13+
## Claude Code
14+
15+
To include the local MCP version in Claude Code, simply run the following command:
16+
17+
```bash
18+
claude mcp add -t stdio -s [scope] svelte npx -y @sveltejs/mcp
19+
```
20+
21+
The `[scope]` must be `user`, `project` or `local`.
22+
23+
## Claude Desktop
24+
25+
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:
26+
27+
```json
28+
{
29+
"mcpServers": {
30+
"svelte": {
31+
"command": "npx",
32+
"args": ["-y", "@sveltejs/mcp"]
33+
}
34+
}
35+
}
36+
```
37+
38+
## Codex CLI
39+
40+
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):
41+
42+
```toml
43+
[mcp_servers.svelte]
44+
command = "npx"
45+
args = ["-y", "@sveltejs/mcp"]
46+
```
47+
48+
## Gemini CLI
49+
50+
To include the local MCP version in Gemini CLI, simply run the following command:
51+
52+
```bash
53+
gemini mcp add -t stdio -s [scope] svelte npx -y @sveltejs/mcp
54+
```
55+
56+
The `[scope]` must be `user`, `project` or `local`.
57+
58+
## OpenCode
59+
60+
Run the command:
61+
62+
```bash
63+
opencode mcp add
64+
```
65+
66+
and follow the instructions, selecting 'Local' under the 'Select MCP server type' prompt:
67+
68+
```bash
69+
opencode mcp add
70+
71+
┌ Add MCP server
72+
73+
◇ Enter MCP server name
74+
│ svelte
75+
76+
◇ Select MCP server type
77+
│ Local
78+
79+
◆ Enter command to run
80+
│ npx -y @sveltejs/mcp
81+
```
82+
83+
## VS Code
84+
85+
- Open the command palette
86+
- Select "MCP: Add Server..."
87+
- Select "Command (stdio)"
88+
- Insert `npx -y @sveltejs/mcp` in the input and press `Enter`
89+
- When prompted for a name, insert `svelte`
90+
- Select if you want to add it as a `Global` or `Workspace` MCP server
91+
92+
## Cursor
93+
94+
- Open the command palette
95+
- Select "View: Open MCP Settings"
96+
- Click on "Add custom MCP"
97+
98+
It will open a file with your MCP servers where you can add the following configuration:
99+
100+
```json
101+
{
102+
"mcpServers": {
103+
"svelte": {
104+
"command": "npx",
105+
"args": ["-y", "@sveltejs/mcp"]
106+
}
107+
}
108+
}
109+
```
110+
111+
## Other clients
112+
113+
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.

0 commit comments

Comments
 (0)