@ema.co/mcp-toolkit 1.5.1 → 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.

@@ -4,64 +4,109 @@ This MCP server is intentionally designed for **LLM + agent ergonomics**:
4
4
 
5
5
  - **Few tools, consistent shapes**: a small set of noun-based tools with predictable `mode` / flag patterns
6
6
  - **Resources-first**: use `ema://...` resources for reference data/templates, then tools for actions
7
- - **Low ambiguity**: defaults are chosen to avoid which of 5 similar tools?” confusion
7
+ - **Low ambiguity**: defaults are chosen to avoid "which of 5 similar tools?" confusion
8
8
 
9
9
  ## Tool names in MCP clients
10
10
 
11
- The server defines **base tool names** like `persona`, `workflow`, `template`.
11
+ The server defines **base tool names** like `persona`, `template`.
12
12
 
13
- Some clients show a **prefixed name** (for example Cursor: `mcp_ema_workflow`). Always call **the tool name your client displays**; the semantics are the same.
13
+ Some clients show a **prefixed name** (for example Cursor: `mcp_ema_persona`). Always call **the tool name your client displays**; the semantics are the same.
14
14
 
15
- ## The tool set (9 tools)
15
+ ## The tool set (8 tools)
16
16
 
17
17
  | Tool | Purpose |
18
18
  |------|---------|
19
19
  | `env` | List available environments and which is default |
20
- | `persona` | AI Employee management (get/list/create/update/compare/templates) |
21
- | `workflow` | Generate/analyze/deploy/optimize/compare/compile workflows |
20
+ | `persona` | **UNIFIED**: Create/modify/analyze/optimize/list AI Employees |
22
21
  | `action` | Actions/agents lookup (API + embedded docs), plus recommendations |
23
- | `template` | Workflow patterns, widget references, qualifying questions |
22
+ | `template` | Qualifying questions, workflow patterns, widget references |
24
23
  | `knowledge` | Data sources + embedding (upload/list/delete/status/toggle) |
25
24
  | `reference` | Concepts + guidance + validation + common mistakes |
26
25
  | `sync` | Sync across environments (run/status/config) |
27
26
  | `demo` | Demo/RAG document utilities (template/consolidate/generate/validate) |
28
27
 
28
+ > **Note**: The `workflow` tool is **DEPRECATED**. Use `persona` instead - it handles everything.
29
+
30
+ ## ⚠️ THE KEY INSIGHT: ONE CALL
31
+
32
+ Creating an AI Employee should be **ONE `persona()` call**, not multiple calls.
33
+
34
+ ```typescript
35
+ persona(
36
+ input="Voice AI SDR: qualifies leads, identifies use-case, sends follow-up email",
37
+ type="voice",
38
+ name="Sales SDR",
39
+ preview=false
40
+ )
41
+ ```
42
+
43
+ **MCP handles internally:** template selection, config generation, widget formatting, API orchestration.
44
+
29
45
  ## Start-here flows (LLM-friendly)
30
46
 
31
47
  ### Create a new AI Employee (greenfield)
32
48
 
33
- 1. **Requirements**: `template(questions=true)` (and `template(questions=true, category="Voice")` for voice)
34
- 2. **Pick agents/pattern**: `action(suggest="<use case>")`
35
- 3. **Get the pattern**: `template(pattern="<pattern>")`
36
- 4. **Generate workflow** (preview by default):
49
+ 1. **Get qualifying questions from MCP**: `template(questions=true)`
50
+ 2. **Ask user those questions**
51
+ 3. **Create in ONE call**:
37
52
  ```typescript
38
- workflow(input="<requirements>", type="chat|voice|dashboard")
53
+ persona(
54
+ input="<everything from user answers>",
55
+ name="My AI Employee",
56
+ type="voice",
57
+ preview=false
58
+ )
39
59
  ```
40
- 5. **Create persona** (if needed): `persona(mode="create", name="...", type="chat|voice|dashboard")`
41
- 6. **Deploy** (preview=false):
42
- ```typescript
43
- workflow(input="<requirements>", persona_id="<id>", preview=false)
44
- ```
45
- 7. **Review**: `workflow(mode="analyze", persona_id="...")`
46
60
 
47
- ### Extend an existing AI Employee (brownfield)
61
+ ### Complex Workflows (email, HITL, multi-intent)
48
62
 
49
- **Combine multiple changes in one command!**
63
+ For complex workflows, MCP returns `status: "needs_llm_generation"` with a prompt you send to an LLM:
50
64
 
