Svelte LSP as MCP
Provides Svelte component analysis through the official Svelte Language Server: compiler diagnostics, hover/type information, definitions, references, document symbols, signature help, completions, rename previews, and formatting edits.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Svelte LSP as MCP check src/App.svelte for TypeScript errors"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Svelte LSP as MCP
Send a Svelte component to an MCP tool and get compiler diagnostics, type information, completions or edit previews. The npm package includes the official Svelte Language Server, Svelte 5, TypeScript and the MCP runtime. Inline source works from an empty directory.
Run with npx
Use Node.js 22.12 or newer.
npx --yes @pacnpal/svelte-lsp-as-mcpThe process waits for MCP messages on standard input. Use --help for the command options or --version to check the installed release.
Connect a local MCP client
Add this entry to a client that accepts mcpServers configuration, then reload the client.
{
"mcpServers": {
"svelte": {
"command": "npx",
"args": ["-y", "@pacnpal/svelte-lsp-as-mcp"]
}
}
}Call svelte_diagnostics with the following arguments. The bundled language server reports TypeScript error 2322 because the initializer is a string and count is declared as a number.
{
"source": "<script lang=\"ts\">let count: number = 'two';</script>\n<p>{count}</p>"
}To pin a release, append a version to the package name, for example @pacnpal/svelte-lsp-as-mcp@0.2.0. To run from GitHub, use github:pacnpal/svelte-lsp-as-mcp#main in the package argument slot. You can replace main with a commit SHA.
Related MCP server: vscode-mcp
Deploy with MCPElevator
Open Servers → Add server → Import JSON and paste the client configuration above. In the manual form, select the
npxrunner, set the command tonpxand enter the two arguments-yand@pacnpal/svelte-lsp-as-mcp.Save and start the server. Open the tools list and call
svelte_diagnosticswith the inline example above. The source travels in the MCP request, so the runner can serve any client's component without a mounted checkout.Copy the server's MCP URL into a Streamable HTTP client. With the default local port and the slug
svelte, the URL ishttp://127.0.0.1:8080/s/svelte/mcp. Remote clients use the MCPElevator base URL and the access credentials configured for that server. MCPElevator setup and client connections
Optional project files
For cross-file navigation, project-specific imports, preprocessors and configuration, run against a trusted checkout with its dependencies installed. Project configuration can execute JavaScript.
npx --yes @pacnpal/svelte-lsp-as-mcp --workspace /absolute/path/to/svelte-projectCall a tool with {"file":"src/App.svelte"} to read the saved component. Relative file paths start at --workspace, or at the server's current directory when the flag is omitted. With MCPElevator in Docker, mount the project into its container for file-based calls and pass the container path to --workspace.
Tools
Every tool accepts either source (the full component text) or file (a saved component path). Inline requests are independent. Pass the source again on each call. Inline imports can use the bundled Svelte package. Use project files to resolve your own modules. A position has a zero-based line and a zero-based character measured in UTF-16 code units. Locations returned by the language server use file URIs and the same coordinates.
Tool | Additional arguments | Result |
| — | Current diagnostics, including severity, message and source range |
|
| Type information and documentation |
|
| Declaration locations, including imported symbols |
|
| Type declaration locations |
|
| Symbol references in the project |
| — | Component outline with source ranges |
|
| Call signatures and the active parameter |
|
| Suggestions, total count and LSP's |
|
| Proposed LSP workspace edit |
| Optional | Proposed formatting edits |
For a position-based example, call svelte_hover with {"source":"<script>let count = 2;</script>\n<p>{count}</p>","position":{"line":1,"character":5}} to inspect count.
Inline results refer to Component.svelte under a private temporary directory owned by the server. Each inline request supplies its text through the language server’s open-document buffer. Results are available as JSON text and under structuredContent.result. An empty array or null can be a valid answer when the language server has no matches. Rename and format return edits for the client to review and apply. Server logs go to stderr.
Troubleshooting
Client cannot launch npx. Check
node --versionandnpx --versionin the runner environment. A desktop client may need the absolute path tonpxand Node's bin directory on itsPATH.File missing or outside the workspace. Check the path from the server process. In Docker, use the mount destination. Symlinks supplied as input must also resolve inside the workspace.
Missing project types or unresolved local imports. Use file mode, install dependencies and run the project's type-generation or SvelteKit sync step. Point
--workspaceat the project or monorepo containing its configuration.Unexpected position or stale editor content. Save the file and check the zero-based coordinates. An emoji outside the Basic Multilingual Plane occupies two UTF-16 code units.
Development
npm ci
npm test
npm start
npm pack --dry-runIntegration tests exercise all ten tools with inline source in an empty directory and with saved project files. CI also installs the packed tarball offline with an empty npm cache and runs the inline tests against that installation.
Publishing
The GitHub Actions workflow tests pushes to main and pull requests. Pushing a version tag such as v0.2.0 runs the tests and package smoke check, verifies the tag matches package.json, then publishes the public package with provenance to npm using OIDC.
The npm package's GitHub Actions trusted publisher uses owner pacnpal, repository svelte-lsp-as-mcp, workflow filename publish.yml, and an empty environment field. Enable the npm publish action. The GitHub-hosted publish job requests id-token: write. npm trusted publishing
For the next patch release, run these commands from a clean, up-to-date main checkout. npm updates the manifest and lockfile, commits the change and tags the version.
npm version patch
git push --follow-tags origin mainLicense
Available Tools
10 toolssvelte_completionsBRead-only
List completion suggestions at the cursor. Use offset and limit to page through the result.
Inputs: position (required), file, limit, offset, +1 more.
svelte_definitionCRead-only
Find where the symbol at a position is defined.
Inputs: position (required), file, source.
svelte_diagnosticsBRead-only
Get current compiler, markup, CSS and TypeScript diagnostics for a component.
Inputs: file, source.
svelte_document_symbolsBRead-only
List the component's symbols and their source ranges.
Inputs: file, source.
svelte_formatARead-only
Preview text edits to format the component using its project configuration.
Inputs: file, source, tabSize, insertSpaces.
svelte_hoverCRead-only
Show type information and documentation at a position.
Inputs: position (required), file, source.
svelte_referencesCRead-only
Find project references to the symbol at a position.
Inputs: position (required), file, source, includeDeclaration.
svelte_renameCRead-only
Preview the workspace edit for renaming a symbol.
Inputs: newName (required), position (required), file, source.
svelte_signature_helpBRead-only
Show call signatures and the active parameter at a position.
Inputs: position (required), file, source.
svelte_type_definitionCRead-only
Find the type declaration of the symbol at a position.
Inputs: position (required), file, source.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool maps to a distinct LSP capability with clear resource/action intent. Definition vs. type_definition and hover vs. signature_help are adjacent but descriptions make their boundaries clear.
All tools follow a consistent svelte_ prefix plus snake_case noun/action pattern. The naming is predictable and easy to scan.
Ten tools is well-scoped for a language-server bridge, covering the most common diagnostic, navigation, completion, formatting, and rename workflows without bloat.
The surface covers core LSP interactions well: diagnostics, symbols, formatting, hover, navigation, references, completions, and rename preview. Notable gaps remain around code actions/quick fixes and some secondary LSP features like document highlights or implementation lookup.
Maintenance
Related MCP Connectors
The official Svelte MCP server providing docs and autofixing tools for Svelte development
Lean 4 MCP server: compile, prove theorems, and formalize math with Mathlib.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Start and manage Reason cloud coding agents, projects and sessions from any MCP client.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables MCP clients and AI coding agents to access real-time editor language-server diagnostics, type/hover/signature information, code references, and workspace-wide symbol renaming, replacing slow tsc/eslint checks.-
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents and MCP clients to retrieve real-time editor diagnostics, LSP type and symbol information, code references, and perform workspace-wide symbol renames without waiting for slow separate build or lint commands.MIT
- AlicenseNot gradedqualityAmaintenanceEnables MCP clients and AI coding agents to access a running editor's language-server data for real-time diagnostics, definitions, hover/signature/type information, references, and workspace-wide symbol renames without waiting for slow tsc/eslint checks.MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents and MCP clients to pull real-time language-server diagnostics, hover/type information, reference navigation with usage context, and workspace-wide symbol renaming without running slow tsc or eslint checks. It also supports opening files and executing editor commands against a specific open workspace.MIT