✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more

mcp-svelte-docs

A Model Context Protocol (MCP) server that provides a comprehensive reference guide for Svelte 5, helping LLMs provide accurate guidance when users are working with Svelte. While it includes migration patterns from Svelte 4 to Svelte 5, it also serves as a detailed reference for Svelte 5 features, common mistakes, and best practices.

Features

📊 Content Categories

  • Migration Patterns: Side-by-side comparisons of Svelte 4 and Svelte 5 code
  • Svelte 5 Features: Detailed documentation on runes, snippets, props, and events
  • Common Mistakes: Patterns showing incorrect code and corrections with explanations
  • Global State Patterns: Various approaches to global state management in Svelte 5

🔄 Key Migration Patterns

  • State Declaration: let count = 0let count = $state(0)
  • Derived Values: $: doubled = count * 2const doubled = $derived(count * 2)
  • Side Effects: $: { /* effect */ }$effect(() => { /* effect */ })
  • Event Handling: on:click={handler}onclick={handler}
  • Props: export let proplet { prop } = $props()
  • Component Events: createEventDispatcher() → callback props
  • Slots: <slot>{@render children()}

🧩 Svelte 5 Features

  • Runes: $state, $derived, $effect, $props, and more
  • Snippets: Reusable chunks of markup with parameters
  • Props: New approach to component props with destructuring
  • Events: Standard HTML event attributes and callback props

⚠️ Common Mistakes

  • Reactivity: Exporting state directly, forgetting $state, etc.
  • Events: Using on:click instead of onclick, event modifiers, etc.
  • Props: Using export let instead of $props, TypeScript issues, etc.

🌐 Global State Patterns

  • Function-based: Getter/setter functions for module-level state
  • Object-based: Objects with getters/setters for more ergonomic APIs
  • Class-based: Classes with stateful properties for structured state
  • Context-based: Svelte contexts for SSR-safe global state

💡 Comprehensive Examples

All content includes:

  • Both JavaScript and TypeScript examples
  • Clear explanations of concepts and usage
  • Best practices and considerations
  • Common pitfalls to avoid

Usage

Installation

# Install dependencies
npm install

# Build the project
npm run build

# Start the server
npm start

Configuration

The server can be configured by setting environment variables:

  • DEBUG: Set to ‘true’ to enable debug logging

Cline Configuration

Add this to your Cline MCP settings:

{
	"mcpServers": {
		"mcp-svelte-docs": {
			"command": "node",
			"args": ["/path/to/mcp-svelte-docs/dist/index.js"],
			"env": {
				"DEBUG": "false"
			},
			"disabled": false,
			"autoApprove": [
				"svelte_pattern",
				"svelte5_feature",
				"svelte5_common_mistakes"
			]
		}
	}
}

Using with LLMs

When an LLM needs to provide guidance about Svelte, it can use the available tools and resources:

Migration Patterns

<use_mcp_tool>
<server_name>mcp-svelte-docs</server_name>
<tool_name>svelte_pattern</tool_name>
<arguments>
{
  "pattern": "event"
}
</arguments>
</use_mcp_tool>

This will return migration patterns related to event handling, showing both Svelte 4 and Svelte 5 implementations.

Svelte 5 Features

<use_mcp_tool>
<server_name>mcp-svelte-docs</server_name>
<tool_name>svelte5_feature</tool_name>
<arguments>
{
  "feature": "state",
  "includeExamples": true
}
</arguments>
</use_mcp_tool>

This will return detailed information about the $state rune, including examples and best practices.

Common Mistakes

<use_mcp_tool>
<server_name>mcp-svelte-docs</server_name>
<tool_name>svelte5_common_mistakes</tool_name>
<arguments>
{
  "feature": "props"
}
</arguments>
</use_mcp_tool>

This will return common mistakes related to props in Svelte 5, along with corrections and explanations.

Resource Access

<access_mcp_resource>
<server_name>mcp-svelte-docs</server_name>
<uri>svelte5://runes/state</uri>
</access_mcp_resource>

