@ema.co/mcp-toolkit 1.5.2 → 1.6.0

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.

Potentially problematic release.


This version of @ema.co/mcp-toolkit might be problematic. Click here for more details.

@@ -1,427 +1,215 @@
1
- # MCP Tool Consolidation Proposal
2
-
3
- > Consolidate 45 tools into 9 core commands following Unix CLI patterns.
4
-
5
- ## Status: Implementation Complete
6
-
7
- Files created:
8
- - `src/mcp/tools-consolidated.ts` - New tool definitions
9
- - `src/mcp/handlers-consolidated.ts` - New handlers with mode-based dispatch
10
-
11
- ## Design Principles
12
-
13
- 1. **Consistent terminology**: Use "persona" everywhere (not "ai_employee")
14
- 2. **Get/List as flags**: `persona("id")` vs `persona(all=True)`
15
- 3. **Related functions as modes**: `workflow(mode="analyze")` includes detect, validate, suggest
16
- 4. **Flags over separate tools**: `template(type="voice")` not `get_voice_template()`
17
-
18
- ---
19
-
20
- ## Proposed Tool Structure
21
-
22
- ### 1. `persona` - AI Employee Management
23
-
24
- **Replaces:** `find_personas`, `get_persona`, `create_ai_employee`, `update_ai_employee`, `compare_ai_employees`
1
+ # IMPLEMENTED: Consolidate `persona` and `workflow` Tools
2
+
3
+ > **Status**: Implemented. The `persona` tool now handles everything. `workflow` is deprecated.
4
+
5
+ ## The Problem
6
+
7
+ Current tool separation is confusing:
8
+
9
+ ```mermaid
10
+ graph TD
11
+ subgraph "Current: Confusing Separation"
12
+ USER[User: "Create an AI Employee"]
13
+
14
+ USER --> PERSONA[persona tool]
15
+ USER --> WORKFLOW[workflow tool]
16
+
17
+ PERSONA --> |"mode=create"| P_CREATE["Creates empty shell<br/>(no workflow = FAILS)"]
18
+ PERSONA --> |"mode=get"| P_GET[Get metadata]
19
+ PERSONA --> |"mode=update"| P_UPDATE[Update metadata only]
20
+
21
+ WORKFLOW --> |"input + type"| W_CREATE["Creates full AI Employee<br/>(config + workflow)"]
22
+ WORKFLOW --> |"persona_id + input"| W_MODIFY[Modify existing]
23
+ WORKFLOW --> |"persona_id"| W_ANALYZE[Analyze]
24
+
25
+ P_CREATE -.->|"⚠️ Useless without workflow"| BROKEN[Broken Persona]
26
+ W_CREATE -->|"✅ Actually works"| SUCCESS[Working AI Employee]
27
+ end
28
+ ```
29
+
30
+ **Problems:**
31
+ 1. `persona(mode="create")` creates a broken persona (no workflow)
32
+ 2. `workflow()` actually creates personas, but it's called "workflow"
33
+ 3. User has to know "use workflow for create, persona for get" - confusing!
34
+ 4. Tool descriptions have to warn "don't use this for X, use that instead"
35
+
36
+ ## The Reality
37
+
38
+ An AI Employee is ONE thing with two aspects:
39
+
40
+ ```mermaid
41
+ graph TD
42
+ subgraph "Reality: AI Employee is ONE Entity"
43
+ AIE[AI Employee / Persona]
44
+
45
+ AIE --> CONFIG[Proto Config<br/>- Voice settings<br/>- Welcome message<br/>- Widgets]
46
+ AIE --> WF[Workflow<br/>- Trigger<br/>- Nodes/Actions<br/>- Connections]
47
+
48
+ CONFIG -.->|"Inseparable"| WF
49
+ end
50
+ ```
51
+
52
+ ## Proposed Solution: Single `persona` Tool
53
+
54
+ Consolidate everything into ONE tool called `persona`:
55
+
56
+ ```mermaid
57
+ graph TD
58
+ subgraph "Proposed: Single persona Tool"
59
+ USER[User: "Create an AI Employee"]
60
+
61
+ USER --> PERSONA[persona tool]
62
+
63
+ PERSONA --> |"input + type + name"| CREATE["CREATE<br/>Full AI Employee"]
64
+ PERSONA --> |"id + input"| MODIFY["MODIFY<br/>Change workflow"]
65
+ PERSONA --> |"id"| GET["GET/ANALYZE<br/>Fetch & analyze"]
66
+ PERSONA --> |"id + optimize"| OPTIMIZE["OPTIMIZE<br/>Auto-fix issues"]
67
+ PERSONA --> |"all=true"| LIST["LIST<br/>Search personas"]
68
+
69
+ CREATE --> SUCCESS[Working AI Employee]
70
+ MODIFY --> SUCCESS
71
+ GET --> INFO[Persona + Analysis]
72
+ OPTIMIZE --> SUCCESS
73
+ LIST --> RESULTS[Search Results]
74
+ end
75
+ ```
76
+
77
+ ## New `persona` Tool Schema
25
78
 
