|
1 | 1 | # mcp-svelte-docs |
2 | 2 |
|
3 | | -A Model Context Protocol (MCP) server that provides a comprehensive |
4 | | -reference guide for Svelte 5 and SvelteKit, helping LLMs provide |
5 | | -accurate guidance when users are working with Svelte. It includes |
6 | | -detailed documentation for: |
7 | | - |
8 | | -- **Svelte 5 core features** (runes, components, events) |
9 | | -- **Modern async patterns** (await expressions, loading states) |
10 | | -- **SvelteKit remote functions** (type-safe client-server |
| 3 | +A Model Context Protocol (MCP) server providing authoritative Svelte 5 |
| 4 | +and SvelteKit definitions extracted directly from TypeScript |
| 5 | +declarations. Get precise syntax, parameters, and examples for all |
| 6 | +Svelte 5 concepts through a single, unified interface. |
| 7 | + |
| 8 | +## Architecture |
| 9 | + |
| 10 | +**Definition-First Approach**: Rather than multiple specialized tools, |
| 11 | +this server provides one powerful `svelte_definition` tool that |
| 12 | +accesses 28+ comprehensive definitions covering: |
| 13 | + |
| 14 | +- **All Svelte 5 runes** ($state, $derived, $props, $effect variants) |
| 15 | +- **Modern features** (snippets, await expressions, remote functions) |
| 16 | +- **Event handling** (DOM events, custom events, component |
11 | 17 | communication) |
12 | | -- **Migration patterns** from Svelte 4 to Svelte 5 |
13 | | -- **Common mistakes** and best practices |
14 | | -- **Advanced patterns** for state management and data flow |
| 18 | +- **Migration guidance** (Svelte 4 to 5 patterns and best practices) |
| 19 | +- **TypeScript interfaces** (Snippet, Snapshot types) |
| 20 | +- **Advanced patterns** (global state, common mistakes, lifecycle |
| 21 | + equivalents) |
15 | 22 |
|
16 | | -## Available Tools |
| 23 | +## Available Tool |
17 | 24 |
|
18 | | -This MCP server provides 16 specialized tools for Svelte 5 and |
19 | | -SvelteKit development: |
| 25 | +### `svelte_definition` |
20 | 26 |
|
21 | | -### Core Svelte 5 Runes |
| 27 | +**Single, powerful tool** for all Svelte 5 and SvelteKit concepts: |
22 | 28 |
|
23 | | -- `svelte5_state` - Documentation for `$state` rune (reactive state) |
24 | | -- `svelte5_derived` - Documentation for `$derived` rune (computed |
25 | | - values) |
26 | | -- `svelte5_props` - Documentation for `$props` rune (component |
27 | | - properties) |
28 | | -- `svelte5_effect` - Documentation for `$effect` rune (side effects) |
| 29 | +```typescript |
| 30 | +svelte_definition(identifier: string, format?: "syntax"|"quick"|"full") |
| 31 | +``` |
| 32 | + |
| 33 | +**Examples:** |
29 | 34 |
|
30 | | -### Svelte 5 Features |
| 35 | +- `svelte_definition("$state")` - Complete $state documentation |
| 36 | +- `svelte_definition("snippets", "quick")` - Snippet overview with |
| 37 | + example |
| 38 | +- `svelte_definition("onclick", "syntax")` - Just the TypeScript |
| 39 | + signature |
| 40 | +- `svelte_definition("migration-patterns")` - Svelte 4 → 5 migration |
| 41 | + guide |
31 | 42 |
|
32 | | -- `svelte5_snippets` - Documentation for snippets (replacement for |
33 | | - slots) |
34 | | -- `svelte5_events` - Event handling patterns in Svelte 5 |
35 | | -- `svelte5_component_events` - Component event patterns and best |
36 | | - practices |
37 | | -- `svelte5_global_state` - Global state management patterns |
| 43 | +**Response Formats:** |
38 | 44 |
|
39 | | -### Modern Async Features ✨ NEW |
| 45 | +- `"syntax"` - TypeScript signature only (~50 words) |
| 46 | +- `"quick"` - Definition + minimal example (~200 words) |
| 47 | +- `"full"` - Complete documentation with examples (~500-1000 words, |
| 48 | + default) |
40 | 49 |
|
41 | | -- `svelte5_await_expressions` - Await expressions for async operations |
42 | | - (experimental) |
43 | | -- `sveltekit_remote_functions` - Remote functions for type-safe |
44 | | - client-server communication (experimental) |
| 50 | +### Available Identifiers (28+) |
45 | 51 |
|
46 | | -### Migration & Guidance |
| 52 | +**Core Runes:** `$state`, `$state.raw`, `$state.snapshot`, `$derived`, |
| 53 | +`$derived.by`, `$props`, `$bindable`, `$effect`, `$effect.pre`, |
| 54 | +`$effect.root`, `$effect.pending`, `$effect.tracking` |
47 | 55 |
|
48 | | -- `svelte5_migration` - Migration patterns from Svelte 4 to Svelte 5 |
49 | | -- `svelte5_mistakes` - Common mistakes and how to avoid them |
50 | | -- `svelte5_overview` - General overview of Svelte 5 features |
51 | | -- `svelte5_runes_overview` - Comprehensive overview of all runes |
| 56 | +**Development Tools:** `$inspect`, `$host` |
52 | 57 |
|
53 | | -### Tool Parameters |
| 58 | +**Features & Patterns:** `snippets`, `onclick`, `component-events`, |
| 59 | +`migration-patterns`, `await-expressions`, `remote-functions`, |
| 60 | +`global-state`, `common-mistakes`, `lifecycle-equivalents` |
54 | 61 |
|
55 | | -All tools support an optional `includeExamples` parameter: |
| 62 | +**Event Handling:** `custom-events`, `event-delegation`, |
| 63 | +`event-modifiers` |
56 | 64 |
|
57 | | -- `includeExamples: true` (default) - Include code examples and |
58 | | - demonstrations |
59 | | -- `includeExamples: false` - Return documentation without code |
60 | | - examples for concise reference |
| 65 | +**TypeScript Interfaces:** `snippet`, `snapshot` |
61 | 66 |
|
62 | 67 | ## Key Features |
63 | 68 |
|
64 | | -### 🚀 Experimental Async Support |
65 | | - |
66 | | -- **Await Expressions**: Use `await` directly in components, |
67 | | - `$derived`, and markup |
68 | | -- **Boundaries**: Error handling and loading states with |
69 | | - `<svelte:boundary>` |
70 | | -- **Synchronized Updates**: Consistent UI updates during async |
71 | | - operations |
72 | | -- **Performance Patterns**: Avoid waterfalls, optimize concurrent |
73 | | - requests |
74 | | - |
75 | | -### ⚡ Remote Functions |
76 | | - |
77 | | -- **Type-safe Communication**: Full TypeScript support between client |
78 | | - and server |
79 | | -- **Four Function Types**: Query (read), Form (submit), Command |
80 | | - (execute), Prerender (static) |
81 | | -- **Optimistic Updates**: Immediate UI feedback with server |
82 | | - synchronization |
83 | | -- **Progressive Enhancement**: Works with and without JavaScript |
84 | | - |
85 | | -### 📚 Comprehensive Documentation |
86 | | - |
87 | | -- **Real-world Examples**: Patterns from core maintainer projects |
88 | | -- **Migration Guidance**: Step-by-step Svelte 4 to 5 migration |
89 | | -- **Error Prevention**: Common mistakes and corrections |
90 | | -- **Best Practices**: Production-ready patterns and recommendations |
| 69 | +### 🎯 **Authoritative & TypeScript-First** |
| 70 | + |
| 71 | +- **Direct from Source**: Definitions extracted from official Svelte 5 |
| 72 | + TypeScript declarations |
| 73 | +- **Always Current**: Reflects the actual API, not outdated tutorials |
| 74 | +- **Type-Safe**: Includes precise parameter types, return values, and |
| 75 | + constraints |
| 76 | + |
| 77 | +### ⚡ **Single Interface, Complete Coverage** |
| 78 | + |
| 79 | +- **One Tool**: `svelte_definition` replaces 16+ specialized tools |
| 80 | +- **28+ Definitions**: Every Svelte 5 rune, feature, and pattern |
| 81 | + covered |
| 82 | +- **Consistent Responses**: Same interface whether you need `$state` |
| 83 | + or `remote-functions` |
| 84 | + |
| 85 | +### 🚀 **Modern Svelte 5 & SvelteKit Support** |
| 86 | + |
| 87 | +- **Await Expressions**: Async operations directly in templates |
| 88 | + (`await-expressions`) |
| 89 | +- **Remote Functions**: Type-safe client-server communication |
| 90 | + (`remote-functions`) |
| 91 | +- **All Runes**: Complete `$effect` family, `$state` variants, |
| 92 | + `$derived.by`, `$bindable` |
| 93 | +- **Advanced Patterns**: Event handling, global state, component |
| 94 | + communication |
| 95 | + |
| 96 | +### 📚 **Smart Error Recovery** |
| 97 | + |
| 98 | +- **Fuzzy Matching**: Suggests correct identifiers for typos |
| 99 | +- **Related Concepts**: Points to similar definitions when searches |
| 100 | + fail |
| 101 | +- **Migration Help**: Converts Svelte 4 patterns to Svelte 5 |
| 102 | + equivalents |
91 | 103 |
|
92 | 104 | ## Config |
93 | 105 |
|
|
0 commit comments