emceepee 0.4.0 → 0.4.2
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.
- package/README.md +114 -8
- package/dist/emceepee-http.js +35 -35
- package/dist/emceepee.js +16 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -194,6 +194,116 @@ Example: Get only protocol logs by excluding stderr/stdout:
|
|
|
194
194
|
| `get_timer` | Get timer details |
|
|
195
195
|
| `delete_timer` | Delete a timer (returns timer body) |
|
|
196
196
|
|
|
197
|
+
### Codemode (Reduced-Context API)
|
|
198
|
+
| Tool | Description |
|
|
199
|
+
|------|-------------|
|
|
200
|
+
| `codemode_search` | Search for capabilities across all servers |
|
|
201
|
+
| `codemode_execute` | Execute JavaScript with access to `mcp.*` API |
|
|
202
|
+
|
|
203
|
+
## Codemode API
|
|
204
|
+
|
|
205
|
+
Codemode is a reduced-context API that exposes just **2 tools** instead of the full set. This dramatically reduces token usage when AI needs to perform complex multi-step MCP operations.
|
|
206
|
+
|
|
207
|
+
### Tools
|
|
208
|
+
|
|
209
|
+
**`codemode_search`** - Search for tools, resources, prompts, or servers using regex patterns:
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"query": "file|read",
|
|
213
|
+
"type": "tools",
|
|
214
|
+
"server": "myserver",
|
|
215
|
+
"includeSchemas": false
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**`codemode_execute`** - Run JavaScript in a sandboxed environment:
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"code": "const tools = await mcp.listTools(); return tools.length;",
|
|
223
|
+
"timeout": 30000
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### The mcp.* API
|
|
228
|
+
|
|
229
|
+
Inside `codemode_execute`, your code has access to:
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
// Server discovery
|
|
233
|
+
await mcp.listServers()
|
|
234
|
+
|
|
235
|
+
// Tool operations
|
|
236
|
+
await mcp.listTools(serverPattern?)
|
|
237
|
+
await mcp.callTool(server, tool, args?)
|
|
238
|
+
|
|
239
|
+
// Resource operations
|
|
240
|
+
await mcp.listResources(serverPattern?)
|
|
241
|
+
await mcp.listResourceTemplates(serverPattern?)
|
|
242
|
+
await mcp.readResource(server, uri)
|
|
243
|
+
|
|
244
|
+
// Prompt operations
|
|
245
|
+
await mcp.listPrompts(serverPattern?)
|
|
246
|
+
await mcp.getPrompt(server, name, args?)
|
|
247
|
+
|
|
248
|
+
// Utilities
|
|
249
|
+
await mcp.sleep(ms) // max 5 seconds per call
|
|
250
|
+
mcp.log(...args) // captured in result.logs
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Example: Multi-Step Operation
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
// Find all "search" tools and call the first one
|
|
257
|
+
const tools = await mcp.listTools();
|
|
258
|
+
const searchTools = tools.filter(t => t.name.includes('search'));
|
|
259
|
+
|
|
260
|
+
if (searchTools.length === 0) {
|
|
261
|
+
return { error: 'No search tools found' };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const tool = searchTools[0];
|
|
265
|
+
mcp.log(`Calling ${tool.server}/${tool.name}`);
|
|
266
|
+
|
|
267
|
+
const result = await mcp.callTool(tool.server, tool.name, {
|
|
268
|
+
query: 'example'
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
tool: tool.name,
|
|
273
|
+
server: tool.server,
|
|
274
|
+
result: result.content
|
|
275
|
+
};
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Security Features
|
|
279
|
+
|
|
280
|
+
- **Sandboxed execution** - Blocked globals: `process`, `require`, `eval`, `fetch`, `setTimeout`, `Function`, etc.
|
|
281
|
+
- **Timeout enforcement** - 1 second to 5 minutes (default 30s)
|
|
282
|
+
- **MCP call limits** - Maximum 100 `mcp.*` calls per execution
|
|
283
|
+
- **Code size limits** - Maximum 100KB of code
|
|
284
|
+
|
|
285
|
+
### Configuration
|
|
286
|
+
|
|
287
|
+
Codemode is enabled by default. To disable:
|
|
288
|
+
|
|
289
|
+
**CLI flag:**
|
|
290
|
+
```bash
|
|
291
|
+
npx emceepee --no-codemode
|
|
292
|
+
npx emceepee-http --no-codemode
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Environment variable:**
|
|
296
|
+
```bash
|
|
297
|
+
EMCEEPEE_NO_CODEMODE=1 npx emceepee
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Library usage:**
|
|
301
|
+
```typescript
|
|
302
|
+
registerTools(server, sessionManager, sessions, requestTracker, {
|
|
303
|
+
codemodeEnabled: false
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
197
307
|
## Context Info
|
|
198
308
|
|
|
199
309
|
Every tool response may include additional context information as a second JSON text block. This provides real-time status without requiring explicit polling:
|
|
@@ -369,19 +479,15 @@ bun run build # Production build
|
|
|
369
479
|
|
|
370
480
|
### Testing
|
|
371
481
|
|
|
372
|
-
The test suite includes integration tests for the stdio client:
|
|
373
|
-
|
|
374
482
|
```bash
|
|
375
483
|
bun run test # Run all tests
|
|
376
|
-
bun run test:stdio # Run stdio client tests
|
|
484
|
+
bun run test:stdio # Run stdio client tests
|
|
485
|
+
bun run test:codemode # Run codemode tests
|
|
377
486
|
```
|
|
378
487
|
|
|
379
488
|
Tests cover:
|
|
380
|
-
- Connection lifecycle
|
|
381
|
-
-
|
|
382
|
-
- Stderr capture with source indication
|
|
383
|
-
- Crash handling and automatic restart with exponential backoff
|
|
384
|
-
- Lifecycle events (process_started, crashed, restarting, restarted, stopped)
|
|
489
|
+
- **Stdio client**: Connection lifecycle, tool invocation, stderr capture, crash recovery, lifecycle events
|
|
490
|
+
- **Codemode**: Sandbox isolation, timeout enforcement, API bindings, search/execute functionality, error handling
|
|
385
491
|
|
|
386
492
|
## License
|
|
387
493
|
|