26
79
  ```typescript
27
- interface PersonaArgs {
28
- // Identifier (optional - if omitted with all=true, lists all)
29
- id?: string; // ID or exact name
30
-
31
- // Mode
32
- mode?: "get" | "create" | "update" | "delete" | "compare" | "sync";
33
-
34
- // List/Search flags
35
- all?: boolean;
36
- query?: string;
37
- status?: "active" | "inactive" | "draft";
38
- trigger_type?: "voice" | "chat" | "dashboard";
39
- limit?: number;
80
+ persona({
81
+ // === IDENTITY ===
82
+ id: string, // Get/modify existing (UUID or name)
40
83
 
41
- // Get flags
42
- include_workflow?: boolean;
43
- include_fingerprint?: boolean;
84
+ // === CREATE NEW ===
85
+ input: string, // Natural language description
86
+ type: "voice" | "chat" | "dashboard",
87
+ name: string,
88
+ description: string,
44
89
 
45
- // Create/Update flags
46
- name?: string;
47
- description?: string;
48
- template_id?: string;
49
- source_persona_id?: string;
90
+ // === OPERATIONS ===
91
+ optimize: boolean, // Auto-fix workflow issues
92
+ analyze: boolean, // Return detailed analysis
93
+ preview: boolean, // Default true - preview before deploy
50
94
 
51
- // Compare/Sync flags
52
- compare_to?: string;
53
- target_env?: string;
54
- dry_run?: boolean;
95
+ // === LIST/SEARCH ===
96
+ all: boolean,
97
+ query: string,
98
+ status: string,
55
99
 
56
- // Environment
57
- env?: string;
58
- }
100
+ // === VERSION MANAGEMENT ===
101
+ mode: "version_list" | "version_get" | "version_restore" | ...,
102
+ })
59
103
  ```
60
104
 
61
- **Usage Examples:**
62
- ```bash
63
- # Get single
64
- persona("IT Support Bot")
65
- persona("abc-123", include_workflow=True)
105
+ ## Usage Examples
66
106
 
67
- # List/Search
68
- persona(all=True)
69
- persona(query="Support", status="active")
107
+ ### Create New AI Employee (ONE call)
70
108
 
71
- # Create
72
- persona(mode="create", name="New Bot", template_id="voice")
73
-
74
- # Update
75
- persona("abc-123", mode="update", name="Renamed")
76
-
77
- # Compare
78
- persona("abc-123", mode="compare", compare_to="def-456")
79
-
80
- # Sync
81
- persona("abc-123", mode="sync", target_env="dev", dry_run=True)
82
- ```
83
-
84
- ---
85
-
86
- ### 2. `workflow` - Workflow Generation & Analysis
87
-
88
- **Replaces:** `workflow`, `deploy_workflow`, `analyze_workflow`, `detect_workflow_issues`, `validate_workflow_connections`, `suggest_workflow_fixes`, `get_workflow_metrics`, `compare_workflow_versions`, `compile_workflow`
89
-
90
- ```typescript
91
- interface WorkflowArgs {
92
- // Input (one of these)
93
- input?: string | object; // Natural language or spec
94
- persona_id?: string; // For existing workflow operations
95
- workflow_def?: object; // For direct analysis
96
-
97
- // Mode
98
- mode?: "generate" | "analyze" | "deploy" | "compare" | "compile";
99
-
100
- // Generate flags
101
- persona_type?: "voice" | "chat" | "dashboard";
102
- use_autobuilder?: boolean;
103
-
104
- // Analyze flags (what to include in analysis)
105
- include?: ("issues" | "connections" | "fixes" | "metrics")[];
106
- // Default: all of them
107
-
108
- // Deploy flags
109
- auto_fix?: boolean;
110
- validate_first?: boolean;
111
-
112
- // Compare flags
113
- compare_to?: string; // Another persona_id
114
-
115
- // Environment
116
- env?: string;
117
- }
118
109
  ```
