Nanostores MCP

io.github.Valyay由 GitHub 帳號 Valyay 發布v0.1.2更新於 Oct 24, 2026

Debug and analyze Nanostores apps with AI: scan stores, monitor runtime events, and search docs.

概覽

AI 產生的概覽

讓助理對專案中的 Nanostores 狀態倉庫做靜態分析、檢索 Nanostores 文件,並查看選用的執行期日誌事件。

可以做什麼
透過 AST 分析掃描 JavaScript 或 TypeScript 專案,找出 Nanostores 倉庫、訂閱者與匯入關係,並提供倉庫摘要、專案概觀、相依子圖與影響鏈等工具。它也會為 Nanostores 文件建立索引,支援全文與依倉庫類型檢索;並可接收選用日誌橋接的執行期事件,回報活動情形、高頻倉庫、錯誤以及靜態與執行期覆蓋差異。
適用情境
適用於使用 Nanostores 的程式庫,希望助理說明倉庫架構、追蹤某個倉庫的下游相依,或排查頻繁更新與失敗動作。只有在應用程式接入日誌用戶端後,執行期分析才有價值。
執行需求
本機 Node.js 程序(^20.0.0 或 >=22.0.0),透過 npx 或全域安裝執行。靜態分析與文件需要安裝 nanostores 套件;@vue/compiler-sfc、svelte 與 @nanostores/logger 為選用相依,分別用於對應檔案類型與執行期監控。專案根目錄透過 NANOSTORES_MCP_ROOT、NANOSTORES_MCP_ROOTS 或編輯器工作區變數設定;日誌橋接使用本機 HTTP 連接埠。
安裝前請注意
執行期監控需要在應用程式中加入日誌程式碼,會把倉庫名稱、時間戳記、事件類型以及選用的截斷值快照傳送到本機 HTTP 橋接;可用 maskEvent 選項丟棄或遮蔽敏感倉庫。橋接僅綁定回送位址,事件保存在記憶體中而不會持久化。靜態分析會讀取專案檔案,多根目錄情境下若不傳 projectRoot 可能產生歧義。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Nanostores MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Nano Stores MCP

[圖片]

Model Context Protocol server for Nanostores — analyze, debug and monitor your nanostores in AI assistants like Claude Desktop.

  • 📊 Static Analysis: AST-based project scanning, dependency graphs, store inspection
  • 🔥 Runtime Monitoring: Live events from @nanostores/logger, performance metrics, activity tracking
  • 📚 Documentation: Search and browse Nanostores docs by topic or store kind
  • 🎯 Zero Config: Works out of the box — auto-detects project roots and nanostores docs
  • 🌐 Framework-Agnostic: Works with React, Vue, Svelte, Angular, Solid, Preact, Lit — any framework that uses Nanostores
bash
npx nanostores-mcp

Ask your AI: "Analyze my store architecture" or "Which stores update most frequently?"


[圖片] Made at Evil Martians, product consulting for developer tools.


Table of Contents

Features

📊 Static Analysis (AST-based)

Understand your nanostores architecture without running your app:

  • Project scanning — find all stores, subscribers, and import/export relationships
  • Dependency graph — visualize how stores depend on each other (Mermaid diagrams)
  • Store inspection — type (atom/map/computed/batched/persistentAtom/persistentMap/router), location, usage patterns, related files
  • Framework-aware subscriber detection — recognizes .subscribe() / .listen() calls and component bindings across React, Vue, Svelte, and Angular
  • Vue SFC support — parses both <script> and <script setup> blocks in .vue files (requires @vue/compiler-sfc)
  • Svelte support — parses <script context="module"> and instance <script> blocks, auto-subscriptions ($storeName in templates), and filters out Svelte 5 runes ($state, $derived, $effect, etc.) so they are not mistaken for store references (requires svelte)
  • Angular DI support — resolves @nanostores/angular NanostoresService constructor injections and detects this.nanostores.useStore(...) call patterns in TypeScript component files

🔥 Runtime Monitoring (Logger Integration)

Real-time insights into your running application:

  • Live event capture — mount/unmount, value changes, action calls from @nanostores/logger
  • Performance analysis — find noisy stores, high error rates, performance bottlenecks
  • Activity metrics — change frequency, action success/failure rates, action duration
  • Combined analysis — merge static structure with runtime behavior for deep debugging

