miadi-mcp-server
v1.0.14
Published
MCP server for Miadi Three-Pathway Agent System API
Downloads
51
Readme
Miadi MCP Server
A Model Context Protocol (MCP) server implementation that exposes the Miadi Three-Pathway Agent System API as MCP tools for Claude to use.
Generated by: Claude-Code and Gemini via gemini-cli MCP on 2025-07-25 / 2025-08-13
IMPORTANT NOTES
- "Miadi Three-Pathway" is not public yet and still in development internally. We plan to publish it publicly in the future.
Overview
This MCP server acts as a bridge between Claude and the Miadi Three-Pathway Agent System, enabling natural language interaction with:
- Memory Operations: Redis-based memory storage and retrieval
- Session Management: Agent persona and mode switching
- Capability Resolution: Dynamic capability resolution based on context
- AI Integration: OpenAI and generic AI model requests
- Workflow Management: GitHub event handling and agent coordination
- Forge State: System state management and glyph operations
Quick Start
1. Installation
# Install dependencies
npm install
# Copy environment template
cp .env.example .env2. Configuration
Edit .env with your Miadi API credentials:
EH_TOKEN=your_miadi_api_token_here
EH_API_URL=https://__YOUR_CUSTOM_DOMAIN__.ngrok-free.app3. Build and Run
# Development mode
npm run dev
# Production build
npm run build
npm startAvailable MCP Tools
Memory Operations
miadi-get-memory- Retrieve memory data from Redismiadi-store-memory- Store data in memory with TTLmiadi-scan-keys- Scan Redis keys with patternsmiadi-gather-memory-values- Gather multiple memory valuesmiadi-collect-memory- Collect specific keysmiadi-view-key-content- View individual key contentmiadi-search-cluster- Search cluster for keys
Session Management
miadi-start-session- Start new agent sessionmiadi-get-current-session- Get current session detailsmiadi-switch-mode- Switch mode in existing sessionmiadi-switch-persona- Switch persona in sessionmiadi-end-session- End active sessionmiadi-list-sessions- List active sessions
Capability Resolution
miadi-resolve-capabilities- Resolve capabilities for persona/modemiadi-get-agent-info- Get comprehensive agent system infomiadi-detect-cues- Detect mode/persona switch cues from text
AI Integration
miadi-openai-request- Make OpenAI API requestsmiadi-ai-request- Make generic AI requests
Workflow Management
miadi-register-agent- Register agent for GitHub eventsmiadi-get-agent-events- Check for agent eventsmiadi-get-workflow-howto- Get workflow setup guides
Forge State
miadi-get-forge-state- Get current forge statemiadi-update-forge-state- Update forge statemiadi-get-glyph-map- Get glyph map information
Architecture
Claude → MCP Tool Calls → MCP Server → HTTP Requests (EH_TOKEN) → Miadi API
← MCP Tool Results ← HTTP Responses ←Key Components
- API Client (
src/api-client.ts): HTTP client with authentication - Tool Definitions (
src/tools/): MCP tools grouped by functionality - Type Definitions (
src/types.ts): TypeScript interfaces from OpenAPI spec - Utilities (
src/utils.ts): Error handling and validation helpers - Main Server (
src/index.ts): MCP server orchestration
Usage Examples
Memory Operations
// Get memory by key
await handleToolRequest('miadi-get-memory', { key: 'user:123' });
// Store memory with TTL
await handleToolRequest('miadi-store-memory', {
key: 'session:abc',
value: JSON.stringify({ user: 'john', active: true }),
ttl: 3600
});
// Scan keys with pattern
await handleToolRequest('miadi-scan-keys', { pattern: 'session:*' });Session Management
// Start new session
await handleToolRequest('miadi-start-session', {
persona: 'mia-recursive-architect',
mode: 'desktop',
userId: 'user123'
});
// Switch mode
await handleToolRequest('miadi-switch-mode', {
sessionId: '550e8400-e29b-41d4-a716-446655440000',
newMode: 'walking'
});AI Integration
// OpenAI request
await handleToolRequest('miadi-openai-request', {
prompt: 'Analyze this data...',
modelId: 'gpt-4',
maxTokens: 500,
temperature: 0.7
});Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| EH_TOKEN | Miadi API authentication token | Yes |
| EH_API_URL | Base URL for Miadi API | Yes |
| MCP_PORT | MCP server port (default: 8080) | No |
| LOG_LEVEL | Logging level (info, debug) | No |
Development
Project Structure
src/
├── index.ts # Main server entry point
├── api-client.ts # HTTP client for Miadi API
├── types.ts # TypeScript type definitions
├── utils.ts # Utility functions
└── tools/ # MCP tool implementations
├── memory-tools.ts # Memory operations
├── session-tools.ts # Session management
├── capability-tools.ts # Capability resolution
├── ai-tools.ts # AI integration
├── workflow-tools.ts # Workflow management
└── forge-tools.ts # Forge state operationsAdding New Tools
- Define types in
src/types.ts - Implement API client methods in
src/api-client.ts - Create tool functions in appropriate
src/tools/*.tsfile - Register tools in
src/index.tsmcpTools registry
Error Handling
All tools include comprehensive error handling:
- Parameter validation
- API error transformation
- User-friendly error messages
- Request/response logging
API Integration
Authentication
- Uses Bearer token authentication via
EH_TOKEN - All requests include
Authorization: Bearer ${EH_TOKEN}header
Request/Response Flow
- MCP Tool Call → Parameter validation
- API Client Call → HTTP request to Miadi API
- Response Processing → Error handling and transformation
- MCP Tool Result → Formatted response to Claude
Rate Limiting
Built-in rate limiting (100 requests/minute per identifier) to prevent API abuse.
Testing
# Manual testing (development)
npm run dev
# Test specific tool
node -e "
const { handleToolRequest } = require('./dist/index.js');
handleToolRequest('miadi-get-agent-info', {}).then(console.log);
"Deployment
- Build the server:
npm run build - Set environment variables in production
- Start the server:
npm start - Configure Claude to use the MCP server endpoint
Troubleshooting
Common Issues
Environment Variables Missing
- Ensure
EH_TOKENandEH_API_URLare set - Check
.envfile is in project root
- Ensure
API Connection Errors
- Verify
EH_API_URLis accessible - Check
EH_TOKENis valid and not expired
- Verify
Tool Not Found
- Ensure tool name matches exactly (case-sensitive)
- Check tool is registered in
mcpToolsregistry
Debugging
Set LOG_LEVEL=debug to see detailed request/response logging:
LOG_LEVEL=debug npm run devLicense
MIT License - Generated via Gemini MCP
Support
For issues and questions:
- Check the troubleshooting section above
- Review the Miadi API documentation
- Verify environment configuration
- Check server logs for detailed error messages
