mirror of
https://github.com/sveltejs/ai-tools.git
synced 2026-07-04 03:19:38 +08:00
Compare commits
92 Commits
@sveltejs/
...
prompt-imp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa0d173db0 | ||
|
|
48d43a0e76 | ||
|
|
1124aefa4b | ||
|
|
283164ca7e | ||
|
|
c6ee414f62 | ||
|
|
a6fc42ec56 | ||
|
|
34ab5c075d | ||
|
|
d2242a1d2c | ||
|
|
b3561dcb2d | ||
|
|
3f70809ce6 | ||
|
|
2d7da648e3 | ||
|
|
ea5bdf66dc | ||
|
|
7d707202d1 | ||
|
|
f0daadfbd0 | ||
|
|
15a7774da7 | ||
|
|
98efa1e09e | ||
|
|
e20cf2974d | ||
|
|
b2ee968a3f | ||
|
|
60297b3c49 | ||
|
|
39076da8ce | ||
|
|
fba733646a | ||
|
|
7fcd4705a5 | ||
|
|
af7d341ba5 | ||
|
|
52546551ff | ||
|
|
1f0a5f1519 | ||
|
|
0bf04bad2e | ||
|
|
f001918925 | ||
|
|
67487c324a | ||
|
|
5beeef5543 | ||
|
|
e1a03fdb85 | ||
|
|
384c1fd209 | ||
|
|
b3027fd815 | ||
|
|
849bf2ad49 | ||
|
|
314538c8e7 | ||
|
|
a9994310c0 | ||
|
|
9fb1a403b7 | ||
|
|
3c7b5033a4 | ||
|
|
b911a00bb7 | ||
|
|
f6ce89ff34 | ||
|
|
846514858e | ||
|
|
b69ea052bd | ||
|
|
e56159dda6 | ||
|
|
1e83c35faa | ||
|
|
31edfe1b5f | ||
|
|
3fabcc0f9b | ||
|
|
deb5f2670c | ||
|
|
02c951baa8 | ||
|
|
41ceb83838 | ||
|
|
3c3a26f031 | ||
|
|
6589c7e250 | ||
|
|
e09b8cd0b9 | ||
|
|
7f52a2b1be | ||
|
|
4eecd75759 | ||
|
|
9015753f77 | ||
|
|
4d6a9cb333 | ||
|
|
60aa30397f | ||
|
|
17ed3a3e23 | ||
|
|
f49bd06fbd | ||
|
|
b98c042ae3 | ||
|
|
917a93d3fd | ||
|
|
371e96befc | ||
|
|
bdfd5a109f | ||
|
|
1c6c0a9fa7 | ||
|
|
a321244543 | ||
|
|
ed25933466 | ||
|
|
72f91dfb7b | ||
|
|
d36855c447 | ||
|
|
5fa2baa270 | ||
|
|
6543150a5b | ||
|
|
4c7f7feeba | ||
|
|
579be877fa | ||
|
|
0d55c0f61a | ||
|
|
7d7b08610d | ||
|
|
c08d8d4df7 | ||
|
|
12dd3c16ac | ||
|
|
ca17a18677 | ||
|
|
cf62286912 | ||
|
|
a4dfaab1c6 | ||
|
|
7b396ad63f | ||
|
|
a9653f9c74 | ||
|
|
cabf1fd96a | ||
|
|
2d50ffd38c | ||
|
|
66c9056e0f | ||
|
|
e639e3ad5c | ||
|
|
322f416c3d | ||
|
|
c40a3fcb5c | ||
|
|
a282623cc7 | ||
|
|
8f6abc6192 | ||
|
|
d0bed3e8f0 | ||
|
|
4c98732f5f | ||
|
|
1f88817cf0 | ||
|
|
87af64f4bc |
5
.changeset/perfect-fishes-scream.md
Normal file
5
.changeset/perfect-fishes-scream.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@sveltejs/mcp-server": patch
|
||||
---
|
||||
|
||||
fix: improve prompt to reduce token usage
|
||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
open_collective: svelte
|
||||
8
.github/workflows/check.yml
vendored
8
.github/workflows/check.yml
vendored
@@ -13,17 +13,17 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.18.2
|
||||
version: 10.26.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '24'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
|
||||
8
.github/workflows/lint.yml
vendored
8
.github/workflows/lint.yml
vendored
@@ -13,17 +13,17 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.18.2
|
||||
version: 10.26.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '24'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
|
||||
11
.github/workflows/publish-mcp.yml
vendored
11
.github/workflows/publish-mcp.yml
vendored
@@ -5,6 +5,7 @@ on:
|
||||
secrets:
|
||||
MCP_KEY:
|
||||
required: true
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish-mcp:
|
||||
@@ -12,19 +13,19 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Publish to MCP Registry
|
||||
working-directory: packages/mcp-stdio
|
||||
env:
|
||||
MCP_KEY: ${{ secrets.MCP_KEY }}
|
||||
run: |
|
||||
NAME=mcp-publisher_1.2.3_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
|
||||
# Download MCP Publisher pinned to v1.2.3 using latest https for security and save it to a file named mcp-publisher.tar.gz
|
||||
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL "https://github.com/modelcontextprotocol/registry/releases/download/v1.2.3/$NAME" -O
|
||||
NAME=mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
|
||||
# Download MCP Publisher pinned to v1.3.10 using latest https for security and save it to a file named mcp-publisher.tar.gz
|
||||
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL "https://github.com/modelcontextprotocol/registry/releases/download/v1.3.10/$NAME" -O
|
||||
|
||||
# Verify the SHA256 checksum of the downloaded file
|
||||
sha256sum --ignore-missing -c ./checksums/registry_1.2.3_checksums.txt
|
||||
sha256sum --ignore-missing -c ./checksums/registry_1.3.10_checksums.txt
|
||||
|
||||
# Extract the tarball
|
||||
mkdir tmp
|
||||
|
||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@@ -25,11 +25,11 @@ jobs:
|
||||
os: [ubuntu-latest]
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v5
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
package-manager-cache: false # pnpm is not installed yet
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
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)
|
||||
echo installing pnpm version $PNPM_VER
|
||||
npm i -g pnpm@$PNPM_VER
|
||||
- uses: actions/setup-node@v5
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
package-manager-cache: true # caches pnpm via packageManager field in package.json
|
||||
|
||||
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@@ -13,17 +13,17 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.18.2
|
||||
version: 10.26.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '24'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
|
||||
8
.github/workflows/update-prompt-docs.yml
vendored
8
.github/workflows/update-prompt-docs.yml
vendored
@@ -19,12 +19,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
package-manager-cache: false # pnpm is not installed yet
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
npm i -g pnpm@$PNPM_VER
|
||||
|
||||
- name: Setup Node.js with pnpm cache
|
||||
uses: actions/setup-node@v5
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
package-manager-cache: true # caches pnpm via packageManager field in package.json
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.git-check.outputs.changed == 'true'
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
uses: peter-evans/create-pull-request@v8
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: 'docs: update prompts documentation'
|
||||
|
||||
@@ -11,4 +11,5 @@ bun.lockb
|
||||
/**/.svelte-kit/*
|
||||
|
||||
# Claude Code
|
||||
.claude/
|
||||
.claude/
|
||||
.changeset/
|
||||
3
.vscode/mcp-snippets.code-snippets
vendored
3
.vscode/mcp-snippets.code-snippets
vendored
@@ -12,6 +12,7 @@
|
||||
"body": [
|
||||
"import type { SvelteMcp } from '../../index.js';",
|
||||
"import * as v from 'valibot';",
|
||||
"import { icons } from '../../icons/index.js';",
|
||||
"",
|
||||
"export function ${1:function_name}(server: SvelteMcp) {",
|
||||
"\t$0",
|
||||
@@ -35,6 +36,7 @@
|
||||
"prefix": "!prompt",
|
||||
"body": [
|
||||
"import type { SvelteMcp } from '../../index.js';",
|
||||
"import { icons } from '../../icons/index.js';",
|
||||
"",
|
||||
"/**",
|
||||
" * Function that actually generates the prompt string. You can use this in the MCP server handler to generate the prompt, it can accept arguments",
|
||||
@@ -69,6 +71,7 @@
|
||||
"\t\t\ttitle: '${2:title}',",
|
||||
"\t\t\tdescription:",
|
||||
"\t\t\t\t'${3:llm_description}',",
|
||||
"\t\t\ticons,",
|
||||
"\t\t},",
|
||||
"\t\tasync () => {",
|
||||
"\t\t\treturn {",
|
||||
|
||||
@@ -37,34 +37,35 @@
|
||||
],
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.3.2",
|
||||
"@eslint/js": "^9.36.0",
|
||||
"@libsql/client": "^0.15.0",
|
||||
"@modelcontextprotocol/inspector": "^0.17.0",
|
||||
"@sveltejs/adapter-vercel": "^5.6.3",
|
||||
"@sveltejs/kit": "^2.22.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
||||
"@types/node": "^24.3.1",
|
||||
"@typescript-eslint/parser": "^8.44.0",
|
||||
"drizzle-kit": "^0.31.0",
|
||||
"drizzle-orm": "^0.44.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-svelte": "^3.12.3",
|
||||
"globals": "^16.0.0",
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-plugin-svelte": "^3.3.3",
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"svelte-eslint-parser": "^1.3.2",
|
||||
"typescript": "^5.0.0",
|
||||
"vite": "^7.0.4",
|
||||
"vite-plugin-devtools-json": "^1.0.0",
|
||||
"vitest": "^3.2.3"
|
||||
"@eslint/compat": "catalog:lint",
|
||||
"@eslint/js": "catalog:lint",
|
||||
"@libsql/client": "catalog:orm",
|
||||
"@modelcontextprotocol/inspector": "catalog:ai",
|
||||
"@sveltejs/adapter-vercel": "catalog:svelte",
|
||||
"@sveltejs/kit": "catalog:svelte",
|
||||
"@sveltejs/vite-plugin-svelte": "catalog:svelte",
|
||||
"@types/node": "catalog:tooling",
|
||||
"@typescript-eslint/parser": "catalog:lint",
|
||||
"drizzle-kit": "catalog:orm",
|
||||
"drizzle-orm": "catalog:orm",
|
||||
"eslint-config-prettier": "catalog:lint",
|
||||
"eslint-plugin-svelte": "catalog:lint",
|
||||
"globals": "catalog:lint",
|
||||
"prettier": "catalog:lint",
|
||||
"prettier-plugin-svelte": "catalog:lint",
|
||||
"svelte": "catalog:svelte",
|
||||
"svelte-check": "catalog:svelte",
|
||||
"svelte-eslint-parser": "catalog:lint",
|
||||
"typescript": "catalog:tooling",
|
||||
"vite": "catalog:tooling",
|
||||
"vite-plugin-devtools-json": "catalog:tooling",
|
||||
"vitest": "catalog:tooling"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sveltejs/mcp-schema": "workspace:^",
|
||||
"@sveltejs/mcp-server": "workspace:^",
|
||||
"@tmcp/transport-http": "^0.6.3",
|
||||
"tmcp": "^1.14.0"
|
||||
"@tmcp/transport-http": "catalog:tmcp",
|
||||
"@vercel/analytics": "catalog:tooling",
|
||||
"tmcp": "catalog:tmcp"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { dev } from '$app/environment';
|
||||
import { http_transport } from '$lib/mcp/index.js';
|
||||
import { db } from '$lib/server/db/index.js';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { track } from '@vercel/analytics/server';
|
||||
|
||||
export async function handle({ event, resolve }) {
|
||||
if (event.request.method === 'GET') {
|
||||
@@ -16,6 +18,12 @@ export async function handle({ event, resolve }) {
|
||||
}
|
||||
const mcp_response = await http_transport.respond(event.request, {
|
||||
db,
|
||||
// only add analytics in production
|
||||
track: dev
|
||||
? undefined
|
||||
: async (session_id, event, extra) => {
|
||||
await track(event, { session_id, ...(extra ? { extra } : {}) });
|
||||
},
|
||||
});
|
||||
// we are deploying on vercel the SSE connection will timeout after 5 minutes...for
|
||||
// the moment we are not sending back any notifications (logs, or list changed notifications)
|
||||
@@ -25,11 +33,14 @@ export async function handle({ event, resolve }) {
|
||||
// 200 or the MCP client will complain)
|
||||
if (mcp_response && event.request.method === 'GET') {
|
||||
try {
|
||||
await mcp_response.body?.cancel();
|
||||
} catch {
|
||||
// ignore
|
||||
return mcp_response;
|
||||
} finally {
|
||||
try {
|
||||
await mcp_response.body?.cancel();
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return new Response('', { status: 200 });
|
||||
}
|
||||
return mcp_response ?? resolve(event);
|
||||
}
|
||||
|
||||
@@ -3,4 +3,5 @@ import { HttpTransport } from '@tmcp/transport-http';
|
||||
|
||||
export const http_transport = new HttpTransport(server, {
|
||||
cors: true,
|
||||
path: '/mcp',
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { createClient } from '@libsql/client';
|
||||
import { drizzle } from 'drizzle-orm/libsql';
|
||||
import * as schema from './schema.js';
|
||||
// let's disable it for the moment...i can't figure out a way to make it wotk with eslint
|
||||
// eslint-disable-next-line import/extensions
|
||||
import { DATABASE_TOKEN, DATABASE_URL } from '$env/static/private';
|
||||
if (!DATABASE_URL) throw new Error('DATABASE_URL is not set');
|
||||
if (!DATABASE_TOKEN) throw new Error('DATABASE_TOKEN is not set');
|
||||
|
||||
BIN
apps/mcp-remote/static/logo.png
Normal file
BIN
apps/mcp-remote/static/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
1
apps/mcp-remote/static/logo.svg
Normal file
1
apps/mcp-remote/static/logo.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M416.9 93.1c-41.1-58.9-122.4-76.3-181.2-38.9L132.5 120c-28.2 17.7-47.6 46.5-53.5 79.3-4.9 27.3-.6 55.5 12.3 80-8.8 13.4-14.9 28.5-17.7 44.2-5.9 33.4 1.8 67.8 21.6 95.4 41.2 58.9 122.4 76.3 181.2 38.9L379.6 392c28.2-17.7 47.6-46.5 53.5-79.3 4.9-27.3.6-55.5-12.3-80 8.8-13.4 14.9-28.4 17.7-44.2 5.8-33.4-1.9-67.8-21.6-95.4" style="fill:#ff3e00"/><path d="M225.6 424.5c-33.3 8.6-68.4-4.4-88-32.6-11.9-16.6-16.5-37.3-13-57.4.6-3.3 1.4-6.5 2.5-9.6l1.9-5.9 5.3 3.9c12.2 9 25.9 15.8 40.4 20.2l3.8 1.2-.4 3.8c-.5 5.4 1 10.9 4.2 15.3 5.9 8.5 16.5 12.4 26.5 9.8 2.2-.6 4.4-1.5 6.3-2.8l103.2-65.8c5.1-3.2 8.6-8.4 9.7-14.4 1.1-6.1-.3-12.3-3.9-17.3-5.9-8.5-16.5-12.4-26.5-9.8-2.2.6-4.4 1.5-6.3 2.8L252 291c-6.5 4.1-13.5 7.2-21 9.2-33.3 8.6-68.4-4.4-88-32.6-11.9-16.6-16.5-37.3-13-57.4 3.5-19.7 15.2-37 32.2-47.7l103.2-65.8c6.5-4.1 13.5-7.2 21-9.2 33.3-8.6 68.4 4.4 88 32.6 11.9 16.6 16.5 37.3 13 57.4-.6 3.3-1.4 6.5-2.5 9.6L383 193l-5.3-3.9c-12.2-9-25.9-15.8-40.4-20.2l-3.8-1.2.4-3.8c.5-5.4-1-10.9-4.2-15.3-5.9-8.5-16.5-12.4-26.5-9.8-2.2.6-4.4 1.5-6.3 2.8l-103.2 65.8c-5.1 3.2-8.6 8.4-9.7 14.4-1.1 6.1.3 12.3 3.9 17.3 5.9 8.5 16.5 12.4 26.5 9.8 2.2-.6 4.4-1.5 6.3-2.8L260 221c6.5-4.1 13.5-7.2 21-9.2 33.3-8.6 68.4 4.4 88 32.6 11.9 16.6 16.5 37.3 13 57.4-3.5 19.7-15.2 37-32.2 47.7l-103.2 65.8c-6.5 4.1-13.6 7.2-21 9.2" style="fill:#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -13,7 +13,9 @@ The setup varies based on the version of the MCP you prefer — remote or local
|
||||
|
||||
## Usage
|
||||
|
||||
To get the most out of the MCP server we recommend including the following prompt in your [`AGENTS.md`](https://agents.md) (or [`CLAUDE.md`](https://docs.claude.com/en/docs/claude-code/memory#claude-md-imports), if using Claude Code). This will tell the LLM which tools are available and when it's appropriate to use them.
|
||||
To get the most out of the MCP server we recommend including the following prompt in your [`AGENTS.md`](https://agents.md) (or [`CLAUDE.md`](https://docs.claude.com/en/docs/claude-code/memory#claude-md-imports), if using Claude Code. Or [`GEMINI.md`](https://geminicli.com/docs/cli/gemini-md/), if using GEMINI). This will tell the LLM which tools are available and when it's appropriate to use them.
|
||||
|
||||
> [!NOTE] This is already setup for you when using `npx sv add mcp`
|
||||
|
||||
```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:
|
||||
|
||||
@@ -110,6 +110,12 @@ It will open a file with your MCP servers where you can add the following config
|
||||
|
||||
## Zed
|
||||
|
||||
Install the [Svelte MCP Server extension](https://zed.dev/extensions/svelte-mcp).
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Configure Manually</summary>
|
||||
|
||||
- Open the command palette
|
||||
- Search and select "agent:open settings"
|
||||
- In settings panel look for `Model Context Protocol (MCP) Servers`
|
||||
@@ -127,6 +133,8 @@ It will open a popup with MCP server config where you can add the following conf
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -42,7 +42,7 @@ To use the remote MCP server with Gemini CLI, simply run the following command:
|
||||
gemini mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp
|
||||
```
|
||||
|
||||
The `[scope]` must be `user`, `project` or `local`.
|
||||
The `[scope]` must be `user` or `project`.
|
||||
|
||||
## OpenCode
|
||||
|
||||
@@ -96,6 +96,27 @@ It will open a file with your MCP servers where you can add the following config
|
||||
}
|
||||
```
|
||||
|
||||
## GitHub Coding Agent
|
||||
|
||||
- Open your repository in GitHub
|
||||
- Go to Settings
|
||||
- Open Copilot > Coding agent
|
||||
- Edit the MCP configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"svelte": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.svelte.dev/mcp",
|
||||
"tools": ["*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- Click _Save MCP configuration_
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -12,7 +12,7 @@ This prompt should be used whenever you are asking the model to work on a Svelte
|
||||
<summary>Copy the prompt</summary>
|
||||
|
||||
```md
|
||||
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:
|
||||
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>
|
||||
|
||||
- title: Overview, use_cases: project setup, creating new svelte apps, scaffolding, cli tools, initializing projects, path: cli/overview
|
||||
@@ -25,6 +25,7 @@ You are a Svelte expert tasked to build components and utilities for Svelte deve
|
||||
- title: drizzle, use_cases: database setup, sql queries, orm integration, data modeling, postgresql, mysql, sqlite, server-side data access, database migrations, type-safe queries, path: cli/drizzle
|
||||
- title: eslint, use_cases: code quality, linting, error detection, project setup, code standards, team collaboration, typescript projects, path: cli/eslint
|
||||
- title: lucia, use_cases: authentication, login systems, user management, registration pages, session handling, auth setup, path: cli/lucia
|
||||
- title: mcp, use_cases: use title and path to estimate use case, path: cli/mcp
|
||||
- title: mdsvex, use_cases: blog, content sites, markdown rendering, documentation sites, technical writing, cms integration, article pages, path: cli/mdsvex
|
||||
- title: paraglide, use_cases: internationalization, multi-language sites, i18n, translation, localization, language switching, global apps, multilingual content, path: cli/paraglide
|
||||
- title: playwright, use_cases: browser testing, e2e testing, integration testing, test automation, quality assurance, ci/cd pipelines, testing user flows, path: cli/playwright
|
||||
|
||||
@@ -7,13 +7,20 @@ import { fileURLToPath } from 'node:url';
|
||||
import ts from 'typescript-eslint';
|
||||
import svelteConfig from './apps/mcp-remote/svelte.config.js';
|
||||
import eslint_plugin_import from 'eslint-plugin-import';
|
||||
import { configs as pnpm } from 'eslint-plugin-pnpm';
|
||||
|
||||
const gitignore_path = fileURLToPath(new URL('./.gitignore', import.meta.url));
|
||||
|
||||
export default /** @type {import("eslint").Linter.Config} */ ([
|
||||
includeIgnoreFile(gitignore_path),
|
||||
{
|
||||
ignores: ['.claude/**/*'],
|
||||
ignores: [
|
||||
'.claude/**/*',
|
||||
'.changeset/*',
|
||||
'.github/**/*.yml',
|
||||
'.github/**/*.yaml',
|
||||
'**/pnpm-lock.yaml',
|
||||
],
|
||||
},
|
||||
js.configs.recommended,
|
||||
...ts.configs.recommended,
|
||||
@@ -48,13 +55,17 @@ export default /** @type {import("eslint").Linter.Config} */ ([
|
||||
'import/no-unresolved': 'off', // this doesn't work well with typescript path mapping
|
||||
'import/extensions': [
|
||||
'error',
|
||||
'ignorePackages',
|
||||
{
|
||||
js: 'always',
|
||||
mjs: 'always',
|
||||
cjs: 'always',
|
||||
ts: 'always',
|
||||
svelte: 'always',
|
||||
ignorePackages: true,
|
||||
pattern: {
|
||||
js: 'always',
|
||||
mjs: 'always',
|
||||
cjs: 'always',
|
||||
ts: 'always',
|
||||
svelte: 'always',
|
||||
svg: 'always',
|
||||
json: 'always',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -70,4 +81,16 @@ export default /** @type {import("eslint").Linter.Config} */ ([
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'pnpm/exclude-some-rules',
|
||||
files: ['**/*.json', '**/*.yaml', '**/*.yml', 'pnpm-workspace.yaml'],
|
||||
rules: {
|
||||
'@typescript-eslint/naming-convention': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'off',
|
||||
'func-style': 'off',
|
||||
},
|
||||
},
|
||||
...pnpm.json,
|
||||
...pnpm.yaml,
|
||||
]);
|
||||
|
||||
45
package.json
45
package.json
@@ -3,7 +3,7 @@
|
||||
"version": "0.0.1",
|
||||
"description": "The official Svelte MCP server implementation",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@10.18.2",
|
||||
"packageManager": "pnpm@10.26.0",
|
||||
"scripts": {
|
||||
"build": "pnpm -r run build",
|
||||
"dev": "pnpm --filter @sveltejs/mcp-remote run dev",
|
||||
@@ -12,6 +12,8 @@
|
||||
"format": "prettier --write .",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"lint:fix": "prettier --write . && eslint . --fix",
|
||||
"lint:inspect": "pnpm dlx @eslint/config-inspector",
|
||||
"node:inspect": "pnpm dlx node-modules-inspector",
|
||||
"test:unit": "vitest",
|
||||
"test": "npm run test:unit -- --run",
|
||||
"test:watch": "npm run test:unit -- --watch",
|
||||
@@ -30,27 +32,24 @@
|
||||
],
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.29.7",
|
||||
"@eslint/compat": "^1.3.2",
|
||||
"@eslint/js": "^9.36.0",
|
||||
"@modelcontextprotocol/inspector": "^0.17.0",
|
||||
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
|
||||
"eslint": "^9.36.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-svelte": "^3.12.3",
|
||||
"globals": "^16.0.0",
|
||||
"node-resolve-ts": "^1.0.2",
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-plugin-svelte": "^3.3.3",
|
||||
"publint": "^0.3.13",
|
||||
"typescript": "^5.0.0",
|
||||
"typescript-eslint": "^8.44.1",
|
||||
"vitest": "^3.2.3"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"esbuild"
|
||||
]
|
||||
"@changesets/cli": "catalog:tooling",
|
||||
"@eslint/compat": "catalog:lint",
|
||||
"@eslint/js": "catalog:lint",
|
||||
"@modelcontextprotocol/inspector": "catalog:ai",
|
||||
"@sveltejs/adapter-vercel": "catalog:svelte",
|
||||
"@svitejs/changesets-changelog-github-compact": "catalog:tooling",
|
||||
"eslint": "catalog:lint",
|
||||
"eslint-config-prettier": "catalog:lint",
|
||||
"eslint-plugin-import": "catalog:lint",
|
||||
"eslint-plugin-pnpm": "catalog:lint",
|
||||
"eslint-plugin-svelte": "catalog:lint",
|
||||
"globals": "catalog:lint",
|
||||
"node-resolve-ts": "catalog:tooling",
|
||||
"prettier": "catalog:lint",
|
||||
"prettier-plugin-svelte": "catalog:lint",
|
||||
"publint": "catalog:tooling",
|
||||
"typescript": "catalog:tooling",
|
||||
"typescript-eslint": "catalog:lint",
|
||||
"vitest": "catalog:tooling"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
"license": "ISC",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"drizzle-orm": "^0.44.0"
|
||||
"drizzle-orm": "catalog:orm"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,29 +17,31 @@
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"drizzle-orm": "^0.44.0"
|
||||
"drizzle-orm": "^0.45.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mcp-ui/server": "catalog:ai",
|
||||
"@sveltejs/mcp-schema": "workspace:^",
|
||||
"@tmcp/adapter-valibot": "^0.1.4",
|
||||
"@typescript-eslint/parser": "^8.44.0",
|
||||
"eslint": "^9.36.0",
|
||||
"eslint-plugin-svelte": "^3.12.3",
|
||||
"svelte": "^5.39.2",
|
||||
"svelte-eslint-parser": "^1.3.2",
|
||||
"tmcp": "^1.13.0",
|
||||
"ts-blank-space": "^0.6.2",
|
||||
"typescript-eslint": "^8.44.0",
|
||||
"valibot": "^1.1.0",
|
||||
"vitest": "^3.2.4",
|
||||
"zimmerframe": "^1.1.4"
|
||||
"@tmcp/adapter-valibot": "catalog:tmcp",
|
||||
"@tmcp/transport-in-memory": "catalog:tmcp",
|
||||
"@typescript-eslint/parser": "catalog:lint",
|
||||
"eslint": "catalog:lint",
|
||||
"eslint-plugin-svelte": "catalog:lint",
|
||||
"svelte": "catalog:svelte",
|
||||
"svelte-eslint-parser": "catalog:lint",
|
||||
"tmcp": "catalog:tmcp",
|
||||
"ts-blank-space": "catalog:tooling",
|
||||
"typescript-eslint": "catalog:lint",
|
||||
"valibot": "catalog:tooling",
|
||||
"vitest": "catalog:tooling",
|
||||
"zimmerframe": "catalog:tooling"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anthropic-ai/sdk": "^0.65.0",
|
||||
"@sveltejs/kit": "^2.42.2",
|
||||
"@types/eslint-scope": "^8.3.2",
|
||||
"@types/estree": "^1.0.8",
|
||||
"@typescript-eslint/types": "^8.44.0",
|
||||
"dotenv": "^17.2.3"
|
||||
"@anthropic-ai/sdk": "catalog:ai",
|
||||
"@sveltejs/kit": "catalog:svelte",
|
||||
"@types/eslint-scope": "catalog:lint",
|
||||
"@types/estree": "catalog:tooling",
|
||||
"@typescript-eslint/types": "catalog:lint",
|
||||
"dotenv": "catalog:tooling"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export const base_runes = [
|
||||
export const nested_runes = [
|
||||
'$state.raw',
|
||||
'$state.snapshot',
|
||||
'$state.eager',
|
||||
'$effect.pre',
|
||||
'$effect.tracking',
|
||||
'$effect.pending',
|
||||
|
||||
@@ -412,6 +412,19 @@ describe('add_autofixers_issues', () => {
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
describe.each(dollarless_runes)('importing $rune from external lib', ({ rune }) => {
|
||||
it(`should not add suggestions when importing from packages that are not svelte`, () => {
|
||||
const content = run_autofixers_on_code(`
|
||||
<script>
|
||||
import { ${rune} } from 'svelte-something-something';
|
||||
</script>`);
|
||||
|
||||
expect(content.suggestions).not.toContain(
|
||||
`You are importing "${rune}" from "svelte-something-something". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('derived_with_function', () => {
|
||||
|
||||
@@ -8,6 +8,7 @@ export function add_autofixers_issues(
|
||||
code: string,
|
||||
desired_svelte_version: number,
|
||||
filename = 'Component.svelte',
|
||||
async = false,
|
||||
) {
|
||||
const parsed = parse(code, filename);
|
||||
|
||||
@@ -15,7 +16,7 @@ export function add_autofixers_issues(
|
||||
for (const autofixer of Object.values(autofixers)) {
|
||||
walk(
|
||||
parsed.ast as unknown as Node,
|
||||
{ output: content, parsed, desired_svelte_version },
|
||||
{ output: content, parsed, desired_svelte_version, async },
|
||||
autofixer,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export function add_compile_issues(
|
||||
code: string,
|
||||
desired_svelte_version: number,
|
||||
filename = 'Component.svelte',
|
||||
async = false,
|
||||
) {
|
||||
let compile = compile_component;
|
||||
const extension = extname(filename);
|
||||
@@ -27,6 +28,7 @@ export function add_compile_issues(
|
||||
filename: filename || 'Component.svelte',
|
||||
generate: false,
|
||||
runes: desired_svelte_version >= 5,
|
||||
experimental: { async },
|
||||
});
|
||||
|
||||
for (const warning of compilation_result.warnings) {
|
||||
|
||||
@@ -51,7 +51,7 @@ function base_config(svelte_config: Config): ESLint.Options['baseConfig'] {
|
||||
];
|
||||
}
|
||||
|
||||
function get_linter(version: number) {
|
||||
function get_linter(version: number, async = false) {
|
||||
if (version < 5) {
|
||||
return (svelte_4_linter ??= new ESLint({
|
||||
overrideConfigFile: true,
|
||||
@@ -67,6 +67,7 @@ function get_linter(version: number) {
|
||||
baseConfig: base_config({
|
||||
compilerOptions: {
|
||||
runes: true,
|
||||
experimental: { async },
|
||||
},
|
||||
}),
|
||||
}));
|
||||
@@ -77,8 +78,9 @@ export async function add_eslint_issues(
|
||||
code: string,
|
||||
desired_svelte_version: number,
|
||||
filename = 'Component.svelte',
|
||||
async = false,
|
||||
) {
|
||||
const eslint = get_linter(desired_svelte_version);
|
||||
const eslint = get_linter(desired_svelte_version, async);
|
||||
const results = await eslint.lintText(code, { filePath: filename || './Component.svelte' });
|
||||
|
||||
for (const message of results[0]?.messages ?? []) {
|
||||
|
||||
@@ -6,7 +6,7 @@ const dollarless_runes = base_runes.map((r) => r.replace('$', ''));
|
||||
export const imported_runes: Autofixer = {
|
||||
ImportDeclaration(node, { state, next }) {
|
||||
const source = (node.source.value || node.source.raw?.slice(1, -1))?.toString();
|
||||
if (source && source.startsWith('svelte')) {
|
||||
if (source && (source === 'svelte' || source.startsWith('svelte/'))) {
|
||||
for (const specifier of node.specifiers) {
|
||||
const id =
|
||||
specifier.type === 'ImportDefaultSpecifier'
|
||||
|
||||
@@ -7,6 +7,7 @@ export type AutofixerState = {
|
||||
output: { issues: string[]; suggestions: string[] };
|
||||
parsed: ParseResult;
|
||||
desired_svelte_version: number;
|
||||
async?: boolean;
|
||||
};
|
||||
|
||||
export type Autofixer = Visitors<Node | AST.SvelteNode, AutofixerState>;
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
import type { SvelteMcp } from '../../index.js';
|
||||
import * as v from 'valibot';
|
||||
import { format_sections_list } from '../../utils.js';
|
||||
import { icons } from '../../icons/index.js';
|
||||
import { prompt } from 'tmcp/utils';
|
||||
|
||||
/**
|
||||
* Function that actually generates the prompt string. You can use this in the MCP server handler to generate the prompt, it can accept arguments
|
||||
* if needed (it will always be invoked manually so it's up to you to provide the arguments).
|
||||
*/
|
||||
function svelte_task(available_docs: string, task: string) {
|
||||
return `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:
|
||||
return `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. However: before invoking the \`get_documentation\` tool, try to answer the users query using your own knowledge and the \`svelte-autofixer\` tool. Be mindful of how many section you request, since it is token-intensive!
|
||||
<available-docs>
|
||||
|
||||
${available_docs}
|
||||
|
||||
</available-docs>
|
||||
|
||||
These are the available documentation sections that \`list-sections\` will return, you do not need to call it again.
|
||||
|
||||
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:
|
||||
@@ -64,21 +68,15 @@ export function setup_svelte_task(server: SvelteMcp) {
|
||||
};
|
||||
},
|
||||
},
|
||||
icons,
|
||||
},
|
||||
async ({ task }) => {
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(server.ctx.sessionId, 'svelte-task');
|
||||
}
|
||||
const available_docs = await format_sections_list();
|
||||
|
||||
return {
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: {
|
||||
type: 'text',
|
||||
text: svelte_task(available_docs, task),
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
return prompt.text(svelte_task(available_docs, task));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { SvelteMcp } from '../../index.js';
|
||||
import { get_sections, fetch_with_timeout } from '../../utils.js';
|
||||
import { icons } from '../../icons/index.js';
|
||||
import { resource } from 'tmcp/utils';
|
||||
|
||||
export async function list_sections(server: SvelteMcp) {
|
||||
const sections = await get_sections();
|
||||
@@ -42,23 +44,23 @@ export async function list_sections(server: SvelteMcp) {
|
||||
},
|
||||
},
|
||||
uri: 'svelte://{/slug*}.md',
|
||||
icons,
|
||||
},
|
||||
async (uri, { slug }) => {
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(
|
||||
server.ctx.sessionId,
|
||||
'svelte-doc-section',
|
||||
Array.isArray(slug) ? slug.join(',') : slug,
|
||||
);
|
||||
}
|
||||
const section = sections.find((section) => {
|
||||
return slug === section.slug;
|
||||
});
|
||||
if (!section) throw new Error(`Section not found: ${slug}`);
|
||||
const response = await fetch_with_timeout(section.url);
|
||||
const content = await response.text();
|
||||
return {
|
||||
contents: [
|
||||
{
|
||||
uri,
|
||||
type: 'text',
|
||||
text: content,
|
||||
},
|
||||
],
|
||||
};
|
||||
return resource.text(uri, content);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@ import type { SvelteMcp } from '../../index.js';
|
||||
import * as v from 'valibot';
|
||||
import { get_sections, fetch_with_timeout, format_sections_list } from '../../utils.js';
|
||||
import { SECTIONS_LIST_INTRO, SECTIONS_LIST_OUTRO } from './prompts.js';
|
||||
import { icons } from '../../icons/index.js';
|
||||
import { tool } from 'tmcp/utils';
|
||||
|
||||
export function get_documentation(server: SvelteMcp) {
|
||||
server.tool(
|
||||
{
|
||||
name: 'get-documentation',
|
||||
description:
|
||||
'Retrieves full documentation content for Svelte 5 or SvelteKit sections. Supports flexible search by title (e.g., "$state", "routing") or file path (e.g., "cli/overview"). Can accept a single section name or an array of sections. Before running this, make sure to analyze the users query, as well as the output from list-sections (which should be called first). Then ask for ALL relevant sections the user might require. For example, if the user asks to build anything interactive, you will need to fetch all relevant runes, and so on.',
|
||||
'Retrieves full documentation content for Svelte 5 or SvelteKit sections. Supports flexible search by title (e.g., "$state", "routing") or file path (e.g., "cli/overview"). Can accept a single section name or an array of sections. Before running this, make sure to analyze the users query, as well as the output from list-sections (which should be called first). Then ask for ALL relevant sections the user might require. For example, if the user asks to build anything interactive, you will need to fetch all relevant runes, and so on. Before calling this tool, try to implement Svelte components using your own knowledge and the `svelte-autofixer` tool, since calling this tool is token intensive.',
|
||||
schema: v.object({
|
||||
section: v.pipe(
|
||||
v.union([v.string(), v.array(v.string())]),
|
||||
@@ -17,8 +19,12 @@ export function get_documentation(server: SvelteMcp) {
|
||||
),
|
||||
),
|
||||
}),
|
||||
icons,
|
||||
},
|
||||
async ({ section }) => {
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(server.ctx.sessionId, 'get-documentation');
|
||||
}
|
||||
let sections: string[];
|
||||
|
||||
if (Array.isArray(section)) {
|
||||
@@ -102,14 +108,7 @@ export function get_documentation(server: SvelteMcp) {
|
||||
final_text += `\n\n---\n\n${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`;
|
||||
}
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: final_text,
|
||||
},
|
||||
],
|
||||
};
|
||||
return tool.text(final_text);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { SvelteMcp } from '../../index.js';
|
||||
import { format_sections_list } from '../../utils.js';
|
||||
import { SECTIONS_LIST_INTRO, SECTIONS_LIST_OUTRO } from './prompts.js';
|
||||
import { icons } from '../../icons/index.js';
|
||||
import { tool } from 'tmcp/utils';
|
||||
|
||||
export function list_sections(server: SvelteMcp) {
|
||||
server.tool(
|
||||
@@ -8,18 +10,15 @@ export function list_sections(server: SvelteMcp) {
|
||||
name: 'list-sections',
|
||||
description:
|
||||
'Lists all available Svelte 5 and SvelteKit documentation sections in a structured format. Each section includes a "use_cases" field that describes WHEN this documentation would be useful. You should carefully analyze the use_cases field to determine which sections are relevant for the user\'s query. The use_cases contain comma-separated keywords describing project types (e.g., "e-commerce", "blog"), features (e.g., "authentication", "forms"), components (e.g., "slider", "modal"), development stages (e.g., "deployment", "testing"), or "always" for fundamental concepts. Match these use_cases against the user\'s intent - for example, if building an e-commerce site, fetch sections with use_cases containing "e-commerce", "product listings", "shopping cart", etc. If building a slider, look for "slider", "carousel", "animation", etc. Returns sections as "* title: [section_title], use_cases: [use_cases], path: [file_path]". Always run list-sections FIRST for any Svelte query, then analyze ALL use_cases to identify relevant sections, and finally use get_documentation to fetch ALL relevant sections at once.',
|
||||
icons,
|
||||
},
|
||||
async () => {
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(server.ctx.sessionId, 'list-sections');
|
||||
}
|
||||
const formatted_sections = await format_sections_list();
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: `${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
return tool.text(`${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import { InMemoryTransport } from '@tmcp/transport-in-memory';
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { server } from '../../index.js';
|
||||
|
||||
const transport = new InMemoryTransport(server);
|
||||
|
||||
let session: ReturnType<typeof transport.session>;
|
||||
|
||||
describe('playground-link tool', () => {
|
||||
beforeEach(async () => {
|
||||
session = transport.session();
|
||||
await session.initialize(
|
||||
'2025-06-18',
|
||||
{},
|
||||
{
|
||||
name: 'test-client',
|
||||
version: '1.0.0',
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('should create a playground link if App.svelte is present', async () => {
|
||||
const result = await session.callTool<{ url: string }>('playground-link', {
|
||||
name: 'My Playground',
|
||||
tailwind: false,
|
||||
files: {
|
||||
'App.svelte': `Hi there!`,
|
||||
},
|
||||
});
|
||||
expect(result.structuredContent).toBeDefined();
|
||||
expect(result.structuredContent?.url).toBeDefined();
|
||||
// Verify URL structure rather than exact match (gzip compression can vary by platform)
|
||||
expect(result.structuredContent?.url).toMatch(/^https:\/\/svelte\.dev\/playground#H4sIA/);
|
||||
expect(result.structuredContent?.url).toContain('svelte.dev/playground');
|
||||
});
|
||||
|
||||
it('should have a content with the stringified version of structured content and an ui resource', async () => {
|
||||
const result = await session.callTool<{ url: string }>('playground-link', {
|
||||
name: 'My Playground',
|
||||
tailwind: false,
|
||||
files: {
|
||||
'App.svelte': `Hi there!`,
|
||||
},
|
||||
});
|
||||
expect(result.structuredContent).toBeDefined();
|
||||
expect(result.content).toStrictEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
type: 'text',
|
||||
text: JSON.stringify(result.structuredContent),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
// Verify resource structure without exact URL match (gzip compression can vary by platform)
|
||||
expect(result.content).toStrictEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
type: 'resource',
|
||||
resource: expect.objectContaining({
|
||||
uri: 'ui://svelte/playground-link',
|
||||
mimeType: 'text/uri-list',
|
||||
_meta: { 'mcpui.dev/ui-preferred-frame-size': ['100%', '1200px'] },
|
||||
text: expect.stringMatching(/^https:\/\/svelte\.dev\/playground\/embed#H4sIA/),
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it('should not create a playground link if App.svelte is missing', async () => {
|
||||
const result = await session.callTool<{ url: string }>('playground-link', {
|
||||
name: 'My Playground',
|
||||
tailwind: false,
|
||||
files: {
|
||||
'Something.svelte': `Hi there!`,
|
||||
},
|
||||
});
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.content?.[0]).toStrictEqual({
|
||||
type: 'text',
|
||||
text: 'The files must contain an App.svelte file as the entry point',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { SvelteMcp } from '../../index.js';
|
||||
import * as v from 'valibot';
|
||||
import { icons } from '../../icons/index.js';
|
||||
import { createUIResource } from '@mcp-ui/server';
|
||||
import { tool } from 'tmcp/utils';
|
||||
|
||||
async function compress_and_encode_text(input: string) {
|
||||
const reader = new Blob([input]).stream().pipeThrough(new CompressionStream('gzip')).getReader();
|
||||
@@ -54,8 +57,12 @@ export function playground_link(server: SvelteMcp) {
|
||||
outputSchema: v.object({
|
||||
url: v.string(),
|
||||
}),
|
||||
icons,
|
||||
},
|
||||
async ({ files, name, tailwind }) => {
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(server.ctx.sessionId, 'playground-link');
|
||||
}
|
||||
const playground_base = new URL('https://svelte.dev/playground');
|
||||
const playground_files: File[] = [];
|
||||
|
||||
@@ -73,17 +80,11 @@ export function playground_link(server: SvelteMcp) {
|
||||
}
|
||||
|
||||
if (!has_app_svelte) {
|
||||
return {
|
||||
isError: true,
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: JSON.stringify({
|
||||
error: 'The files must contain an App.svelte file as the entry point',
|
||||
}),
|
||||
},
|
||||
],
|
||||
};
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(server.ctx.sessionId, 'playground-link-no-app-svelte');
|
||||
}
|
||||
|
||||
return tool.error('The files must contain an App.svelte file as the entry point');
|
||||
}
|
||||
|
||||
const playground_config = {
|
||||
@@ -98,12 +99,26 @@ export function playground_link(server: SvelteMcp) {
|
||||
url: playground_base.toString(),
|
||||
};
|
||||
|
||||
// use the embed path to have a cleaner UI for mcp-ui
|
||||
playground_base.pathname = '/playground/embed';
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: JSON.stringify(content),
|
||||
},
|
||||
createUIResource({
|
||||
uri: 'ui://svelte/playground-link',
|
||||
content: {
|
||||
type: 'externalUrl',
|
||||
iframeUrl: playground_base.toString(),
|
||||
},
|
||||
uiMetadata: {
|
||||
'preferred-frame-size': ['100%', '1200px'],
|
||||
},
|
||||
encoding: 'text',
|
||||
}),
|
||||
],
|
||||
structuredContent: content,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { InMemoryTransport } from '@tmcp/transport-in-memory';
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { server } from '../../index.js';
|
||||
|
||||
const transport = new InMemoryTransport(server);
|
||||
|
||||
let session: ReturnType<typeof transport.session>;
|
||||
|
||||
async function autofixer_tool_call(
|
||||
code: string,
|
||||
is_error = false,
|
||||
desired_svelte_version = 5,
|
||||
async = false,
|
||||
) {
|
||||
const result = await session.callTool('svelte-autofixer', {
|
||||
code,
|
||||
desired_svelte_version,
|
||||
filename: 'App.svelte',
|
||||
async,
|
||||
});
|
||||
|
||||
expect(result).toBeDefined();
|
||||
if (is_error) {
|
||||
return result as any;
|
||||
}
|
||||
expect(result.structuredContent).toBeDefined();
|
||||
return result.structuredContent as any;
|
||||
}
|
||||
|
||||
describe('svelte-autofixer tool', () => {
|
||||
beforeEach(async () => {
|
||||
session = transport.session();
|
||||
|
||||
session = transport.session();
|
||||
await session.initialize(
|
||||
'2025-06-18',
|
||||
{},
|
||||
{
|
||||
name: 'test-client',
|
||||
version: '1.0.0',
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('should add suggestions for js parse errors', async () => {
|
||||
const content = await autofixer_tool_call(`<script>
|
||||
$state count = 0;
|
||||
</script>`);
|
||||
expect(content.issues.length).toBeGreaterThan(0);
|
||||
expect(content.suggestions).toContain(
|
||||
"The code can't be compiled because a Javascript parse error. In case you are using runes like this `$state variable_name = 3;` or `$derived variable_name = 3 * count` that's not how runes are used. You need to use them as function calls without importing them: `const variable_name = $state(3)` and `const variable_name = $derived(3 * count)`.",
|
||||
);
|
||||
});
|
||||
|
||||
it('should error out if async is true with a version less than 5', async () => {
|
||||
const content = await autofixer_tool_call(
|
||||
`<script>
|
||||
$state count = 0;
|
||||
</script>`,
|
||||
true,
|
||||
4,
|
||||
true,
|
||||
);
|
||||
expect(content.isError).toBeTruthy();
|
||||
expect(content.content[0]).toBeDefined();
|
||||
expect(content.content[0].text).toBe(
|
||||
'The async option can only be used with Svelte version 5 or higher.',
|
||||
);
|
||||
});
|
||||
|
||||
it('should not add suggestion/issues if async is true and await is used in the template/derived', async () => {
|
||||
const content = await autofixer_tool_call(
|
||||
`<script>
|
||||
import { slow_double } from './utils.js';
|
||||
let count = $state(0);
|
||||
let double = $derived(await slow_double(count));
|
||||
</script>
|
||||
|
||||
{double}
|
||||
{await slow_double(count)}`,
|
||||
false,
|
||||
5,
|
||||
true,
|
||||
);
|
||||
expect(content.issues).toHaveLength(0);
|
||||
expect(content.suggestions).toHaveLength(0);
|
||||
expect(content.require_another_tool_call_after_fixing).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should add suggestion/issues if async is false and await is used in the template/derived', async () => {
|
||||
const content = await autofixer_tool_call(
|
||||
`<script>
|
||||
import { slow_double } from './utils.js';
|
||||
let count = $state(0);
|
||||
let double = $derived(await slow_double(count));
|
||||
</script>
|
||||
|
||||
{double}
|
||||
{await slow_double(count)}`,
|
||||
false,
|
||||
5,
|
||||
);
|
||||
expect(content.issues.length).toBeGreaterThanOrEqual(1);
|
||||
expect(content.issues).toEqual(
|
||||
expect.arrayContaining([expect.stringContaining('experimental_async')]),
|
||||
);
|
||||
expect(content.require_another_tool_call_after_fixing).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should add suggestions for css invalid identifier', async () => {
|
||||
const content = await autofixer_tool_call(`<script>
|
||||
let my_color = $state('red');
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.my-class {
|
||||
color: {my_color};
|
||||
}
|
||||
</style>`);
|
||||
|
||||
expect(content.issues.length).toBeGreaterThan(0);
|
||||
expect(content.suggestions).toContain(
|
||||
"The code can't be compiled because a valid CSS identifier is expected. This sometimes means you are trying to use a variable in CSS like this: `color: {my_color}` but Svelte doesn't support that. You can use inline CSS variables for that `<div style:--color={my_color}></div>` and then use the variable as usual in CSS with `color: var(--color)`.",
|
||||
);
|
||||
});
|
||||
|
||||
it('should error in case the passed in version is different from 4 or 5', async () => {
|
||||
const content = await autofixer_tool_call(`whatever`, true, 3);
|
||||
|
||||
expect(content.content).toBeDefined();
|
||||
expect(content.content[0]).toBeDefined();
|
||||
expect(content.content[0].text).toContain(
|
||||
'The desired_svelte_version MUST be either 4 or 5 but received "3"',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,8 @@ import * as v from 'valibot';
|
||||
import { add_compile_issues } from '../../autofixers/add-compile-issues.js';
|
||||
import { add_eslint_issues } from '../../autofixers/add-eslint-issues.js';
|
||||
import { add_autofixers_issues } from '../../autofixers/add-autofixers-issues.js';
|
||||
import { icons } from '../../icons/index.js';
|
||||
import { tool } from 'tmcp/utils';
|
||||
|
||||
export function svelte_autofixer(server: SvelteMcp) {
|
||||
server.tool(
|
||||
@@ -20,6 +22,12 @@ export function svelte_autofixer(server: SvelteMcp) {
|
||||
'The desired svelte version...if possible read this from the package.json of the user project, otherwise use some hint from the wording (if the user asks for runes it wants version 5). Default to 5 in case of doubt.',
|
||||
),
|
||||
),
|
||||
async: v.pipe(
|
||||
v.optional(v.boolean()),
|
||||
v.description(
|
||||
'If true the code is an async component/module and might use await in the markup or top-level awaits in the script tag. If possible check the svelte.config.js/svelte.config.ts to check if the option is enabled otherwise asks the user if they prefer using it or not. You can only use this option if the version is 5.',
|
||||
),
|
||||
),
|
||||
filename: v.pipe(
|
||||
v.optional(v.string()),
|
||||
v.description(
|
||||
@@ -38,31 +46,37 @@ export function svelte_autofixer(server: SvelteMcp) {
|
||||
readOnlyHint: true,
|
||||
openWorldHint: false,
|
||||
},
|
||||
icons,
|
||||
},
|
||||
async ({
|
||||
code,
|
||||
filename: filename_or_path,
|
||||
desired_svelte_version: desired_svelte_version_unchecked,
|
||||
async,
|
||||
}) => {
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(server.ctx.sessionId, 'svelte-autofixer');
|
||||
}
|
||||
// we validate manually because some clients don't support union in the input schema (looking at you cursor)
|
||||
const parsed_version = v.safeParse(
|
||||
v.union([v.literal(4), v.literal(5), v.literal('4'), v.literal('5')]),
|
||||
desired_svelte_version_unchecked,
|
||||
);
|
||||
if (parsed_version.success === false) {
|
||||
return {
|
||||
isError: true,
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: `The desired_svelte_version MUST be either 4 or 5 but received "${desired_svelte_version_unchecked}"`,
|
||||
},
|
||||
],
|
||||
};
|
||||
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||
await server.ctx.custom?.track?.(server.ctx.sessionId, 'svelte-autofixer-wrong-version');
|
||||
}
|
||||
return tool.error(
|
||||
`The desired_svelte_version MUST be either 4 or 5 but received "${desired_svelte_version_unchecked}"`,
|
||||
);
|
||||
}
|
||||
|
||||
const desired_svelte_version = parsed_version.output;
|
||||
|
||||
if (async && +desired_svelte_version < 5) {
|
||||
return tool.error('The async option can only be used with Svelte version 5 or higher.');
|
||||
}
|
||||
|
||||
const content: {
|
||||
issues: string[];
|
||||
suggestions: string[];
|
||||
@@ -74,11 +88,11 @@ export function svelte_autofixer(server: SvelteMcp) {
|
||||
|
||||
const filename = filename_or_path ? basename(filename_or_path) : 'Component.svelte';
|
||||
|
||||
add_compile_issues(content, code, +desired_svelte_version, filename);
|
||||
add_compile_issues(content, code, +desired_svelte_version, filename, async);
|
||||
|
||||
add_autofixers_issues(content, code, +desired_svelte_version, filename);
|
||||
add_autofixers_issues(content, code, +desired_svelte_version, filename, async);
|
||||
|
||||
await add_eslint_issues(content, code, +desired_svelte_version, filename);
|
||||
await add_eslint_issues(content, code, +desired_svelte_version, filename, async);
|
||||
} catch (e: unknown) {
|
||||
const error = e as Error & { start?: { line: number; column: number } };
|
||||
content.issues.push(
|
||||
@@ -88,6 +102,10 @@ export function svelte_autofixer(server: SvelteMcp) {
|
||||
content.suggestions.push(
|
||||
"The code can't be compiled because a Javascript parse error. In case you are using runes like this `$state variable_name = 3;` or `$derived variable_name = 3 * count` that's not how runes are used. You need to use them as function calls without importing them: `const variable_name = $state(3)` and `const variable_name = $derived(3 * count)`.",
|
||||
);
|
||||
} else if (error.message.includes('css_expected_identifier')) {
|
||||
content.suggestions.push(
|
||||
"The code can't be compiled because a valid CSS identifier is expected. This sometimes means you are trying to use a variable in CSS like this: `color: {my_color}` but Svelte doesn't support that. You can use inline CSS variables for that `<div style:--color={my_color}></div>` and then use the variable as usual in CSS with `color: var(--color)`.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,15 +113,7 @@ export function svelte_autofixer(server: SvelteMcp) {
|
||||
content.require_another_tool_call_after_fixing = true;
|
||||
}
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: JSON.stringify(content),
|
||||
},
|
||||
],
|
||||
structuredContent: content,
|
||||
};
|
||||
return tool.structured(content);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
14
packages/mcp-server/src/mcp/icons/index.ts
Normal file
14
packages/mcp-server/src/mcp/icons/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export const icons = [
|
||||
{
|
||||
src: 'https://mcp.svelte.dev/logo.svg',
|
||||
mimeType: 'image/svg+xml',
|
||||
},
|
||||
{
|
||||
src: 'https://mcp.svelte.dev/logo.png',
|
||||
mimeType: 'image/png',
|
||||
},
|
||||
{
|
||||
src: 'data:image/png;base64,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',
|
||||
mimeType: 'image/png',
|
||||
},
|
||||
];
|
||||
@@ -3,12 +3,15 @@ import { McpServer } from 'tmcp';
|
||||
import { setup_prompts, setup_resources, setup_tools } from './handlers/index.js';
|
||||
import type { LibSQLDatabase } from 'drizzle-orm/libsql';
|
||||
import type { Schema } from '@sveltejs/mcp-schema';
|
||||
import { icons } from './icons/index.js';
|
||||
|
||||
export const server = new McpServer(
|
||||
{
|
||||
name: 'Svelte MCP',
|
||||
version: '0.0.1',
|
||||
description: 'The official Svelte MCP server implementation',
|
||||
websiteUrl: 'https://mcp.svelte.dev',
|
||||
icons,
|
||||
},
|
||||
{
|
||||
adapter: new ValibotJsonSchemaAdapter(),
|
||||
@@ -21,10 +24,18 @@ export const server = new McpServer(
|
||||
instructions:
|
||||
'This is the official Svelte MCP server. It MUST be used whenever svelte development is involved. It can provide official documentation, code examples and correct your code. After you correct the component call this tool again to confirm all the issues are fixed.',
|
||||
},
|
||||
).withContext<{ db: LibSQLDatabase<Schema> }>();
|
||||
).withContext<{
|
||||
db: LibSQLDatabase<Schema>;
|
||||
track?: (sessionId: string, event: string, extra?: string) => Promise<void>;
|
||||
}>();
|
||||
|
||||
export type SvelteMcp = typeof server;
|
||||
|
||||
setup_tools(server);
|
||||
setup_resources(server);
|
||||
setup_prompts(server);
|
||||
|
||||
server.on('initialize', async ({ clientInfo: client_info }) => {
|
||||
if (!server.ctx.custom?.track || !server.ctx.sessionId) return;
|
||||
server.ctx.custom.track(server.ctx.sessionId, 'initialize', client_info.name);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,67 @@
|
||||
# @sveltejs/mcp
|
||||
|
||||
## 0.1.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix: revert name change and add title ([`98efa1e`](https://github.com/sveltejs/mcp/commit/98efa1e09ebcca7827b10dc6bc8e1699fc1e5171))
|
||||
|
||||
## 0.1.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix: update server name on mcp registry ([`60297b3`](https://github.com/sveltejs/mcp/commit/60297b3c49bf110b48908e61b5d5d902ea1bdf39))
|
||||
|
||||
- chore: update tmcp ([#99](https://github.com/sveltejs/mcp/pull/99))
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix: add `async` parameter to `svelte-autofixer` ([#94](https://github.com/sveltejs/mcp/pull/94))
|
||||
|
||||
- fix: install latest eslint svelte packages to support `$state.eager` ([`f6ce89f`](https://github.com/sveltejs/mcp/commit/f6ce89ff34faabc3d746a350ea347298ecfed2ec))
|
||||
|
||||
## 0.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix: add icons to `server.json` ([`02c951b`](https://github.com/sveltejs/mcp/commit/02c951baa86ac8103ffc158a202c06cfe6b15c01))
|
||||
|
||||
- fix: add `preferred-frame-size` to UI resource ([`3fabcc0`](https://github.com/sveltejs/mcp/commit/3fabcc0f9bfee916c0deb9c2ffa931ed2168af2d))
|
||||
|
||||
- feat: support: `$state.eager` ([#90](https://github.com/sveltejs/mcp/pull/90))
|
||||
|
||||
## 0.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- feat: return `mcp-ui` resource from `playground-link` ([#84](https://github.com/sveltejs/mcp/pull/84))
|
||||
|
||||
- feat: suggest against js variables in css ([#78](https://github.com/sveltejs/mcp/pull/78))
|
||||
|
||||
## 0.1.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix: upgrade registry publisher cli ([`5fa2baa`](https://github.com/sveltejs/mcp/commit/5fa2baa27009f01e0e4e91cee7984b81a81c1c29))
|
||||
|
||||
## 0.1.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix: use correct server schema version ([`579be87`](https://github.com/sveltejs/mcp/commit/579be877fa9f87f7f173450ca5bc918824d68282))
|
||||
|
||||
## 0.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix: prevent `imported_runes` suggestion from being added for libs that are not svelte ([`87af64f`](https://github.com/sveltejs/mcp/commit/87af64f4bc6d07b75640eb987a33655654363997))
|
||||
|
||||
- feat: add svelte icon and website url for mcp server ([#75](https://github.com/sveltejs/mcp/pull/75))
|
||||
|
||||
- fix: use `data:` uri for local icon & add icons to tools + resources + prompts ([`cf62286`](https://github.com/sveltejs/mcp/commit/cf622869129382a97ad059bb1389f115907adc8e))
|
||||
|
||||
## 0.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
4e7c92f289d903d4649c59f82df6e7b014caebb49d8b5c1d2466667fd6caf68c mcp-publisher_1.2.3_darwin_amd64.tar.gz
|
||||
09637600871bec7cce25e098d6ce23b7c7577a8e537f618d24a5630d2d782afa mcp-publisher_1.2.3_darwin_amd64.tar.gz.sbom.json
|
||||
9ac90d3182bae9af4b48fb3cd19c3cade3e52c8ea25d7aa14327326a209bcf71 mcp-publisher_1.2.3_darwin_arm64.tar.gz
|
||||
0b2cedf3f42c5a7b33bdd3f72ce7f4c938ff4fe2aca5cabd60094dc4b855c1f6 mcp-publisher_1.2.3_darwin_arm64.tar.gz.sbom.json
|
||||
868a54268f21580ec97ec9dfc4fc3442a7f69c241ee7c745c7032f2e43cdf47b mcp-publisher_1.2.3_linux_amd64.tar.gz
|
||||
a7bce190ea1c1b5682d1b5069b20dd9c67f3688e02dbc93e7273e942097dac4d mcp-publisher_1.2.3_linux_amd64.tar.gz.sbom.json
|
||||
319cdefb4c4f19fa35eeb0337e30be3169dbf3107a8c160651691a6342a6783b mcp-publisher_1.2.3_linux_arm64.tar.gz
|
||||
bc9309ab843531e811990dcf637b9912c470fc38eddc13a5af0512fcef498944 mcp-publisher_1.2.3_linux_arm64.tar.gz.sbom.json
|
||||
298026e0252547046f50dcb7817239d44107f5a3ae64f4e43b6a31d0c5b89f9b mcp-publisher_1.2.3_windows_amd64.tar.gz
|
||||
971b835ce4df2b37ddcf8591d4400dc94d1e3f730b181b325c905261b75b9e6e mcp-publisher_1.2.3_windows_amd64.tar.gz.sbom.json
|
||||
64da67b451d0fba12f15f7b0f6ab8d71c718bb2263f90f198ff1fe15a5ff2024 mcp-publisher_1.2.3_windows_arm64.tar.gz
|
||||
f591b2153f1277cb67817763a23de9e77188fa94b893fac00e91d13160d696e3 mcp-publisher_1.2.3_windows_arm64.tar.gz.sbom.json
|
||||
265377b343500898e3c3fea798926ff2695fe7500c1225c8a97f390a5892d849 registry-1.2.3.tar.gz
|
||||
a9c03a84d2e30176d6ed7b493e7e3a8a05d446f1611a35bad6007fbe3ba80657 registry_1.2.3_darwin_amd64.tar.gz
|
||||
4db4e8a0b1f3d0ca193e5356fef89b74c0666cdf56d6f3c8fc2d0aba1cac3b55 registry_1.2.3_darwin_amd64.tar.gz.sbom.json
|
||||
2933a11990db16035e4896f394ada389166046911e6868f79b84636048dfe6fb registry_1.2.3_darwin_arm64.tar.gz
|
||||
edd36e62f4b1c5b857da1862f20cbcf6dd3dfd9717888c08bd5c25740d8b11f6 registry_1.2.3_darwin_arm64.tar.gz.sbom.json
|
||||
59bdd9977795891220e6fdb8f79dd7d14f48166362e94699bee59e745f7c7df6 registry_1.2.3_linux_amd64.tar.gz
|
||||
7f7efb180aa312f674377e32a92ac3600e50c62e37d697d2d16acfe60227a2fd registry_1.2.3_linux_amd64.tar.gz.sbom.json
|
||||
7fef1088a664850dd75e54a699fce6a5fb32e8ebbdc0d2869b6b34945727ba9c registry_1.2.3_linux_arm64.tar.gz
|
||||
ca0488e5cbb04c8ee515e1b80e08b755a55d6af1784368a2f55e429137359a25 registry_1.2.3_linux_arm64.tar.gz.sbom.json
|
||||
5bc29310aacc08437dcc973cfc1e1129f7065d2050396012f5ed98c4eb0ea75b registry_1.2.3_windows_amd64.tar.gz
|
||||
e918c604f23e6d33f9952f18eddf0e50e50d7ce3e87ca5258bf78f4f1da243ab registry_1.2.3_windows_amd64.tar.gz.sbom.json
|
||||
394cad1e6f5e37a583defdd522edbff854de5035d6e025a195664db31b58c0c0 registry_1.2.3_windows_arm64.tar.gz
|
||||
c93df66f3257ba4b9c29f7bfded4cf04d712ec220b044ddfa019da3e4bd6475f registry_1.2.3_windows_arm64.tar.gz.sbom.json
|
||||
25
packages/mcp-stdio/checksums/registry_1.3.10_checksums.txt
Normal file
25
packages/mcp-stdio/checksums/registry_1.3.10_checksums.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
aada17479e04faa55e380ae1ee0de3c5a5d86b4c0ad5dd4b64f68426f87c84e0 mcp-publisher_darwin_amd64.tar.gz
|
||||
d426c953218a61699bb47d1dae6f0b89807313f082d650f243b8a91bc7f448f3 mcp-publisher_darwin_amd64.tar.gz.sbom.json
|
||||
75a14ff2570bca0eba656dee1d4ad4b2955de67e97aacc5884bcab1793d8dd2d mcp-publisher_darwin_arm64.tar.gz
|
||||
988adc169f9ce4cded2b08ab0df7c1738f8ea77dccb581a234f7e036ad7b478e mcp-publisher_darwin_arm64.tar.gz.sbom.json
|
||||
dc97c003df75d40134b9bf003077ac9057187d64f8d601c4f2457980712dbb62 mcp-publisher_linux_amd64.tar.gz
|
||||
49e63cd1c1ade8988f6c6f679b3172ab28b5ae6ef92243a4f8a78c58150853c7 mcp-publisher_linux_amd64.tar.gz.sbom.json
|
||||
094e70c73ff671da69b138b448c68336f582e9245355d469c8372a48639bbc6c mcp-publisher_linux_arm64.tar.gz
|
||||
3888ef7db7a77efeb3cfb711527a00ed93188ff3fce05468a6308ae75e2bb913 mcp-publisher_linux_arm64.tar.gz.sbom.json
|
||||
43a1f3ca680350dd898697c93e4e0a1489c2b638dc946c4ef496a815c0e46d53 mcp-publisher_windows_amd64.tar.gz
|
||||
512ac8c24275845bcc9c4c4faf4f08d950de3585e13d283e1aa48c567735ad73 mcp-publisher_windows_amd64.tar.gz.sbom.json
|
||||
739347d69d4979faf06365843c49ede92e16975cd1afe3ef627e9511459fa30b mcp-publisher_windows_arm64.tar.gz
|
||||
b8ecb1cf98caef446447a1ad89f7259699632f09bd19d600c89fd800aa3c7698 mcp-publisher_windows_arm64.tar.gz.sbom.json
|
||||
5b4d676da2a574ee0d3cfd752d9d3a663e675d48d928706dda0084271ded1cb5 registry-1.3.10.tar.gz
|
||||
d5140c2730991dfc236305d3e6eddb6c05da9325d9803b1eaee50c06953d5991 registry_darwin_amd64.tar.gz
|
||||
fd1380e0d308a1702d040427603d203a9407603e1156cd23743a3074e1313b06 registry_darwin_amd64.tar.gz.sbom.json
|
||||
db22e6b0f518b1ccaf44f749babc28d70d2573ba5641b06ff085430826eac688 registry_darwin_arm64.tar.gz
|
||||
4415141c7b490b1c7d9643e799df5a2885f3292b4c1c3e4c71f2841aae52fdeb registry_darwin_arm64.tar.gz.sbom.json
|
||||
8fbb607254b412513eeec45c89fb3051fe9ce623196f6361ded1d335a5348566 registry_linux_amd64.tar.gz
|
||||
c256554e7060cbfc92494f9b22c4e857b0606ca57479a29fa61649917c63c974 registry_linux_amd64.tar.gz.sbom.json
|
||||
86ff45f0c5afc674e9b30ec47815ab54401d716b12d70f27bd73f72d5b5ad2f8 registry_linux_arm64.tar.gz
|
||||
0ccb7a3d856a7951bea5d5e63314459b365199577f573c2fbcd11e7e98b9b94c registry_linux_arm64.tar.gz.sbom.json
|
||||
f56d75a2569e6e37f44d8f7bede0bd01f8056130f8eab58b1211d55d43fa08fe registry_windows_amd64.tar.gz
|
||||
d941a82dd69937edff791b4f84b61006d78802280fb0c06d15c07a5d90d6e0a0 registry_windows_amd64.tar.gz.sbom.json
|
||||
b2e6fff3cd9bab76d4431294b2844e1e9a399d45728e5459492b21367da62453 registry_windows_arm64.tar.gz
|
||||
1954a54f47048e1ac25c92196440f0c2b1ba2357e01720d5b14e6faf43be46b2 registry_windows_arm64.tar.gz.sbom.json
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sveltejs/mcp",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.13",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"mcpName": "dev.svelte/mcp",
|
||||
@@ -9,7 +9,7 @@
|
||||
"url": "https://github.com/sveltejs/mcp/issues"
|
||||
},
|
||||
"bin": {
|
||||
"svelte-mcp": "./dist/index.js"
|
||||
"svelte-mcp": "./dist/index.mjs"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -32,14 +32,15 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/mcp-server": "workspace:^",
|
||||
"@tmcp/transport-stdio": "^0.3.1",
|
||||
"@types/node": "^22.15.17",
|
||||
"publint": "^0.3.13",
|
||||
"tsdown": "^0.15.0",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^3.1.3"
|
||||
"@tmcp/transport-stdio": "catalog:tmcp",
|
||||
"@types/node": "catalog:tooling",
|
||||
"publint": "catalog:tooling",
|
||||
"tsdown": "catalog:tooling",
|
||||
"typescript": "catalog:tooling",
|
||||
"vitest": "catalog:tooling"
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint": "^9.36.0"
|
||||
"eslint": "catalog:lint",
|
||||
"tmcp": "catalog:tmcp"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
|
||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
|
||||
"name": "dev.svelte/mcp",
|
||||
"title": "Svelte MCP",
|
||||
"description": "The official Svelte MCP server providing docs and autofixing tools for Svelte development",
|
||||
"repository": {
|
||||
"id": "1054419133",
|
||||
@@ -8,13 +9,23 @@
|
||||
"subfolder": "packages/mcp-stdio",
|
||||
"source": "github"
|
||||
},
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.13",
|
||||
"websiteUrl": "https://svelte.dev/docs/mcp/overview",
|
||||
"icons": [
|
||||
{
|
||||
"src": "https://mcp.svelte.dev/logo.svg",
|
||||
"mimeType": "image/svg+xml"
|
||||
},
|
||||
{
|
||||
"src": "https://mcp.svelte.dev/logo.png",
|
||||
"mimeType": "image/png"
|
||||
}
|
||||
],
|
||||
"packages": [
|
||||
{
|
||||
"registryType": "npm",
|
||||
"identifier": "@sveltejs/mcp",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.13",
|
||||
"runtimeHint": "npx",
|
||||
"transport": {
|
||||
"type": "stdio"
|
||||
|
||||
1463
pnpm-lock.yaml
generated
1463
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,60 @@
|
||||
packages:
|
||||
- './packages/*'
|
||||
- './apps/*'
|
||||
- ./packages/*
|
||||
- ./apps/*
|
||||
|
||||
catalogs:
|
||||
ai:
|
||||
'@anthropic-ai/sdk': ^0.71.0
|
||||
'@mcp-ui/server': ^5.12.0
|
||||
'@modelcontextprotocol/inspector': ^0.18.0
|
||||
lint:
|
||||
'@eslint/compat': ^2.0.0
|
||||
'@eslint/js': ^9.36.0
|
||||
'@types/eslint-scope': ^8.3.2
|
||||
'@typescript-eslint/parser': ^8.44.0
|
||||
'@typescript-eslint/types': ^8.44.0
|
||||
eslint: ^9.36.0
|
||||
eslint-config-prettier: ^10.0.1
|
||||
eslint-plugin-import: ^2.32.0
|
||||
eslint-plugin-pnpm: ^1.3.0
|
||||
eslint-plugin-svelte: ^3.12.5
|
||||
globals: ^16.0.0
|
||||
prettier: ^3.4.2
|
||||
prettier-plugin-svelte: ^3.3.3
|
||||
svelte-eslint-parser: ^1.4.0
|
||||
typescript-eslint: ^8.44.0
|
||||
orm:
|
||||
'@libsql/client': ^0.15.0
|
||||
drizzle-kit: ^0.31.0
|
||||
drizzle-orm: ^0.45.0
|
||||
svelte:
|
||||
'@sveltejs/adapter-vercel': ^6.0.0
|
||||
'@sveltejs/kit': ^2.42.2
|
||||
'@sveltejs/vite-plugin-svelte': ^6.0.0
|
||||
svelte: ^5.39.2
|
||||
svelte-check: ^4.0.0
|
||||
tmcp:
|
||||
'@tmcp/adapter-valibot': ^0.1.4
|
||||
'@tmcp/transport-http': ^0.8.3
|
||||
'@tmcp/transport-in-memory': ^0.0.5
|
||||
'@tmcp/transport-stdio': ^0.4.0
|
||||
tmcp: ^1.19.0
|
||||
tooling:
|
||||
'@changesets/cli': ^2.29.7
|
||||
'@svitejs/changesets-changelog-github-compact': ^1.2.0
|
||||
'@types/estree': ^1.0.8
|
||||
'@types/node': ^24.3.1
|
||||
'@vercel/analytics': ^1.5.0
|
||||
dotenv: ^17.2.3
|
||||
node-resolve-ts: ^1.0.2
|
||||
publint: ^0.3.13
|
||||
ts-blank-space: ^0.6.2
|
||||
tsdown: ^0.18.0
|
||||
typescript: ^5.0.0
|
||||
valibot: ^1.1.0
|
||||
vite: ^7.0.4
|
||||
vite-plugin-devtools-json: ^1.0.0
|
||||
vitest: ^4.0.0
|
||||
zimmerframe: ^1.1.4
|
||||
|
||||
useNodeVersion: 22.19.0
|
||||
|
||||
Reference in New Issue
Block a user