@ema.co/mcp-toolkit 2026.1.25 → 2026.1.26-4

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 (87) 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 +47 -18
  9. package/dist/mcp/handlers/persona/index.js +14 -11
  10. package/dist/mcp/handlers/persona/update.js +4 -2
  11. package/dist/mcp/handlers/persona/version.js +234 -0
  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/deploy.js +73 -0
  17. package/dist/mcp/handlers/workflow/generate.js +350 -0
  18. package/dist/mcp/handlers/workflow/index.js +294 -0
  19. package/dist/mcp/handlers/workflow/modify.js +456 -0
  20. package/dist/mcp/handlers/workflow/optimize.js +136 -0
  21. package/dist/mcp/handlers/workflow/types.js +4 -0
  22. package/dist/mcp/handlers/workflow/utils.js +30 -0
  23. package/dist/mcp/handlers-consolidated.js +73 -2696
  24. package/dist/mcp/prompts.js +83 -43
  25. package/dist/mcp/resources.js +382 -57
  26. package/dist/mcp/server.js +199 -391
  27. package/dist/mcp/{tools-v2.js → tools.js} +20 -54
  28. package/dist/mcp/workflow-operations.js +2 -2
  29. package/dist/sdk/client-adapter.js +267 -32
  30. package/dist/sdk/client.js +45 -16
  31. package/dist/sdk/ema-client.js +183 -0
  32. package/dist/sdk/generated/deprecated-actions.js +171 -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 +139 -86
  37. package/dist/sdk/workflow-intent.js +27 -0
  38. package/dist/sdk/workflow-transformer.js +0 -342
  39. package/docs/mcp-tools-guide.md +37 -45
  40. package/package.json +10 -4
  41. package/dist/mcp/handlers/persona/analyze.js +0 -275
  42. package/dist/mcp/handlers/persona/compare.js +0 -32
  43. package/dist/mcp/tools-consolidated.js +0 -875
  44. package/dist/mcp/tools-legacy.js +0 -736
  45. package/docs/CODEBASE-ANALYSIS-2026-01-23.md +0 -936
  46. package/docs/CODEBASE-ANALYSIS-PRIORITIZED.md +0 -774
  47. package/docs/api-contracts.md +0 -216
  48. package/docs/auto-builder-analysis.md +0 -271
  49. package/docs/blog/mcp-tool-design-lessons.md +0 -309
  50. package/docs/data-architecture.md +0 -166
  51. package/docs/demos/ap-invoice-generation.md +0 -347
  52. package/docs/demos/ap-invoice-processing.md +0 -271
  53. package/docs/ema-auto-builder-guide.html +0 -394
  54. package/docs/lessons-learned.md +0 -209
  55. package/docs/llm-native-workflow-design.md +0 -252
  56. package/docs/local-generation.md +0 -508
  57. package/docs/mcp-flow-diagram.md +0 -135
  58. package/docs/migration/action-composition-migration.md +0 -270
  59. package/docs/naming-conventions.md +0 -278
  60. package/docs/proposals/HANDOFF-tool-restructure.md +0 -526
  61. package/docs/proposals/action-composition.md +0 -490
  62. package/docs/proposals/explicit-method-restructure.md +0 -328
  63. package/docs/proposals/mcp-tool-restructure-2026-01.md +0 -366
  64. package/docs/proposals/self-contained-guidance.md +0 -427
  65. package/docs/proto-sdk-generation.md +0 -242
  66. package/docs/release-impact.md +0 -102
  67. package/docs/release-process.md +0 -157
  68. package/docs/staging.RULE.md +0 -142
  69. package/docs/test-persona-creation.md +0 -196
  70. package/docs/tool-consolidation-v2.md +0 -225
  71. package/docs/tool-response-standards.md +0 -256
  72. package/resources/demo-kits/README.md +0 -175
  73. package/resources/demo-kits/finance-ap/manifest.json +0 -150
  74. package/resources/demo-kits/tags.json +0 -91
  75. package/resources/docs/getting-started.md +0 -97
  76. package/resources/templates/auto-builder-rules.md +0 -224
  77. package/resources/templates/chat-ai/README.md +0 -119
  78. package/resources/templates/chat-ai/persona-config.json +0 -111
  79. package/resources/templates/dashboard-ai/README.md +0 -156
  80. package/resources/templates/dashboard-ai/persona-config.json +0 -180
  81. package/resources/templates/demo-scenarios/README.md +0 -63
  82. package/resources/templates/demo-scenarios/test-published-package.md +0 -116
  83. package/resources/templates/document-gen-ai/README.md +0 -132
  84. package/resources/templates/document-gen-ai/persona-config.json +0 -316
  85. package/resources/templates/voice-ai/README.md +0 -123
  86. package/resources/templates/voice-ai/persona-config.json +0 -74
  87. package/resources/templates/voice-ai/workflow-prompt.md +0 -121
