Skip to content

Commit 7f85892

Browse files
committed
Merge branch 'main' into copy-tables-from-current-mcp
2 parents b4259dd + 6b5588c commit 7f85892

File tree

20 files changed

+2841
-15
lines changed

20 files changed

+2841
-15
lines changed

.github/workflows/check.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Type Check
2+
3+
on:
4+
push:
5+
branches: [main, redesign]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v4
20+
with:
21+
version: 10
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22'
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm i
31+
32+
- name: Run type check
33+
run: pnpm run check
34+
env:
35+
DATABASE_URL: file:test.db
36+
VOYAGE_API_KEY: dummy-key

.github/workflows/lint.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main, redesign]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v4
20+
with:
21+
version: 10
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22'
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm i
31+
32+
- name: Run linting
33+
run: pnpm run lint
34+
env:
35+
DATABASE_URL: file:test.db
36+
VOYAGE_API_KEY: dummy-key

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main, redesign]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v4
20+
with:
21+
version: 10
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22'
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm i
31+
32+
- name: Build project
33+
run: pnpm run build
34+
env:
35+
DATABASE_URL: file:test.db
36+
VOYAGE_API_KEY: dummy-key
37+
38+
- name: Run tests
39+
run: pnpm run test
40+
env:
41+
DATABASE_URL: file:test.db
42+
VOYAGE_API_KEY: dummy-key

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ vite.config.ts.timestamp-*
2424

2525
# SQLite
2626
*.db
27+
dist

.mcp.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mcpServers": {
3+
"svelte-llm": {
4+
"type": "http",
5+
"url": "https://svelte-llm.stanislav.garden/mcp/mcp"
6+
}
7+
}
8+
}

.vscode/mcp.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"servers": {
3+
"Svelte MCP": {
4+
"type": "stdio",
5+
"command": "node",
6+
"args": ["dist/lib/stdio.js"]
7+
}
8+
},
9+
"inputs": []
10+
}

CLAUDE.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
This is a Svelte MCP (Model Context Protocol) server implementation that includes both SvelteKit web interface and MCP server functionality.
8+
9+
### Setup
10+
11+
```bash
12+
pnpm i
13+
cp .env.example .env
14+
# Set the VOYAGE_API_KEY for embeddings support in .env
15+
pnpm dev
16+
```
17+
18+
### Common Commands
19+
20+
- `pnpm dev` - Start SvelteKit development server
21+
- `pnpm build` - Build the application for production
22+
- `pnpm start` - Run the MCP server (Node.js entry point)
23+
- `pnpm check` - Run Svelte type checking
24+
- `pnpm check:watch` - Run type checking in watch mode
25+
- `pnpm lint` - Run prettier check and eslint
26+
- `pnpm format` - Format code with prettier
27+
- `pnpm test` - Run unit tests with vitest
28+
- `pnpm test:watch` - Run tests in watch mode
29+
30+
### Database Commands (Drizzle ORM)
31+
32+
- `pnpm db:push` - Push schema changes to database
33+
- `pnpm db:generate` - Generate migration files
34+
- `pnpm db:migrate` - Run migrations
35+
- `pnpm db:studio` - Open Drizzle Studio
36+
37+
## Architecture
38+
39+
### MCP Server Implementation
40+
41+
The core MCP server is implemented in `src/lib/mcp/index.ts` using the `tmcp` library with:
42+
43+
- **Transport Layers**: Both HTTP (`HttpTransport`) and STDIO (`StdioTransport`) support
44+
- **Schema Validation**: Uses Valibot with `ValibotJsonSchemaAdapter`
45+
- **Main Tool**: `svelte-autofixer` - analyzes Svelte code and provides suggestions/fixes
46+
47+
### Code Analysis Engine
48+
49+
Located in `src/lib/server/analyze/`:
50+
51+
- **Parser** (`parse.ts`): Uses `svelte-eslint-parser` and TypeScript parser to analyze Svelte components
52+
- **Scope Analysis**: Tracks variables, references, and scopes across the AST
53+
- **Rune Detection**: Identifies Svelte 5 runes (`$state`, `$effect`, `$derived`, etc.)
54+
55+
### Autofixer System
56+
57+
- **Autofixers** (`src/lib/mcp/autofixers.ts`): Visitor pattern implementations for code analysis
58+
- **Walker Utility** (`src/lib/index.ts`): Enhanced AST walking with visitor mixing capabilities
59+
- **Current Autofixer**: `assign_in_effect` - detects assignments to `$state` variables inside `$effect` blocks
60+
61+
### Database Layer
62+
63+
- **ORM**: Drizzle with SQLite backend
64+
- **Schema** (`src/lib/server/db/schema.ts`): Vector table for embeddings support
65+
- **Utils** (`src/lib/server/db/utils.ts`): Custom float32 array type for vectors
66+
67+
### SvelteKit Integration
68+
69+
- **Hooks** (`src/hooks.server.ts`): Integrates MCP HTTP transport with SvelteKit requests
70+
- **Routes**: Basic web interface for the MCP server
71+
72+
## Key Dependencies
73+
74+
- **tmcp**: Core MCP server implementation
75+
- **@tmcp/transport-http** & **@tmcp/transport-stdio**: Transport layers
76+
- **@tmcp/adapter-valibot**: Schema validation adapter
77+
- **svelte-eslint-parser**: Svelte component parsing
78+
- **zimmerframe**: AST walking utilities
79+
- **drizzle-orm**: Database ORM with SQLite
80+
- **valibot**: Schema validation library
81+
82+
## Environment Configuration
83+
84+
Required environment variables:
85+
86+
- `DATABASE_URL`: SQLite database path (default: `file:test.db`)
87+
- `VOYAGE_API_KEY`: API key for embeddings support (optional)
88+
89+
When connected to the svelte-llm MCP server, you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively:
90+
91+
## Available MCP Tools:
92+
93+
### 1. list_sections
94+
95+
Use this FIRST to discover all available documentation sections. Returns a structured list with titles and paths.
96+
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
97+
98+
### 2. get_documentation
99+
100+
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
101+
After calling the list_sections tool, you MUST analyze the returned documentation sections and then use the get_documentation tool to fetch ALL documentation sections that are relevant for the users task.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
# @sveltejs/mcp
22