119
-
120
- **Usage Examples:**
121
- ```bash
122
- # Generate
123
- workflow("IT helpdesk with KB search and tickets")
124
- workflow(input={intents: [...]}, persona_type="voice")
125
-
126
- # Analyze (unified - returns issues, connections, fixes, metrics)
127
- workflow(persona_id="abc-123", mode="analyze")
128
-
129
- # Analyze with specific includes
130
- workflow(persona_id="abc-123", mode="analyze", include=["issues", "metrics"])
131
-
132
- # Analyze from JSON (not deployed)
133
- workflow(workflow_def={...}, mode="analyze")
134
-
135
- # Deploy
136
- workflow(persona_id="abc-123", mode="deploy", workflow_def={...}, auto_fix=True)
137
-
138
- # Compare versions
139
- workflow(persona_id="abc-123", mode="compare", compare_to="def-456")
140
-
141
- # Compile spec to workflow_def
142
- workflow(input={nodes: [...]}, mode="compile")
110
+ persona(
111
+ input="Voice AI SDR: qualifies leads, identifies use-case, sends follow-up email",
112
+ type="voice",
113
+ name="Sales SDR",
114
+ preview=false
115
+ )
143
116
  ```
144
117
 
145
- ---
118
+ ### Modify Existing
146
119
 
147
- ### 3. `action` - Workflow Actions/Agents
148
-
149
- **Replaces:** `find_workflow_actions`, `get_workflow_action`, `list_auto_builder_agents`, `get_auto_builder_agent`, `suggest_agents_for_use_case`
150
-
151
- ```typescript
152
- interface ActionArgs {
153
- // Identifier (optional)
154
- id?: string; // Action ID or name
155
-
156
- // List/Search flags
157
- all?: boolean;
158
- category?: string;
159
- query?: string;
160
- persona_id?: string; // Actions in this workflow
161
- enabled?: boolean;
162
-
163
- // Suggestion mode
164
- suggest_for?: string; // Use case description
165
-
166
- // Include flags
167
- include_docs?: boolean; // Include full documentation
168
-
169
- // Environment
170
- env?: string;
171
- }
172
120
  ```
121
+ // Analyze first
122
+ persona(id="abc-123")
173
123
 
174
- **Usage Examples:**
175
- ```bash
176
- # Get single
177
- action("chat_categorizer")
178
- action("abc-123-uuid")
179
- action("chat_categorizer", include_docs=True)
180
-
181
- # List/Search
182
- action(all=True)
183
- action(category="routing")
184
- action(persona_id="abc-123") # Actions in workflow
185
- action(query="search")
186
-
187
- # Suggest for use case
188
- action(suggest_for="IT helpdesk with ServiceNow")
124
+ // Modify
125
+ persona(id="abc-123", input="add HITL before email", preview=false)
189
126
  ```
190
127
 
191
- ---
192
-
193
- ### 4. `template` - Templates & Patterns
194
-
195
- **Replaces:** `get_workflow_pattern`, `list_workflow_patterns`, `get_widget_reference`, `get_voice_persona_template`, `list_ai_employee_templates`
128
+ ### List/Search
196
129
 
