@ema.co/mcp-toolkit 0.2.2 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +111 -109
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -7,7 +7,6 @@ MCP (Model Context Protocol) server for managing Ema AI Employees. Works with Cu
7
7
  ### Option 1: npx (Recommended)
8
8
 
9
9
  ```bash
10
- # Run directly without installing
11
10
  npx @ema.co/mcp-toolkit
12
11
  ```
13
12
 
@@ -21,8 +20,8 @@ ema-mcp # Start MCP server
21
20
  ### Option 3: Clone & Build (Development)
22
21
 
23
22
  ```bash
24
- git clone https://github.com/Ema-Unlimited/@ema.co/mcp-toolkit.git
25
- cd @ema.co/mcp-toolkit
23
+ git clone https://github.com/Ema-Unlimited/ema-mcp-toolkit.git
24
+ cd ema-mcp-toolkit
26
25
  npm install
27
26
  npm run build
28
27
  ```
@@ -31,27 +30,31 @@ npm run build
31
30
 
32
31
  ## Quick Start
33
32
 
34
- ### 1. Set Your Credentials
33
+ ### 1. Get Your Bearer Token
35
34
 
36
- **Option A: API Key (Recommended)**
35
+ 1. Log in to your Ema environment (e.g., [app.ema.co](https://app.ema.co))
36
+ 2. Open browser DevTools (F12) → Network tab
37
+ 3. Find any API request's `Authorization: Bearer ...` header
38
+ 4. Copy the token (the part after "Bearer ")
37
39
 
38
- API keys are stable and auto-refresh (24h token validity):
40
+ ### 2. Set Up Environment Variables
39
41
 
40
- ```bash
41
- export EMA_API_KEY="your-api-key"
42
- # Or for specific environment:
43
- export EMA_PROD_API_KEY="your-prod-api-key"
44
- ```
45
-
46
- **Option B: Bearer Token**
42
+ Add to your shell profile (`~/.zshrc` or `~/.bashrc`):
47
43
 
48
44
  ```bash
49
- export EMA_BEARER_TOKEN="your-token"
50
- # Or for specific environment:
51
- export EMA_PROD_BEARER_TOKEN="your-prod-token"
45
+ # Single environment
46
+ export EMA_BEARER_TOKEN="eyJhbGciOiJSUzI1..."
47
+
48
+ # Or multiple environments (recommended)
49
+ export EMA_PROD_BEARER_TOKEN="eyJ..." # from app.ema.co
50
+ export EMA_DEMO_BEARER_TOKEN="eyJ..." # from demo.ema.co
51
+ export EMA_DEV_BEARER_TOKEN="eyJ..." # from dev.ema.co
52
+ export EMA_STAGING_BEARER_TOKEN="eyJ..." # from staging.ema.co
52
53
  ```
53
54
 
54
- ### 2. Add to Your AI Assistant
55
+ Then reload: `source ~/.zshrc`
56
+
57
+ ### 3. Configure Your AI Assistant
55
58
 
56
59
  **Cursor** (`~/.cursor/mcp.json`):
57
60
 
@@ -62,14 +65,38 @@ export EMA_PROD_BEARER_TOKEN="your-prod-token"
62
65
  "command": "npx",
63
66
  "args": ["@ema.co/mcp-toolkit"],
64
67
  "env": {
65
- "EMA_API_KEY": "${EMA_API_KEY}"
68
+ "EMA_ENV_NAME": "demo",
69
+ "EMA_PROD_BEARER_TOKEN": "${env:EMA_PROD_BEARER_TOKEN}",
70
+ "EMA_DEMO_BEARER_TOKEN": "${env:EMA_DEMO_BEARER_TOKEN}",
71
+ "EMA_DEV_BEARER_TOKEN": "${env:EMA_DEV_BEARER_TOKEN}",
72
+ "EMA_STAGING_BEARER_TOKEN": "${env:EMA_STAGING_BEARER_TOKEN}"
66
73
  }
67
74
  }
68
75
  }
69
76
  }
