An MCP (Model Context Protocol) server that indexes Svelte 5 and SvelteKit projects, providing rich code intelligence for AI assistants.
<script>, <script module>, template, and <style> blocks. Automatically detects Svelte version from package.json; rejects Svelte 4 and earlier with a clear error.$state, $derived, $effect, $props, $bindable, $inspect, $host, $snippet, and $render usage*Button* matches MyButton, ButtonRow, etc.) with optional kind filteringgit clone <repository>
cd svelte-index-mcp
cargo build --release
# Binary is at target/release/svelte-index-mcp
cp target/release/svelte-index-mcp ~/.local/bin/
# or
cargo install --path .
# Index current directory
svelte-index-mcp index
# Index specific path
svelte-index-mcp index ./my-svelte-project
# Force full re-index
svelte-index-mcp index . --force
# Verbose output
svelte-index-mcp index . --verbose
Output:
Indexing project at "my-project"
Found 42 Svelte files to index
Indexed 42 files, 156 symbols, 12 components
# Use default database (.svelte-index.db)
svelte-index-mcp serve
# Use custom database path
svelte-index-mcp serve --db-path /path/to/index.db
The server communicates via JSON-RPC over stdin/stdout, compatible with MCP clients like Claude Desktop, Cursor, and others.
| File Kind | Detected By | Examples |
|---|---|---|
page |
+page.svelte |
src/routes/about/+page.svelte |
layout |
+layout.svelte |
src/routes/+layout.svelte |
error |
+error.svelte |
src/routes/+error.svelte |
server |
+server.ts / +server.js |
src/routes/api/+server.ts |
component |
.svelte files |
src/lib/Button.svelte |
module |
Files in /lib/ |
src/lib/utils.ts |
| Kind | Description |
|---|---|
function |
Function declarations |
variable |
Variable declarations |
rune |
Svelte 5 runes ($state, $derived, etc.) |
component |
Component references in templates |
import |
Import statements |
export |
Export statements |
prop |
$props() declarations |
effect |
$effect() / $effect.pre() |
derived |
$derived() / $derived.by() |
snippet |
{#snippet} definitions |
Routes are automatically extracted from the file path relative to src/routes/:
/ → src/routes/+page.svelte/about → src/routes/about/+page.svelte/sverdle/how-to-play → src/routes/sverdle/how-to-play/+page.svelte[id] are detected and stored| Tool | Description |
|---|---|
query_symbols |
Search symbols by name pattern. Returns file locations, kinds, and signatures. |
search_symbols |
Search symbols by wildcard pattern. Use * as a wildcard (e.g., *Button* matches MyButton, ButtonRow). Optionally filter by kind (function, variable, rune, import). |
get_symbol |
Get full details of a symbol by name and optional file path. |
list_symbols |
List all symbols, optionally filtered by kind (function, variable, rune, etc.) or file. |
get_component |
Get component details including props, slots, snippets, runes used, and generics. |
list_components |
List all indexed components, optionally filtered by directory path. |
find_dead_code |
Find exported symbols that are never imported by other files. Filter by path prefix and symbol kinds (function, variable). |
| Tool | Description |
|---|---|
find_usage |
Find all locations where a symbol is used. |
find_imports |
List all imports for a given file. |
trace |
Trace call/usage chains. Direction: inbound (who uses this) or outbound (what this uses). |
find_context |
Find setContext/getContext usage. Filter by context key or direction (set/get). |
| Tool | Description |
|---|---|
find_routes |
Find SvelteKit routes. Filter by path pattern. Returns path, kind, and parameters. |
index |
Trigger re-indexing. Use force=true to reindex all files. |
index_status |
Get indexing status: file count, last indexed time, project root. |
The index is stored in a SQLite database (.svelte-index.db):
<Counter />)setContext/getContext usagecargo build
# All tests
cargo test
# Just integration tests
cargo test --test integration_tests
# With output
cargo test -- --nocapture
# Check for warnings (CI uses this)
cargo clippy --all-targets --all-features -- -D warnings
# Auto-fix
cargo clippy --all-targets --all-features --fix
# Format
cargo fmt
src/
main.rs # CLI entry point (index, serve commands)
lib.rs # Library exports
indexer.rs # Orchestrates: walk → parse → store in SQLite
walker.rs # Find .svelte files, detect project root, file kinds
db/mod.rs # SQLite schema, queries, and CRUD operations
parser/
svelte.rs # Block separation: script/template/style
typescript.rs # JS/TS parsing: runes, functions, imports, exports
template.rs # Template AST: components, blocks, directives, snippets
mcp/
mod.rs # MCP server entry
server.rs # JSON-RPC server setup
handler.rs # Tool dispatch and request handling
tools.rs # Tool definitions with JSON schemas
docs/roadmap.md — Current development priorities and upcoming featureswalker.rs) — Recursively find .svelte files (excludes node_modules and .svelte-kit)parser/) — Extract blocks, then parse TypeScript and template contentdb/mod.rs) — Insert into SQLite with incremental hash-based updates<script module>, <script>, template, <style>{#if}, {#each}, {#snippet}), directives (bind:, on:, use:, transition:)[License information]