197
- ```typescript
198
- interface TemplateArgs {
199
- // What to get
200
- type?: "voice" | "chat" | "dashboard"; // Persona config template
201
- pattern?: string; // Workflow pattern name
202
- widgets?: "voice" | "chat" | "dashboard"; // Widget reference
203
-
204
- // List flags
205
- all?: boolean;
206
- patterns?: boolean; // List workflow patterns
207
-
208
- // Environment
209
- env?: string;
210
- }
211
130
  ```
212
-
213
- **Usage Examples:**
214
- ```bash
215
- # Persona config templates
216
- template(type="voice")
217
- template(type="chat")
218
-
219
- # Workflow patterns
220
- template(pattern="intent-routing")
221
- template(patterns=True) # List all patterns
222
- template(patterns=True, type="voice") # Filter by persona type
223
-
224
- # Widget reference
225
- template(widgets="voice")
226
-
227
- # List all persona templates
228
- template(all=True)
131
+ persona(all=true)
132
+ persona(query="support", status="active")
229
133
  ```
230
134
 
231
- ---
232
-
233
- ### 5. `knowledge` - Data Sources & KB
135
+ ### Optimize
234
136
 
235
- **Replaces:** `upload_data_source`, `delete_data_source`, `list_data_sources`, `get_embedding_status`, `toggle_embedding`
236
-
237
- ```typescript
238
- interface KnowledgeArgs {
239
- persona_id: string;
240
-
241
- // Mode
242
- mode?: "list" | "upload" | "delete" | "status" | "toggle";
243
-
244
- // Upload flags
245
- file_path?: string;
246
- tags?: string;
247
-
248
- // Delete flags
249
- file_id?: string;
250
-
251
- // Toggle flags
252
- embedding_enabled?: boolean;
253
-
254
- // Environment
255
- env?: string;
256
- }
257
137
  ```
258
-
259
- **Usage Examples:**
260
- ```bash
261
- # List files
262
- knowledge(persona_id="abc-123", mode="list")
263
-
264
- # Upload
265
- knowledge(persona_id="abc-123", mode="upload", file_path="/path/to/file.pdf")
266
-
267
- # Delete
268
- knowledge(persona_id="abc-123", mode="delete", file_id="file-123")
269
-
270
- # Embedding status
271
- knowledge(persona_id="abc-123", mode="status")
272
-
273
- # Toggle embedding
274
- knowledge(persona_id="abc-123", mode="toggle", embedding_enabled=True)
138
+ persona(id="abc-123", optimize=true, preview=false)
275
139
  ```
276
140
 
277
- ---
141
+ ## What Happens to `workflow` Tool?
278
142
 
279
- ### 6. `reference` - Platform Knowledge
143
+ **Option A: Deprecate with alias**
144
+ - Keep `workflow` as an alias that routes to `persona`
145
+ - Show deprecation warning
146
+ - Remove in future version
280
147
 
281
- **Replaces:** `get_platform_concept`, `list_platform_concepts`, `get_common_mistakes`, `get_debug_checklist`, `get_workflow_execution_model`, `get_auto_builder_guidance`, `get_qualifying_questions`, `validate_workflow_prompt`, `check_type_compatibility`
148
+ **Option B: Remove immediately**
149
+ - Breaking change
150
+ - Cleaner, but disruptive
282
151
 
