svelte-component-graph-mcp
Provides tools to analyze the component dependency graph of Svelte/SvelteKit projects, including tracking imports, detecting unused components, and inspecting props and slots.
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-component-graph-mcp Which components are unused in this project?"
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-component-graph-mcp
An MCP server that exposes a Svelte/SvelteKit project's
component dependency graph over stdio, so an AI coding assistant can ask questions like
"what imports Button.svelte?", "which components are unused?", or "what does this route pull
in?" without opening an editor.
It is the command-line companion to the
Svelte Component Visualizer
VS Code extension and uses the same analysis: the Svelte compiler's AST + estree-walker to track
default and named .svelte imports, resolve static <svelte:component this={Identifier}> usage,
and flag imported-but-unused components.
What it gives you
A graph of every component and route in the project:
Nodes are keyed by workspace-relative path (
src/lib/Button.svelte) — so two files that share a name are never conflated — with a human-readablelabel, atype(component|route), and anunusedflag.Links are import edges (
sourceimportstarget).
The server is stateless across projects: every tool takes a root argument, so one running
server can answer questions about many projects (and many git worktrees) at once. Results are cached
per root and refreshed automatically when files change (checked on each call by mtime + size; only
changed files are re-parsed).
Related MCP server: CodeGraphMCPServer
Installation
This is a stdio MCP server — your MCP client launches it; you don't run it by hand. Requires Node.js ≥ 20. Pick the path that matches your setup.
Claude Code — plugin (recommended)
Installs the MCP server and the companion /svelte-graph skill in one step:
/plugin marketplace add jamcgrath/svelte-component-graph-mcp
/plugin install svelte-component-graph@jamcgrathRestart Claude Code afterward so the server connects. Nothing to clone or build — it runs via npx.
(The two commands can be combined: /plugin install svelte-component-graph@jamcgrath/svelte-component-graph-mcp.)
Claude Code — server only (no skill)
claude mcp add svelte-graph --scope user -- npx -y svelte-component-graph-mcpOther MCP clients (Claude Desktop, Cursor, Cline, …)
Add it to the client's MCP config:
{
"mcpServers": {
"svelte-graph": {
"command": "npx",
"args": ["-y", "svelte-component-graph-mcp"]
}
}
}(If you npm install -g svelte-component-graph-mcp, use "command": "svelte-component-graph-mcp" with
"args": [].)
Quick test, no client
Drive it with the MCP Inspector:
npx @modelcontextprotocol/inspector npx -y svelte-component-graph-mcpThe root argument
Every tool requires root: an absolute path to the project you want analyzed. The server
validates that it exists, is a directory, and contains at least one .svelte file.
Guidance for the assistant when choosing root:
If a
svelte.config.jsexists in the current working directory, the project root is the cwd — pass$PWD.Otherwise (e.g. a monorepo, or the cwd is a subfolder), pass the project's absolute path explicitly.
Companion skill
A Claude Code skill (skills/svelte-graph/) teaches the assistant
when to reach for these tools (impact analysis, dead-code hunts, prop lookups) and how to resolve
root. The MCP tools work without it; the skill just makes the assistant use them more readily.
If you installed the plugin, you already have it — nothing to do. Otherwise, copy the folder into a skills directory:
# user-level (all your projects)
cp -r skills/svelte-graph ~/.claude/skills/svelte-graph
# or project-level (this repo only)
cp -r skills/svelte-graph .claude/skills/svelte-graphThen invoke it with /svelte-graph, or let the assistant trigger it automatically.
Tools
get_graph(root)
The full graph.
{
"nodes": [
{ "id": "src/routes/+page.svelte", "label": "(page) /", "type": "route" },
{ "id": "src/lib/Button.svelte", "label": "Button", "type": "component" },
{ "id": "src/lib/Unused.svelte", "label": "Unused", "type": "component", "unused": true }
],
"links": [
{ "source": "src/routes/+page.svelte", "target": "src/lib/Button.svelte" }
]
}get_component(root, path)
Details for one component/route, including its public API surface. path is workspace-relative
(src/lib/Button.svelte).
{
"id": "src/lib/Widget.svelte",
"label": "Widget",
"type": "component",
"unused": false,
"isRoute": false,
"parents": ["src/routes/+page.svelte"], // components that import it
"children": [], // components it imports
"props": [ // from $props()
{ "name": "size", "optional": true, "bindable": false },
{ "name": "open", "optional": true, "bindable": true },
{ "name": "title", "optional": false, "bindable": false },
{ "name": "rest", "optional": true, "bindable": false, "rest": true }
],
"slots": ["default", "footer"] // <slot> / <slot name="…">
}Props come from Svelte 5 runes ($props(), $bindable(), ...rest). Events are not a separate
concept in Svelte 5 — they are ordinary callback props, so they appear in props.
get_unused(root)
Every component imported somewhere but never used in the importing file's template.
[
{ "id": "src/lib/Unused.svelte", "label": "Unused", "type": "component", "unused": true }
]get_routes(root)
Every route (+page / +layout / +error) with the components it directly pulls in.
[
{
"id": "src/routes/dashboard/+page.svelte",
"label": "(page) /dashboard",
"children": ["src/lib/Icon.svelte", "src/lib/components/Button.svelte"]
}
]scan(root)
Force a full re-parse (bypassing all caches) and return the resulting size.
{ "nodes": 7, "links": 5 }How resolution works (and its limits)
Relative imports (
./,../) resolve against the importing file's directory.SvelteKit's
$lib/…resolves to the nearestsrc/lib(monorepo-aware — it uses the importing file's ownsrc/, not a global root).Other bare/aliased specifiers (custom Vite aliases beyond
$lib) are kept as best-effort leaf nodes rather than resolved to a file. As a corollary, a bare package import likeimport X from 'some-pkg/Foo.svelte'is keyed by that raw path and would merge with a local file at the same relative path (some-pkg/Foo.svelte) if one exists — an unlikely but possible collision.<svelte:component this={…}>is resolved only whenthisis a plain imported identifier; dynamic expressions (member access, conditionals) are not traced.componentPaths/routePathsaccept negation globs (!**/*.stories.svelte) to exclude files: a file is included when it matches a positive pattern and no negation pattern.propsare read from the$props()object destructuring. A non-destructured binding (let props = $props()) has no statically-known prop names, sopropscomes back empty for it.
License
MIT © James McGrath
Available Tools
5 toolsget_componentGet one componentA
Look up a single component or route by its workspace-relative path (e.g. "src/lib/Button.svelte"). Returns its parents (components that import it), children (components it imports), whether it is unused/a route, and its Svelte 5 public API surface: props (name, optional, bindable, rest) and slots.
Inputs: path (required), root (required).
get_graphGet component graphA
Return the full Svelte component dependency graph for a project: every component/route node (workspace-relative path id + display label + type + unused flag) and every import link.
Inputs: root (required).
get_routesGet routesA
Return every route node (+page/+layout/+error) with its display label and the direct child components it pulls in.
Inputs: root (required).
get_unusedGet unused componentsA
Return every component that is imported somewhere in the project but rendered nowhere (never referenced in any importer's template). Computed globally, so the result does not depend on file order.
Inputs: root (required).
scanForce rescanA
Invalidate all caches for the project and re-parse every file from scratch. Returns a summary with the node and link counts. Use when you want to guarantee fresh results.
Inputs: root (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct aspect of the component graph: global view (get_graph), per-node detail (get_component), unused analysis (get_unused), route view (get_routes), and cache refresh (scan). There is no functional overlap.
Four tools consistently follow the 'get_' prefix pattern, while 'scan' is a bare verb, which is a minor deviation but still understandable.
With five tools, the server strikes a good balance—neither too sparse nor overwhelming for its focus on graph analysis.
The tools cover all necessary operations for a read-only component graph server: fetching the full graph, drilling into a component, finding unused components, routing information, and cache invalidation. No obvious missing capability.
Maintenance
Related MCP Connectors
The official Svelte MCP server providing docs and autofixing tools for Svelte development
An MCP server that gives your AI access to the source code and docs of all public github repos
Repository knowledge graph MCP server for codebase understanding and debugging.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that wraps the Svelte Language Server to provide IDE-like tools for Claude Code and other MCP clients. It enables advanced Svelte development features including symbol navigation, diagnostics, refactoring, and component-specific analysis.21MIT
- AlicenseNot gradedqualityDmaintenanceA lightweight, zero-configuration MCP server for source code analysis with GraphRAG capabilities, enabling structural understanding and efficient code completion from MCP-compatible AI tools.49 PyPI14MIT
- AlicenseBqualityDmaintenanceAn MCP server that scans React and Vue projects, extracts component metadata (props, slots, events, imports, usage), and exposes it to AI coding agents via structured tools.71MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that indexes your codebase using tree-sitter AST parsing and gives AI tools instant access to structural intelligence like dependency graphs, call trees, and dead code detection from a local SQLite database.MIT