51
65
  ```typescript
52
- // Preview changes (safe default)
53
- workflow(mode="extend", persona_id="abc-123", input="add caller_type categorizer, add HITL before email")
66
+ // Step 1: Request creation
67
+ result = persona(
68
+ input="SDR that qualifies leads and sends follow-up emails",
69
+ type="voice",
70
+ name="Sales SDR",
71
+ preview=true
72
+ )
73
+
74
+ // If result.status === "needs_llm_generation":
75
+ // Step 2: Send result.llm_prompt to an LLM (Claude, GPT-4, etc.)
76
+ // Step 3: Deploy the LLM's workflow response
77
+ persona(
78
+ workflow_def=llm_response_json,
79
+ name="Sales SDR",
80
+ type="voice",
81
+ preview=false
82
+ )
83
+ ```
54
84
 
55
- // Deploy changes
56
- workflow(mode="extend", persona_id="abc-123", input="...", preview=false)
85
+ **Simple workflows** (basic Q&A, search + respond) deploy directly without this extra step.
86
+
87
+ ### Modify an existing AI Employee (brownfield)
88
+
89
+ ```typescript
90
+ // Optional: Understand what exists first
91
+ persona(id="abc-123")
92
+
93
+ // Modify in ONE call
94
+ persona(id="abc-123", input="add HITL before email, add compliance intent", preview=false)
57
95
  ```
58
96
 
59
- ### Review or debug an existing AI Employee
97
+ ### Analyze/Review an AI Employee
60
98
 
61
- 1. Fetch full workflow: `persona(id="<id-or-exact-name>", include_workflow=true)`
62
- 2. Analyze: `workflow(mode="analyze", persona_id="<persona_id>")`
63
- 3. Preview fixes: `workflow(mode="optimize", persona_id="<persona_id>")`
64
- 4. Apply fixes: `workflow(mode="optimize", persona_id="<persona_id>", preview=false)`
99
+ ```typescript
100
+ persona(id="abc-123") // Get with analysis
101
+ persona(id="abc-123", include_workflow=true) // Include full workflow
102
+ ```
103
+
104
+ ### Optimize (auto-fix issues)
105
+
106
+ ```typescript
107
+ persona(id="abc-123", optimize=true) // Preview fixes
108
+ persona(id="abc-123", optimize=true, preview=false) // Apply fixes
109
+ ```
65
110
 
66
111
  ### Upload / manage knowledge base documents
67
112
 
@@ -74,116 +119,96 @@ workflow(mode="extend", persona_id="abc-123", input="...", preview=false)
74
119
  - Run (single): `sync(id="My Bot", source="demo", target="dev", dry_run=true|false)`
75
120
  - Run (all tagged): `sync(target="dev", scope="all", dry_run=true|false)`
76
121
  - Status: `sync(mode="status", id="My Bot", env="dev")`
77
- - List all synced in env: `sync(mode="status", list_synced=true, env="dev")`
78
- - Config: `sync(mode="config")`
79
122
 
80
123
  ### Version / snapshot AI Employees
81
124
 
82
- Take snapshots before making changes, restore if something breaks.
83
-
84
125
  ```typescript
85
126
  // Before a risky change - create a snapshot
86
127
  persona(id="My Bot", mode="version_create", message="Before adding HITL")
87
128
 
88
129
  // Make changes...
89
- workflow(mode="extend", persona_id="abc", input="add HITL before email", preview=false)
130
+ persona(id="abc", input="add HITL before email", preview=false)
90
131
 
91
- // If something breaks - list versions and restore
132
+ // If something breaks - restore
92
133
  persona(id="My Bot", mode="version_list")
93
134
  persona(id="My Bot", mode="version_restore", version="v3")
94
135
  ```
95
136
 
96
- **Auto-snapshot on deploy:**
137
+ ## Tool reference (high-signal)
138
+
139
+ ### `persona` (UNIFIED - use for everything)
140
+
141
+ **Create new AI Employee:**
97
142
  ```typescript
98
- persona(id="My Bot", mode="version_policy", auto_on_deploy=true)
99
- // Now every deploy automatically creates a snapshot first
143
+ persona(input="<what it does>", type="voice", name="My Bot", preview=false)
100
144
  ```
101
145
 
102
- ### Demo data → RAG-ready Markdown → upload
146
+ **Modify existing:**
147
+ ```typescript
148
+ persona(id="abc", input="add HITL before email", preview=false)
149
+ ```
103
150
 
