Uses ESLint for code quality and linting standards in the development workflow
Built on Node.js runtime (18+) for MCP server execution and TypeScript compilation
Uses npm package manager for dependency management and build scripts
Uses Prettier for consistent code formatting across the TypeScript codebase
Uses SQLite with FTS5 full-text search capabilities for persistent storage of scratchpads and workflows, with optional Chinese word segmentation through jieba tokenization extensions
Implemented in TypeScript with strict type safety and comprehensive validation for all MCP tool parameters
Uses Vitest testing framework for comprehensive test coverage including database, MCP tools, and performance testing
Scratchpad MCP v2
A Model Context Protocol (MCP) server that provides shared scratchpad functionality for Claude Code sub-agents, enabling seamless context sharing and collaboration within workflows.
🚀 TL;DR / Try it now
⚠️ Important: always use start-mcp.sh
Why the startup script matters:
- Correct path resolution and database path handling
- Cross-directory support (works from any working directory)
- Proper loading of optional Chinese tokenization extensions
🚀 Quick Start
Prerequisites
- Node.js 18.0.0 or newer
- SQLite (FTS5 handled automatically)
Installation
Running as MCP Server
Environment Configuration
🧰 Available MCP Tools
create-workflow
- Create workflow containerslist-workflows
- List all workflowsget-latest-active-workflow
- Get the most recently updated active workflowupdate-workflow-status
- Activate/deactivate a workflowcreate-scratchpad
- Create a scratchpad within a workflowget-scratchpad
- Retrieve a scratchpad by ID with optional line range and context selectionget-scratchpad-outline
- Parse markdown headers and return structured outline with line numbersappend-scratchpad
- Append content to an existing scratchpadtail-scratchpad
- Tail content with line/char/block modes, or setfull_content=true
to get full contentchop-scratchpad
- Remove lines or blocks from the end of a scratchpad (supports semantic block removal)update-scratchpad
- Multi-mode editing tool with replace/insert/replace-lines/append-section modeslist-scratchpads
- List scratchpads in a workflowsearch-scratchpads
- Full-text search with context-aware snippets (grep-like functionality, intelligent Chinese tokenization)search-scratchpad-content
- Search within a single scratchpad content using string/regex patterns (VS Code Ctrl+F style)search-workflows
- 🆕 Search workflows with weighted scoring (5/3/3/1) based on name/description/scratchpads contentextract-workflow-info
- Extract specific information from workflows using OpenAI models
🔗 Claude Code Integration
Prerequisites
- Node.js 18.0.0 or newer
- Claude Code CLI installed and configured
- Project built:
npm run build
⚠️ Critical configuration
Always use an absolute path to start-mcp.sh
to ensure correct path resolution and cross-directory compatibility.
Method 1: CLI installation (recommended)
Method 2: Manual configuration
Project-level .mcp.json
(recommended)
Global ~/.claude.json
❌ Invalid configuration examples (do not use)
Cross-project usage
Verification
Troubleshooting
- Server does not start: verify Node 18+, run
npm run build
, ensurestart-mcp.sh
is executable, use absolute path in MCP config - Chinese search returns no results: most likely running
dist/server.js
directly — switch tostart-mcp.sh
- Message "Simple 擴展載入失敗": normal when extensions are not installed; system falls back to FTS5/LIKE
- Tools not available: run
claude mcp list
, reload configuration, verify startup script path
Best practices
- Always use
start-mcp.sh
- Prefer absolute paths
- Verify Chinese tokenizer loading messages
- Commit a project-level
.mcp.json
for teams
🌐 Workflow Web Viewer
A standalone HTTP server to browse scratchpad workflows via a web UI.
Quick Start
Database path configuration
Priority order:
Features
- 🔍 Search & filter: full-text search across workflows and scratchpads
- 🎨 Syntax highlighting: Prism.js with automatic dark/light theme
- 📱 Responsive UI with organization and pagination
- ⚡ Live updates
🇨🇳 Optional Chinese Text Enhancement
Optional feature to improve Chinese search accuracy (the system works fine without it via FTS5/LIKE fallback).
Installation
- Create an
extensions
directory
- Download the extension and dictionaries for your platform
macOS
Linux
- Create the required symlink for jieba dictionaries (use absolute path)
- Use the automated installation script (includes proper symlinks)
- Verify
Note: even without extensions installed, all search features work (fallback to FTS5/LIKE).
🛠️ MCP Tools API
Workflow Management
create-workflow
Create a new workflow container.
list-workflows
List all workflows.
get-latest-active-workflow
Get the most recently updated active workflow.
update-workflow-status
Activate or deactivate a workflow.
Scratchpad Operations
create-scratchpad
Create a scratchpad within a workflow.
get-scratchpad
Retrieve a specific scratchpad with optional line range and context selection.
Range Selection Features:
line_range
: Extract specific line range from scratchpad contentline_context
: Add context lines before/after the selected rangeinclude_block
: Use semantic block boundaries for more intelligent context extraction
Parameter Conflicts: Cannot use line_range
/line_context
with include_block
- they are mutually exclusive.
get-scratchpad-outline
Parse markdown headers in a scratchpad and return a structured outline with line numbers.
Features:
- Parses markdown headers (# ## ### #### ##### ######) and returns structured outline
- Provides line numbers for each header for precise navigation
- Configurable depth limit to focus on main sections
- Returns hierarchical structure showing header relationships
- Useful for navigation, content organization, and structured content extraction
Response Format:
append-scratchpad
Append content to an existing scratchpad.
tail-scratchpad
Tail content, or return full content with full_content=true
. Supports block-based extraction for semantic content handling.
Parameter priority: full_content
> tail_size
> default (50 lines)
Block-based extraction: Uses the new append splitter format (---\n<!--- block start --->\n
) to extract semantic content blocks rather than arbitrary lines. Perfect for retrieving complete logical sections.
chop-scratchpad
Remove content from the end of a scratchpad. Supports both line-based and block-based removal. Does not return content after completion.
Block-based removal: Use blocks
parameter to remove complete semantic blocks rather than arbitrary lines. Uses the append splitter format to identify block boundaries. Only one of lines
or blocks
should be specified.
update-scratchpad
Multi-mode scratchpad editing tool with four precise editing modes.
Editing Modes:
replace
: Complete content replacement (no additional parameters)insert_at_line
: Insert at specific line number (requiresline_number
)replace_lines
: Replace line range (requiresstart_line
andend_line
)append_section
: Smart append after markdown section marker (requiressection_marker
)
Response includes detailed operation feedback:
- Lines affected count
- Size change in bytes
- Insertion point (for insert/append modes)
- Replaced range (for replace_lines mode)
list-scratchpads
List scratchpads with pagination and content control.
Content control priority: include_content
> preview_mode
> max_content_chars
Search & Discovery
search-workflows
🆕
NEW: Search workflows with intelligent weighted scoring based on scratchpads content. Perfect for finding relevant workflows across projects.
Key Features:
- Weighted Scoring: workflows.name (5pts) > workflows.description (3pts) = scratchpads.title (3pts) > scratchpads.content (1pt)
- Mixed Language:
"React組件開發"
→ English:["React"]
+ Chinese:["組件開發"]
- Project Isolation: Use
project_scope
for exact match filtering - Performance Optimized: Search workflows first, then load scratchpads for scoring
search-scratchpad-content
🆕
NEW: Search within a single scratchpad content using string or regex patterns. Similar to VS Code Ctrl+F or grep for a single file. Supports context-aware search results with line-based context.
Key Features:
- VS Code Style Search: Find-in-file functionality with precise line targeting
- Dual Search Modes: String literals (
query
) or regex patterns (queryRegex
) - Context Awareness: Show surrounding lines like
grep -A -B -C
- Smart Snippets: Character-based or context-based snippet generation
- Match Details: Line numbers, character positions, and match text extraction
search-scratchpads
Full-text search with automatic Chinese tokenization and graceful fallbacks. Supports context-aware search similar to grep -A -B -C.
Search intelligence: automatic detection → jieba → simple → FTS5 → LIKE; target <100ms. Context search provides grep-like functionality with line-based snippets.
AI Analysis
extract-workflow-info
Extract specific information from workflows using OpenAI's GPT models.
Prerequisites: Requires OPENAI_API_KEY
environment variable.
Supported Models: gpt-5-nano, gpt-5-mini, gpt-4o, gpt-4o-mini and other OpenAI models. GPT-5 models support the reasoning_effort
parameter for enhanced analysis quality.
Returns: Structured analysis based on the extraction prompt, including the model used and number of scratchpads processed.
📋 Usage Examples (more)
Basic Workflow
Integration with Claude Code (highlights)
- Multi-agent collaboration via workflows
- Context persistence across conversations
- Intelligent search for both Chinese and English content
- Project organization through workflows and project scopes
- Cross-directory support via the startup script
💻 Development Guide
Available Scripts
Project Structure
Testing Strategy
- Database layer: CRUD, FTS5, error and edge cases, Chinese tokenization
- MCP tools integration: 14 tools parameter validation, scenarios, protocol compliance
- Performance: FTS5 <100ms, 1MB content, concurrent access, tokenization performance
- Project scope: workflow isolation, cross-project restrictions
Code Quality Standards
- TypeScript strict mode (no
any
) - ESLint + Prettier
95% test coverage
- Targets: <100ms search, 1MB content
- Path resolution via the startup script
🌩️ Cloud Sync & Database Tools
Real-time Cloud Sync (live-sync.cjs
)
Sync your scratchpad database to cloud storage without disconnecting MCP servers, perfect for multi-machine workflows.
Key Features:
- ✅ No MCP Server disconnection required
- ✅ Uses passive checkpoint (non-blocking)
- ✅ Smart sync (only when files change)
- ✅ Automatic backup with rotation
- ✅ Works with WAL mode seamlessly
Basic Usage
Advanced Options
Multi-machine Setup
Database Management Tools
Database Migration (migrate-workflows-fts.cjs
)
🆕 NEW: Migrate existing databases to support the new search-workflows
tool with weighted scoring.
Automatic Migration (Recommended):
- Migration happens automatically when starting the MCP server
- Existing databases are upgraded from v3 → v4 seamlessly
- No downtime or data loss
Manual Migration:
What's Added:
- ✅
workflows_fts
virtual table for full-text search - ✅ Automatic FTS5 triggers for data synchronization
- ✅
search-workflows
tool with 5/3/3/1 weighted scoring - ✅ Mixed English/Chinese language support
- ✅ Project scope filtering and smart pagination
Safety Features:
- 🔒 Automatic backup before migration (
.backup.timestamp
) - 🔄 FTS5 graceful fallback to LIKE search if unsupported
- ✅ Data integrity verification after migration
- 🛡️ Rollback support via backup files
WAL Checkpoint (checkpoint-database.cjs
)
Handle WAL files and perform database maintenance:
Search Mode Diagnostics (check-search-mode.cjs
)
Check FTS5/LIKE search mode status:
🔧 Advanced Configuration
Startup Script Features
Benefits: stable working directory, proper extension/dictionary loading, DB path setup, cross-directory support.
FTS5 Configuration
- Disabled automatically in test environments
- Tokenizer selection: simple/jieba/standard
- Fallback strategy: jieba → simple → FTS5 → LIKE
- Indexed fields: title and content (with triggers)
- Ranking: BM25
Database Optimization
- WAL mode, prepared statements, single connection with proper cleanup, smart tokenization
📊 Technical Specifications
Architecture
- Server: MCP over stdio
- Tools: 16 core tools with comprehensive parameter validation
- Database: SQLite with FTS5 full-text search, WAL mode, optional Chinese tokenization
- Content Management: Block-based operations with semantic content handling via BlockParser utility
- Append System: Enhanced splitter format (
---\n<!--- block start --->\n
) for clear content separation - Extension layer: optional Chinese word segmentation with cross-directory support
Performance Characteristics
Metric | Target | Implementation |
---|---|---|
Search Response | <100ms | FTS5 indexing with prepared statements |
Chinese Search | <150ms | Jieba tokenization with fallback strategy |
Content Limit | 1MB per scratchpad | Validated at tool level |
Workflow Capacity | 50 scratchpads | Enforced by database constraints |
Concurrent Access | Thread-safe | SQLite WAL mode |
Cross-Directory | ✅ Supported | Via startup script path resolution |
Data Model
Environment Variables
Variable | Description | Default | Example |
---|---|---|---|
SCRATCHPAD_DB_PATH | Database file path (relative to project root) | ./scratchpad.db | ./my-scratchpad.db |
OPENAI_API_KEY | OpenAI API key for AI analysis features | - | sk-... |
SCRATCHPAD_DISABLED_TOOLS | Comma-separated list of tools to disable for token optimization | "" (all enabled) | get-scratchpad,get-scratchpad-outline |
Tool Control Examples
Available tools for disabling:
get-scratchpad
- Retrieve scratchpad content (can be replaced bytail-scratchpad
withfull_content=true
)get-scratchpad-outline
- Parse markdown headers structure
Token Savings:
- Disabling
get-scratchpad
: ~200-300 tokens - Disabling
get-scratchpad-outline
: ~150-200 tokens - Total potential savings: ~350-500 tokens
Environment Requirements
- Node.js 18+
- SQLite with FTS5
- Memory ~50MB
- Storage varies (1MB per scratchpad limit)
- Optional extensions: libsimple.dylib/.so for Chinese support
Dependencies
- Core:
@modelcontextprotocol/sdk
,better-sqlite3
- AI Features:
openai
,tiktoken
- Web Viewer:
marked
,marked-highlight
,prismjs
- Dev:
typescript
,tsup
,vitest
,eslint
,prettier
🤝 Contributing
- Fork the repository
- Create a branch:
git checkout -b feature/amazing-feature
- Install deps:
npm install
- Build:
npm run build
- Test startup script:
./start-mcp.sh
- Make changes and add tests
- Run tests:
npm test
- Quality checks:
npm run typecheck && npm run lint
- Commit:
git commit -m 'feat: add amazing feature'
- Push:
git push origin feature/amazing-feature
- Open a PR
Development Standards
- New features must include tests; maintain >95% coverage
- Follow TypeScript strict mode
- Conventional Commits
- Update docs for API changes
- Use
start-mcp.sh
for manual testing
📄 License
MIT License (see LICENSE
)
📞 Support
- Issues: GitHub Issues for bug reports and feature requests
- Documentation: inline code docs and tests
- Performance: FTS5 target <100ms
- Chinese support: ensure tokenizer is loaded via the startup script
Remember: always use ./start-mcp.sh
to launch the MCP server. Running dist/server.js
directly causes path resolution and cross-directory compatibility issues.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables shared scratchpad functionality for Claude Code sub-agents with full-text search, workflow organization, and intelligent Chinese text tokenization. Supports seamless context sharing and collaboration across workflows with project scope isolation.
- 🚀 TL;DR / Try it now
- 🚀 Quick Start
- 🧰 Available MCP Tools
- 🔗 Claude Code Integration
- 🌐 Workflow Web Viewer
- 🇨🇳 Optional Chinese Text Enhancement
- 🛠️ MCP Tools API
- 📋 Usage Examples (more)
- 💻 Development Guide
- 🌩️ Cloud Sync & Database Tools
- 🔧 Advanced Configuration
- 📊 Technical Specifications
- 🤝 Contributing
- 📄 License
- 📞 Support
Related MCP Servers
- -securityAlicense-qualityFacilitates integration with the Cursor code editor by enabling real-time code indexing, analysis, and bi-directional communication with Claude, supporting concurrent sessions and automatic reconnection.Last updated -238MIT License
- -securityFlicense-qualityAllows Claude Code to offload AI coding tasks to Aider, reducing costs and enabling more control over which models handle specific coding tasks.Last updated -281
- -securityAlicense-qualityEnables multiple Claude Code instances to collaborate in real-time through channels, allowing AI agents to work together on projects without requiring local setup beyond Docker.Last updated -2MIT License
- -securityAlicense-qualityEnables Claude Code and other MCP-compatible tools to leverage MeshAI's multi-agent orchestration capabilities for code review, refactoring, debugging, documentation, architecture analysis, and feature development. Automatically selects appropriate AI agents based on task content and works with agents built on LangChain, CrewAI, AutoGen, and other frameworks.Last updated -MIT License