📚 Documentation Search

Search and browse Nanostores documentation directly from your AI assistant:

  • Full-text search — find guides, API references, and best practices by query
  • Store-kind lookup — get docs relevant to a specific store type (atom, map, computed, etc.)
  • Auto-detection — picks up docs from nanostores in your node_modules automatically

Requirements

RequirementVersion
Node.js^20.0.0 || >=22.0.0

Required peer dependency (for static analysis):

bash
npm install nanostores

Optional peer dependencies — install only if you use the corresponding file format:

PackageWhen needed
@vue/compiler-sfcVue SFC (.vue) file scanning
svelteSvelte (.svelte) file scanning
@nanostores/loggerRuntime monitoring (attachMcpLogger)

Without these optional packages the server still works — it silently skips unsupported file types.

Installation

bash
npm install -g nanostores-mcp# orpnpm add -g nanostores-mcp

Or run directly without installation:

bash
npx nanostores-mcp

Configuration

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

json
{	"mcpServers": {		"nanostores": {			"command": "npx",			"args": ["-y", "nanostores-mcp"],			"env": {				"NANOSTORES_MCP_ROOT": "/path/to/your/project"			}		}	}}

VS Code

Requires GitHub Copilot extension (VS Code 1.99+). Create .vscode/mcp.json in your project:

json
{	"servers": {		"nanostores": {			"type": "stdio",			"command": "npx",			"args": ["-y", "nanostores-mcp"]		}	}}

Tools are available in Copilot's Agent mode (select "Agent" in the Copilot Chat dropdown).

Cursor

Create .cursor/mcp.json in your project root (or ~/.cursor/mcp.json for global):

json
{	"mcpServers": {		"nanostores": {			"command": "npx",			"args": ["-y", "nanostores-mcp"]		}	}}

Zed

Add to your Zed settings.json:

json
{	"context_servers": {		"nanostores": {			"command": "npx",			"args": ["-y", "nanostores-mcp"],			"env": {				"NANOSTORES_MCP_ROOT": "/path/to/your/project"			}		}	}}

The server appears in Zed's Agent Panel settings.

Windsurf

Add to ~/.codeium/windsurf/mcp_config.json:

json
{	"mcpServers": {		"nanostores": {			"command": "npx",			"args": ["-y", "nanostores-mcp"],			"env": {				"NANOSTORES_MCP_ROOT": "/path/to/your/project"			}		}	}}

You can also open this file from the MCP icon in the Cascade panel → "Configure".

Claude Code

Add via CLI:

bash
claude mcp add --transport stdio nanostores -- npx -y nanostores-mcp

Or create .mcp.json in your project root (shared with the team):

json
{	"mcpServers": {		"nanostores": {			"command": "npx",			"args": ["-y", "nanostores-mcp"],			"env": {				"NANOSTORES_MCP_ROOT": "/path/to/your/project"			}		}	}}

Environment Variables

