miadi 1.0.14 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/package.json +17 -48
  2. package/.env.example +0 -28
  3. package/ARCHITECTURE.md +0 -290
  4. package/CLAUDE.md +0 -269
  5. package/GEMINI.md +0 -80
  6. package/MCP_CONNECTOR_READY.md +0 -219
  7. package/MCP_LEARNING_NOTES.md +0 -178
  8. package/MCP_REBUILD_PLAN.md +0 -159
  9. package/MCP_REMOTE_SERVER_SPEC.md +0 -373
  10. package/MIA.md +0 -344
  11. package/MIETTE.md +0 -195
  12. package/README.md +0 -264
  13. package/REMOTE_MCP_TRANSFORMATION_GUIDE.md +0 -384
  14. package/STATUS.md +0 -191
  15. package/TOOL_SELECTION_PLAN.md +0 -340
  16. package/WAKE_UP_SUMMARY.md +0 -102
  17. package/__PUBLISH.sh +0 -1
  18. package/book/_/ledgers/ledger_miadi_mcp_analysis_250730.md +0 -0
  19. package/conversations/2507301433.claude.issue.11.2025-07-30-this-mcp-is-not-working-another-instance-of-yours.txt +0 -756
  20. package/conversations/2507301601.cursor.reverse_engineer_mcp_service_for.md +0 -808
  21. package/conversations/2508050125.llmcon.claude.MIADI_TOOLS-implement-what-is-in-toolselectionplanmd.txt +0 -1235
  22. package/conversations/2508051939.llmcon.claude.issue-14.TransitionToPlanningIT.implement-what-is-in-toolselectionplanmd.txt +0 -1424
  23. package/conversations/2508082352.llmcon.claude.MCP-Remote-Take-II.txt +0 -1658
  24. package/dist/index-remote.js +0 -54736
  25. package/dist/index.js +0 -32363
  26. package/mcp.sample.json +0 -14
  27. package/openapi.yml +0 -2161
  28. package/research/MCP_Research_Perplexity_2508060045.md +0 -410
  29. package/samples/README.md +0 -2
  30. package/scripts/ngrokserve.sh +0 -6
  31. package/scripts/start-remote.sh +0 -141
  32. package/scripts/start-with-ngrok.sh +0 -140
  33. package/src/api-client.ts +0 -254
  34. package/src/index-remote.ts +0 -406
  35. package/src/index-simple.ts +0 -232
  36. package/src/index.ts +0 -510
  37. package/src/tool-registry.ts +0 -223
  38. package/src/tools/ai-tools.ts +0 -69
  39. package/src/tools/capability-tools.ts +0 -79
  40. package/src/tools/forge-tools.ts +0 -51
  41. package/src/tools/memory-tools.ts +0 -137
  42. package/src/tools/session-tools.ts +0 -135
  43. package/src/tools/workflow-tools.ts +0 -65
  44. package/src/types.ts +0 -291
  45. package/src/utils.ts +0 -279
  46. package/tests/quick-test.sh +0 -116
  47. package/tests/run-all-tests.sh +0 -167
  48. package/tests/test-agent-capabilities.sh +0 -364
  49. package/tests/test-connectivity.sh +0 -90
  50. package/tests/test-memory-operations.sh +0 -236
  51. package/tests/test-session-management.sh +0 -320
  52. package/tests/test-tool-discovery.sh +0 -151
  53. package/tsconfig.json +0 -24
