MCP Tool Factory

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.

Category
访问服务器

README

MCP Tool Factory

Conversational infrastructure for spawning permission-graded, hot-loadable MCP tool classes.

Status Version Tools


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.md for 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:

  1. SQLite (default): No configuration needed, tests run against in-memory database
  2. Supabase (optional): Create .env.test from .env.test.example with 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:

  1. npm run build completes successfully ✅
  2. MCP server hot-reloads and sees the new tool ✅
  3. Server logs show: [ToolRegistry] Loaded 3 tools: admin-tool, data-tool, example-tool
  4. But: Client still only sees the previous 2 tools ❌

Workaround:

  1. Add or update tool source file
  2. Run npm run build
  3. Restart Claude Desktop:
    • macOS: Cmd+Q to quit, then reopen
    • Windows: Close application completely, then relaunch
  4. 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选