This will return a detailed reference for the $state rune in markdown format.

API

The server implements the following MCP Tools:

svelte_pattern

Get Svelte 4 to Svelte 5 migration patterns.

Parameters:

  • pattern (string, required): Pattern name or category to search for

Example response:

{
	"patterns": [
		{
			"name": "Basic state",
			"description": "Declaring and using component state",
			"svelte4": "<script>n  let count = 0;n  n  function increment() {n    count++;n  }n</script>nn<button on:click={increment}>n  Clicked {count} timesn</button>",
			"svelte5": "<script>n  let count = $state(0);n  n  function increment() {n    count++;n  }n</script>nn<button onclick={increment}>n  Clicked {count} timesn</button>",
			"notes": "In Svelte 5, state is explicitly declared using the $state rune, and event handlers use standard HTML attributes (onclick) instead of the directive syntax (on:click)."
		}
	]
}

svelte5_feature

Get detailed information about Svelte 5 features.

Parameters:

  • feature (string, required): Feature name (e.g., “runes”, “snippets”, “props”)
  • includeExamples (boolean, optional): Whether to include code examples

Example response:

{
	"features": [
		{
			"name": "$state",
			"description": "The $state rune is used to declare reactive state in Svelte 5.",
			"examples": [
				{
					"code": "<script>n  let count = $state(0);n  n  function increment() {n    count++;n  }n</script>nn<button onclick={increment}>n  Clicked {count} timesn</button>",
					"explanation": "Basic usage of $state to create a reactive counter. When the button is clicked, the count is incremented and the UI updates automatically."
				}
			],
			"bestPractices": [
				"Use $state for any value that needs to trigger UI updates when changed",
				"For large arrays or objects that don't need deep reactivity, consider using $state.raw",
				"Don't export $state variables directly from modules, use getter/setter functions instead"
			]
		}
	]
}

svelte5_common_mistakes

Get common mistakes and corrections for Svelte 5 features.

Parameters:

  • feature (string, required): Feature name (e.g., “runes”, “snippets”, “events”)

Example response:

{
	"mistakes": [
		{
			"name": "Exporting state directly",
			"description": "Directly exporting a stateful variable from a module",
			"mistake": "// counter.svelte.jsnlet count = $state(0);nnexport { count };",
			"correction": "// counter.svelte.jsnlet count = $state(0);nnexport function getCount() {n  return count;n}nnexport function setCount(value) {n  count = value;n}",
			"explanation": "When you export a stateful variable directly, the reactivity is lost when it's imported elsewhere. This is because the importing module only gets the current value, not the reactive binding. Instead, export functions that access and modify the state."
		}
	]
}

Resources

The server also provides the following MCP Resources:

Direct Resources

  • svelte5://overview: Overview of Svelte 5 features and changes
  • svelte5://runes/overview: Overview of all runes in Svelte 5
  • svelte5://snippets/overview: Overview of snippets in Svelte 5
  • svelte5://global-state/overview: Overview of global state approaches in Svelte 5

Resource Templates

  • svelte5://runes/{rune_name}: Detailed reference for a specific rune
  • svelte5://patterns/{category}/{pattern_name}: Reference for a specific Svelte pattern
  • svelte5://mistakes/{category}: Common mistakes for a specific category

Development

Project Structure

src/
├── index.ts                # MCP server entry point
├── config.ts               # Basic configuration
├── tools/                  # Tool implementations
│   └── handler.ts          # Tool registration
├── resources/              # Resource implementations
│   └── index.ts            # Resource registration
└── patterns/               # Pattern database
    ├── index.ts            # Exports all patterns
    ├── state.ts            # State management patterns
    ├── events.ts           # Event handling patterns
    ├── props.ts            # Props and component patterns
    ├── templating.ts       # Templating patterns
    ├── lifecycle.ts        # Lifecycle patterns
    ├── svelte5_features.ts # Svelte 5 specific features
    ├── common_mistakes.ts  # Common mistakes and corrections
    └── global_state.ts     # Global state patterns

Adding New Content

Migration Patterns