104
- 1. Get a template: `demo(mode="template", entity="customer")`
105
- 2. Consolidate a dataset: `demo(mode="consolidate", source="./data", output="./kb", entity="customer", primary="customers.json", joins=[...])`
106
- 3. Upload: `knowledge(persona_id="...", mode="upload", file="/full/path/to/kb/customer_*.md")`
151
+ **Analyze/Get:**
152
+ ```typescript
153
+ persona(id="abc")
154
+ persona(id="abc", include_workflow=true)
155
+ ```
107
156
 
108
- ## Tool reference (high-signal)
157
+ **Optimize:**
158
+ ```typescript
159
+ persona(id="abc", optimize=true, preview=false)
160
+ ```
109
161
 
110
- ### `persona`
111
-
112
- - **Get**: `persona(id="...", include_workflow=true)`
113
- - **List/search**: `persona(all=true)` / `persona(query="support", status="active")`
114
- - **Create**: `persona(mode="create", name="...", type="chat|voice|dashboard")`
115
- - **Update**: `persona(id="<id>", mode="update", name="...", description="...", enabled=true|false)`
116
- - **Compare**: `persona(id="<id>", mode="compare", compare_to="<id>", compare_env="dev")`
117
- - **Templates**: `persona(templates=true)`
118
- - **Version management**:
119
- ```typescript
120
- persona(id="abc", mode="version_create", message="Before major update") // Create snapshot
121
- persona(id="abc", mode="version_list") // List all versions
122
- persona(id="abc", mode="version_get", version="v3") // Get specific version
123
- persona(id="abc", mode="version_compare", v1="v2", v2="v3") // Compare versions
124
- persona(id="abc", mode="version_restore", version="v2") // Restore to version
125
- persona(id="abc", mode="version_policy", auto_on_deploy=true) // Auto-snapshot settings
126
- ```
127
-
128
- ### `workflow`
129
-
130
- All modification modes default to `preview=true` for safety. Use `preview=false` to deploy.
131
-
132
- - **Generate (greenfield)**: Create new workflow
133
- ```typescript
134
- workflow(input="IT helpdesk with KB search") // Preview
135
- workflow(input="...", persona_id="abc", preview=false) // Generate AND deploy
136
- ```
137
-
138
- - **Extend (brownfield)**: Modify existing workflow with natural language
139
- ```typescript
140
- workflow(mode="extend", persona_id="abc", input="add caller_type categorizer")
141
- workflow(mode="extend", persona_id="abc", input="add X, add Y, add Z") // Multiple changes!
142
- workflow(mode="extend", persona_id="abc", input="...", preview=false) // Extend AND deploy
143
- ```
144
-
145
- - **Optimize**: Fix issues in existing workflow
146
- ```typescript
147
- workflow(mode="optimize", persona_id="abc") // Preview fixes
148
- workflow(mode="optimize", persona_id="abc", preview=false) // Apply fixes
149
- ```
150
-
151
- - **Analyze** (always read-only):
152
- ```typescript
153
- workflow(mode="analyze", persona_id="abc")
154
- workflow(mode="analyze", workflow_def={...})
155
- workflow(mode="analyze", persona_id="abc", include=["issues", "fixes"])
156
- ```
157
-
158
- - **Compare** (always read-only):
159
- ```typescript
160
- workflow(mode="compare", persona_id="abc", compare_to="def")
161
- ```
162
-
163
- - **Compile** (returns workflow_def from explicit node spec):
164
- ```typescript
165
- workflow(mode="compile", name="...", description="...", nodes=[...])
166
- ```
162
+ **List/Search:**
163
+ ```typescript
164
+ persona(all=true)
165
+ persona(query="support", status="active")
166
+ ```
167
167
 
168
- ### `action`
168
+ **Compare:**
169
+ ```typescript
170
+ persona(id="abc", compare_to="def")
171
+ ```
169
172
 
170
- - **Get**: `action(id="chat_categorizer", include_docs=true)`
171
- - **List/search**: `action(all=true)` / `action(query="search")` / `action(category="routing")`
172
- - **Suggest**: `action(suggest="IT helpdesk that creates ServiceNow tickets")`
173
+ **Version management:**
174
+ ```typescript
175
+ persona(id="abc", mode="version_create", message="Before update")
176
+ persona(id="abc", mode="version_list")
177
+ persona(id="abc", mode="version_restore", version="v2")
178
+ persona(id="abc", mode="version_policy", auto_on_deploy=true)
179
+ ```
173
180
 
174
181
  ### `template`
175
182
 