70
77
  ```
71
78
 
72
- > **Note**: Use `${ENV_VAR}` syntax to reference environment variables from your shell. Set them in your `~/.zshrc` or `~/.bashrc`.
79
+ > **Important**:
80
+ > - Use `${env:VAR_NAME}` syntax to reference shell environment variables
81
+ > - After changing mcp.json, restart the MCP server: `Cmd+Shift+P` → "MCP: Restart Server"
82
+ > - After changing ~/.zshrc, reload it AND restart Cursor for changes to take effect
83
+
84
+ **Alternative: Direct tokens** (if env expansion doesn't work):
85
+
86
+ ```json
87
+ {
88
+ "mcpServers": {
89
+ "ema": {
90
+ "command": "npx",
91
+ "args": ["@ema.co/mcp-toolkit"],
92
+ "env": {
93
+ "EMA_ENV_NAME": "demo",
94
+ "EMA_DEMO_BEARER_TOKEN": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ```
73
100
 
74
101
  **Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
75
102
 
@@ -80,67 +107,51 @@ export EMA_PROD_BEARER_TOKEN="your-prod-token"
80
107
  "command": "npx",
81
108
  "args": ["@ema.co/mcp-toolkit"],
82
109
  "env": {
83
- "EMA_API_KEY": "your-api-key-here"
110
+ "EMA_BEARER_TOKEN": "your-token-here"
84
111
  }
85
112
  }
86
113
  }
87
114
  }
88
115
  ```
89
116
 
90
- ### 3. Start Using
117
+ ### 4. Verify It Works
91
118
 
92
119
  Ask your AI assistant:
93
- - "List my AI Employees"
94
- - "Analyze the workflow for Customer Support Bot"
95
- - "Create a new Voice AI for appointment scheduling"
120
+ - "List ema environments" - should show your configured environments
121
+ - "List personas in demo" - should show AI Employees
96
122
 
97
123
  ---
98
124
 
99
125
  ## Authentication
100
126
 
101
- ### Option 1: API Key (Recommended)
102
-
103
- API keys provide stable authentication with automatic JWT refresh:
127
+ ### Bearer Tokens (Most Common)
104
128
 
105
- 1. Get your API key from the Ema team
106
- 2. Set the environment variable:
107
- ```bash
108
- export EMA_API_KEY="your-api-key"
109
- ```
129
+ Bearer tokens are JWTs obtained from the Ema web app:
110
130
 
111
- The toolkit automatically:
112
- - Exchanges the API key for a JWT token
113
- - Caches the token (valid 24 hours)
114
- - Refreshes before expiry
131
+ 1. Each token is tied to a specific environment (prod, demo, dev, staging)
132
+ 2. Tokens expire after ~24 hours - get fresh ones when they expire
133
+ 3. The token's issuer (`iss` field) must match the API endpoint:
134
+ - `ema.co` token → `https://api.ema.co`
135
+ - `demo.ema.co` token → `https://api.demo.ema.co`
136
+ - etc.
115
137
 
116
- ### Option 2: Bearer Token
138
+ ### API Keys (If Available)
117
139
 
118
- For quick testing or when API keys aren't available:
119
-
120
- 1. Log in to [Ema Platform](https://app.ema.co)
121
- 2. Open browser DevTools → Network tab
122
- 3. Find any API request's `Authorization: Bearer ...` header
123
- 4. Copy the token (without "Bearer " prefix)
140
+ If you have an API key (different from bearer token):
124
141
 
125
142
  ```bash
126
- export EMA_BEARER_TOKEN="your-token"
143
+ export EMA_PROD_API_KEY="your-api-key"
127
144
  ```
128
145
 
129
- > **Note**: Bearer tokens expire after ~1 hour. Use API keys for production.
146
+ The toolkit will automatically exchange it for a JWT and refresh before expiry.
130
147
 
131
- ### Multiple Environments
148
+ ### Verifying Token Environment
132
149
 
133
- Use environment-specific credentials:
150
+ Check which environment a token belongs to:
134
151
 
135
152
  ```bash
136
- # API keys (preferred)
137
- export EMA_PROD_API_KEY="..."
138
- export EMA_DEMO_API_KEY="..."
139
- export EMA_DEV_API_KEY="..."
140
-
141
- # Or bearer tokens
142
- export EMA_PROD_BEARER_TOKEN="..."
143
- export EMA_DEMO_BEARER_TOKEN="..."
153
+ echo $EMA_DEMO_BEARER_TOKEN | cut -d'.' -f2 | base64 -d 2>/dev/null | jq -r .iss
154
+ # Should output: demo.ema.co
144
155
  ```
145
156
 
146
157
  ---
@@ -152,28 +163,26 @@ export EMA_DEMO_BEARER_TOKEN="..."
152
163
  No config file needed! The toolkit auto-detects environments from environment variables:
153
164
 
154
165
  ```bash
155
- # Pattern: EMA_<ENV>_API_KEY or EMA_<ENV>_BEARER_TOKEN
156
- export EMA_PROD_API_KEY="..." # → creates "prod" environment
157
- export EMA_DEMO_API_KEY="..." # → creates "demo" environment
158
- export EMA_DEV_BEARER_TOKEN="..." # → creates "dev" environment
166
+ # Pattern: EMA_<ENV>_BEARER_TOKEN or EMA_<ENV>_API_KEY
167
+ export EMA_PROD_BEARER_TOKEN="..." # → creates "prod" environment
168
+ export EMA_DEMO_BEARER_TOKEN="..." # → creates "demo" environment
169
+ export EMA_DEV_BEARER_TOKEN="..." # → creates "dev" environment
159
170
  ```
160
171
 
161
172
  **Default Environment**:
162
- - External users: `prod`
163
- - Ema employees: `demo` (auto-detected if demo token exists)
164
- - Override: `export EMA_ENV_NAME="dev"`
173
+ - Set explicitly: `export EMA_ENV_NAME="demo"`
174
+ - Or auto-detected from available credentials
165
175
 
166
176
  **Well-known URLs** (automatic):
177
+
167
178
  | Environment | URL |
168
179
  |-------------|-----|
169
180
  | `prod` | `https://api.ema.co` |
170
181
  | `<env>` | `https://api.<env>.ema.co` |
171
182
 
172
- > For internal environments, use `EMA_<ENV>_API_KEY` or `EMA_<ENV>_BEARER_TOKEN` environment variables.
173
-
174
183
  ### Config File (Advanced)
175
184
 
176
- For complex setups, create `ema.config.yaml`:
185
+ For custom setups, create `ema.config.yaml`:
177
186
 
178
187
  ```yaml
179
188
  environments:
@@ -182,9 +191,9 @@ environments:
182
191
  bearerTokenEnv: EMA_PROD_BEARER_TOKEN
183
192
  isMaster: true
184
193
 
185
- - name: myenv
186
- baseUrl: https://api.<env>.ema.co
187
- bearerTokenEnv: EMA_MYENV_BEARER_TOKEN
194
+ - name: custom
195
+ baseUrl: https://api.custom.ema.co
196
+ bearerTokenEnv: EMA_CUSTOM_BEARER_TOKEN
188
197
  ```
189
198
 
190
199
  ---
@@ -195,7 +204,7 @@ environments:
195
204
  |------|---------|
196
205
  | `env` | List available environments |
197
206
  | `persona` | AI Employee management (get/list/create/update/compare) |
198
- | `workflow` | Generate/analyze/deploy/optimize/explain/extend workflows |
207
+ | `workflow` | Generate/analyze/deploy/optimize/explain workflows |
199
208
  | `action` | Agent lookup, docs, and recommendations |
200
209
  | `template` | Patterns, widgets, qualifying questions |
201
210
  | `knowledge` | Data sources + embedding (upload/list/delete/toggle) |
@@ -232,7 +241,7 @@ ema sync status
232
241
  ## SDK
233
242
 
234
243
  ```typescript
235
- import { EmaClient } from "@ema.co/mcp-toolkit";
244
+ import { EmaClient } from "@ema.co/mcp-toolkit/sdk";
236
245
 
237
246
  const client = new EmaClient({
238
247
  name: "prod",
@@ -255,64 +264,57 @@ const actions = await client.listActions();
255
264
 
256
265
  ---
257
266
 
258
- ## Development
267
+ ## Environment Variables
259
268
 
260
- ```bash
261
- # Build
262
- npm run build
269
+ | Variable | Description |
270
+ |----------|-------------|
271
+ | `EMA_BEARER_TOKEN` | Default bearer token |
272
+ | `EMA_<ENV>_BEARER_TOKEN` | Token for specific environment (PROD, DEMO, DEV, STAGING) |
273
+ | `EMA_API_KEY` | API key (auto-exchanges for JWT) |
274
+ | `EMA_<ENV>_API_KEY` | API key for specific environment |
275
+ | `EMA_ENV_NAME` | Default environment name |
276
+ | `EMA_AGENT_SYNC_CONFIG` | Path to config file |
263
277
 
264
- # Test
265
- npm test
278
+ ---
266
279
 
267
- # Type check
268
- npm run typecheck
269
- ```
280
+ ## Troubleshooting
270
281
 
271
- ---
282
+ ### "Missing token for environment X"
272
283
 
273
- ## Environment Variables
284
+ The token isn't set or isn't being passed to the MCP server:
274
285
 
275
- | Variable | Required | Description |
276
- |----------|----------|-------------|
277
- | `EMA_API_KEY` | Yes* | API key (auto-exchanges for JWT) |
278
- | `EMA_BEARER_TOKEN` | Yes* | Bearer token (direct auth) |
279
- | `EMA_<ENV>_API_KEY` | Yes* | API key for specific environment |
280
- | `EMA_<ENV>_BEARER_TOKEN` | Yes* | Token for specific environment |
281
- | `EMA_ENV_NAME` | No | Default environment name |
282
- | `EMA_EMPLOYEE` | No | Set to "true" to default to demo |
283
- | `EMA_AGENT_SYNC_CONFIG` | No | Path to config file |
286
+ 1. Check the token is set in your shell: `echo $EMA_X_BEARER_TOKEN`
287
+ 2. Ensure it's in `~/.zshrc` and you've run `source ~/.zshrc`
288
+ 3. Restart the MCP server in Cursor after config changes
289
+ 4. If `${env:...}` isn't working, paste the token directly in mcp.json
284
290
 
285
- *At least one credential required.
291
+ ### "Invalid API key" error
286
292
 
287
- ---
293
+ You're using a bearer token (JWT) with an `_API_KEY` variable name:
294
+ - Rename `EMA_X_API_KEY` to `EMA_X_BEARER_TOKEN`
288
295
 
289
- ## Troubleshooting
296
+ ### Only some environments detected
290
297
 
291
- ### "Missing token for environment X"
298
+ Check each token's issuer matches its environment:
292
299
 
293
- Set the corresponding environment variable:
294
300
  ```bash
295
- export EMA_X_API_KEY="your-api-key"
296
- # or
297
- export EMA_X_BEARER_TOKEN="your-token"
301
+ # Should show: demo.ema.co
302
+ echo $EMA_DEMO_BEARER_TOKEN | cut -d'.' -f2 | base64 -d 2>/dev/null | jq -r .iss
298
303
  ```
299
304
 
300
- ### "API key not yet initialized"
305
+ ### Token expired / 401 errors
301
306
 
302
- API keys are initialized asynchronously at startup. Either:
303
- - Wait a moment and retry
304
- - Use a bearer token instead
307
+ Bearer tokens expire after ~24 hours. Get fresh tokens from each environment's web app.
305
308
 
306
- ### "Token expired" / 401 errors
309
+ ### MCP server not picking up new tokens
307
310
 
308
- - **API keys**: Should auto-refresh. Check your API key is valid.
309
- - **Bearer tokens**: Expire after ~1 hour. Get a fresh token or switch to API keys.
311
+ 1. Run `source ~/.zshrc` to reload env vars
312
+ 2. Restart MCP server: `Cmd+Shift+P` "MCP: Restart Server" "ema"
313
+ 3. Or restart Cursor entirely
310
314
 
311
- ### MCP server not connecting
315
+ ### Cursor `${env:...}` not expanding
312
316
 
313
- 1. Verify credentials are set: `echo $EMA_API_KEY`
314
- 2. Try running manually: `npx @ema.co/mcp-toolkit`
315
- 3. Check MCP config path is correct
317
+ Some Cursor versions have issues with env var expansion. Workaround: paste tokens directly in mcp.json (less secure but works).
316
318
 
317
319
  ---
318
320
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ema.co/mcp-toolkit",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
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",