@ema.co/mcp-toolkit 2026.1.24 → 2026.1.26-3

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.

Files changed (81) hide show
  1. package/README.md +10 -2
  2. package/dist/mcp/handlers/action/index.js +3 -18
  3. package/dist/mcp/handlers/data/index.js +385 -41
  4. package/dist/mcp/handlers/data/templates.js +107 -0
  5. package/dist/mcp/handlers/deprecation.js +50 -0
  6. package/dist/mcp/handlers/env/index.js +8 -4
  7. package/dist/mcp/handlers/knowledge/index.js +44 -237
  8. package/dist/mcp/handlers/persona/create.js +5 -11
  9. package/dist/mcp/handlers/persona/index.js +5 -1
  10. package/dist/mcp/handlers/persona/version.js +234 -0
  11. package/dist/mcp/handlers/reference/index.js +101 -1
  12. package/dist/mcp/handlers/sync/index.js +3 -18
  13. package/dist/mcp/handlers/template/index.js +75 -10
  14. package/dist/mcp/handlers/workflow/analyze.js +171 -0
  15. package/dist/mcp/handlers/workflow/compare.js +70 -0
  16. package/dist/mcp/handlers/workflow/compile.js +39 -0
  17. package/dist/mcp/handlers/workflow/deploy.js +73 -0
  18. package/dist/mcp/handlers/workflow/generate.js +350 -0
  19. package/dist/mcp/handlers/workflow/index.js +136 -0
  20. package/dist/mcp/handlers/workflow/modify.js +456 -0
  21. package/dist/mcp/handlers/workflow/optimize.js +136 -0
  22. package/dist/mcp/handlers/workflow/types.js +4 -0
  23. package/dist/mcp/handlers/workflow/utils.js +132 -0
  24. package/dist/mcp/handlers-consolidated.js +62 -2691
  25. package/dist/mcp/prompts.js +13 -14
  26. package/dist/mcp/resources.js +55 -54
  27. package/dist/mcp/server.js +93 -124
  28. package/dist/mcp/{tools-v2.js → tools.js} +1 -1
  29. package/dist/mcp/workflow-operations.js +2 -2
  30. package/dist/sdk/client-adapter.js +267 -32
  31. package/dist/sdk/client.js +31 -15
  32. package/dist/sdk/ema-client.js +183 -0
  33. package/dist/sdk/generated/template-fallbacks.js +123 -0
  34. package/dist/sdk/guidance.js +65 -11
  35. package/dist/sdk/index.js +3 -1
  36. package/dist/sdk/knowledge.js +16 -86
  37. package/dist/sdk/workflow-intent.js +27 -0
  38. package/dist/sdk/workflow-transformer.js +0 -342
  39. package/docs/DEBUG-ANALYSIS-unused-category-type-mismatch.md +481 -0
  40. package/docs/TODO-fix-analyzer-and-modify.md +182 -0
  41. package/package.json +9 -4
  42. package/dist/mcp/tools-consolidated.js +0 -866
  43. package/dist/mcp/tools-legacy.js +0 -736
  44. package/docs/CODEBASE-ANALYSIS-2026-01-23.md +0 -936
  45. package/docs/CODEBASE-ANALYSIS-PRIORITIZED.md +0 -774
  46. package/docs/api-contracts.md +0 -216
  47. package/docs/auto-builder-analysis.md +0 -271
  48. package/docs/blog/mcp-tool-design-lessons.md +0 -309
  49. package/docs/data-architecture.md +0 -166
  50. package/docs/ema-auto-builder-guide.html +0 -394
  51. package/docs/lessons-learned.md +0 -209
  52. package/docs/llm-native-workflow-design.md +0 -252
  53. package/docs/local-generation.md +0 -508
  54. package/docs/mcp-flow-diagram.md +0 -135
  55. package/docs/migration/action-composition-migration.md +0 -270
  56. package/docs/naming-conventions.md +0 -278
  57. package/docs/proposals/HANDOFF-tool-restructure.md +0 -526
  58. package/docs/proposals/action-composition.md +0 -490
  59. package/docs/proposals/explicit-method-restructure.md +0 -328
  60. package/docs/proposals/mcp-tool-restructure-2026-01.md +0 -366
  61. package/docs/proposals/self-contained-guidance.md +0 -427
  62. package/docs/proto-sdk-generation.md +0 -242
  63. package/docs/release-impact.md +0 -102
  64. package/docs/release-process.md +0 -157
  65. package/docs/staging.RULE.md +0 -142
  66. package/docs/test-persona-creation.md +0 -196
  67. package/docs/tool-consolidation-v2.md +0 -225
  68. package/docs/tool-response-standards.md +0 -256
  69. package/resources/docs/getting-started.md +0 -97
  70. package/resources/templates/auto-builder-rules.md +0 -224
  71. package/resources/templates/chat-ai/README.md +0 -119
  72. package/resources/templates/chat-ai/persona-config.json +0 -111
  73. package/resources/templates/dashboard-ai/README.md +0 -156
  74. package/resources/templates/dashboard-ai/persona-config.json +0 -180
  75. package/resources/templates/demo-scenarios/README.md +0 -63
  76. package/resources/templates/demo-scenarios/test-published-package.md +0 -116
  77. package/resources/templates/document-gen-ai/README.md +0 -132
  78. package/resources/templates/document-gen-ai/persona-config.json +0 -316
  79. package/resources/templates/voice-ai/README.md +0 -123
  80. package/resources/templates/voice-ai/persona-config.json +0 -74
  81. package/resources/templates/voice-ai/workflow-prompt.md +0 -121