package/package.json CHANGED
@@ -1,56 +1,25 @@
1
1
  {
2
2
  "name": "miadi",
3
- "version": "1.0.14",
4
- "description": "MCP server for Miadi Three-Pathway Agent System API",
5
- "main": "dist/index.js",
6
- "bin": {
7
- "miadi-mcp-server": "dist/index.js",
8
- "miadi-mcp-server-remote": "dist/index-remote.js"
9
- },
3
+ "version": "2.0.1",
4
+ "description": "A software factory for producing relational movies",
5
+ "main": "index.js",
10
6
  "scripts": {
11
- "start": "node dist/index.js",
12
- "start:remote": "node dist/index-remote.js",
13
- "prestart": "npm run build",
14
- "prestart:remote": "npm run build:remote",
15
- "build:std": "esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js --external:@modelcontextprotocol/sdk",
16
- "build:remote": "esbuild src/index-remote.ts --bundle --platform=node --outfile=dist/index-remote.js --external:@modelcontextprotocol/sdk",
17
- "build": "npm run build:std && npm run build:remote",
18
- "dev": "nodemon --exec ts-node src/index.ts",
19
- "dev:remote": "nodemon --exec ts-node src/index-remote.ts",
20
7
  "test": "echo \"Error: no test specified\" && exit 1"
21
8
  },
22
- "keywords": [
23
- "mcp",
24
- "miadi",
25
- "agent",
26
- "api",
27
- "server"
28
- ],
29
- "author": "Generated via Gemini MCP",
30
- "license": "MIT",
9
+ "keywords": [],
10
+ "author": "JGWill",
11
+ "license": "ISC",
12
+ "type": "commonjs",
31
13
  "dependencies": {
32
- "@modelcontextprotocol/sdk": "^1.17.0",
33
- "axios": "^1.6.0",
34
- "cors": "^2.8.5",
35
- "dotenv": "^16.3.0",
36
- "express": "^4.18.2",
37
- "jsonwebtoken": "^9.0.2",
38
- "passport": "^0.7.0",
39
- "passport-jwt": "^4.0.1",
40
- "uuid": "^9.0.1",
41
- "zod": "^3.22.0"
42
- },
43
- "devDependencies": {
44
- "@types/cors": "^2.8.17",
45
- "@types/express": "^4.17.21",
46
- "@types/jsonwebtoken": "^9.0.5",
47
- "@types/node": "^20.10.0",
48
- "@types/passport": "^1.0.16",
49
- "@types/passport-jwt": "^4.0.1",
50
- "@types/uuid": "^9.0.7",
51
- "esbuild": "^0.25.8",
52
- "nodemon": "^3.0.0",
53
- "ts-node": "^10.9.0",
54
- "typescript": "^5.3.0"
14
+ "@miadi/a2a-contracts": "^0.1.1",
15
+ "@miadi/agent-pi": "^2.0.0",
16
+ "@miadi/episodic-memory-schema": "^0.2.0",
17
+ "@miadi/hermes-conductor": "^0.1.0",
18
+ "@miadi/hooks-core": "^0.4.0",
19
+ "@miadi/inquiry-weave": "^0.2.0",
20
+ "@miadi/plan-insight": "^0.1.0",
21
+ "@miadi/tide": "^0.1.4",
22
+ "@miadi/tide-contract": "^0.1.3",
23
+ "passages": "^0.1.3"
55
24
  }
56
25
  }