33
Repo for the official Svelte MCP server.
4+
5+
## Dev setup instructions
6+
7+
```
8+
pnpm i
9+
cp .env.example .env
10+
pnpm dev
11+
```
12+
13+
1. Set the VOYAGE_API_KEY for embeddings support
14+
15+
### Local dev tools
16+
17+
#### MCP inspector
18+
19+
```
20+
pnpm run inspect
21+
```
22+
23+
Then visit http://localhost:6274/
24+
25+
- Transport type: `Streamable HTTP`
26+
- http://localhost:5173/mcp
27+
28+
#### Database inspector
29+
30+
```
31+
pnpm run db:studio
32+
```
33+
34+
https://local.drizzle.studio/

package.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,30 @@
44
"description": "The official Svelte MCP server implementation",
55
"type": "module",
66
"main": "src/index.js",
7+
"bin": {
8+
"svelte-mcp": "./dist/lib/stdio.js"
9+
},
710
"scripts": {
811
"start": "node src/index.js",
912
"dev": "vite dev",
1013
"build": "vite build",
14+
"build:mcp": "tsc --project tsconfig.build.json",
15+
"prepublishOnly": "pnpm build:mcp",
1116
"preview": "vite preview",
1217
"prepare": "svelte-kit sync || echo ''",
1318
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1419
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
1520
"format": "prettier --write .",
1621
"lint": "prettier --check . && eslint .",
22+
"lint:fix": "prettier --write . && eslint . --fix",
1723
"test:unit": "vitest",
1824
"test": "npm run test:unit -- --run",
25+
"test:watch": "npm run test:unit -- --watch",
1926
"db:push": "drizzle-kit push",
2027
"db:generate": "drizzle-kit generate",
2128
"db:migrate": "drizzle-kit migrate",
22-
"db:studio": "drizzle-kit studio"
29+
"db:studio": "drizzle-kit studio",
30+
"inspect": "DANGEROUSLY_OMIT_AUTH=true npx @modelcontextprotocol/inspector"
2331
},
2432
"keywords": [
2533
"svelte",
@@ -32,10 +40,14 @@
3240
"@eslint/compat": "^1.2.5",
3341
"@eslint/js": "^9.18.0",
3442
"@libsql/client": "^0.14.0",
43+
"@modelcontextprotocol/inspector": "^0.16.7",
3544
"@sveltejs/adapter-vercel": "^5.6.3",
3645
"@sveltejs/kit": "^2.22.0",
3746
"@sveltejs/vite-plugin-svelte": "^6.0.0",
47+
"@types/eslint-scope": "^8.3.2",
48+
"@types/estree": "^1.0.8",
3849
"@types/node": "^24.3.1",
50+
"@typescript-eslint/types": "^8.43.0",
3951
"drizzle-kit": "^0.30.2",
4052
"drizzle-orm": "^0.40.0",
4153
"eslint": "^9.18.0",
@@ -56,12 +68,15 @@
5668
"@tmcp/adapter-valibot": "^0.1.4",
5769
"@tmcp/transport-http": "^0.6.0",
5870
"@tmcp/transport-stdio": "^0.1.3",
71+
"@typescript-eslint/parser": "^8.43.0",
72+
"svelte-eslint-parser": "^1.3.2",
5973
"tmcp": "^1.12.2",
60-
"valibot": "^1.1.0"
74+
"valibot": "^1.1.0",
75+
"zimmerframe": "^1.1.4"
6176
},
6277
"pnpm": {
6378
"onlyBuiltDependencies": [
6479
"esbuild"
6580
]
6681
}
67-
}
82+
}

0 commit comments

Comments
 (0)