@@ -1,225 +0,0 @@
1
- # MCP Tool Consolidation v2
2
-
3
- > **Status: IMPLEMENTED** (v2026.01.17)
4
-
5
- ## Overview
6
-
7
- Consolidate tools with cleaner separation of concerns.
8
-
9
- **Primary tools (use these):**
10
- - `persona` - AI Employee management
11
- - `data` - Persona data management
12
- - `reference` - All reference info (envs, actions, templates, patterns, concepts)
13
- - `sync` - Cross-environment sync
14
-
15
- **Legacy tools (still work, route to primary):**
16
- - `env`, `action`, `template`, `knowledge`, `demo`
17
-
18
- ## Final Tool Design
19
-
20
- ### 1. `persona` - Manage AI Employees
21
-
22
- ```typescript
23
- persona(
24
- id?: string, // get specific persona
25
- query?: string, // search by name
26
- all?: boolean, // list all
27
-
28
- // Create/Clone
29
- name?: string, // for create
30
- type?: "voice" | "chat" | "dashboard",
31
- input?: string, // natural language description
32
- clone_from?: string, // clone source persona ID
33
- clone_data?: boolean, // also clone files
34
- sanitize?: boolean, // sanitize PII during clone
35
-
36
- // Update
37
- enabled?: boolean, // enable/disable
38
-
39
- // Compare
40
- compare_to?: string, // compare two personas
41
-
42
- // Output control
43
- include_workflow?: boolean, // include workflow_def in response
44
- )
45
- ```
46
-
47
- **Examples:**
48
- ```
49
- persona(all=true) # list all
50
- persona(id="abc-123") # get specific
51
- persona(query="support") # search
52
- persona(name="My Bot", type="voice", input="...") # create
53
- persona(clone_from="abc", name="Clone", clone_data=true, sanitize=true)
54
- ```
55
-
56
- ---
57
-
58
- ### 2. `data` - Manage Persona Data
59
-
60
- ```typescript
61
- data(
62
- persona_id: string, // REQUIRED - data belongs to persona
63
- mode?: "list" | "get" | "upload" | "delete" | "sanitize", // default: list
64
- file_id?: string, // for get/delete specific
65
- include_results?: boolean, // for dashboard: show extracted values
66
- )
67
- ```
68
-
69
- **Examples:**
70
- ```
71
- data(persona_id="abc") # list files
72
- data(persona_id="abc", file_id="x") # get file details
73
- data(persona_id="abc", mode="upload") # upload (file from context)
74
- data(persona_id="abc", mode="delete", file_id="x")
75
- data(persona_id="abc", mode="sanitize") # sanitize all data
76
- data(persona_id="abc", include_results=true) # list with extraction results
77
- ```
78
-
79
- **For dashboard personas, file listing includes:**
80
- ```json
81
- {
82
- "files": [{
83
- "id": "file-123",
84
- "name": "contract.pdf",
85
- "processing": {
86
- "status": "success",
87
- "extracted": { "vendor": "Acme", "amount": "$50k" }
88
- }
89
- }]
90
- }
91
- ```
92
-
93
- ---
94
-
95
- ### 3. `workflow` - Workflow Operations
96
-
97
- ```typescript
98
- workflow(
99
- persona_id?: string, // target persona
100
-
101
- // Generate/Modify
102
- input?: string, // natural language description
103
-
104
- // Analyze
105
- analyze?: boolean, // analyze current workflow
106
- optimize?: boolean, // suggest optimizations
107
-
108
- // Deploy
109
- workflow_def?: object, // direct workflow deployment
110
- preview?: boolean, // preview without deploying (default: true)
111
- )
112
- ```
113
-
114
- **Examples:**
115
- ```
116
- workflow(persona_id="abc", input="Add email notification")
117
- workflow(persona_id="abc", analyze=true)
118
- workflow(persona_id="abc", optimize=true, preview=false)
119
- ```
120
-
121
- ---
122
-
123
- ### 4. `reference` - All Reference Information
124
-
125
- ```typescript
126
- reference(
127
- type?: "actions" | "templates" | "patterns" | "envs" | "concepts" | "guidance",
128
-
129
- // For actions
130
- action_id?: string, // get specific action
131
- query?: string, // search
132
- suggest?: string, // suggest actions for use case
133
-
134
- // For guidance
135
- topic?: string, // guidance topic
136
-
137
- // For concepts
138
- concept?: string, // specific concept
139
-
140
- // Validation helpers
141
- check_types?: { source: string, target: string },
142
- validate_prompt?: string,
143
- )
144
- ```
145
-
146
- **Examples:**
147
- ```
148
- reference(type="actions") # list all actions
149
- reference(type="actions", query="email") # search actions
150
- reference(type="actions", suggest="IT helpdesk")
151
- reference(action_id="send_email") # get specific action
152
- reference(type="templates") # list workflow templates
153
- reference(type="patterns") # list patterns
154
- reference(type="envs") # list environments
155
- reference(type="concepts") # list concepts
156
- reference(concept="HITL") # get specific concept
157
- reference(type="guidance", topic="categorizer-routing")
158
- ```
159
-
160
- ---
161
-
162
- ### 5. `sync` - Environment Sync
163
-
164
- ```typescript
165
- sync(
166
- id?: string, // persona ID or name
167
- target?: string, // target environment
168
- dry_run?: boolean, // simulate without changes
169
-
170
- // Status
171
- mode?: "run" | "status" | "config",
172
- list_synced?: boolean, // list all synced personas
173
- )
174
- ```
175
-
176
- **Examples:**
177
- ```
178
- sync(id="IT Support", target="dev")
179
- sync(id="abc-123", target="staging", dry_run=true)
180
- sync(mode="status", id="abc-123")
181
- sync(mode="config")
182
- ```
183
-
184
- ---
185
-
186
- ## Migration Path
187
-
188
- | Old Tool | New Location |
189
- |----------|--------------|
190
- | `env` | `reference(type="envs")` |
191
- | `knowledge` | `data` |
192
- | `demo` | Removed (generate separately or future addition) |
193
- | `action` | `reference(type="actions")` |
194
- | `template` | `reference(type="templates")` / `reference(type="patterns")` |
195
-
196
- ## Mental Model
197
-
198
- ```
199
- ┌─────────────────────────────────────────┐
200
- │ PERSONA │
201
- │ ┌─────────┐ ┌──────────┐ │
202
- │ │ data │ │ workflow │ │
203
- │ └─────────┘ └──────────┘ │
204
- └─────────────────────────────────────────┘
205
- │ │
206
- └──────┬───────┘
207
-
208
- ┌───────────▼───────────┐
209
- │ reference │ (actions, templates, guidance)
210
- └───────────────────────┘
211
-
212
- ┌───────────▼───────────┐
213
- │ sync │ (copy between envs)
214
- └───────────────────────┘
215
- ```
216
-
217
- ## Implementation Checklist
218
-
219
- - [x] Update `tools-consolidated.ts` with new tool definitions
220
- - [x] Update `handlers-consolidated.ts` with routing logic
221
- - [x] Add `data` tool (wraps knowledge with simplified interface)
222
- - [x] Expand `reference` to support type="envs|actions|templates|patterns|widgets"
223
- - [x] Update tests
224
- - [x] Update documentation
225
- - [x] Keep legacy tools for backwards compatibility (they still work)
@@ -1,256 +0,0 @@
1
- # MCP Tool Response Standards
2
-
3
- Uniform structure and formatting rules for all MCP tool responses.
4
-
5
- ## Core Principles
6
-
7
- 1. **Explicit over implicit**: Always return clear status, never silently succeed/fail
8
- 2. **Actionable responses**: Include next steps, commands, or guidance
9
- 3. **Consistent shape**: Same response structure within each mode category
10
- 4. **Progressive disclosure**: Summary first, details on request
11
-
12
- ## Response Categories
13
-
14
- ### 1. Success Responses
15
-
16
- ```typescript
17
- {
18
- status: "success",
19
- // Primary result data
20
- [result_key]: data,
21
- // Optional metadata
22
- _meta?: {
23
- duration_ms?: number;
24
- cached?: boolean;
25
- }
26
- }
27
- ```
28
-
29
- ### 2. Error Responses
30
-
31
- ```typescript
32
- {
33
- status: "error",
34
- error: "Short error message",
35
- details?: "Longer explanation",
36
- suggestion?: "How to fix",
37
- code?: "ERROR_CODE"
38
- }
39
- ```
40
-
41
- ### 3. Clarification Responses
42
-
43
- When mode is omitted or ambiguous:
44
-
45
- ```typescript
46
- {
47
- status: "clarification_needed",
48
- message: "What operation would you like?",
49
- suggested_mode?: "mode_name", // If intent is detectable
50
- options: ["mode1", "mode2", ...],
51
- hint?: "Use mode='...' for direct execution",
52
- examples?: ["command1", "command2"]
53
- }
54
- ```
55
-
56
- ### 4. Analysis Responses
57
-
58
- For analyze/review/audit operations:
59
-
60
- ```typescript
61
- {
62
- status: "healthy" | "issues_found" | "critical",
63
- summary: {
64
- total_issues: number,
65
- by_severity: { critical: number, warning: number, info: number },
66
- by_category?: Record<string, number>
67
- },
68
- issues: Array<{
69
- id: string,
70
- severity: "critical" | "warning" | "info",
71
- category: string,
72
- title: string,
73
- description: string,
74
- auto_fixable: boolean,
75
- fix_description?: string
76
- }>,
77
- next_steps: {
78
- auto_fix_available: boolean,
79
- command?: string,
80
- manual_actions?: string[]
81
- }
82
- }
83
- ```
84
-
85
- ### 5. List Responses
86
-
87
- ```typescript
88
- {
89
- count: number,
90
- [items_key]: Array<item>, // e.g., "personas", "files", "templates"
91
- // Optional pagination
92
- pagination?: {
93
- offset: number,
94
- limit: number,
95
- has_more: boolean
96
- }
97
- }
98
- ```
99
-
100
- ### 6. Single Item Responses
101
-
102
- ```typescript
103
- {
104
- id: string,
105
- name?: string,
106
- // ... item-specific fields
107
- _meta?: {
108
- retrieved_at: string,
109
- source: string
110
- }
111
- }
112
- ```
113
-
114
- ## Mode + Flag Pattern
115
-
116
- ### Rule: Mode defines WHAT, flags define HOW
117
-
118
- ```typescript
119
- // Mode = the operation type
120
- mode: "analyze" | "list" | "get" | "create" | "update" | "delete" | ...
121
-
122
- // Flags modify the operation behavior
123
- fix: boolean // Auto-apply fixes (for analyze)
124
- preview: boolean // Don't persist changes (for create/update)
125
- include: string[] // What to include in response
126
- force: boolean // Skip confirmations
127
- ```
128
-
129
- ### Anti-Pattern: Mode as flag
130
-
131
- ```typescript
132
- // ❌ BAD: Using mode to toggle behavior
133
- mode: "optimize" // This is just mode="analyze" + fix=true
134
-
135
- // ✅ GOOD: Clear mode + flag
136
- mode: "analyze", fix: true
137
- ```
138
-
139
- ### Anti-Pattern: Flag that changes operation type
140
-
141
- ```typescript
142
- // ❌ BAD: Flag changes what the operation does
143
- mode: "get", optimize: true // Does this get or optimize?
144
-
145
- // ✅ GOOD: Mode is explicit
146
- mode: "analyze", fix: true // Analyze and apply fixes
147
- ```
148
-
149
- ## Severity Levels
150
-
151
- | Level | Meaning | Action |
152
- |-------|---------|--------|
153
- | `critical` | Breaks functionality, must fix | Block deployment |
154
- | `warning` | Degraded behavior, should fix | Warn on deployment |
155
- | `info` | Improvement opportunity | Optional |
156
-
157
- ## Standard Fields
158
-
159
- ### Identifiers
160
-
161
- - `id` - Primary identifier (UUID preferred)
162
- - `name` - Human-readable name
163
- - `identifier` - DEPRECATED, use `id`
164
-
165
- ### Status
166
-
167
- - `status` - Current state: "active", "inactive", "draft", "error"
168
- - `enabled` - Boolean toggle
169
-
170
- ### Timestamps
171
-
172
- - Use ISO 8601 format
173
- - Field names: `created_at`, `updated_at`, `retrieved_at`
174
-
175
- ## Tool-Specific Standards
176
-
177
- ### persona tool
178
-
179
- | Mode | Primary Response Key | Status Field |
180
- |------|---------------------|--------------|
181
- | list | `personas` | `count` |
182
- | get | (flat object) | `status` |
183
- | create | `persona_id`, `name` | `success` |
184
- | update | `updated` | `success` |
185
- | analyze | `issues` | `status` (healthy/issues_found/critical) |
186
-
187
- ### data tool
188
-
189
- | Mode | Primary Response Key | Status Field |
190
- |------|---------------------|--------------|
191
- | list | `files` | `count` |
192
- | get | (flat object) | - |
193
- | upload | `file_id` | `success` |
194
- | generate | `document` | `status` |
195
- | analyze | `issues` | `status` |
196
-
197
- ### sync tool
198
-
199
- | Mode | Primary Response Key | Status Field |
200
- |------|---------------------|--------------|
201
- | run | `synced` | `success` |
202
- | status | `sync_status` | `status` |
203
- | config | `config` | - |
204
-
205
- ## Example: Uniform Analyze Response
206
-
207
- ```json
208
- {
209
- "status": "issues_found",
210
- "summary": {
211
- "total_issues": 5,
212
- "by_severity": { "critical": 0, "warning": 2, "info": 3 },
213
- "by_category": { "workflow": 3, "config": 1, "data": 1 }
214
- },
215
- "issues": [
216
- {
217
- "id": "orphaned-node-1",
218
- "severity": "warning",
219
- "category": "workflow",
220
- "title": "Orphaned node: general_inquiry handler",
221
- "description": "Node 'call_llm_general' has no incoming connections",
222
- "auto_fixable": true,
223
- "fix_description": "Remove orphaned node"
224
- },
225
- {
226
- "id": "missing-embedding-1",
227
- "severity": "info",
228
- "category": "data",
229
- "title": "File without embedding",
230
- "description": "company-faq.pdf has embedding disabled",
231
- "auto_fixable": true,
232
- "fix_description": "Enable embedding for file"
233
- }
234
- ],
235
- "next_steps": {
236
- "auto_fix_available": true,
237
- "command": "persona(mode=\"analyze\", id=\"...\", fix=true)",
238
- "manual_actions": [
239
- "Review orphaned node before removal",
240
- "Verify FAQ file should be searchable"
241
- ]
242
- }
243
- }
244
- ```
245
-
246
- ## Checklist for New Modes
247
-
248
- When adding a new mode to any tool:
249
-
250
- - [ ] Response follows category pattern (success/error/list/analysis)
251
- - [ ] Error responses include `suggestion` field
252
- - [ ] Status field uses standard values
253
- - [ ] Identifiers use `id` not `identifier`
254
- - [ ] List responses have `count` + array field
255
- - [ ] Analysis responses have `summary` + `issues` + `next_steps`
256
- - [ ] Flags don't change operation type (only modify behavior)
@@ -1,97 +0,0 @@
1
- # Getting Started with Ema MCP
2
-
3
- Welcome! This guide helps you work effectively with Ema AI Employees.
4
-
5
- ## First Steps
6
-
7
- ### 1. List Available Personas
8
- ```
9
- persona(mode="list")
10
- ```
11
-
12
- ### 2. Get Details on One
13
- ```
14
- persona(mode="get", id="persona-name-or-id")
15
- ```
16
-
17
- ### 3. Create Your First AI Employee
18
- ```
19
- persona(mode="create", name="My Assistant", type="voice", input="Handles customer support inquiries", preview=true)
20
- ```
21
-
22
- ## Key Concepts
23
-
24
- | Term | Meaning |
25
- |------|---------|
26
- | **Persona** | An AI Employee (Voice, Chat, or Dashboard) |
27
- | **Workflow** | The logic that powers a persona |
28
- | **Action** | A building block in workflows (search, email, ticket, etc.) |
29
- | **HITL** | Human-in-the-loop - approval before taking action |
30
-
31
- ## Essential Rules
32
-
33
- ### 1. Always Preview First
34
- ```
35
- preview=true # Safe - shows what would happen
36
- preview=false # Deploys to production
37
- ```
38
-
39
- ### 2. One Call, Complete Information
40
- Don't make multiple calls. Put all parameters in one call:
41
- ```
42
- # ✅ Good
43
- persona(mode="create", name="Bot", type="voice", input="...", preview=false)
44
-
45
- # ❌ Bad - multiple calls
46
- persona(mode="create", name="Bot")
47
- persona(mode="update", ...)
48
- ```
49
-
50
- ### 3. Ask Before Creating
51
- Before creating a new persona, ask:
52
- - What should it do? (purpose)
53
- - What type? (voice/chat/dashboard)
54
- - What name?
55
-
56
- ### 4. Use Templates
57
- List available templates:
58
- ```
59
- persona(mode="templates")
60
- ```
61
-
62
- Create from template (recommended):
63
- ```
64
- persona(mode="create", from="Voice AI Starter", name="My SDR", preview=false)
65
- ```
66
-
67
- ## Common Operations
68
-
69
- | Task | Command |
70
- |------|---------|
71
- | List all personas | `persona(mode="list")` |
72
- | Get one | `persona(mode="get", id="...")` |
73
- | Create new | `persona(mode="create", name="...", type="voice", input="...")` |
74
- | Update | `persona(mode="update", id="...", proto_config={...})` |
75
- | Analyze issues | `persona(mode="analyze", id="...")` |
76
- | Compare two | `persona(mode="compare", id="...", compare_to="...")` |
77
-
78
- ## Getting Help
79
-
80
- - **List actions**: `action(all=true)`
81
- - **Get guidance**: `reference(guidance="hitl-patterns")`
82
- - **Common mistakes**: `reference(mistakes=true)`
83
- - **Check templates**: `template(patterns=true)`
84
-
85
- ## Environments
86
-
87
- Most users have multiple environments (demo, staging, prod).
88
-
89
- ```
90
- # List environments
91
- env()
92
-
93
- # Target specific environment
94
- persona(mode="list", env="prod")
95
- ```
96
-
97
- Default is usually `demo` (safe for testing).