package/.env.example DELETED
@@ -1,28 +0,0 @@
1
- # Miadi MCP Server Environment Configuration
2
- # Copy this file to $HOME/.env and configure with your values
3
-
4
- # Required: Miadi API Configuration
5
- EH_TOKEN=your-miadi-api-token-here
6
- EH_API_URL=https://your-miadi-api-url.com
7
-
8
- # Optional: Server Configuration
9
- NODE_ENV=development
10
- MCP_PORT=3330
11
- MCP_HOST=0.0.0.0
12
- LOG_LEVEL=info
13
-
14
- # Optional: ngrok Configuration (dedicated domain)
15
- NGROK_DOMAIN=__YOUR_CUSTOM_DOMAIN__.ngrok-free.app
16
- MCP_BASE_URL=https://__YOUR_CUSTOM_DOMAIN__.ngrok-free.app
17
-
18
- # Optional: OAuth Configuration
19
- JWT_SECRET=your-jwt-secret-key-change-in-production
20
- OAUTH_ISSUER=https://__YOUR_CUSTOM_DOMAIN__.ngrok-free.app/oauth
21
-
22
- # Optional: Tool Selection (uncomment to use)
23
- # MIADI_TOOLS_ENABLED=memory,session,capability
24
- # MIADI_TOOLS_DISABLED=ai,workflow
25
- # MIADI_TOOLS_DEFAULT_ENABLED=true
26
-
27
- # Optional: CORS Configuration
28
- # CORS_ORIGINS=https://claude.ai,https://app.claude.ai
package/ARCHITECTURE.md DELETED
@@ -1,290 +0,0 @@
1
- # 🧠 Miadi MCP Server - Architecture Documentation
2
-
3
- **Generated**: 2025-07-30
4
- **Status**: ✅ **WORKING** - Complete implementation with 26 tools
5
-
6
- ## 🏗️ Core Architecture Overview
7
-
8
- ### Bridge Pattern Implementation
9
- ```
10
- Claude → MCP Tool Calls → MCP Server → HTTP API → Miadi Agent System
11
- ← Tool Results ← ← ←
12
- ```
13
-
14
- ### Key Components
15
-
16
- #### 1. **Main Server** (`src/index.ts`)
17
- - **MCP SDK Integration**: Uses `@modelcontextprotocol/sdk v1.17.0`
18
- - **StdioServerTransport**: Handles MCP protocol communication
19
- - **Tool Registration**: 26 tools registered with Zod schemas
20
- - **Environment Validation**: Validates `EH_TOKEN` and `EH_API_URL` on startup
21
-
22
- #### 2. **API Client** (`src/api-client.ts`)
23
- - **Axios HTTP Client**: Configured with Bearer token authentication
24
- - **Error Interceptors**: Transform HTTP errors to user-friendly messages
25
- - **Request/Response Mapping**: TypeScript interfaces for all API endpoints
26
- - **Timeout Handling**: 30-second timeout with proper error handling
27
-
28
- #### 3. **Tool Modules** (`src/tools/*.ts`)
29
- - **Memory Tools** (`memory-tools.ts`): Redis-based storage operations
30
- - **Session Tools** (`session-tools.ts`): Agent persona/mode management
31
- - **Capability Tools** (`capability-tools.ts`): Dynamic capability resolution
32
- - **AI Tools** (`ai-tools.ts`): OpenAI and generic AI integration
33
- - **Workflow Tools** (`workflow-tools.ts`): GitHub event handling
34
- - **Forge Tools** (`forge-tools.ts`): System state management
35
-
36
- #### 4. **Type System** (`src/types.ts`)
37
- - **OpenAPI Derived**: All interfaces from `openapi.yml` specification
38
- - **Request/Response Types**: Complete type safety for API communication
39
- - **Error Handling**: Structured error response types
40
-
41
- #### 5. **Utilities** (`src/utils.ts`)
42
- - **Error Handling**: `handleMCPError()` for consistent error responses
43
- - **Response Formatting**: `createMCPResponse()` for MCP protocol compliance
44
- - **Logging**: `logToolUsage()` for request tracking
45
- - **Environment**: `getEnvVar()` for configuration validation
46
-
47
- ## 🔧 Build System
48
-
49
- ### Dependencies
50
- ```json
51
- {
52
- "@modelcontextprotocol/sdk": "^1.17.0",
53
- "axios": "^1.6.0",
54
- "dotenv": "^16.3.0",
55
- "zod": "^3.22.0"
56
- }
57
- ```
58
-
59
- ### Build Process
60
- ```bash
61
- # Development build with esbuild
62
- npm run build
63
- # esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js --external:@modelcontextprotocol/sdk
64
- ```
65
-
66
- ### Environment Configuration
67
- ```bash
68
- EH_TOKEN="your_miadi_api_token"
69
- EH_API_URL="https://your-api-endpoint.com"
70
- ```
71
-
72
- ## 🛠️ Tool Registration Pattern
73
-
74
- ### Complete Tool Example
75
- ```typescript
76
- server.tool(
77
- 'miadi-store-memory',
78
- 'Store data in memory with TTL',
79
- {
80
- key: z.string().describe('The key to store the memory under'),
81
- value: z.string().describe('The value to store'),
82
- ttl: z.number().optional().describe('Time to live for the memory in seconds'),
83
- type: z.enum(['string', 'hash', 'list']).optional().describe('Type of memory to store'),
84
- },
85
- async (args: any) => {
86
- logToolUsage('miadi-store-memory', args);
87
- const { key, value, ttl, type } = args;
88
- const result = await memoryTools.storeMemory(key, value, ttl, type);
89
- return createMCPResponse(result, 'miadi-store-memory');
90
- }
91
- );
92
- ```
93
-
94
- ### Tool Categories
95
-
96
- #### Memory Operations (9 tools)
97
- - `miadi-get-memory` - Retrieve memory data from Redis
98
- - `miadi-store-memory` - Store data with TTL (✅ Complete Zod schema)
99
- - `miadi-update-memory-ttl` - Update memory TTL
100
- - `miadi-get-memory-meta` - Get memory metadata
101
- - `miadi-scan-keys` - Scan Redis keys (✅ Complete Zod schema)
102
- - `miadi-gather-memory-values` - Gather multiple memory values
103
- - `miadi-collect-memory` - Collect specific keys
104
- - `miadi-view-key-content` - View individual key content
105
- - `miadi-search-cluster` - Search cluster for keys
106
-
107
- #### Session Management (6 tools)
108
- - `miadi-start-session` - Start new agent session (✅ Complete Zod schema)
109
- - `miadi-get-current-session` - Get current session details
110
- - `miadi-switch-mode` - Switch mode in existing session
111
- - `miadi-switch-persona` - Switch persona in session
112
- - `miadi-end-session` - End active session
113
- - `miadi-list-sessions` - List active sessions
114
-
115
- #### Capability Resolution (3 tools)
116
- - `miadi-resolve-capabilities` - Resolve capabilities for persona/mode
117
- - `miadi-get-agent-info` - Get comprehensive agent system info
118
- - `miadi-detect-cues` - Detect mode/persona switch cues from text
119
-
120
- #### AI Integration (2 tools)
121
- - `miadi-openai-request` - Make OpenAI API requests
122
- - `miadi-ai-request` - Make generic AI requests
123
-
124
- #### Workflow Management (3 tools)
125
- - `miadi-register-agent` - Register agent for GitHub events
126
- - `miadi-get-agent-events` - Check for agent events
127
- - `miadi-get-workflow-howto` - Get workflow setup guides
128
-
129
- #### Forge State (3 tools)
130
- - `miadi-get-forge-state` - Get current forge state
131
- - `miadi-update-forge-state` - Update forge state
132
- - `miadi-get-glyph-map` - Get glyph map information
133
-
134
- ## 🔄 Error Handling Architecture
135
-
136
- ### Multi-layered Approach
137
- 1. **Axios Interceptors**: Transform HTTP errors to consistent format
138
- 2. **Tool-level Wrapping**: Catch exceptions and provide user-friendly messages
139
- 3. **MCP Response Formatting**: Standardized success/error responses
140
- 4. **Comprehensive Logging**: Request/response logging with `logToolUsage()`
141
-
142
- ### Error Flow
143
- ```
144
- API Error → Axios Interceptor → Tool Error Handler → MCP Error Response → Claude
145
- ```
146
-
147
- ### Error Response Format
148
- ```typescript
149
- {
150
- content: [
151
- {
152
- type: "text",
153
- text: "Error message with context"
154
- }
155
- ]
156
- }
157
- ```
158
-
159
- ## 🧪 Testing Strategy
160
-
161
- ### Test Categories
162
- - **Connectivity**: API reachability and authentication
163
- - **Tool Discovery**: MCP tool registration and schemas
164
- - **Memory Operations**: Redis-based storage and retrieval
165
- - **Session Management**: Agent persona/mode workflows
166
- - **Agent Capabilities**: Capability resolution and cue detection
167
-
168
- ### Test Results (2025-07-30)
169
- - ✅ **Server Startup**: Clean startup without errors
170
- - ✅ **Tool Registration**: All 26 tools successfully registered
171
- - ✅ **MCP Protocol**: Proper initialization and tool call handling
172
- - ✅ **API Integration**: Successfully communicates with Miadi API endpoints
173
- - ⚠️ **Zod Schemas**: 7 complete, 19 with TODO schemas
174
- - ⚠️ **Parameter Validation**: Some validation tests need improvement
175
-
176
- ## 🚀 Deployment Configuration
177
-
178
- ### Claude Desktop Integration
179
- ```json
180
- {
181
- "mcpServers": {
182
- "miadi": {
183
- "command": "node",
184
- "args": ["/absolute/path/to/dist/index.js"],
185
- "env": {
186
- "EH_TOKEN": "your_token_here",
187
- "EH_API_URL": "https://your-api-endpoint.com"
188
- }
189
- }
190
- }
191
- }
192
- ```
193
-
194
- ### Production Deployment
195
- 1. **Build**: `npm run build`
196
- 2. **Environment**: Set `EH_TOKEN` and `EH_API_URL`
197
- 3. **Start**: `npm start`
198
- 4. **Monitor**: Check logs for tool usage and errors
199
-
200
- ## 📊 Performance Characteristics
201
-
202
- ### Build Output
203
- - **Size**: 576.0kb (esbuild bundle)
204
- - **Dependencies**: External MCP SDK dependency
205
- - **Startup Time**: ~300ms build, instant server start
206
-
207
- ### API Performance
208
- - **Timeout**: 30 seconds per request
209
- - **Rate Limiting**: Built-in protection against API abuse
210
- - **Error Recovery**: Automatic retry logic for transient failures
211
-
212
- ## 🔍 Critical Implementation Details
213
-
214
- ### Zod Schema Completeness
215
- **CRITICAL**: All MCP tools must have complete Zod parameter schemas. Incomplete schemas (marked with `// TODO: Define Zod schema`) will cause MCP protocol failures.
216
-
217
- ### MCP Response Format
218
- All tools must return responses in the correct MCP format:
219
- ```typescript
220
- {
221
- content: [
222
- {
223
- type: "text",
224
- text: "Tool result or error message"
225
- }
226
- ]
227
- }
228
- ```
229
-
230
- ### Environment Validation
231
- Server exits on startup if required environment variables are missing:
232
- - `EH_TOKEN`: Bearer authentication token
233
- - `EH_API_URL`: Base URL for Miadi API
234
-
235
- ### Type Safety
236
- Complete TypeScript typing throughout with interfaces derived from OpenAPI specification.
237
-
238
- ## 🎯 Recreation Checklist
239
-
240
- To recreate this MCP server:
241
-
242
- 1. **Setup Project Structure**
243
- - Create `src/` directory with tool modules
244
- - Configure `package.json` with dependencies
245
- - Set up `tsconfig.json` for TypeScript
246
-
247
- 2. **Implement Core Components**
248
- - `src/index.ts`: Main server with tool registration
249
- - `src/api-client.ts`: HTTP client with authentication
250
- - `src/types.ts`: TypeScript interfaces from OpenAPI
251
- - `src/utils.ts`: Error handling and utilities
252
-
253
- 3. **Create Tool Modules**
254
- - `src/tools/memory-tools.ts`: Redis operations
255
- - `src/tools/session-tools.ts`: Session management
256
- - `src/tools/capability-tools.ts`: Capability resolution
257
- - `src/tools/ai-tools.ts`: AI integration
258
- - `src/tools/workflow-tools.ts`: Workflow management
259
- - `src/tools/forge-tools.ts`: Forge operations
260
-
261
- 4. **Configure Build System**
262
- - Install esbuild for bundling
263
- - Configure external MCP SDK dependency
264
- - Set up development and production scripts
265
-
266
- 5. **Implement Testing**
267
- - Create test scripts for each tool category
268
- - Set up comprehensive test suite
269
- - Configure environment for testing
270
-
271
- 6. **Deploy and Configure**
272
- - Build production bundle
273
- - Configure Claude Desktop integration
274
- - Set up environment variables
275
-
276
- ## 🌟 Key Success Factors
277
-
278
- 1. **Complete Zod Schemas**: All 26 tools need proper parameter validation
279
- 2. **Error Handling**: Comprehensive error handling at all layers
280
- 3. **Type Safety**: Full TypeScript typing throughout
281
- 4. **Testing**: Complete test coverage for all tool categories
282
- 5. **Documentation**: Clear architecture and usage documentation
283
-
284
- ## 📈 Future Enhancements
285
-
286
- 1. **Complete Zod Schemas**: Finish parameter validation for all tools
287
- 2. **Enhanced Testing**: Add unit tests and integration tests
288
- 3. **Performance Optimization**: Add caching and connection pooling
289
- 4. **Monitoring**: Add health checks and metrics
290
- 5. **Documentation**: Add tool usage examples and API mapping
package/CLAUDE.md DELETED
@@ -1,269 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- This is a **Model Context Protocol (MCP) server** that acts as a bridge between Claude and the **Miadi Three-Pathway Agent System API**. It exposes 26 MCP tools covering memory operations, session management, capability resolution, AI integration, workflow management, and forge operations.
8
-
9
- **🚀 REBUILT USING OFFICIAL MCP SDK** - Now uses proper `StreamableHTTPServerTransport` and official patterns instead of custom HTTP implementation.
10
-
11
- **📚 For Future Development**: See [REMOTE_MCP_TRANSFORMATION_GUIDE.md](./REMOTE_MCP_TRANSFORMATION_GUIDE.md) for a comprehensive guide on transforming any standard MCP server into a Claude.ai remote connector.
12
-
13
- ## Core Architecture
14
-
15
- ### Bridge Pattern
16
- ```
17
- Claude.ai → MCP Tool Calls → Remote MCP Server → HTTP API → Miadi Agent System
18
- ← Tool Results ← ← ←
19
- ```
20
-
21
- ### Key Components
22
- - **Remote Server** (`src/index-remote.ts`): HTTP transport for Claude.ai remote connections
23
- - **Local Server** (`src/index.ts`): Standard MCP server for local connections
24
- - **API Client** (`src/api-client.ts`): HTTP client with Bearer token auth (`EH_TOKEN`)
25
- - **Tool Modules** (`src/tools/*.ts`): Grouped by functionality (memory, session, AI, etc.)
26
- - **Type System** (`src/types.ts`): TypeScript interfaces derived from OpenAPI spec
27
-
28
- ### Critical Configuration
29
- The server requires these environment variables and will exit on startup if missing:
30
- - `EH_TOKEN`: Bearer authentication token for Miadi API
31
- - `EH_API_URL`: Base URL for the Miadi API endpoint
32
-
33
- ## Development Commands
34
-
35
- ```bash
36
- # Build the remote server (for Claude.ai HTTP connections)
37
- npm run build:remote
38
-
39
- # Build the local server (standard MCP)
40
- npm run build
41
-
42
- # Development mode with auto-reload
43
- npm run dev:remote # Remote server development
44
- npm run dev # Local server development
45
-
46
- # Production start (requires build first)
47
- npm run start:remote # Remote server for Claude.ai
48
- npm run start # Local server for MCP clients
49
-
50
- # Start with ngrok tunnel for Claude.ai
51
- ./scripts/start-remote.sh
52
-
53
- # Run comprehensive test suite
54
- ./tests/run-all-tests.sh
55
-
56
- # Quick validation test
57
- ./tests/quick-test.sh
58
-
59
- # Test specific categories
60
- ./tests/test-connectivity.sh # API connection and auth
61
- ./tests/test-memory-operations.sh # Memory tool testing
62
- ./tests/test-session-management.sh # Session workflow testing
63
- ```
64
-
65
- ## Tool Development Pattern
66
-
67
- ### Adding New Tools
68
- 1. **Define TypeScript interfaces** in `src/types.ts` (follow OpenAPI spec)
69
- 2. **Implement API client method** in `src/api-client.ts`
70
- 3. **Create tool function** in appropriate `src/tools/*.ts` file
71
- 4. **Register with Zod schema** in `src/index.ts`
72
-
73
- ### Tool Registration Format
74
- ```typescript
75
- server.tool(
76
- 'tool-name',
77
- 'Tool description',
78
- {
79
- // Complete Zod schema - incomplete schemas cause MCP failures
80
- param: z.string().describe('Parameter description'),
81
- optional: z.number().optional().describe('Optional parameter')
82
- },
83
- async (args: any) => {
84
- logToolUsage('tool-name', args);
85
- const result = await toolModule.toolFunction(args.param, args.optional);
86
- return createMCPResponse(result, 'tool-name');
87
- }
88
- );
89
- ```
90
-
91
- ## Error Handling Architecture
92
-
93
- ### Multi-layered Approach
94
- 1. **Axios Interceptors**: Transform HTTP errors to consistent format
95
- 2. **Tool-level Wrapping**: Catch exceptions and provide user-friendly messages
96
- 3. **MCP Response Formatting**: Standardized success/error responses
97
- 4. **Comprehensive Logging**: Request/response logging with `logToolUsage()`
98
-
99
- ### Error Flow
100
- ```
101
- API Error → Axios Interceptor → Tool Error Handler → MCP Error Response → Claude
102
- ```
103
-
104
- ## Testing Strategy
105
-
106
- ### Test Categories
107
- - **Connectivity**: API reachability and authentication
108
- - **Tool Discovery**: MCP tool registration and schemas
109
- - **Memory Operations**: Redis-based storage and retrieval
110
- - **Session Management**: Agent persona/mode workflows
111
- - **Agent Capabilities**: Capability resolution and cue detection
112
-
113
- ### Testing Notes
114
- - Tests use real API endpoints (not mocked)
115
- - Environment variables must be configured for tests to pass
116
- - Each test category can be run independently
117
-
118
- ## Critical Development Notes
119
-
120
- ### Zod Schema Completeness
121
- **CRITICAL**: All MCP tools must have complete Zod parameter schemas. Incomplete schemas (marked with `// TODO: Define Zod schema`) will cause MCP protocol failures and prevent tool invocation.
122
-
123
- ### Debug Output Interference
124
- Remove console.error debug statements from production code - they can interfere with MCP JSON-RPC protocol communication.
125
-
126
- ### Type Safety
127
- The codebase maintains strict TypeScript typing throughout. All API interfaces in `src/types.ts` are derived from the OpenAPI specification (`openapi.yml`).
128
-
129
- ### Memory Operation Patterns
130
- Memory tools support Redis data types with automatic type detection to prevent WRONGTYPE errors. The API client handles type conversion transparently.
131
-
132
- ## Current Status
133
-
134
- ✅ **26 tools registered and functional using Official MCP SDK**
135
- ✅ **Complete rebuild using official MCP TypeScript SDK patterns**
136
- ✅ **StreamableHTTPServerTransport for proper HTTP handling**
137
- ✅ **Direct tool registration with server.registerTool()**
138
- ✅ **Intelligent parameter adapter with automatic parameter routing**
139
- ✅ **Clean implementation with smart error handling**
140
- ✅ **Ready for Claude.ai remote connector usage**
141
-
142
- **📁 Files**: Use `src/index-remote.ts` and `./scripts/start-remote.sh` for Claude.ai remote connections.
143
-
144
- ## Tool Categories
145
-
146
- ### Memory Operations (8 tools)
147
- Redis-based storage with pattern matching, TTL support, and type detection
148
-
149
- ### Session Management (6 tools)
150
- Agent persona/mode switching with context override support
151
-
152
- ### Capability Resolution (3 tools)
153
- Dynamic capability resolution and natural language cue detection
154
-
155
- ### AI Integration (2 tools)
156
- OpenAI and generic AI model request handling
157
-
158
- ### Workflow Management (3 tools)
159
- GitHub event handling and agent coordination
160
-
161
- ### Forge Operations (3 tools)
162
- System state management and glyph mapping operations
163
-
164
- ### Cluster Operations (2 tools)
165
- Distributed key search and content viewing
166
-
167
- ## Tool Selection System
168
-
169
- ✅ **Tool Selection Enhancement** - **IMPLEMENTED**
170
-
171
- **Status**: Production ready - Environment variable-based tool selection fully implemented
172
-
173
- ### Configuration Options
174
-
175
- The MCP server now supports flexible tool selection via environment variables:
176
-
177
- #### Category-based Selection
178
- ```bash
179
- # Enable entire categories (recommended for simplicity)
180
- MIADI_TOOLS_ENABLED="memory,session,ai"
181
-
182
- # Alternative: Disable specific categories
183
- MIADI_TOOLS_DISABLED="workflow,forge"
184
- ```
185
-
186
- #### Individual Tool Selection
187
- ```bash
188
- # Enable only specific tools (fine-grained control)
189
- MIADI_TOOLS_ENABLED="miadi-get-memory,miadi-store-memory,miadi-start-session"
190
- ```
191
-
192
- #### Hybrid Approach
193
- ```bash
194
- # Enable categories with specific exclusions
195
- MIADI_TOOLS_ENABLED="memory,session,-miadi-collect-memory,-miadi-view-key-content"
196
- ```
197
-
198
- #### Default Behavior Control
199
- ```bash
200
- # Control default enablement when no configuration is provided
201
- MIADI_TOOLS_DEFAULT_ENABLED="false" # Default is true
202
- ```
203
-
204
- ### Tool Categories
205
-
206
- - **memory** (9 tools): Redis operations, key scanning, cluster search
207
- - **session** (6 tools): Agent session management and switching
208
- - **capability** (3 tools): Capability resolution and agent info
209
- - **ai** (2 tools): OpenAI and generic AI model requests
210
- - **workflow** (3 tools): GitHub event handling and agent coordination
211
- - **forge** (3 tools): System state management and glyph operations
212
-
213
- ### Benefits Achieved
214
-
215
- ✅ **Performance**: 70-80% reduction in tool registration overhead for targeted deployments
216
- ✅ **Security**: Disable sensitive tools (AI, workflow) in restricted environments
217
- ✅ **Debugging**: Enable only relevant tools during development/testing
218
- ✅ **Deployment Flexibility**: Different tool sets for different deployment targets
219
- ✅ **Compliance**: Meet security/regulatory requirements by disabling specific capabilities
220
- ✅ **Backward Compatibility**: All tools enabled by default when no environment variables set
221
-
222
- ### Implementation Details
223
-
224
- - **ToolRegistry class** manages tool registration with environment-based selection
225
- - **Comprehensive validation** with warnings for invalid category/tool names
226
- - **Detailed logging** shows enabled/disabled tool counts and categories on startup
227
- - **Configuration summary** displays active configuration for debugging
228
-
229
- ### Usage Examples
230
-
231
- #### Development Environment
232
- ```bash
233
- # Only memory and session tools for lightweight development
234
- MIADI_TOOLS_ENABLED="memory,session"
235
- # Result: 15/26 tools enabled
236
- ```
237
-
238
- #### Production Environment
239
- ```bash
240
- # All tools except experimental/dangerous ones
241
- MIADI_TOOLS_DISABLED="workflow,forge"
242
- # Result: 18/26 tools enabled
243
- ```
244
-
245
- #### Testing Environment
246
- ```bash
247
- # Only specific tools needed for tests
248
- MIADI_TOOLS_ENABLED="miadi-get-memory,miadi-store-memory,miadi-start-session"
249
- # Result: 3/26 tools enabled
250
- ```
251
-
252
- #### Security-Constrained Environment
253
- ```bash
254
- # No AI integration or workflow tools
255
- MIADI_TOOLS_DISABLED="ai,workflow"
256
- # Result: 21/26 tools enabled
257
- ```
258
-
259
- ## 📚 Documentation & Guides
260
-
261
- ### Transformation Guide
262
- **[REMOTE_MCP_TRANSFORMATION_GUIDE.md](./REMOTE_MCP_TRANSFORMATION_GUIDE.md)** - Complete guide for transforming any standard MCP server into a Claude.ai remote connector using official SDK patterns.
263
-
264
- **Key Resources**:
265
- - [MCP_LEARNING_NOTES.md](./MCP_LEARNING_NOTES.md) - Analysis of official MCP patterns vs custom implementations
266
- - [MCP_REBUILD_PLAN.md](./MCP_REBUILD_PLAN.md) - Step-by-step rebuild plan using official SDK
267
-
268
- ### Success Story
269
- This project was successfully transformed from a 1,600+ line custom HTTP implementation to a 150-line official SDK implementation with 100% functionality preserved. The transformation guide captures this entire process for reuse by other developers.