Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/sxzz/stackblitz-mcp. MCP server for reading files from StackBlitz projects stackblitz-mcp.sxzz.dev
Something went wrong. Try again.
stackblitz-mcp AGENTS.md
2.2 kB
Markdown
CLAUDE.md #
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What This Is #
An MCP (Model Context Protocol) server that provides read-only access to StackBlitz project files. It fetches project data from the StackBlitz API (https://stackblitz.com/api/projects/{id}?include_files=true) and exposes it via MCP tools and resources over stdio transport.
Commands #
pnpm run build # Build with tsdown → dist/index.mjs
pnpm run dev # Watch mode build
pnpm run test # Run tests (vitest, watch mode)
pnpm run test -- --run # Run tests once
pnpm run lint # ESLint check
pnpm run lint:fix # ESLint auto-fix
pnpm run typecheck # Type check with tsgo (native TS)
pnpm run format # Prettier format
Architecture #
The server has three modules:
src/index.ts— MCP server entry point. Registers 2 resources and 4 tools onMcpServer, then connects viaStdioServerTransport. UseregisterResource/registerTool(not the deprecatedresource/toolmethods).src/stackblitz.ts— StackBlitz API client.resolveProjectId()extracts project IDs from URLs or passes plain IDs through.fetchProject()calls the API with a TTL cache (5 min, max 50 entries).src/tree.ts— Builds aFileNodetree from flat file paths and formats it as ASCII art with├──/└──connectors.
Key Conventions #
- ESM only (
"type": "module"). Use.jsextensions in imports (e.g.,./stackblitz.js). verbatimModuleSyntaxis enabled — useimport typefor type-only imports.- Type checking uses
tsgo(native TypeScript preview), which has stricter overload resolution thantsc. - ESLint uses
@sxzz/eslint-configwhich enforces:toSorted()oversort(),for-ofover index loops,node:prefix for Node.js builtins, no duplicate imports. - Prettier uses
@sxzz/prettier-config. - Tool results use
type: 'text' as constandtype: 'resource_link' as constfor content items.resource_linkfields (uri,name,mimeType) are at top level, not nested in aresourceobject.