283
- ```typescript
284
- interface ReferenceArgs {
285
- // What to get (one of these)
286
- concept?: string; // Platform concept (e.g., "HITL", "Workflow")
287
- guidance?: string; // Topic guidance (e.g., "categorizer-routing")
288
- questions?: boolean; // Qualifying questions
289
- mistakes?: boolean; // Common mistakes
290
- checklist?: boolean; // Debug checklist
291
- execution?: boolean; // Workflow execution model
292
-
293
- // List flags
294
- concepts?: boolean; // List all concepts
295
-
296
- // Questions filter
297
- category?: string; // Filter questions by category
298
- required_only?: boolean;
299
-
300
- // Type compatibility check
301
- check_types?: { source: string; target: string };
302
-
303
- // Prompt validation
304
- validate_prompt?: string;
305
- }
306
- ```
307
-
308
- **Usage Examples:**
309
- ```bash
310
- # Concepts
311
- reference(concept="HITL")
312
- reference(concepts=True)
313
-
314
- # Guidance
315
- reference(guidance="categorizer-routing")
316
- reference(guidance="type-compatibility")
317
-
318
- # Questions
319
- reference(questions=True)
320
- reference(questions=True, category="Voice", required_only=True)
321
-
322
- # Debugging
323
- reference(mistakes=True)
324
- reference(checklist=True)
325
- reference(execution=True)
152
+ **Recommendation: Option A** - Deprecate gracefully
326
153
 
327
- # Validation
328
- reference(check_types={source: "CHAT_CONVERSATION", target: "TEXT_WITH_SOURCES"})
329
- reference(validate_prompt="Create a bot that...")
154
+ ```mermaid
155
+ graph LR
156
+ subgraph "Migration Path"
157
+ OLD[workflow tool] -->|"Alias + Warning"| NEW[persona tool]
158
+ OLD -->|"6 months"| REMOVED[Removed]
159
+ end
330
160
  ```
331
161
 
332
- ---
162
+ ## Benefits
333
163
 
334
- ### 7. `sync` - Environment Sync
164
+ 1. **One tool, one concept** - "persona" = AI Employee = everything
165
+ 2. **No confusion** - Don't have to explain "use workflow for X, persona for Y"
166
+ 3. **Simpler mental model** - User thinks "I want to do X with my AI Employee" → `persona`
167
+ 4. **Matches UI** - Ema UI calls them "AI Employees", we call the tool "persona"
335
168
 
336
- **Replaces:** `sync`, `sync_info`
169
+ ## Implementation Plan
337
170
 
338
- ```typescript
339
- interface SyncArgs {
340
- // What to sync
341
- id?: string; // Persona ID or name
342
-
343
- // Mode
344
- mode?: "run" | "status" | "config";
345
-
346
- // Sync flags
347
- target_env: string;
348
- source_env?: string;
349
- scope?: "one" | "all";
350
- dry_run?: boolean;
351
- include_status?: boolean;
352
-
353
- // Status flags
354
- list_synced?: boolean;
355
- master_env?: string;
356
- }
357
- ```
171
+ ### Phase 1: Add unified operations to `persona`
172
+ - Add `input`, `type`, `optimize` params to persona tool
173
+ - persona internally calls the same handlers as workflow
358
174
 
359
- **Usage Examples:**
360
- ```bash
361
- # Sync single
362
- sync(id="IT Support", target_env="dev")
363
- sync(id="abc-123", target_env="staging", dry_run=True)
175
+ ### Phase 2: Deprecate `workflow`
176
+ - workflow() returns result + deprecation warning
177
+ - Update all docs/rules to use persona
364
178
 
365
- # Sync all
366
- sync(target_env="dev", scope="all")
179
+ ### Phase 3: Remove `workflow` (v2.0)
180
+ - Breaking change, major version bump
367
181
 
368
- # Status
369
- sync(mode="status", id="abc-123")
370
- sync(mode="status", list_synced=True, env="dev")
182
+ ## Alternative: Rename to `employee`
371
183
 
