Skip to main content

CLI

The @sveltejs/mcp npm package normally launches the local stdio MCP server:

npx -y @sveltejs/mcp

If you invoke it with a subcommand, it behaves like a regular CLI and prints the result directly in your terminal instead. This is useful for agents, scripts and quick manual checks.

Usage

npx -y @sveltejs/mcp <command> [options]

Available commands:

  • list-sections
  • get-documentation <sections>
  • svelte-autofixer <code_or_path>

You can learn more about the commands with

npx -y @sveltejs/mcp --help
npx -y @sveltejs/mcp <command> --help
npx -y @sveltejs/mcp --version

list-sections

Lists all available Svelte and SvelteKit documentation sections.

npx -y @sveltejs/mcp list-sections

The output is a structured text list of sections, including each section's title, use_cases, and documentation path. This is the same catalog the MCP tool uses before calling get-documentation.

get-documentation

Fetches the full documentation for one or more sections.

npx -y @sveltejs/mcp get-documentation 'svelte/$state'
# or
npx -y @sveltejs/mcp get-documentation 'svelte/$state,svelte/await-expressions'

Each section can be matched by title or by documentation path. If a section cannot be found, the CLI returns an error plus similar matches when available.

svelte-autofixer

Runs the Svelte autofixer against either inline code or a file path:

npx -y @sveltejs/mcp svelte-autofixer 'src/routes/+page.svelte'

If the argument is an existing path, the CLI reads the file automatically. Otherwise it treats the argument as raw Svelte code.

Because most shells expand $, inline code should be quoted or escaped correctly. In practice, passing a file path is usually easier than passing source directly.

Available options:

  • --svelte-version <4|5> - choose which Svelte version to validate against (defaults to 5)
  • --async - enable async Svelte analysis for Svelte 5 projects

The command prints an object with:

  • issues
  • suggestions
  • require_another_tool_call_after_fixing

This makes it easy to use in an agentic loop: run the autofixer, apply fixes, then run it again until it reports no remaining issues or suggestions.

Edit this page on GitHub llms.txt

previous next