"Each Claude Code session spawns a dedicated task-master-ai Node.js process via stdio MCP, consuming ~370 MB RSS. At scale (15 parent + 50 subprocess sessions = 65 processes), this is ~24 GB just for TaskMaster."
Motivation
The MCP server loads 60+ npm dependencies including 10+ AI SDK providers (Anthropic, OpenAI, Google, Mistral, xAI, Perplexity, OpenRouter, AWS Bedrock, Azure), Sentry, googleapis, etc. — all at startup. However, 80% of MCP calls are pure JSON file I/O (reads, status updates, task additions) that never touch AI providers.
In environments with many concurrent sessions (agentic orchestration, multi-terminal development), memory consumption becomes the dominant resource constraint.
Proposed Solution
Lazy-load AI SDK providers — only import AI dependencies when an AI operation is actually requested:
- Core ops (80% of calls):
get_tasks, get_task, set_task_status, add_task (manual fields), use_tag, list_tags — need only fs, path, JSON parsing
- AI ops (20% of calls):
expand_task, parse_prd, update_task (with prompt) — need AI SDK
This could reduce idle RSS from ~370 MB to ~50-80 MB for sessions that primarily do read/status operations.
High-Level Workflow
- At startup, load only core modules (fs, path, JSON, git)
- Register all MCP tools with their schemas
- When an AI operation is called, dynamically import the required AI SDK provider
- Cache the imported provider for subsequent AI calls in the same session
Key Elements
- Lazy
import() for AI SDK packages (@anthropic-ai/sdk, openai, etc.)
- Only load the provider configured in
.taskmaster/config.json (main, research, fallback)
- Consider
TASK_MASTER_TOOLS mode — core mode should never load AI deps
- Sentry could also be lazy-loaded or made opt-in
Example Workflow
# Current: All 370 MB loaded immediately
$ node task-master-ai # RSS: 370 MB
# Proposed: Core only at startup
$ node task-master-ai # RSS: ~50-80 MB
# First AI operation triggers lazy load
$ expand_task(...) # RSS grows to ~200 MB (only loads configured provider)
Implementation Considerations
- AI SDK lazy loading must handle async import gracefully
- Provider selection already exists in config — extend to lazy init
- Backward compatible — no API changes
core and standard modes benefit most (no AI ops expected)
Benchmarks (from our Python replacement)
We built a Python MCP server replacement that handles core ops natively:
- Python server RSS: ~44 MB (handles 27 of 44 tools)
- Node.js server RSS: ~370 MB (all 44 tools)
- Savings at 65 processes: ~22 GB reduction
Out of Scope (Future Considerations)
- HTTP/SSE transport for shared server (separate feature request)
- Splitting into separate core/AI packages
Motivation
The MCP server loads 60+ npm dependencies including 10+ AI SDK providers (Anthropic, OpenAI, Google, Mistral, xAI, Perplexity, OpenRouter, AWS Bedrock, Azure), Sentry, googleapis, etc. — all at startup. However, 80% of MCP calls are pure JSON file I/O (reads, status updates, task additions) that never touch AI providers.
In environments with many concurrent sessions (agentic orchestration, multi-terminal development), memory consumption becomes the dominant resource constraint.
Proposed Solution
Lazy-load AI SDK providers — only import AI dependencies when an AI operation is actually requested:
get_tasks,get_task,set_task_status,add_task(manual fields),use_tag,list_tags— need onlyfs,path, JSON parsingexpand_task,parse_prd,update_task(with prompt) — need AI SDKThis could reduce idle RSS from ~370 MB to ~50-80 MB for sessions that primarily do read/status operations.
High-Level Workflow
Key Elements
import()for AI SDK packages (@anthropic-ai/sdk,openai, etc.).taskmaster/config.json(main, research, fallback)TASK_MASTER_TOOLSmode —coremode should never load AI depsExample Workflow
Implementation Considerations
coreandstandardmodes benefit most (no AI ops expected)Benchmarks (from our Python replacement)
We built a Python MCP server replacement that handles core ops natively:
Out of Scope (Future Considerations)