Skip to main content
Glama
Svelte LSP as MCP

Svelte LSP as MCP

by pacnpal

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-mcp

The 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

  1. Open Servers → Add server → Import JSON and paste the client configuration above. In the manual form, select the npx runner, set the command to npx and enter the two arguments -y and @pacnpal/svelte-lsp-as-mcp.

  2. Save and start the server. Open the tools list and call svelte_diagnostics with the inline example above. The source travels in the MCP request, so the runner can serve any client's component without a mounted checkout.

  3. Copy the server's MCP URL into a Streamable HTTP client. With the default local port and the slug svelte, the URL is http://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-project

Call 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

svelte_diagnostics

—

Current diagnostics, including severity, message and source range

svelte_hover

position

Type information and documentation

svelte_definition

position

Declaration locations, including imported symbols

svelte_type_definition

position

Type declaration locations

svelte_references

position, optional includeDeclaration (default true)

Symbol references in the project

svelte_document_symbols

—

Component outline with source ranges

svelte_signature_help

position

Call signatures and the active parameter

svelte_completions

position, optional offset (default 0) and limit (default 50, max 200)

Suggestions, total count and LSP's isIncomplete flag

svelte_rename

position, newName

Proposed LSP workspace edit

svelte_format

Optional tabSize (default 2) and insertSpaces (default true)

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 --version and npx --version in the runner environment. A desktop client may need the absolute path to npx and Node's bin directory on its PATH.

  • 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 --workspace at 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-run

Integration 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 main

License

MIT

Available Tools

10 tools
svelte_completionsB
Read-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_definitionC
Read-only

Find where the symbol at a position is defined.

Inputs: position (required), file, source.

svelte_diagnosticsB
Read-only

Get current compiler, markup, CSS and TypeScript diagnostics for a component.

Inputs: file, source.

svelte_document_symbolsB
Read-only

List the component's symbols and their source ranges.

Inputs: file, source.

svelte_formatA
Read-only

Preview text edits to format the component using its project configuration.

Inputs: file, source, tabSize, insertSpaces.

svelte_hoverC
Read-only

Show type information and documentation at a position.

Inputs: position (required), file, source.

svelte_referencesC
Read-only

Find project references to the symbol at a position.

Inputs: position (required), file, source, includeDeclaration.

svelte_renameC
Read-only

Preview the workspace edit for renaming a symbol.

Inputs: newName (required), position (required), file, source.

svelte_signature_helpB
Read-only

Show call signatures and the active parameter at a position.

Inputs: position (required), file, source.

svelte_type_definitionC
Read-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

    A3.5/5.0

    Scored across 10 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    All tools follow a consistent svelte_ prefix plus snake_case noun/action pattern. The naming is predictable and easy to scan.

    Tool Count5/5

    Ten tools is well-scoped for a language-server bridge, covering the most common diagnostic, navigation, completion, formatting, and rename workflows without bloat.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables 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.
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables 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
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables 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
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables 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