372
- # Config
373
- sync(mode="config")
374
- ```
375
-
376
- ---
377
-
378
- ### 8. `env` - Environment Management
184
+ Instead of `persona`, use `employee` to match UI terminology:
379
185
 
380
- **Replaces:** `list_environments`
381
-
382
- ```typescript
383
- interface EnvArgs {
384
- all?: boolean; // List all environments
385
- }
386
186
  ```
387
-
388
- **Usage Examples:**
389
- ```bash
390
- env(all=True) # List available environments
187
+ employee(input="Voice AI for sales", type="voice", name="Sales SDR")
188
+ employee(id="abc-123", input="add HITL before email")
189
+ employee(id="abc-123", optimize=true)
391
190
  ```
392
191
 
393
- ---
394
-
395
- ## Summary: Before & After
396
-
397
- | Before (45+ tools) | After (8 tools) |
398
- |-------------------|-----------------|
399
- | `find_personas`, `get_persona`, `create_ai_employee`, `update_ai_employee`, `compare_ai_employees` | `persona` |
400
- | `workflow`, `deploy_workflow`, `analyze_workflow`, `detect_workflow_issues`, `validate_workflow_connections`, `suggest_workflow_fixes`, `get_workflow_metrics`, `compare_workflow_versions`, `compile_workflow` | `workflow` |
401
- | `find_workflow_actions`, `get_workflow_action`, `list_auto_builder_agents`, `get_auto_builder_agent`, `suggest_agents_for_use_case` | `action` |
402
- | `get_workflow_pattern`, `list_workflow_patterns`, `get_widget_reference`, `get_voice_persona_template`, `list_ai_employee_templates` | `template` |
403
- | `upload_data_source`, `delete_data_source`, `list_data_sources`, `get_embedding_status`, `toggle_embedding` | `knowledge` |
404
- | `get_platform_concept`, `list_platform_concepts`, `get_common_mistakes`, `get_debug_checklist`, `get_workflow_execution_model`, `get_auto_builder_guidance`, `get_qualifying_questions`, `validate_workflow_prompt`, `check_type_compatibility` | `reference` |
405
- | `sync`, `sync_info` | `sync` |
406
- | `list_environments` | `env` |
192
+ **Pros:**
193
+ - Matches "AI Employee" terminology in UI
194
+ - Fresh name, no baggage
407
195
 
408
- **Result: 45+ tools → 8 commands**
196
+ **Cons:**
197
+ - Breaking change for existing users
198
+ - "persona" is the API term
409
199
 
410
- ---
200
+ ## Decision Matrix
411
201
 
412
- ## Migration Strategy
202
+ | Approach | User Clarity | Breaking Change | Implementation Effort |
203
+ |----------|--------------|-----------------|----------------------|
204
+ | Keep separate (current) | ❌ Poor | None | None |
205
+ | Consolidate to `persona` | ✅ Good | Low (deprecation) | Medium |
206
+ | Rename to `employee` | ✅ Best | High | Medium |
413
207
 
414
- 1. **Phase 1**: Create new consolidated tools alongside existing
415
- 2. **Phase 2**: Mark old tools as deprecated with pointer to new
416
- 3. **Phase 3**: Remove deprecated tools after transition period
208
+ ## Recommendation
417
209
 
418
- ## Backward Compatibility
210
+ **Consolidate to `persona` with `workflow` as deprecated alias.**
419
211
 
420
- Old tool names can be aliases:
421
- ```typescript
422
- // In server.ts
423
- get_persona: (args) => persona({ ...args, mode: "get" }),
424
- find_personas: (args) => persona({ ...args, all: true }),
425
- analyze_workflow: (args) => workflow({ ...args, mode: "analyze" }),
426
- // etc.
427
- ```
212
+ This gives us:
213
+ - Clear mental model (one tool = one concept)
214
+ - Backward compatibility (workflow still works, just warns)
215
+ - Path to clean future (remove workflow in v2)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ema.co/mcp-toolkit",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "Ema AI Employee toolkit - MCP server, CLI, and SDK for managing AI Employees across environments",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,6 +43,7 @@
43
43
  "cli": "tsx src/cli/index.ts",
44
44
  "test": "vitest run --exclude 'test/integration/**'",
45
45
  "test:watch": "vitest --exclude 'test/integration/**'",
46
+ "test:coverage": "vitest run --coverage --exclude 'test/integration/**'",
46
47
  "test:integration": "EMA_TEST_INTEGRATION=true vitest run test/integration/",
47
48
  "test:all": "npm run test && npm run test:integration",
48
49
  "typecheck": "tsc --noEmit",
@@ -92,6 +93,7 @@
92
93
  "@types/js-yaml": "^4.0.9",
93
94
  "@types/node": "^22.10.2",
94
95
  "@types/node-cron": "^3.0.11",
96
+ "@vitest/coverage-v8": "^4.0.17",
95
97
  "husky": "^9.1.7",
96
98
  "openapi-typescript": "^7.0.0",
97
99
  "tsx": "^4.19.2",