Overview
The MCP server package (@tempad-dev/mcp) is a Hub/CLI that exposes MCP tools and proxies calls to the browser extension via WebSocket.
Location: packages/mcp-server/
NPM Package: @tempad-dev/mcp
Repository: https://github.com/ecomfe/tempad-dev
Responsibilities
- Tool registration and routing in the Hub
- Asset storage and HTTP/MCP resource serving
- CLI/Hub lifecycle stability
- WebSocket server for extension communication
- MCP stdio transport for AI clients
Tech Stack
- Language: TypeScript
- Runtime: Node.js 18+
- MCP SDK:
@modelcontextprotocol/sdk - Transport: WebSocket + stdio
- Logging: Pino
Directory Structure
Key Commands
Building
dist/cli.mjs (binary entrypoint)
Testing
Quality Checks
Publishing
build runs automatically via prepublishOnly
Architecture
CLI Entrypoint
File:src/cli.ts
Starts the MCP server with stdio transport:
Hub
File:src/hub.ts
Responsibilities:
- MCP server lifecycle
- Tool routing
- WebSocket server for extension communication
- Resource serving (assets via HTTP)
Tool Definitions
File:src/tools.ts
Tools are registered via TOOL_DEFS:
extension- Proxied to browser extensionhub- Handled locally by MCP server
Request Tracking
File:src/request.ts
Manages pending tool calls:
- Request ID generation
- Timeout tracking
- Promise resolution/rejection
Asset Storage
File:src/asset-store.ts
In-memory asset store:
- Asset index by ID
- Automatic cleanup
- MIME type tracking
src/asset-http-server.ts
HTTP server for asset upload/download:
POST /assets- Upload assetGET /assets/:id- Download asset- MCP resource serving
asset://<id>
Tool Registration
Define a Tool
Formatter Function
Formatters convert tool results to MCP response format:Asset Pipeline
Upload Asset (from Extension)
Extension uploads assets via HTTP:Serve Asset (to AI Client)
MCP server serves assets as resources:Asset Cleanup
Assets are automatically cleaned up after a TTL.Code Style Guidelines
Tool Registration
Good:Avoid Embedding Binary Data
Bad:Testing Strategy
Strict Pure Coverage
These files have enforced coverage:src/asset-utils.tssrc/tools.tssrc/config.tssrc/request.tssrc/asset-store.tssrc/asset-http-server.tssrc/shared.ts
Test Files
Location:tests/
Pattern: *.test.ts (Node runtime only)
Deterministic Tests
Boundaries and Constraints
Schema Changes
Updatepackages/shared before changing tool schemas:
Asset URIs
Do not changeasset:// URI format without cross-package review.
Payload Caps
Do not change payload caps without assessing impact on extension and hub.Dependencies
Do not add new dependencies without approval.Verification Checklist
Always Run
Coverage Check
Cross-Package Validation
After schema changes:Publishing Workflow
- Update version in
package.json - Build:
- Verify:
- Publish:
build automatically.
Related Documentation
In source repo:- Testing architecture:
docs/testing/architecture.md