176
- - **Patterns**: `template(patterns=true)` / `template(pattern="intent-routing")`
177
- - **Qualifying questions**: `template(questions=true)` / `template(questions=true, category="Voice", required_only=true)`
178
- - **Widget reference**: `template(widgets="voice")`
183
+ **Primary use - Get qualifying questions:**
184
+ ```typescript
185
+ template(questions=true) // All questions
186
+ template(questions=true, category="Voice") // Voice-specific
187
+ ```
188
+
189
+ **Reference (understand options):**
190
+ ```typescript
191
+ template(patterns=true)
192
+ template(pattern="intent-routing")
193
+ template(widgets="voice")
194
+ ```
195
+
196
+ ### `action`
197
+
198
+ ```typescript
199
+ action(id="chat_categorizer", include_docs=true) // Get specific
200
+ action(all=true) // List all
201
+ action(suggest="IT helpdesk with ServiceNow") // Get recommendations
202
+ ```
179
203
 
180
204
  ### `reference`
181
205
 
182
- - **Concept**: `reference(concept="HITL")`
183
- - **Guidance**: `reference(guidance="categorizer-routing")`
184
- - **Validate Auto Builder prompt**: `reference(validate_prompt="<prompt>")`
185
- - **Common mistakes**: `reference(mistakes=true)`
186
- - **Debug checklist**: `reference(checklist=true)`
206
+ ```typescript
207
+ reference(concept="HITL")
208
+ reference(guidance="categorizer-routing")
209
+ reference(mistakes=true)
210
+ reference(checklist=true)
211
+ ```
187
212
 
188
213
  ## Resources (read-first)
189
214
 
@@ -191,89 +216,39 @@ Start with:
191
216
 
192
217
  - `ema://index/all-resources` (index)
193
218
  - `ema://docs/readme` (toolkit overview)
194
- - `ema://docs/ema-user-guide` (platform concepts)
195
219
  - `ema://catalog/agents-summary` (quick agent overview)
196
- - `ema://catalog/templates` (persona templates from API - dynamic)
197
- - `ema://catalog/templates-summary` (template overview - dynamic)
198
- - `ema://catalog/patterns` (workflow patterns)
199
- - `ema://rules/input-sources` and `ema://rules/anti-patterns` (validation rules)
220
+ - `ema://catalog/templates` (persona templates - dynamic)
221
+ - `ema://rules/anti-patterns` (what NOT to do)
200
222
 
201
223
  ## Auto-Fix Capabilities
202
224
 
203
- The `workflow(mode="optimize")` can automatically fix common issues:
225
+ The `persona(id="...", optimize=true)` can automatically fix common issues:
204
226
 
205
227
  | Issue | Severity | Auto-Fix? | Action |
206
228
  |-------|----------|-----------|--------|
207
229
  | `orphan` | warning | ✅ | Removes unreachable nodes |
208
230
  | `dead_end` | critical | ✅ | Adds results mapping |
209
- | `missing_workflow_output` | critical | ✅ | Adds results mapping for response nodes |
210
- | `wrong_input_source` (email_to) | warning | ✅ | Adds `entity_extraction` node, wires to extracted `email_address` |
211
- | `wrong_input_source` (query) | warning | ✅ | Rewires from `chat_conversation` to `user_query` |
212
- | `missing_fallback` | critical | ✅ | Adds Fallback category to categorizer |
213
- | `type_mismatch` | critical | ✅ | Rewires to type-compatible source |
231
+ | `missing_workflow_output` | critical | ✅ | Adds results mapping |
232
+ | `wrong_input_source` (email_to) | warning | ✅ | Adds entity_extraction |
233
+ | `missing_fallback` | critical | ✅ | Adds Fallback category |
234
+ | `type_mismatch` | critical | ✅ | Rewires to compatible source |
214
235
  | `cycle` | critical | ❌ | Requires manual restructuring |
215
- | `incomplete_hitl` | critical | ❌ | Needs success/failure response node configuration |
216
- | `side_effect_without_hitl` | info | ℹ️ | Informational only - HITL is opt-in |
217
236
 
218
237
  ## HITL (Human-in-the-Loop) Policy
219
238
 
