
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.
概览
让助手对项目中的 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 端口。
安装
在 SourceWeft 中
- 打开 控制台中的 Nanostores MCP,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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
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
- Requirements
- Installation
- Configuration
- Quick Start
- MCP Interface
- Runtime Monitoring
- Example Queries
- Architecture
- Limitations & Caveats
- Development
- Troubleshooting
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.vuefiles (requires@vue/compiler-sfc) - Svelte support — parses
<script context="module">and instance<script>blocks, auto-subscriptions ($storeNamein templates), and filters out Svelte 5 runes ($state,$derived,$effect, etc.) so they are not mistaken for store references (requiressvelte) - Angular DI support — resolves
@nanostores/angularNanostoresServiceconstructor injections and detectsthis.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
nanostoresin yournode_modulesautomatically
Requirements
Required peer dependency (for static analysis):
Optional peer dependencies — install only if you use the corresponding file format:
Without these optional packages the server still works — it silently skips unsupported file types.
Installation
Or run directly without installation:
Configuration
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
VS Code
Requires GitHub Copilot extension (VS Code 1.99+). Create .vscode/mcp.json in your project:
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):
Zed
Add to your Zed settings.json:
The server appears in Zed's Agent Panel settings.
Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
You can also open this file from the MCP icon in the Cascade panel → "Configure".
Claude Code
Add via CLI:
Or create .mcp.json in your project root (shared with the team):
Environment Variables
How the Project Root Is Resolved
The server picks workspace roots in priority order:
- Environment variables (highest priority) —
NANOSTORES_MCP_ROOTS/NANOSTORES_MCP_ROOT/WORKSPACE_FOLDER_PATHS/WORKSPACE_FOLDER - Client roots — roots reported by the MCP client via the
roots/listcapability (set automatically by some editors) - 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:
If nanostores_scan_project returns zero stores, check that NANOSTORES_MCP_ROOT points to the correct project directory.
MCP Interface
MCP Resources
MCP Tools
Static Analysis
Runtime Monitoring
Documentation
Use nanostores://docs/page/{id} resource to read the full content of pages returned by search.
Utilities
MCP Prompts
Advanced Tool Arguments
Most tools accept these optional arguments that significantly change their behavior:
Runtime Monitoring
For runtime analysis, integrate the MCP Logger client into your application.
1. Install in your app and enable the logger bridge:
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):
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
Flush Before Shutdown
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-errorevents. 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:
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 to0.0.0.0is 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
maskEventto filter or redact events client-side before they are batched and sent:
- 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
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
Troubleshooting
Logger not receiving events:
- Use the
pingtool to verify logger bridge is enabled and running - Check browser console for
[nanostores-mcp]warnings about connection issues - Confirm the port matches between server (
NANOSTORES_MCP_LOGGER_PORT) and client URL - Test with a simple atom store to verify events flow
Port conflicts:
TypeScript errors:
Documentation not found:
- The server auto-detects docs from
nanostoresin yournode_modules - Make sure
nanostoresis installed:npm install nanostores - Or set
NANOSTORES_DOCS_ROOTto point at a docs directory manually
Related Projects
Nanostores ecosystem:
- nanostores — Tiny state manager (atom, map, computed, batched, deepMap)
- @nanostores/logger — Logger and action system
- @nanostores/persistent — Persistent stores (localStorage, sessionStorage)
- @nanostores/router — SPA router
- @nanostores/i18n — Internationalization
- @nanostores/react, @nanostores/vue, @nanostores/preact, @nanostores/solid, @nanostores/lit — Framework bindings
MCP:
- Model Context Protocol — MCP specification
- Playwright MCP — Browser automation (works with nanostores-mcp for runtime analysis)
License
MIT
Contributing
Contributions are welcome! Please open an issue or PR.
来源:README.md,提交 9a48a35
工具
0版本历史
1- v0.1.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分