VariableDefaultDescription
NANOSTORES_MCP_ROOTcwdProject root path
NANOSTORES_MCP_ROOTS—Platform-delimited roots (: on Unix, ; on Windows) for multi-project setup
WORKSPACE_FOLDER—Alias for NANOSTORES_MCP_ROOT — set automatically by VS Code and some editors
WORKSPACE_FOLDER_PATHS—Alias for NANOSTORES_MCP_ROOTS — set automatically by some editors
NANOSTORES_MCP_LOGGER_ENABLEDtrueSet to false or 0 to disable runtime event collection and the logger bridge
NANOSTORES_MCP_LOGGER_PORT3999HTTP port for logger bridge
NANOSTORES_MCP_LOGGER_HOST127.0.0.1Host to bind. Allowed values: 127.0.0.1, localhost, ::1
NANOSTORES_DOCS_ROOTauto-detectPath to documentation directory
NANOSTORES_DOCS_PATTERNS**/*.mdComma-separated glob patterns for docs

How the Project Root Is Resolved

The server picks workspace roots in priority order:

  1. Environment variables (highest priority) — NANOSTORES_MCP_ROOTS / NANOSTORES_MCP_ROOT / WORKSPACE_FOLDER_PATHS / WORKSPACE_FOLDER
  2. Client roots — roots reported by the MCP client via the roots/list capability (set automatically by some editors)
  3. Current working directory — process.cwd() used as fallback when neither env nor client roots are configured

When a tool is called without an explicit projectRoot argument the server uses the first configured root. In a multi-root setup always pass projectRoot to avoid ambiguity.

Quick Start

1. Static Analysis

Works out of the box — just point at your project and ask:

  • "Analyze my store architecture"
  • "Explain how nanostores is used in this project"
  • "Give me a summary of the $cart store"
  • "My stores changed — re-scan the project" ← the AI will force a fresh scan

2. Documentation Search

Auto-detected from nanostores in your node_modules:

  • "How do I use computed stores?"
  • "Show me the docs for persistentAtom"

3. Runtime Monitoring (Optional)

Requires logger integration in your app. See Runtime Monitoring below.

  • "Which stores update most frequently?"
  • "Show me recent activity for $user"
  • "Give me an overall health report"

Verify Your Setup

Run these four tools in order to confirm everything is working:

nanostores_ping              → should return server status and logger bridge statenanostores_scan_project      → should list your stores and subscribersnanostores_docs_search       → should return documentation results (requires nanostores in node_modules)nanostores_runtime_overview  → should return overview (or "no runtime data" if logger is disabled — that's fine)

If nanostores_scan_project returns zero stores, check that NANOSTORES_MCP_ROOT points to the correct project directory.

MCP Interface

MCP Resources

ResourceDescription
nanostores://graphFull dependency graph (text + Mermaid)
nanostores://store/{key}Store details by name or id
nanostores://docsDocumentation index — all pages and tags
nanostores://docs/page/{id}Full content of a documentation page

MCP Tools

Static Analysis

ToolDescription
nanostores_scan_projectScan project for all stores, subscribers, and dependencies
nanostores_store_summaryDetailed summary of a specific store
nanostores_project_outlineHigh-level overview: store kinds, top directories, hub stores
nanostores_store_subgraphBFS-expanded dependency neighborhood of a store
nanostores_store_impactDownstream causal chain — what recomputes/re-renders if X changes

Runtime Monitoring

ToolDescription
nanostores_runtime_overviewOverall health report with statistics for all stores
nanostores_store_activityActivity timeline for a specific store (filterable by kind/action)
nanostores_find_noisy_storesIdentify stores with high change frequency or error rates
nanostores_runtime_coverageCompare static graph with runtime events to find coverage gaps

Documentation

ToolDescription
nanostores_docs_searchSearch docs by query (full-text), storeKind (atom, map, computed, persistentAtom, etc.), or both. Optional: limit (default 10), tags

Use nanostores://docs/page/{id} resource to read the full content of pages returned by search.

Utilities

ToolDescription
nanostores_pingServer health check and logger bridge status
nanostores_clear_cacheClear project index cache to force rescan

MCP Prompts

PromptParametersDescription
explain-projectfocus (optional)AI-guided explanation of your project's store architecture. focus narrows to a feature/domain (e.g. "cart", "auth")
explain-storestore_name (required)Deep dive into a specific store's implementation and usage
debug-storestore_name (required)Comprehensive analysis combining static + runtime data
debug-project-activity—Project-wide performance analysis and optimization
docs-how-totask (required)Step-by-step guidance for a Nanostores task, backed by docs (e.g. "How do I sync a map store to localStorage?")

Advanced Tool Arguments

Most tools accept these optional arguments that significantly change their behavior:

ArgumentTypeUsed inDescription
storeIdstringstore_summary, store_subgraph, store_impactExact store identifier — format: store:src/stores.ts#$counterName. Takes priority over name when both are provided.
namestringstore_summary, store_subgraph, store_impactStore name (e.g. "$user"). Used when storeId is not provided.
radiusnumber (0–10, default 2)nanostores_store_subgraphBFS hops around the store. 1 = direct deps only; 2 = deps of deps. Warning: on highly-connected hub stores (hub score > 5) radius ≥ 2 may return most of the project — start with 1.
projectRootstringmost toolsWhich project root to analyze in multi-root setups. Omit to use the first configured root. Always specify this in multi-root projects.
windowMsnumberstore_activity, find_noisy_stores, runtime_overviewLook-back window in milliseconds (e.g. 60000 = last 60 s). Filters events to that time range.
kindsstring[]nanostores_store_activityFilter events by type. Values: "mount", "unmount", "change", "action-start", "action-end", "action-error".
actionNamestringnanostores_store_activityFilter events to a specific action (e.g. "increment").
compactbooleanscan_project, find_noisy_stores, runtime_overviewReturn a compressed token-efficient table instead of full text. Useful for large projects to reduce context usage.

Runtime Monitoring

For runtime analysis, integrate the MCP Logger client into your application.

1. Install in your app and enable the logger bridge:

bash
npm install nanostores-mcp

The logger bridge starts automatically — no extra config needed. To disable it, set NANOSTORES_MCP_LOGGER_ENABLED=false in your MCP server config.

2. Define stores with logger attached (src/stores.ts):

typescript
import { atom, map, computed } from "nanostores";import { initMcpLogger, attachMcpLogger } from "nanostores-mcp/mcpLogger";
// Automatically disabled in production (checks NODE_ENV / import.meta.env.DEV)initMcpLogger();
// Storesexport const $count = atom(0);export const $user = map({ name: "", role: "guest" });export const $greeting = computed($user, user => `Hello, ${user.name}`);
// Attach logger — each call returns a cleanup functionattachMcpLogger($count, "$count");attachMcpLogger($user, "$user");attachMcpLogger($greeting, "$greeting");

3. Use stores normally — events (mount, unmount, change, actions) are captured automatically and batched to the MCP server every second.

4. Ask your AI assistant:

  • "Which stores change most frequently?" → nanostores_find_noisy_stores
  • "Show me recent activity for $user" → nanostores_store_activity
  • "Give me an overall health report" → nanostores_runtime_overview

Logger Options

typescript
initMcpLogger({	url: "http://127.0.0.1:3999/nanostores-logger", // default; change if using a custom port	batchMs: 1000, // default; lower for faster delivery (e.g. 200)	projectRoot: "/absolute/path/to/project", // link runtime events with static analysis
	// Mask sensitive data — return null to skip event entirely	maskEvent: event => {		if (event.storeName === "authToken") return null;		return event;	},});

Flush Before Shutdown

typescript
import { getMcpLogger } from "nanostores-mcp/mcpLogger";
window.addEventListener("beforeunload", async () => {	await getMcpLogger()?.forceFlush();});

Reading Results

nanostores_runtime_overview health summary

The overview groups stores into three categories:

  • Top active stores — sorted by total event count (changes + actions). A store that appears here with hundreds of changes in seconds may be a performance concern.
  • Error-prone stores — stores with action-error events. High error counts indicate failing async actions.
  • Unmounted stores — stores seen at mount but never unmounted. May indicate memory leaks.

nanostores_runtime_coverage

Compares your static store graph against observed runtime events:

TermMeaning
static-onlyStore found by AST scan but no runtime events observed. Possible dead code, deferred initialization, or missing attachMcpLogger call.
runtime-onlyEvents received for a store not found by the scanner. Common for dynamically-created stores, factory patterns, or stores in node_modules.
Coverage by kindE.g. atom: 3/5 (60%) — 3 out of 5 atom stores received runtime events. 0% for a kind usually means attachMcpLogger was not called for those stores.

nanostores_find_noisy_stores

Returns stores ranked by total activity (changes + actions combined) within the windowMs period. A store is considered "noisy" when its change frequency is disproportionately high relative to visible UI updates — use this to find re-render hotspots or thrashing computed chains.

Privacy & Security

The runtime logger is designed to stay on your local machine:

  • Loopback-only binding — the HTTP bridge accepts connections exclusively from 127.0.0.1, localhost, or ::1. Binding to 0.0.0.0 is explicitly blocked. Data never leaves your machine.
  • What is transmitted — from your app to the MCP server over localhost: store name, timestamp, event kind, and optionally value snapshots (truncated to 200 characters). Nothing is sent to Anthropic or any third party.
  • Nothing is persisted — events are held in a ring buffer (5 000 events max) in process memory and discarded when the server restarts.
  • Mask sensitive data — use maskEvent to filter or redact events client-side before they are batched and sent:
typescript
initMcpLogger({	maskEvent: event => {		if (event.storeName === "$authToken") return null; // drop entirely		if (event.storeName === "$paymentInfo") return { ...event, newValue: undefined }; // strip value		return event;	},});
  • CORS — the bridge rejects cross-origin requests from non-loopback origins.

Example Queries

Ask your AI assistant natural language questions:

Static Analysis:

  • "Analyze my store architecture for potential issues"
  • "What happens when $user changes? Show subscribers and derived stores"

Runtime Debugging:

  • "Which stores update most frequently?"
  • "Are there stores declared in code but never used at runtime?"
  • "Debug the $user store — combine static analysis with runtime behavior"

With Playwright MCP:

  • "Open my app in the browser, interact with it, and analyze which stores cause the most recalculations"

Documentation:

  • "How do I use computed stores?"
  • "Show me best practices for persistent stores"

Architecture

┌──────────────────────┐│   Your Application   ││                      ││  @nanostores/logger  ││        events        │└──────────┬───────────┘           │ HTTP POST (localhost:3999)           ▼┌──────────────────────┐│   nanostores-mcp     ││                      ││   ┌──────────────┐   ││   │ Logger Bridge │   │ ← HTTP server for runtime events│   └──────┬───────┘   ││          ▼           ││   ┌──────────────┐   ││   │ Event Store  │   │ ← Ring buffer (5000 events) + stats│   └──────┬───────┘   ││          │           ││   ┌──────┴───────┐   ││   │  AST Scanner │   │ ← ts-morph static analysis│   └──────┬───────┘   ││          │           ││   ┌──────┴───────┐   ││   │  Docs Index  │   │ ← Auto-detected from node_modules│   └──────┬───────┘   ││          │           ││   ┌──────┴───────┐   ││   │ MCP Interface│   │ ← Resources, Tools, Prompts│   └──────────────┘   │└──────────┬───────────┘           │ MCP Protocol (stdio)           ▼┌──────────────────────┐│    LLM Client        ││ (Claude, VS Code, …) │└──────────────────────┘

Limitations & Caveats

Multi-root: same store name in multiple projects

In multi-root mode a store named $user can exist in two different projects. The runtime event store uses a composite key (projectRoot + storeName) to keep them separate, but summary views may show the same name twice with no project label. Always specify projectRoot when querying tools in a multi-root setup to get unambiguous results.

Static analysis only covers discovered files

The AST scanner follows TypeScript/JavaScript imports from your project root. Stores created dynamically at runtime, generated by factories, or living in node_modules will not appear in static results — they may show up as "runtime-only" in coverage reports.

Vue and Svelte parsing requires optional dependencies

If @vue/compiler-sfc or svelte are not installed, .vue / .svelte files are silently skipped during scanning. Install them as dev dependencies if you want full coverage for those file types.

Event ring buffer is capped at 5 000 events

Older events are dropped when the buffer is full. For high-frequency stores use windowMs to narrow your queries to recent data, or lower batchMs in initMcpLogger to deliver events more frequently and reduce the chance of buffer overflow during bursts.

radius on hub stores can be very large

Stores with many dependencies (hub score > 5) can return most of the project graph at radius=2. Start with radius=1 and increase only if you need broader context.

Development

bash
git clone https://github.com/Valyay/nanostores-mcp.gitcd nanostores-mcppnpm install
pnpm dev          # Run dev serverpnpm build        # TypeScript compilepnpm test         # Run vitestpnpm lint         # ESLintpnpm check        # All checks: lint + format + test + build
# Test with MCP Inspectornpx @modelcontextprotocol/inspector pnpm run dev

Troubleshooting

Logger not receiving events:

  1. Use the ping tool to verify logger bridge is enabled and running
  2. Check browser console for [nanostores-mcp] warnings about connection issues
  3. Confirm the port matches between server (NANOSTORES_MCP_LOGGER_PORT) and client URL
  4. Test with a simple atom store to verify events flow

Port conflicts:

bash
# Change server portNANOSTORES_MCP_LOGGER_PORT=4000 npx nanostores-mcp
# Update clientinitMcpLogger({ url: "http://127.0.0.1:4000/nanostores-logger" });

TypeScript errors:

typescript
// Import from the mcpLogger subpath exportimport { initMcpLogger, attachMcpLogger } from "nanostores-mcp/mcpLogger";

Documentation not found:

  • The server auto-detects docs from nanostores in your node_modules
  • Make sure nanostores is installed: npm install nanostores
  • Or set NANOSTORES_DOCS_ROOT to point at a docs directory manually

Related Projects

Nanostores ecosystem:

MCP:

License

MIT

Contributing

Contributions are welcome! Please open an issue or PR.

來源:README.md,提交 9a48a35

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分