@moda-ai/cli 1.0.4 → 1.0.5

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 (41) hide show
  1. package/README.md +24 -54
  2. package/dist/auth.js +39 -67
  3. package/dist/cli.js +93 -12
  4. package/dist/config.d.ts +1 -2
  5. package/dist/config.js +1 -2
  6. package/dist/init/detect.d.ts +1 -1
  7. package/dist/init/detect.js +28 -5
  8. package/dist/init/index.js +26 -68
  9. package/dist/init/mcp.d.ts +1 -7
  10. package/dist/init/mcp.js +5 -88
  11. package/dist/init/rules.d.ts +1 -1
  12. package/dist/init/rules.js +151 -58
  13. package/dist/init/tenant.js +3 -41
  14. package/dist/schemas.d.ts +59 -0
  15. package/dist/schemas.js +35 -0
  16. package/package.json +6 -17
  17. package/skills/integrate-moda/SKILL.md +63 -0
  18. package/skills/moda-cli/SKILL.md +291 -0
  19. package/dist/__tests__/api-client.test.d.ts +0 -2
  20. package/dist/__tests__/api-client.test.js +0 -73
  21. package/dist/__tests__/cli.test.d.ts +0 -2
  22. package/dist/__tests__/cli.test.js +0 -109
  23. package/dist/__tests__/e2e.test.d.ts +0 -2
  24. package/dist/__tests__/e2e.test.js +0 -239
  25. package/dist/__tests__/handlers.test.d.ts +0 -2
  26. package/dist/__tests__/handlers.test.js +0 -71
  27. package/dist/__tests__/integration.test.d.ts +0 -2
  28. package/dist/__tests__/integration.test.js +0 -114
  29. package/dist/__tests__/schemas.test.d.ts +0 -2
  30. package/dist/__tests__/schemas.test.js +0 -81
  31. package/dist/handlers.d.ts +0 -7
  32. package/dist/handlers.js +0 -117
  33. package/dist/http-server.d.ts +0 -3
  34. package/dist/http-server.js +0 -74
  35. package/dist/index.d.ts +0 -3
  36. package/dist/index.js +0 -26
  37. package/dist/tools.d.ts +0 -260
  38. package/dist/tools.js +0 -133
  39. package/dist/worker.d.ts +0 -9
  40. package/dist/worker.js +0 -24
  41. package/mcp-config.example.json +0 -12
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
- import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
4
- import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
- import express from 'express';
6
- import cors from 'cors';
7
- import { validateConfig, PORT, VERSION } from './config.js';
8
- import { getToolDefinitions } from './tools.js';
9
- import { handleToolCall } from './handlers.js';
10
- validateConfig();
11
- const app = express();
12
- const allowedOrigins = process.env.ALLOWED_ORIGINS?.split(',').map((o) => o.trim());
13
- app.use(cors(allowedOrigins
14
- ? { origin: allowedOrigins }
15
- : undefined));
16
- app.use(express.json());
17
- const transports = new Map();
18
- app.get('/health', (_req, res) => {
19
- res.json({ status: 'ok', service: 'moda-cli', version: VERSION });
20
- });
21
- app.get('/mcp/sse', async (req, res) => {
22
- console.log('Client connected to SSE endpoint');
23
- const transport = new SSEServerTransport('/mcp/messages', res);
24
- transports.set(transport.sessionId, transport);
25
- const server = new Server({ name: 'moda-data-api', version: VERSION }, { capabilities: { tools: {} } });
26
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
27
- tools: getToolDefinitions(),
28
- }));
29
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
30
- const { name, arguments: args } = request.params;
31
- return handleToolCall(name, args);
32
- });
33
- await server.connect(transport);
34
- req.on('close', () => {
35
- console.log('Client disconnected');
36
- transports.delete(transport.sessionId);
37
- server.close();
38
- });
39
- });
40
- app.post('/mcp/messages', express.text(), async (req, res) => {
41
- const sessionId = req.query.sessionId;
42
- const transport = transports.get(sessionId);
43
- if (!transport) {
44
- res.status(404).end('Session not found');
45
- return;
46
- }
47
- await transport.handlePostMessage(req, res);
48
- });
49
- const server = app.listen(PORT, () => {
50
- console.log(`Moda MCP Server (HTTP) running on http://localhost:${PORT}`);
51
- console.log(` SSE endpoint: http://localhost:${PORT}/mcp/sse`);
52
- console.log(` Health check: http://localhost:${PORT}/health`);
53
- });
54
- function shutdown() {
55
- console.log('Shutting down...');
56
- for (const [id, transport] of transports) {
57
- try {
58
- transport.close?.();
59
- }
60
- catch {
61
- // ignore close errors during shutdown
62
- }
63
- transports.delete(id);
64
- }
65
- server.close(() => {
66
- console.log('Server stopped');
67
- process.exit(0);
68
- });
69
- // Force exit after 10s if connections don't close
70
- setTimeout(() => process.exit(1), 10_000).unref();
71
- }
72
- process.on('SIGTERM', shutdown);
73
- process.on('SIGINT', shutdown);
74
- //# sourceMappingURL=http-server.js.map
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
- import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
- import { validateConfig } from './config.js';
6
- import { getToolDefinitions } from './tools.js';
7
- import { handleToolCall } from './handlers.js';
8
- validateConfig();
9
- const server = new Server({ name: 'moda-data-api', version: '1.0.0' }, { capabilities: { tools: {} } });
10
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
11
- tools: getToolDefinitions(),
12
- }));
13
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
14
- const { name, arguments: args } = request.params;
15
- return handleToolCall(name, args);
16
- });
17
- async function main() {
18
- const transport = new StdioServerTransport();
19
- await server.connect(transport);
20
- console.error('Moda Data API MCP server running on stdio');
21
- }
22
- main().catch((error) => {
23
- console.error('Fatal error:', error);
24
- process.exit(1);
25
- });
26
- //# sourceMappingURL=index.js.map
package/dist/tools.d.ts DELETED
@@ -1,260 +0,0 @@
1
- export declare function getToolDefinitions(): ({
2
- name: string;
3
- description: string;
4
- inputSchema: {
5
- type: "object";
6
- properties: {
7
- days_back: {
8
- type: string;
9
- description: string;
10
- default: number;
11
- };
12
- parent_id?: undefined;
13
- time_range?: undefined;
14
- node_id?: undefined;
15
- limit?: undefined;
16
- offset?: undefined;
17
- search?: undefined;
18
- cluster_id?: undefined;
19
- user_id?: undefined;
20
- environment?: undefined;
21
- conversation_id?: undefined;
22
- msg_index?: undefined;
23
- window?: undefined;
24
- tool_name?: undefined;
25
- subtype?: undefined;
26
- };
27
- required?: undefined;
28
- };
29
- } | {
30
- name: string;
31
- description: string;
32
- inputSchema: {
33
- type: "object";
34
- properties: {
35
- parent_id: {
36
- type: string;
37
- description: string;
38
- };
39
- time_range: {
40
- type: string;
41
- enum: string[];
42
- description: string;
43
- default: string;
44
- };
45
- days_back?: undefined;
46
- node_id?: undefined;
47
- limit?: undefined;
48
- offset?: undefined;
49
- search?: undefined;
50
- cluster_id?: undefined;
51
- user_id?: undefined;
52
- environment?: undefined;
53
- conversation_id?: undefined;
54
- msg_index?: undefined;
55
- window?: undefined;
56
- tool_name?: undefined;
57
- subtype?: undefined;
58
- };
59
- required?: undefined;
60
- };
61
- } | {
62
- name: string;
63
- description: string;
64
- inputSchema: {
65
- type: "object";
66
- properties: {
67
- node_id: {
68
- type: string;
69
- description: string;
70
- };
71
- limit: {
72
- type: string;
73
- description: string;
74
- default: number;
75
- };
76
- offset: {
77
- type: string;
78
- description: string;
79
- default: number;
80
- };
81
- days_back?: undefined;
82
- parent_id?: undefined;
83
- time_range?: undefined;
84
- search?: undefined;
85
- cluster_id?: undefined;
86
- user_id?: undefined;
87
- environment?: undefined;
88
- conversation_id?: undefined;
89
- msg_index?: undefined;
90
- window?: undefined;
91
- tool_name?: undefined;
92
- subtype?: undefined;
93
- };
94
- required: string[];
95
- };
96
- } | {
97
- name: string;
98
- description: string;
99
- inputSchema: {
100
- type: "object";
101
- properties: {
102
- search: {
103
- type: string;
104
- description: string;
105
- };
106
- cluster_id: {
107
- type: string;
108
- description: string;
109
- };
110
- user_id: {
111
- type: string;
112
- description: string;
113
- };
114
- time_range: {
115
- type: string;
116
- enum: string[];
117
- description: string;
118
- default: string;
119
- };
120
- environment: {
121
- type: string;
122
- enum: string[];
123
- description: string;
124
- default: string;
125
- };
126
- limit: {
127
- type: string;
128
- description: string;
129
- default: number;
130
- };
131
- offset: {
132
- type: string;
133
- description: string;
134
- default: number;
135
- };
136
- days_back?: undefined;
137
- parent_id?: undefined;
138
- node_id?: undefined;
139
- conversation_id?: undefined;
140
- msg_index?: undefined;
141
- window?: undefined;
142
- tool_name?: undefined;
143
- subtype?: undefined;
144
- };
145
- required?: undefined;
146
- };
147
- } | {
148
- name: string;
149
- description: string;
150
- inputSchema: {
151
- type: "object";
152
- properties: {
153
- conversation_id: {
154
- type: string;
155
- description: string;
156
- };
157
- msg_index: {
158
- type: string;
159
- description: string;
160
- };
161
- window: {
162
- type: string;
163
- description: string;
164
- default: number;
165
- };
166
- days_back?: undefined;
167
- parent_id?: undefined;
168
- time_range?: undefined;
169
- node_id?: undefined;
170
- limit?: undefined;
171
- offset?: undefined;
172
- search?: undefined;
173
- cluster_id?: undefined;
174
- user_id?: undefined;
175
- environment?: undefined;
176
- tool_name?: undefined;
177
- subtype?: undefined;
178
- };
179
- required: string[];
180
- };
181
- } | {
182
- name: string;
183
- description: string;
184
- inputSchema: {
185
- type: "object";
186
- properties: {
187
- days_back: {
188
- type: string;
189
- description: string;
190
- default: number;
191
- };
192
- limit: {
193
- type: string;
194
- description: string;
195
- default: number;
196
- };
197
- offset: {
198
- type: string;
199
- description: string;
200
- default: number;
201
- };
202
- parent_id?: undefined;
203
- time_range?: undefined;
204
- node_id?: undefined;
205
- search?: undefined;
206
- cluster_id?: undefined;
207
- user_id?: undefined;
208
- environment?: undefined;
209
- conversation_id?: undefined;
210
- msg_index?: undefined;
211
- window?: undefined;
212
- tool_name?: undefined;
213
- subtype?: undefined;
214
- };
215
- required?: undefined;
216
- };
217
- } | {
218
- name: string;
219
- description: string;
220
- inputSchema: {
221
- type: "object";
222
- properties: {
223
- tool_name: {
224
- type: string;
225
- description: string;
226
- };
227
- subtype: {
228
- type: string;
229
- description: string;
230
- };
231
- days_back: {
232
- type: string;
233
- description: string;
234
- default: number;
235
- };
236
- limit: {
237
- type: string;
238
- description: string;
239
- default: number;
240
- };
241
- offset: {
242
- type: string;
243
- description: string;
244
- default: number;
245
- };
246
- parent_id?: undefined;
247
- time_range?: undefined;
248
- node_id?: undefined;
249
- search?: undefined;
250
- cluster_id?: undefined;
251
- user_id?: undefined;
252
- environment?: undefined;
253
- conversation_id?: undefined;
254
- msg_index?: undefined;
255
- window?: undefined;
256
- };
257
- required: string[];
258
- };
259
- })[];
260
- //# sourceMappingURL=tools.d.ts.map
package/dist/tools.js DELETED
@@ -1,133 +0,0 @@
1
- // src/tools.ts
2
- export function getToolDefinitions() {
3
- return [
4
- {
5
- name: 'moda_get_overview',
6
- description: 'Get dashboard overview with KPIs, top clusters, and recent activity. Start here to understand the current state of your conversations.',
7
- inputSchema: {
8
- type: 'object',
9
- properties: {
10
- days_back: {
11
- type: 'number',
12
- description: 'Number of days to look back (1-90)',
13
- default: 7,
14
- },
15
- },
16
- },
17
- },
18
- {
19
- name: 'moda_get_clusters',
20
- description: 'Browse the topic cluster hierarchy. Omit parent_id to get root-level categories, or provide it to drill down.',
21
- inputSchema: {
22
- type: 'object',
23
- properties: {
24
- parent_id: {
25
- type: 'string',
26
- description: 'Parent node ID to list children of (omit for root)',
27
- },
28
- time_range: {
29
- type: 'string',
30
- // FIX: expanded enum to match backend
31
- enum: ['all', '1h', '3d', '7d', '24h', '30d', '90d'],
32
- description: 'Time range filter',
33
- default: 'all',
34
- },
35
- },
36
- },
37
- },
38
- {
39
- name: 'moda_get_cluster_conversations',
40
- description: 'List conversations belonging to a specific cluster. Use node_id from cluster listing.',
41
- inputSchema: {
42
- type: 'object',
43
- properties: {
44
- node_id: { type: 'string', description: 'Cluster node ID' },
45
- limit: { type: 'number', description: 'Max results per page (1-100)', default: 10 },
46
- offset: { type: 'number', description: 'Pagination offset', default: 0 },
47
- },
48
- required: ['node_id'],
49
- },
50
- },
51
- {
52
- name: 'moda_search_conversations',
53
- // FIX: note that cluster_id filtering is not yet implemented in backend
54
- description: 'Search and filter conversations. Supports full-text search, filtering by user, time range, and environment.',
55
- inputSchema: {
56
- type: 'object',
57
- properties: {
58
- search: { type: 'string', description: 'Full-text search in summaries' },
59
- cluster_id: { type: 'string', description: 'Filter by cluster node ID (not yet implemented)' },
60
- user_id: { type: 'string', description: 'Filter by user ID' },
61
- time_range: {
62
- type: 'string',
63
- // FIX: add '3d' to match backend
64
- enum: ['all', '1h', '3d', '24h', '7d', '30d', '90d'],
65
- description: 'Time range filter',
66
- default: 'all',
67
- },
68
- environment: {
69
- type: 'string',
70
- enum: ['all', 'development', 'staging', 'production'],
71
- description: 'Environment filter',
72
- default: 'all',
73
- },
74
- limit: { type: 'number', description: 'Max results per page (1-100)', default: 20 },
75
- offset: { type: 'number', description: 'Pagination offset', default: 0 },
76
- },
77
- },
78
- },
79
- {
80
- name: 'moda_get_conversation_context',
81
- description: 'Get windowed conversation context (max 5 messages). Returns summary and messages around a center point.',
82
- inputSchema: {
83
- type: 'object',
84
- properties: {
85
- conversation_id: { type: 'string', description: 'Conversation ID' },
86
- msg_index: { type: 'number', description: 'Message index to center on (0-indexed, omit for middle)' },
87
- window: { type: 'number', description: 'Messages before and after center (1-5)', default: 2 },
88
- },
89
- required: ['conversation_id'],
90
- },
91
- },
92
- {
93
- name: 'moda_get_frustrations',
94
- description: 'Get user frustration detections with inline conversation evidence, signal breakdown, and user quotes. Returns frustrated + at-risk conversations.',
95
- inputSchema: {
96
- type: 'object',
97
- properties: {
98
- days_back: { type: 'number', description: 'Number of days to look back (1-90)', default: 7 },
99
- // FIX: corrected max from 100 to 20
100
- limit: { type: 'number', description: 'Max results per page (1-20)', default: 10 },
101
- offset: { type: 'number', description: 'Pagination offset', default: 0 },
102
- },
103
- },
104
- },
105
- {
106
- name: 'moda_get_tool_failures',
107
- description: 'Get tool failure overview showing which tools are failing and how much. Start here before drilling into specific tools.',
108
- inputSchema: {
109
- type: 'object',
110
- properties: {
111
- days_back: { type: 'number', description: 'Number of days to look back (1-90)', default: 7 },
112
- },
113
- },
114
- },
115
- {
116
- name: 'moda_get_tool_failure_detail',
117
- description: 'Get per-tool failure detail with subtype breakdown and examples with inline conversation context. Use tool_name from overview.',
118
- inputSchema: {
119
- type: 'object',
120
- properties: {
121
- tool_name: { type: 'string', description: 'Name of the tool to inspect' },
122
- subtype: { type: 'string', description: 'Filter by error subtype (optional)' },
123
- days_back: { type: 'number', description: 'Number of days to look back (1-90)', default: 7 },
124
- // FIX: corrected max from 100 to 20
125
- limit: { type: 'number', description: 'Max examples to return (1-20)', default: 5 },
126
- offset: { type: 'number', description: 'Pagination offset', default: 0 },
127
- },
128
- required: ['tool_name'],
129
- },
130
- },
131
- ];
132
- }
133
- //# sourceMappingURL=tools.js.map
package/dist/worker.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export interface Env {
2
- MODA_API_KEY: string;
3
- MODA_BASE_URL: string;
4
- }
5
- declare const _default: {
6
- fetch(request: Request, env: Env): Promise<Response>;
7
- };
8
- export default _default;
9
- //# sourceMappingURL=worker.d.ts.map
package/dist/worker.js DELETED
@@ -1,24 +0,0 @@
1
- // src/worker.ts
2
- // Cloudflare Workers entry point for the MCP HTTP/SSE transport.
3
- //
4
- // NOTE: The MCP SDK's SSEServerTransport expects an Express Response object,
5
- // which is incompatible with the Cloudflare Workers fetch handler model.
6
- // Full SSE support requires either the MCP SDK's StreamableHTTPServerTransport
7
- // or a custom adapter. This file provides the skeleton and a /health endpoint
8
- // that works today; SSE transport implementation is tracked as a follow-up.
9
- import { getToolDefinitions } from './tools.js';
10
- export default {
11
- async fetch(request, env) {
12
- const url = new URL(request.url);
13
- if (url.pathname === '/health') {
14
- return new Response(JSON.stringify({ status: 'ok', service: 'moda-mcp' }), { headers: { 'Content-Type': 'application/json' } });
15
- }
16
- if (url.pathname === '/tools' && request.method === 'GET') {
17
- return new Response(JSON.stringify({ tools: getToolDefinitions() }), { headers: { 'Content-Type': 'application/json' } });
18
- }
19
- // SSE/MCP streaming transport handling is deferred pending SDK compatibility
20
- // investigation. See Phase 3 open question in implementation plan.
21
- return new Response('Not Found', { status: 404 });
22
- },
23
- };
24
- //# sourceMappingURL=worker.js.map
@@ -1,12 +0,0 @@
1
- {
2
- "mcpServers": {
3
- "moda-data-api": {
4
- "command": "node",
5
- "args": ["/absolute/path/to/apps/moda-cli/dist/index.js"],
6
- "env": {
7
- "MODA_API_KEY": "moda_sk_your_api_key_here"
8
- },
9
- "comment": "Uses production API (https://modaflows.com) by default. For local dev, add: \"MODA_BASE_URL\": \"http://localhost:3001\""
10
- }
11
- }
12
- }