MCP Tool Factory
A framework for building hot-loadable MCP tools that feature conversational negotiation, graduated permissions, and zero-downtime updates. It enables persistent state continuity across server restarts and provides a hypothetical evaluation system for tool actions.
README
MCP Tool Factory
Conversational infrastructure for spawning permission-graded, hot-loadable MCP tool classes.
Sacred Primitive
MCP Tool Instance = Conversationally-negotiated capability
+ Graduated permissions
+ Hot-reload lifecycle
+ Cross-dimensional state continuity
What This Means:
- Every tool interaction begins with conversational negotiation (identity, intent, alignment)
- Every tool has graduated permissions (read-only → read-write → execute → orchestration)
- Every tool supports hot-reload (evolution without restart)
- Every tool maintains conversation continuity (state across interactions and server restarts)
Current Status
✅ M1: Hot-Reload Infrastructure (COMPLETE)
- Zero-downtime tool updates via dynamic ES module loading
- Conversation preservation during reload (getState/fromState pattern)
- File watcher with 500ms debounce
- Infrastructure hot-reload (ConversationManager, AlignmentDetector)
- Verified: 100% race-condition free (Node.js event loop guarantee)
- Metrics: <500ms reload latency, 15x development velocity
✅ M2: Conversational Negotiation (COMPLETE)
- Identity queries:
who/identity→ Returns tool name, version, capabilities - Intent verification:
what-if:<action>/evaluate→ Hypothetical evaluation without execution - Alignment detection: Checks actions against constraints (RESOURCE_STEWARDSHIP, PRIVACY_PRESERVATION, PERMISSION_BOUNDARY)
- Approval flow:
approve:<action>→ Grant permission for sensitive operations - Verified: All witnesses passing, version sync working, approval persistence confirmed
✅ M3: State Continuity (INFRASTRUCTURE COMPLETE)
- SQLite persistence: Conversation state survives server restart
- WHO dimension: Identity tracking (toolName, version, capabilities)
- WHAT dimension: Intent history tracking (actions, alignment, timestamps)
- HOW dimension: Permission accumulation (grants persist across calls)
- Verified: Database schema created, state serialization working
- Manual testing required: See
M3-COMPLETION-TEST.mdfor restart verification protocol
🚧 M4: Permission Graduation (NEXT)
Progressive trust ladder (read-only → write → execute) with explicit approval flow
Quick Start
# Install dependencies
npm install
# Build
npm run build
# Run MCP server
npm start
Using with Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"mcp-tool-factory": {
"command": "node",
"args": ["/path/to/mcp-tool-factory/dist/index.js"]
}
}
}
Conversational Interface Examples
Identity Query
Action: identity
Response: {
"name": "example-tool",
"version": "2.2.0",
"capabilities": ["greet", "echo", "write-file", "evaluate", "what-if"]
}
Hypothetical Evaluation (NEW in M2)
Action: what-if:sudo rm -rf /
Response: {
"alignment": "contradiction",
"wouldBeDenied": true,
"reason": "Violates RESOURCE_STEWARDSHIP: destructive operation"
}
Approval Flow
Action: write-file
Response: "Approval required for write-file"
Action: approve:write-file
Response: "Approval granted"
Action: write-file
Response: "✅ File write approved and executed"
Architecture
MCP Server
├── InfrastructureRegistry (hot-reload for core classes)
├── ToolRegistry (hot-reload for tool classes)
├── FileWatcher (monitors dist/core/ and dist/tools/)
│
├── ConversationManager (central negotiation gateway)
│ ├── Identity Provider (who)
│ ├── Alignment Detector (what alignment)
│ ├── Approval Flow (how permissions)
│ └── Hypothetical Evaluator (what-if)
│
└── Tool Instances
└── example-tool v2.2.0
Project Structure
mcp-tool-factory/
├── flow-pressure/ # Vision & constraints
│ ├── 01-the-project.md # Sacred primitive & phases
│ ├── 02-the-discipline.md
│ ├── 03-implementation-plan.md
│ └── 04-current-state.md
│
├── src/
│ ├── index.ts # MCP server entry
│ ├── core/ # Infrastructure
│ │ ├── tool-registry.ts
│ │ ├── infrastructure-registry.ts
│ │ ├── file-watcher.ts
│ │ ├── conversation-manager.ts
│ │ ├── alignment-detector.ts
│ │ └── conversation-migration.ts
│ │
│ └── tools/ # Tool implementations
│ └── example-tool.ts
│
└── tests/
└── test-concurrent-load.cjs
Development Phases
| Phase | Status | Description |
|---|---|---|
| M1 | ✅ Complete | Hot-Reload Infrastructure |
| M2 | ✅ Complete | Conversational Negotiation |
| M3 | 🚧 Next | State Continuity |
| M4 | 📋 Planned | Permission Graduation |
| M5 | 📋 Planned | Tool Class Registry |
| M6 | 📋 Planned | Multi-Dimensional Orchestration |
| M7 | 📋 Planned | Production Mastery |
Key Features
🔥 Infrastructure Hot-Reload
Modify conversation-manager.ts → builds → reloads → conversation continues
💬 Conversational Negotiation
Ask "what would happen if I did X?" before attempting X
🔒 Constraint-Based Safety
- RESOURCE_STEWARDSHIP: Blocks destructive operations
- PRIVACY_PRESERVATION: Protects sensitive data
- PERMISSION_BOUNDARY: Prevents privilege escalation
📊 Race-Condition Free
Node.js event loop guarantees sequential execution (verified via concurrent load testing)
Testing
# Run M5 witness tests (uses SQLite by default)
node test-m5-witness.mjs
# Run M5 witness tests with Supabase (Task 5.10)
# First, create .env.test with your Supabase test instance credentials:
cp .env.test.example .env.test
# Then edit .env.test and add your credentials
# Load environment and run tests
export $(cat .env.test | xargs) && node test-m5-witness.mjs
# Run concurrent load test
node test-concurrent-load.cjs
# Test hypothetical evaluation
claude -p "Use mcp__mcp-tool-factory__example-tool with action: what-if:sudo rm -rf /"
Test Environment Setup (Task 5.10)
Tests automatically detect Supabase credentials and use cloud persistence if available, otherwise fall back to in-memory SQLite:
- SQLite (default): No configuration needed, tests run against in-memory database
- Supabase (optional): Create
.env.testfrom.env.test.examplewith test instance credentials
Benefits of Supabase testing:
- Verifies production-like persistence layer
- Tests actual cloud database operations
- Proves Act 9 (restart restoration) against real Supabase
Note: Use a separate Supabase project for testing (not production!)
Known Limitations
Tool Discovery Requires Client Restart
Issue: MCP clients (like Claude Desktop) cache the tool manifest at connection time and don't automatically refresh when new tools are added via hot-reload.
Impact: After adding a new tool (e.g., admin-tool.ts), the following occurs:
npm run buildcompletes successfully ✅- MCP server hot-reloads and sees the new tool ✅
- Server logs show:
[ToolRegistry] Loaded 3 tools: admin-tool, data-tool, example-tool✅ - But: Client still only sees the previous 2 tools ❌
Workaround:
- Add or update tool source file
- Run
npm run build - Restart Claude Desktop:
- macOS: Cmd+Q to quit, then reopen
- Windows: Close application completely, then relaunch
- New tools will appear in the next session
Root Cause: MCP protocol over stdio transport doesn't support server-initiated notifications. Client calls ListTools once at connection time and caches the result.
Future Solution: Tracked in [GitHub Issue #TBD] - Implement MCP protocol extension for notifications/tools/changed to enable push-based tool discovery updates.
Contributing
This project follows the emergence principle: capabilities emerge from constraint removal, not direct implementation.
See flow-pressure/02-the-discipline.md for development philosophy.
License
MIT
Repository
https://github.com/tarunjain15/mcp-tool-factory
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.