220
- **HITL is opt-in, not forced by default.** The MCP does NOT automatically add HITL for email or external actions.
221
-
222
- | Scenario | Default Behavior | How to Add HITL |
223
- |----------|-----------------|-----------------|
224
- | Send email | ❌ No HITL | Request explicitly: "add approval before sending" |
225
- | External API call | ❌ No HITL | Request explicitly: "require human approval" |
226
- | Create/update records | ❌ No HITL | Request explicitly in prompt |
227
-
228
- To add HITL after deployment: `workflow(persona_id="...", input="add human approval before email")`
229
-
230
-
231
- ## Brownfield Workflow Extension
232
-
233
- Extend existing workflows with new capabilities while preserving existing logic.
234
-
235
- ### Usage
236
-
237
- ```typescript
238
- // Add new nodes/intents
239
- workflow(persona_id="abc", input="add caller_type categorizer with Advisor and Client roles")
240
-
241
- // Add enum options to existing categorizer
242
- workflow(persona_id="abc", input="add Market Analysis intent to the categorizer")
243
-
244
- // Add custom wiring
245
- workflow(persona_id="abc", input="add send_email node connected to entity_extractor output")
246
-
247
- // Merge a complete workflow_def (extend mode - preserves existing)
248
- workflow(persona_id="abc", workflow_def={...}, merge_mode="extend")
249
-
250
- // Replace with a new workflow (destructive)
251
- workflow(persona_id="abc", workflow_def={...}, merge_mode="replace", force=true)
252
- ```
253
-
254
- ### Merge Modes
255
-
256
- | Mode | Behavior |
257
- |------|----------|
258
- | `extend` (default) | Add new nodes, preserve existing, merge enums |
259
- | `replace` | Replace nodes not in incoming (destructive) |
260
-
261
- ### Capabilities
262
-
263
- | Capability | Example |
264
- |------------|---------|
265
- | ✅ Add new nodes | `input="add password reset intent"` |
266
- | ✅ Add enum options | `input="add Advisor/Client to caller_type"` |
267
- | ✅ Add HITL gates | `input="add approval before sending emails"` |
268
- | ✅ Modify node wiring | `input="wire entity_extraction to email handler"` |
269
- | ✅ Preserve existing logic | Existing nodes/enums kept unless modified |
239
+ **HITL is opt-in, not forced by default.**
270
240
 
241
+ | Scenario | Default | How to Add HITL |
242
+ |----------|---------|-----------------|
243
+ | Send email | ❌ No HITL | `persona(id="...", input="add approval before sending")` |
244
+ | External API | ❌ No HITL | Request explicitly in input |
245
+ | Create records | ❌ No HITL | Request explicitly in input |
271
246
 
272
247
  ## Auto Builder Prompt Length Limits
273
248
 
274
- **⚠️ CRITICAL:** Auto Builder has strict prompt length limits. Long prompts (>2500 chars) cause timeouts.
249
+ **⚠️ CRITICAL:** Auto Builder has strict prompt length limits (~2500 chars).
275
250
 
276
- ### Good Prompt Format (Works)
251
+ ### Good Prompt Format
277
252
  ```text
278
253
  Voice AI for [use case]. Supports [capabilities].
279
254
 
@@ -285,33 +260,24 @@ Core Capabilities:
285
260
  Rules:
286
261
  • Rule 1
287
262
  • Rule 2
288
-
289
- Output: All responses return through WORKFLOW_OUTPUT.
290
263
  ```
291
264
 
292
265
  ### Bad Prompt Format (Times Out)
293
266
  - Narrative descriptions with multiple paragraphs
294
267
  - Example conversations embedded in prompt
295
- - Detailed step-by-step flows for each intent
296
268
  - Prompts > 2500 characters
297
269
 
298
- The MCP automatically condenses long prompts via `condensePromptForAutobuilder()`, but best practice is to provide concise prompts from the start.
299
-
300
- ## Workflow Generation Strategy
301
-
302
- | Approach | When to Use | Notes |
303
- |----------|-------------|-------|
304
- | **Local compilation** | Simple/medium workflows | `workflow(mode="compile", ...)` - reliable, fast |
305
- | **Auto Builder** | Complex/exploratory workflows | Requires concise prompts (<2500 chars) |
306
-
307
- Prefer local compilation for deterministic results. Use `use_autobuilder=false` flag when generating workflows.
270
+ ## Deprecated: `workflow` tool
308
271
 
309
- ## Legacy tools (migration only)
272
+ The `workflow` tool is **DEPRECATED**. It still works but routes to `persona`.
310
273
 
311
- Legacy tools are **disabled by default** to reduce duplicate semantics and tool confusion for LLMs.
312
-
313
- If you must enable them (temporary):
314
-
315
- - Set `EMA_ENABLE_LEGACY_TOOLS=true`
316
- - Prefer the consolidated tools for new usage
274
+ **Migration:**
275
+ ```typescript
276
+ // OLD (deprecated)
277
+ workflow(input="...", type="voice", name="Bot", preview=false)
278
+ workflow(persona_id="abc", input="add HITL")
317
279
 
280
+ // NEW (use this)
281
+ persona(input="...", type="voice", name="Bot", preview=false)
282
+ persona(id="abc", input="add HITL")
283
+ ```