To add new migration patterns, add them to the appropriate pattern file in the src/patterns directory:

{
  name: 'Pattern Name',
  description: 'Description of the pattern',
  svelte4: `Svelte 4 code example`,
  svelte5: `Svelte 5 code example`,
  notes: 'Additional notes about migration considerations'
}

Svelte 5 Features

To add new Svelte 5 features, add them to the src/patterns/svelte5_features.ts file:

{
  name: 'Feature Name',
  description: 'Description of the feature',
  examples: [
    {
      code: `Code example`,
      explanation: 'Explanation of the example'
    }
  ],
  bestPractices: [
    'Best practice 1',
    'Best practice 2'
  ]
}

Common Mistakes

To add new common mistakes, add them to the src/patterns/common_mistakes.ts file:

{
  name: 'Mistake Name',
  description: 'Description of the common mistake',
  mistake: `Incorrect code example`,
  correction: `Corrected code example`,
  explanation: 'Detailed explanation of why the mistake is problematic and how the correction addresses it'
}

Global State Patterns

To add new global state patterns, add them to the src/patterns/global_state.ts file:

{
  name: 'Global State Pattern Name',
  description: 'Description of the global state pattern',
  code: `Implementation example`,
  usage: `Usage example`,
  notes: 'Additional notes about the pattern, including considerations for server vs. client usage'
}

Setup

  1. Clone the repository
  2. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Run in development mode:
npm run dev

Troubleshooting

Common Issues

  • Pattern not found: Make sure you’re searching for a pattern that exists in the database. Try using more general terms like “state” or “event” instead of specific pattern names.
  • Server not starting: Ensure you have the correct permissions to run the server and that the port is not already in use.
  • TypeScript errors: Make sure you have the correct version of TypeScript installed and that your code follows the project’s TypeScript configuration.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details.

Acknowledgments

Built on:

  • Model Context Protocol
  • Svelte

Svelte Documentation Server

Project Details

Recomended MCP Servers

DuckDB Knowledge Graph Memory Server
DuckDB Knowledge Graph Memory Server

MCP Memory Server with DuckDB backend

🧩
MCP Filesystem Python

A MCP Filesystem implementation for Claude, written mostly by Claude

Local MCP Server
Local MCP Server

大家好!我是功能丰富的 MCP 服务,旨在打破设备与服务的隔阂,为用户带来便捷体验。 天气工具和气象平台联动,快速为用户推送全球实时天气,助力大家规划出行。控制浏览器工具模拟人工操作,自动搜索、浏览网页,大幅节省时间。摄像头工具调用本地摄像头拍照、录像,实现人脸识别,保障家庭安防。 为实现工具协同,我搭建了稳定框架,开发者可以基于现有服务进行拓展

Code Indexer
Code Indexer

A Model Context Protocol (MCP) server that helps large language models index, search, and analyze code repositories with...

Speckle MCP Server
Speckle MCP Server
Long-Term Memory for AI Agents
Long-Term Memory for AI Agents

MCP server for long term agent memory with Mem0. Also useful as a template to get you started...

🧩
Figma to React Converter

MCP server for converting Figma designs to React components

Web Research Server
Web Research Server

MCP web research server (give Claude real-time info from the web)

🧩
MCP2Lambda

Run any AWS Lambda function as a Large Language Model (LLM) tool without code changes using Anthropic's Model...

Code MCP
Code MCP
Zerodha Integration
Zerodha Integration

Mcp server to connect with zerodha's kite trade apis

FirstCycling MCP Server
FirstCycling MCP Server

This is a Model Context Protocol (MCP) server that provides professional cycling data from FirstCycling. It allows you...

Featured Templates

View More
AI Assistants
Talk with Claude 3
156 1166
AI Characters
Sarcastic AI Chat Bot
128 1440
Data Analysis
Pharmacy Admin Panel
238 1704
AI Assistants
Image to text with Claude 3
150 1122
Verified Icon
AI Assistants
Speech to Text
134 1510

Start your free trial

Build your solution today. No credit card required.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.