@@ -1,102 +0,0 @@
1
- # Release Impact Assessment
2
-
3
- ## Two Versioning Contexts
4
-
5
- This repo has two audiences with different versioning needs:
6
-
7
- | Context | Versioned Via | Audience | What Changes Matter |
8
- |---------|---------------|----------|---------------------|
9
- | **npm package** | CalVer tags (`v2026.01.21`) | External MCP users | `src/*.ts`, `resources/`, `package.json` |
10
- | **Git repo** | Git commits | Internal developers | Everything, including `.cursor/`, `docs/` |
11
-
12
- ### Cursor Rules: Out of Band
13
-
14
- `.cursor/` changes affect internal developer experience but NOT external npm users:
15
- - They're tracked in git history
16
- - No npm release needed
17
- - No version number changes
18
- - Developers pulling the repo get them automatically
19
-
20
- **If cursor rules change significantly**, consider noting in commit message or PR description.
21
-
22
- ---
23
-
24
- ## Quick Reference
25
-
26
- | Change Type | Release Needed? | Version Bump |
27
- |-------------|-----------------|--------------|
28
- | `src/**/*.ts` (runtime code) | **Yes** | patch/minor/major |
29
- | `package.json` dependencies | **Yes** | patch |
30
- | `resources/**` (MCP resources) | **Yes** | patch |
31
- | `.cursor/**`, `docs/**`, `*.md` | No | - |
32
- | `test/**` | No | - |
33
- | `.github/**` | No | - |
34
-
35
- ## Detailed Rules
36
-
37
- ### Requires Release (affects npm package users)
38
-
39
- ```
40
- src/**/*.ts # Runtime TypeScript code
41
- package.json # If dependencies change
42
- resources/**/*.json # MCP static resources
43
- resources/**/*.md # MCP resource content
44
- ```
45
-
46
- ### Does NOT Require Release
47
-
48
- ```
49
- .cursor/** # Cursor rules (local dev only)
50
- .github/** # CI/CD workflows
51
- docs/** # Documentation
52
- test/** # Test files
53
- *.md (root) # README, CLAUDE.md, AGENTS.md
54
- .ctx/** # Agent coordination
55
- scripts/** # Build/dev scripts (not runtime)
56
- ```
57
-
58
- ## Version Bump Guidelines
59
-
60
- | Change | Bump | Example |
61
- |--------|------|---------|
62
- | Breaking API change | Major | Tool renamed, param removed |
63
- | New feature | Minor | New tool, new mode |
64
- | Bug fix | Patch | Fix silent failure |
65
- | Docs only | None | Update README |
66
- | Internal refactor (no API change) | Patch | Restructure handlers |
67
-
68
- ## Automated Assessment
69
-
70
- Run this to check if release is needed:
71
-
72
- ```bash
73
- # Files changed since last release
74
- git diff --name-only $(git tag --sort=-v:refname | head -1)..HEAD
75
-
76
- # Check for release-requiring changes
77
- git diff --name-only $(git tag --sort=-v:refname | head -1)..HEAD | \
78
- grep -E '^(src/.*\.ts|package\.json|resources/)' && \
79
- echo "RELEASE NEEDED" || echo "No release needed"
80
- ```
81
-
82
- ## Pre-Release Checklist
83
-
84
- Before releasing, verify:
85
-
86
- - [ ] `npm run build` passes
87
- - [ ] `npm test` passes
88
- - [ ] No breaking changes without major bump
89
- - [ ] CHANGELOG updated (if maintaining one)
90
- - [ ] Version tag follows CalVer: `v2026.MM.DD[.N]`
91
-
92
- ## CalVer Scheme
93
-
94
- This project uses Calendar Versioning:
95
-
96
- ```
97
- v2026.01.21 # First release on Jan 21, 2026
98
- v2026.01.21.1 # Second release same day
99
- v2026.01.21.2 # Third release same day
100
- ```
101
-
102
- No manual `package.json` version updates needed - CI generates from tag.
@@ -1,157 +0,0 @@
1
- # Release Process
2
-
3
- ## Lessons Learned (2026-01-16)
4
-
5
- The `feat/v1.5.0-intelligence-layer` branch was orphaned for weeks, containing 5,600+ lines of code that diverged significantly from main. This document establishes processes to prevent similar situations.
6
-
7
- ## Branch Hygiene Rules
8
-
9
- ### 1. No Long-Lived Feature Branches
10
-
11
- **Rule:** Feature branches should be merged or closed within **2 weeks**.
12
-
13
- **Why:** Long-lived branches diverge and become difficult to merge.
14
-
15
- **Process:**
16
- - If a feature takes longer than 2 weeks, break it into smaller PRs
17
- - If blocked, document why and set a reminder to revisit
18
-
19
- ### 2. Pre-Branch Checklist
20
-
21
- Before creating a new feature branch:
22
-
23
- ```bash
24
- # 1. Fetch latest and check for unmerged work
25
- git fetch origin
26
- git branch -r --no-merged main | grep -v HEAD
27
-
28
- # 2. If unmerged branches exist, decide:
29
- # - Merge them first? OR
30
- # - Explicitly abandon them?
31
-
32
- # 3. Start from latest main
33
- git checkout main
34
- git pull origin main
35
- git checkout -b feat/my-feature
36
- ```
37
-
38
- ### 3. Weekly Stale Branch Review
39
-
40
- Run weekly to identify abandoned branches:
41
-
42
- ```bash
43
- # Show branches not merged to main, sorted by age
44
- git for-each-ref --sort=committerdate refs/remotes/origin \
45
- --format='%(committerdate:short) %(refname:short)' | \
46
- grep -v HEAD | grep -v main
47
- ```
48
-
49
- ### 4. Post-Merge Cleanup
50
-
51
- After merging a PR:
52
-
53
- ```bash
54
- # Delete the remote branch
55
- git push origin --delete feat/my-feature
56
-
57
- # Delete local branch
58
- git branch -d feat/my-feature
59
-
60
- # Verify cleanup
61
- git remote prune origin
62
- ```
63
-
64
- ## Versioning: CalVer (Date-Based)
65
-
66
- We use **Calendar Versioning** (CalVer): `YYYY.MM.DD`
67
-
68
- | Format | Example | Notes |
69
- |--------|---------|-------|
70
- | Standard | `2026.01.17` | First release of the day |
71
- | Same-day | `2026.01.17.1` | Second release same day |
72
- | Same-day | `2026.01.17.2` | Third release same day |
73
-
74
- **No manual `package.json` updates needed!** The publish workflow auto-generates the version from the release tag.
75
-
76
- ### Branch Naming Convention
77
-
78
- | Type | Pattern | Example |
79
- |------|---------|---------|
80
- | Feature | `feat/descriptive-name` | `feat/tool-consolidation-v2` |
81
- | Fix | `fix/descriptive-name` | `fix/fallback-detection` |
82
- | Chore | `chore/descriptive-name` | `chore/update-deps` |
83
-
84
- ### Release Process (CalVer)
85
-
86
- 1. **Check for unmerged work:**
87
- ```bash
88
- git branch -r --no-merged main
89
- ```
90
-
91
- 2. **Run full test suite:**
92
- ```bash
93
- npm run build && npm test
94
- ```
95
-
96
- 3. **Merge your PR to main**
97
-
98
- 4. **Create a GitHub Release:**
99
- - Go to GitHub → Releases → "Draft a new release"
100
- - Create tag: `v2026.01.17` (use today's date)
101
- - Write release notes
102
- - Publish
103
-
104
- 5. **The publish workflow automatically:**
105
- - Updates `package.json` with the version from the tag
106
- - Builds and tests
107
- - Publishes to npm
108
-
109
- **For same-day releases:** Use `v2026.01.17.1`, `v2026.01.17.2`, etc.
110
-
111
- ## Conflict Prevention
112
-
113
- ### When Parallel Work Happens
114
-
115
- If two features are being developed in parallel:
116
-
117
- 1. **Communicate:** Let the team know what you're working on
118
- 2. **Small PRs:** Merge frequently to reduce divergence
119
- 3. **Rebase often:** Keep feature branches up to date with main
120
-
121
- ```bash
122
- # Rebase feature branch on latest main
123
- git fetch origin
124
- git rebase origin/main
125
- ```
126
-
127
- ### When Merging a Large Feature
128
-
129
- For large features (>500 lines):
130
-
131
- 1. **Create a tracking issue** documenting what's being added
132
- 2. **Break into reviewable chunks** (≤300 lines per PR)
133
- 3. **Merge incrementally** rather than one giant PR
134
-
135
- ## Automation (Future)
136
-
137
- Consider adding GitHub Actions for:
138
-
139
- 1. **Stale branch alerts:** Weekly notification of branches >14 days old
140
- 2. **PR size warnings:** Flag PRs with >500 lines changed
141
- 3. **Unmerged branch check:** CI fails if important branches are unmerged before release
142
-
143
- ## Quick Reference
144
-
145
- ```bash
146
- # Check for unmerged branches
147
- git branch -r --no-merged main | grep -v HEAD
148
-
149
- # Compare branch to main
150
- git log main..origin/feat/branch-name --oneline
151
- git diff --stat main...origin/feat/branch-name
152
-
153
- # Clean up after merge
154
- git push origin --delete feat/branch-name
155
- git branch -d feat/branch-name
156
- git remote prune origin
157
- ```
@@ -1,142 +0,0 @@
1
- ---
2
- description: "Guide for using Ema MCP tools - 7 active tools with explicit mode"
3
- alwaysApply: true
4
- globs: ["src/mcp/**", "src/sdk/**"]
5
- ---
6
-
7
- # Ema MCP Client Guide
8
-
9
- ## Tool Overview: 7 Active Tools
10
-
11
- | Tool | Purpose | Mode Required? |
12
- |------|---------|----------------|
13
- | `env` | List environments | No (single operation) |
14
- | `persona` | Manage AI Employees | **YES** |
15
- | `data` | Manage data + generation | **YES** |
16
- | `action` | Actions lookup | No (flag-based) |
17
- | `template` | Patterns & questions | No (flag-based) |
18
- | `reference` | Platform concepts | No (flag-based) |
19
- | `sync` | Environment sync | **YES** |
20
-
21
- **Deprecated tools** (still work, but use new ones):
22
- - `workflow` → use `persona` instead
23
- - `knowledge` → use `data` instead
24
- - `demo` → use `data` + `persona` instead
25
-
26
- ## Primary Tool: `persona`
27
-
28
- Everything for AI Employee management is in the `persona` tool. **Explicit mode required.**
29
-
30
- ### `persona` Tool Modes
31
-
32
- ```
33
- persona(mode="list") // List all
34
- persona(mode="get", id="abc-123") // Get specific
35
- persona(mode="get", id="abc-123", include_workflow=true) // Get with workflow
36
-
37
- persona(mode="create", from="Voice AI Starter", name="My SDR", input="...", preview=false)
38
- persona(mode="create", type="voice", name="My SDR", input="...", preview=false)
39
-
40
- persona(mode="update", id="abc-123", proto_config={...}) // Update config
41
- persona(mode="clone", from="source-id", name="My Copy", include_data=true)
42
- persona(mode="compare", id="abc-123", compare_to="def-456")
43
- persona(mode="sanitize", id="abc-123")
44
- persona(mode="analyze", id="abc-123") // Show issues
45
- persona(mode="analyze", id="abc-123", fix=true) // Auto-fix issues
46
- persona(mode="templates") // List templates
47
- ```
48
-
49
- ## Explicit Mode Pattern
50
-
51
- Tools with multiple operations require **explicit `mode`**. If omitted, the tool will **clarify** what operation you want - it won't guess.
52
-
53
- ### `data` Tool Modes
54
-
55
- ```
56
- data(persona_id="abc", mode="list") // List files
57
- data(persona_id="abc", mode="get", file_id="...") // Get specific file
58
- data(persona_id="abc", mode="upload", file="/path") // Upload file
59
- data(persona_id="abc", mode="generate", input="...") // Generate from NL
60
- data(persona_id="abc", mode="generate", from="customer", count=5) // From template
61
- data(persona_id="abc", mode="delete", file_id="...") // Delete file
62
- data(persona_id="abc", mode="sanitize") // Sanitize PII
63
- data(persona_id="abc", mode="embedding") // Embedding status
64
- data(persona_id="abc", mode="embedding", enabled=true) // Toggle embedding
65
- data(mode="templates") // List templates
66
- data(mode="templates", template="customer") // Get template details
67
- ```
68
-
69
- ### `sync` Tool Modes
70
-
71
- ```
72
- sync(id="...", target="dev", mode="run") // Sync persona to target
73
- sync(all=true, target="dev", mode="run") // Sync all tagged
74
- sync(id="...", mode="status") // Get sync status
75
- sync(mode="config") // Get sync config
76
- ```
77
-
78
- ## Document Generation
79
-
80
- Generate content via the Ema Document Generation API:
81
-
82
- ```
83
- // From a template
84
- data(persona_id="abc", mode="generate", from="customer", count=5)
85
- data(persona_id="abc", mode="generate", from="demo-sales-sdr")
86
-
87
- // From natural language
88
- data(persona_id="abc", mode="generate", input="Generate 5 B2B customer profiles for SaaS")
89
-
90
- // List available templates
91
- data(mode="templates")
92
- ```
93
-
94
- **Available templates:**
95
- - Reference: `countries`, `industries`, `currencies`
96
- - Demo kits: `demo-sales-sdr`, `demo-support`, `demo-hr`
97
- - Entities: `customer`, `product`, `faq`, `employee`
98
-
99
- ## Clarification Behavior
100
-
101
- If you call `persona()`, `data()`, or `sync()` without explicit mode, you get a clarification response:
102
-
103
- ```json
104
- {
105
- "status": "clarification_needed",
106
- "message": "What operation would you like to perform?",
107
- "options": ["list", "get", "create", "update", ...],
108
- "hint": "Specify mode='...' for direct execution"
109
- }
110
- ```
111
-
112
- This prevents unintended operations (e.g., silent no-ops) and ensures explicit user intent.
113
-
114
- ## Key Rules
115
-
116
- 1. **ONE CALL** - Put everything in `input`, explicit `name`, let MCP handle the rest
117
- 2. **EXPLICIT MODE** - For `data` and `sync`, always specify `mode`
118
- 3. **STOP after success** - Don't make follow-up "fix" calls
119
- 4. **preview=false** - Required to actually deploy (default is preview)
120
-
121
- ## Migration from Deprecated Tools
122
-
123
- | Old | New |
124
- |-----|-----|
125
- | `workflow(input="...")` | `persona(input="...")` |
126
- | `knowledge(mode="list")` | `data(mode="list")` |
127
- | `knowledge(mode="upload")` | `data(mode="upload")` |
128
- | `knowledge(mode="status")` | `data(mode="embedding")` |
129
- | `knowledge(mode="toggle")` | `data(mode="embedding", enabled=...)` |
130
- | `demo(mode="generate")` | `data(mode="generate", from="...")` |
131
- | `demo(mode="scenarios")` | `data(mode="templates")` |
132
- | `demo(mode="template")` | `data(mode="templates", template="...")` |
133
-
134
- ## Anti-Patterns
135
-
136
- ```
137
- ❌ Making multiple calls to create one AI Employee
138
- ❌ Omitting `name` parameter for new personas
139
- ❌ Using deprecated tools (workflow, knowledge, demo)
140
- ❌ Calling data() without mode and expecting it to guess
141
- ❌ preview=true then complaining it didn't deploy
142
- ```
@@ -1,196 +0,0 @@
1
- # Persona Creation Test Guide
2
-
3
- This guide tests the workflow tool's ability to create and configure AI Employees (personas).
4
-
5
- ## Architecture
6
-
7
- ### Greenfield (New Personas)
8
- 1. **Create** persona from template (provides valid workflow structure)
9
- 2. **Fetch** the created persona (get template's structure)
10
- 3. **Update** proto_config only (voice settings, welcome message, etc.)
11
- 4. **Customize workflow later** via modify mode if needed
12
-
13
- ### Brownfield (Existing Personas)
14
- 1. **Fetch** existing persona and workflow
15
- 2. **Decompile** workflow_def → WorkflowSpec (typed representation)
16
- 3. **Transform** spec based on user intent (LLM-native)
17
- 4. **Compile** back to workflow_def
18
- 5. **Update** persona with transformed workflow
19
-
20
- ## Prerequisites
21
-
22
- 1. **Rebuild the code**:
23
- ```bash
24
- cd /path/to/ema-mcp-toolkit
25
- npm run build
26
- ```
27
-
28
- 2. **Restart the MCP server** (Cursor caches code):
29
- - `Cmd+Shift+P` → "Developer: Reload Window"
30
-
31
- 3. Access to Ema dev environment
32
-
33
- ---
34
-
35
- ## Test Cases
36
-
37
- ### Test 1: Create Voice AI Employee (Greenfield)
38
-
39
- **Goal:** Create a new Voice AI persona from template with configured settings.
40
-
41
- **Command:**
42
- ```
43
- workflow(
44
- input="Voice AI sales development representative for Ema. Handles discovery calls, qualifies prospects, explains value propositions.",
45
- name="SP-TEST-VOICE-GREENFIELD",
46
- type="voice",
47
- preview=false,
48
- env="dev"
49
- )
50
- ```
51
-
52
- **Expected Result:**
53
- - `status: "deployed"`
54
- - `deployed_to.created: true`
55
- - `deployed_to.persona_id` returned
56
- - `next_steps` explains how to customize workflow
57
-
58
- **Verify:**
59
- ```
60
- persona(id="<persona_id>", include_workflow=true, env="dev")
61
- ```
62
-
63
- **Check:**
64
- - [ ] Persona exists with correct name
65
- - [ ] `proto_config.widgets` contains `conversationSettings` with:
66
- - [ ] `welcomeMessage` - generated greeting
67
- - [ ] `identityAndPurpose` - from description
68
- - [ ] `workflow_def` has template workflow (trigger node + possibly more from template)
69
-
70
- ---
71
-
72
- ### Test 2: Create Chat AI Employee (Greenfield)
73
-
74
- **Command:**
75
- ```
76
- workflow(
77
- input="IT helpdesk chatbot that answers employee questions about password resets, VPN setup, and software installation.",
78
- name="SP-TEST-CHAT-GREENFIELD",
79
- type="chat",
80
- preview=false,
81
- env="dev"
82
- )
83
- ```
84
-
85
- **Expected Result:**
86
- - `status: "deployed"`
87
- - `deployed_to.created: true`
88
-
89
- **Verify:**
90
- ```
91
- persona(id="<persona_id>", include_workflow=true, env="dev")
92
- ```
93
-
94
- ---
95
-
96
- ### Test 3: Modify Existing Workflow (Brownfield)
97
-
98
- **Prerequisites:** Create a persona first (Test 1 or 2).
99
-
100
- **Goal:** Add functionality to an existing persona's workflow.
101
-
102
- **Command:**
103
- ```
104
- workflow(
105
- persona_id="<persona_id_from_test_1>",
106
- input="add a search node that queries the knowledge base before responding",
107
- preview=true,
108
- env="dev"
109
- )
110
- ```
111
-
112
- **Expected Result:**
113
- - `mode: "modify"`
114
- - Shows proposed changes
115
- - `modified_workflow` with new nodes
116
-
117
- **Deploy the changes:**
118
- ```
119
- workflow(
120
- persona_id="<persona_id>",
121
- input="add a search node that queries the knowledge base before responding",
122
- preview=false,
123
- env="dev"
124
- )
125
- ```
126
-
127
- ---
128
-
129
- ### Test 4: Analyze Workflow
130
-
131
- **Command:**
132
- ```
133
- workflow(persona_id="<persona_id>", env="dev")
134
- ```
135
-
136
- **Expected Result:**
137
- - `mode: "analyze"`
138
- - `issues` array (may be empty if healthy)
139
- - `metrics` with node_count, edge_count
140
-
141
- ---
142
-
143
- ### Test 5: Preview Only (No Deploy)
144
-
145
- **Goal:** Verify preview mode returns workflow without deploying.
146
-
147
- **Command:**
148
- ```
149
- workflow(
150
- input="Customer support voice AI that handles billing inquiries",
151
- type="voice"
152
- )
153
- ```
154
-
155
- **Expected Result:**
156
- - `status: "preview"`
157
- - `workflow_def` returned
158
- - `proto_config` with voice settings populated
159
- - NO persona created
160
-
161
- ---
162
-
163
- ## Cleanup
164
-
165
- After testing, delete test personas via the Ema UI or leave them for inspection.
166
-
167
- Test persona names:
168
- - SP-TEST-VOICE-GREENFIELD
169
- - SP-TEST-CHAT-GREENFIELD
170
-
171
- ---
172
-
173
- ## Troubleshooting
174
-
175
- ### "Internal Server Error"
176
- - Usually means workflow format is wrong
177
- - Check if MCP server has latest code (restart Cursor)
178
-
179
- ### "Widget name is empty"
180
- - Old code issue - restart MCP server
181
-
182
- ### "Workflow name does not match"
183
- - Old code tried to replace workflow - now we don't touch workflow in greenfield
184
-
185
- ### proto_config not updated
186
- - Check that greenfield flow only updates proto_config, not workflow
187
- - Widget merging should preserve template structure
188
-
189
- ---
190
-
191
- ## Key Code Locations
192
-
193
- - **Greenfield flow**: `src/mcp/handlers-consolidated.ts` (search for "GREENFIELD")
194
- - **Brownfield/modify flow**: `src/mcp/handlers-consolidated.ts` (search for "modify")
195
- - **Workflow transformer**: `src/sdk/workflow-transformer.ts` (decompile/compile)
196
- - **Proto config generation**: `src/sdk/workflow-generator.ts` (buildProtoConfig)