nana800-mcp-server 1.0.5 → 1.2.0
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/LICENSE +22 -0
- package/README.md +47 -9
- package/dist/index.js +298 -124
- package/package.json +16 -18
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Bekender
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -31,7 +31,8 @@ Add to your `~/.cursor/mcp.json`:
|
|
|
31
31
|
"env": {
|
|
32
32
|
"MCP_API_KEY": "your_api_key_here",
|
|
33
33
|
"MCP_PROJECT_ID": "your_default_project_id",
|
|
34
|
-
"MCP_SCHEME_ID": "your_default_scheme_id"
|
|
34
|
+
"MCP_SCHEME_ID": "your_default_scheme_id",
|
|
35
|
+
"MCP_ANALYTICS_ORG_ID": "your_default_analytics_org_id"
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -51,7 +52,8 @@ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_
|
|
|
51
52
|
"env": {
|
|
52
53
|
"MCP_API_KEY": "your_api_key_here",
|
|
53
54
|
"MCP_PROJECT_ID": "your_default_project_id",
|
|
54
|
-
"MCP_SCHEME_ID": "your_default_scheme_id"
|
|
55
|
+
"MCP_SCHEME_ID": "your_default_scheme_id",
|
|
56
|
+
"MCP_ANALYTICS_ORG_ID": "your_default_analytics_org_id"
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -71,7 +73,8 @@ Add to your extension settings:
|
|
|
71
73
|
"env": {
|
|
72
74
|
"MCP_API_KEY": "your_api_key_here",
|
|
73
75
|
"MCP_PROJECT_ID": "your_default_project_id",
|
|
74
|
-
"MCP_SCHEME_ID": "your_default_scheme_id"
|
|
76
|
+
"MCP_SCHEME_ID": "your_default_scheme_id",
|
|
77
|
+
"MCP_ANALYTICS_ORG_ID": "your_default_analytics_org_id"
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
}
|
|
@@ -85,6 +88,11 @@ Add to your extension settings:
|
|
|
85
88
|
| `MCP_API_KEY` | Yes | Your nana800.io API key |
|
|
86
89
|
| `MCP_PROJECT_ID` | No | Default project ID (can be overridden per tool call) |
|
|
87
90
|
| `MCP_SCHEME_ID` | No | Default scheme ID (can be overridden per tool call) |
|
|
91
|
+
| `MCP_API_URL` | No | API origin, `https://api.nana800.io` by default |
|
|
92
|
+
| `MCP_ANALYTICS_ORG_ID` | No | Default analytics org ID (can be overridden per tool call), get it with `analytics_orgs_list` or from the `org` parameter in the analytics page URL |
|
|
93
|
+
| `MCP_ANALYTICS_API_URL` | No | Analytics API origin, `https://api.analytics.nana800.io` by default |
|
|
94
|
+
|
|
95
|
+
Every API request has a 30 second timeout. Requires Node.js 18 or newer.
|
|
88
96
|
|
|
89
97
|
## Available Tools
|
|
90
98
|
|
|
@@ -105,7 +113,7 @@ Add to your extension settings:
|
|
|
105
113
|
| `scheme_create` | Create a new scheme (workflow) |
|
|
106
114
|
| `scheme_get` | Get scheme details |
|
|
107
115
|
| `scheme_list_by_project` | List all schemes in a project |
|
|
108
|
-
| `scheme_update` | Update scheme
|
|
116
|
+
| `scheme_update` | Update scheme name, description and enable or disable it |
|
|
109
117
|
| `scheme_delete` | Delete a scheme |
|
|
110
118
|
| `scheme_export` | Export scheme as JSON |
|
|
111
119
|
| `scheme_import` | Import nodes into a scheme |
|
|
@@ -116,6 +124,7 @@ Add to your extension settings:
|
|
|
116
124
|
|
|
117
125
|
| Tool | Description |
|
|
118
126
|
|------|-------------|
|
|
127
|
+
| `get_nodes_info` | List available trigger and action types with their configuration |
|
|
119
128
|
| `node_create_trigger` | Create a trigger node |
|
|
120
129
|
| `node_create_action` | Create an action node |
|
|
121
130
|
| `node_get` | Get node details |
|
|
@@ -123,7 +132,7 @@ Add to your extension settings:
|
|
|
123
132
|
| `node_update` | Update node properties |
|
|
124
133
|
| `node_update_config` | Update node configuration |
|
|
125
134
|
| `node_delete` | Delete a node |
|
|
126
|
-
| `node_connect` | Connect two nodes |
|
|
135
|
+
| `node_connect` | Connect two nodes (for condition nodes `connection_index` 0 is the "true" output, 1 is the "false" output) |
|
|
127
136
|
| `node_disconnect` | Disconnect two nodes |
|
|
128
137
|
| `node_copy` | Copy a node |
|
|
129
138
|
| `node_get_scheme_edges` | Get all connections in a scheme |
|
|
@@ -134,7 +143,7 @@ Add to your extension settings:
|
|
|
134
143
|
| Tool | Description |
|
|
135
144
|
|------|-------------|
|
|
136
145
|
| `node_process_get` | Get node process details |
|
|
137
|
-
| `node_process_list_filtered` | List node processes
|
|
146
|
+
| `node_process_list_filtered` | List node processes, filter by scheme, node or scheme process is required |
|
|
138
147
|
| `node_process_delete` | Delete a node process record |
|
|
139
148
|
|
|
140
149
|
### Scheme Process Management
|
|
@@ -142,7 +151,7 @@ Add to your extension settings:
|
|
|
142
151
|
| Tool | Description |
|
|
143
152
|
|------|-------------|
|
|
144
153
|
| `scheme_process_get` | Get scheme process details |
|
|
145
|
-
| `scheme_process_list_filtered` | List scheme processes
|
|
154
|
+
| `scheme_process_list_filtered` | List scheme processes, filter by scheme or project is required |
|
|
146
155
|
| `scheme_process_delete` | Delete a scheme process record |
|
|
147
156
|
|
|
148
157
|
### Payment Account Management
|
|
@@ -151,10 +160,38 @@ Add to your extension settings:
|
|
|
151
160
|
|------|-------------|
|
|
152
161
|
| `payment_account_get_by_user` | Get payment account by user ID |
|
|
153
162
|
| `payment_account_get_by_project` | Get payment account by project ID |
|
|
154
|
-
| `payment_account_update` | Update payment account
|
|
163
|
+
| `payment_account_update` | Update payment account name and automatic balance refill |
|
|
155
164
|
| `payment_account_remove` | Remove payment account |
|
|
156
165
|
| `payment_account_get_transactions` | Get transaction history |
|
|
157
166
|
|
|
167
|
+
### Analytics Data Export
|
|
168
|
+
|
|
169
|
+
The API key user must be a member of the analytics org. The org ID (`org_id`) comes from `analytics_orgs_list`, the `MCP_ANALYTICS_ORG_ID` env variable or the `org` parameter in the analytics page URL. Exports run in the background and the tools return only the status and a download link, never the rows.
|
|
170
|
+
|
|
171
|
+
| Tool | Description |
|
|
172
|
+
|------|-------------|
|
|
173
|
+
| `analytics_orgs_list` | List analytics orgs the API key owner is a member of |
|
|
174
|
+
| `analytics_projects_list` | List app projects of an analytics org |
|
|
175
|
+
| `analytics_event_types_list` | List tracked event types of an app project, for export filters |
|
|
176
|
+
| `analytics_export_create` | Start an export of events (`EVENTS`), events of one user (`USER_EVENTS`) or users (`USERS`) to CSV or JSONL |
|
|
177
|
+
| `analytics_export_status` | Get export status (`QUEUED`, `RUNNING`, `DONE`, `FAILED`) and the download link when it is done |
|
|
178
|
+
| `analytics_exports_list` | List the 20 newest exports of an org |
|
|
179
|
+
|
|
180
|
+
Export limits:
|
|
181
|
+
|
|
182
|
+
- Up to 1,000,000 rows per file, `is_truncated` is `true` when more rows matched
|
|
183
|
+
- One active export per org, 10 exports per org per hour, exports started with an API key: one per 10 minutes per org
|
|
184
|
+
- `time_from` and `time_to` are ISO 8601 date-times with a timezone, e.g. `2026-10-01T00:00:00.000Z`
|
|
185
|
+
- Poll `analytics_export_status` not more often than once per ~10 seconds
|
|
186
|
+
- The download link is valid for 15 minutes, call `analytics_export_status` again for a fresh one
|
|
187
|
+
- Files are deleted after 7 days
|
|
188
|
+
|
|
189
|
+
The file is served gzipped (`Content-Encoding: gzip`). A browser saves plain CSV or JSONL, from a shell use:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
curl --compressed -o export.csv "<download_url>"
|
|
193
|
+
```
|
|
194
|
+
|
|
158
195
|
## Usage Examples
|
|
159
196
|
|
|
160
197
|
Once configured, you can ask your AI assistant things like:
|
|
@@ -165,10 +202,11 @@ Once configured, you can ask your AI assistant things like:
|
|
|
165
202
|
- "Connect the webhook trigger to the email action"
|
|
166
203
|
- "Export the scheme configuration"
|
|
167
204
|
- "What processes are currently running?"
|
|
205
|
+
- "Export all purchase events of the last week to CSV and give me the download link"
|
|
168
206
|
|
|
169
207
|
## API Documentation
|
|
170
208
|
|
|
171
|
-
Full API documentation available at: [https://api.nana800.io/
|
|
209
|
+
Full API documentation available at: [https://api.nana800.io/public-api](https://api.nana800.io/public-api)
|
|
172
210
|
|
|
173
211
|
## License
|
|
174
212
|
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,14 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
|
|
10
10
|
// src/api-client.ts
|
|
11
|
-
var API_BASE_URL = "https://api.nana800.io";
|
|
11
|
+
var API_BASE_URL = (process.env.MCP_API_URL || "https://api.nana800.io").replace(/\/+$/, "");
|
|
12
|
+
var ANALYTICS_API_BASE_URL = (process.env.MCP_ANALYTICS_API_URL || "https://api.analytics.nana800.io").replace(/\/+$/, "");
|
|
12
13
|
var API_KEY_HEADER = "x-nana-api-key";
|
|
14
|
+
var REQUEST_TIMEOUT_MS = 3e4;
|
|
15
|
+
var MAX_ERROR_TEXT_LENGTH = 2e3;
|
|
13
16
|
var DEFAULT_PROJECT_ID = process.env.MCP_PROJECT_ID || "";
|
|
14
17
|
var DEFAULT_SCHEME_ID = process.env.MCP_SCHEME_ID || "";
|
|
18
|
+
var DEFAULT_ANALYTICS_ORG_ID = process.env.MCP_ANALYTICS_ORG_ID || "";
|
|
15
19
|
var getProjectId = (providedId) => {
|
|
16
20
|
const id = providedId || DEFAULT_PROJECT_ID;
|
|
17
21
|
if (!id) {
|
|
@@ -26,109 +30,98 @@ var getSchemeId = (providedId) => {
|
|
|
26
30
|
}
|
|
27
31
|
return id;
|
|
28
32
|
};
|
|
33
|
+
var getAnalyticsOrgId = (providedId) => {
|
|
34
|
+
const id = providedId || DEFAULT_ANALYTICS_ORG_ID;
|
|
35
|
+
if (!id) {
|
|
36
|
+
throw new Error("org_id is required. Provide it as parameter or set MCP_ANALYTICS_ORG_ID env variable");
|
|
37
|
+
}
|
|
38
|
+
return id;
|
|
39
|
+
};
|
|
40
|
+
var apiPath = (strings, ...values) => {
|
|
41
|
+
return strings.reduce((path, part, index) => path + part + (index < values.length ? encodeURIComponent(values[index]) : ""), "");
|
|
42
|
+
};
|
|
43
|
+
var getErrorMessage = (error) => {
|
|
44
|
+
if (error instanceof Error) {
|
|
45
|
+
return error.name === "TimeoutError" || error.name === "AbortError" ? `request timed out after ${REQUEST_TIMEOUT_MS / 1e3}s` : error.message;
|
|
46
|
+
}
|
|
47
|
+
return "Unknown error";
|
|
48
|
+
};
|
|
29
49
|
var ApiClient = class {
|
|
30
50
|
apiKey;
|
|
31
|
-
|
|
51
|
+
baseUrl;
|
|
52
|
+
constructor(apiKey, baseUrl) {
|
|
32
53
|
this.apiKey = apiKey;
|
|
54
|
+
this.baseUrl = baseUrl;
|
|
55
|
+
}
|
|
56
|
+
get(path, queryParams) {
|
|
57
|
+
return this.request("GET", path, { query: queryParams });
|
|
58
|
+
}
|
|
59
|
+
post(path, body) {
|
|
60
|
+
return this.request("POST", path, { body });
|
|
33
61
|
}
|
|
34
|
-
|
|
62
|
+
put(path, body) {
|
|
63
|
+
return this.request("PUT", path, { body });
|
|
64
|
+
}
|
|
65
|
+
delete(path) {
|
|
66
|
+
return this.request("DELETE", path, {});
|
|
67
|
+
}
|
|
68
|
+
async request(method, path, { query, body }) {
|
|
35
69
|
try {
|
|
36
|
-
const url = new URL(`${
|
|
37
|
-
if (
|
|
38
|
-
Object.entries(
|
|
70
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
71
|
+
if (query) {
|
|
72
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
39
73
|
if (value !== void 0) {
|
|
40
74
|
url.searchParams.append(key, String(value));
|
|
41
75
|
}
|
|
42
76
|
});
|
|
43
77
|
}
|
|
44
78
|
const response = await fetch(url.toString(), {
|
|
45
|
-
method
|
|
46
|
-
headers: {
|
|
47
|
-
[API_KEY_HEADER]: this.apiKey,
|
|
48
|
-
"Content-Type": "application/json"
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (!response.ok) {
|
|
52
|
-
const errorText = await response.text();
|
|
53
|
-
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
|
54
|
-
}
|
|
55
|
-
const data = await response.json();
|
|
56
|
-
return { success: true, data };
|
|
57
|
-
} catch (error) {
|
|
58
|
-
return { success: false, error: error instanceof Error ? error.message : "Unknown error" };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async post(path, body) {
|
|
62
|
-
try {
|
|
63
|
-
const response = await fetch(`${API_BASE_URL}${path}`, {
|
|
64
|
-
method: "POST",
|
|
79
|
+
method,
|
|
65
80
|
headers: {
|
|
66
81
|
[API_KEY_HEADER]: this.apiKey,
|
|
67
82
|
"Content-Type": "application/json"
|
|
68
83
|
},
|
|
69
|
-
body: body ? JSON.stringify(body) : void 0
|
|
84
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
85
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
70
86
|
});
|
|
87
|
+
const text = await response.text();
|
|
71
88
|
if (!response.ok) {
|
|
72
|
-
|
|
73
|
-
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
|
89
|
+
return { success: false, error: `HTTP ${response.status}: ${text.slice(0, MAX_ERROR_TEXT_LENGTH)}` };
|
|
74
90
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} catch (error) {
|
|
78
|
-
return { success: false, error: error instanceof Error ? error.message : "Unknown error" };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async put(path, body) {
|
|
82
|
-
try {
|
|
83
|
-
const response = await fetch(`${API_BASE_URL}${path}`, {
|
|
84
|
-
method: "PUT",
|
|
85
|
-
headers: {
|
|
86
|
-
[API_KEY_HEADER]: this.apiKey,
|
|
87
|
-
"Content-Type": "application/json"
|
|
88
|
-
},
|
|
89
|
-
body: body ? JSON.stringify(body) : void 0
|
|
90
|
-
});
|
|
91
|
-
if (!response.ok) {
|
|
92
|
-
const errorText = await response.text();
|
|
93
|
-
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
|
91
|
+
if (!text) {
|
|
92
|
+
return { success: true, data: null };
|
|
94
93
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async delete(path) {
|
|
102
|
-
try {
|
|
103
|
-
const response = await fetch(`${API_BASE_URL}${path}`, {
|
|
104
|
-
method: "DELETE",
|
|
105
|
-
headers: {
|
|
106
|
-
[API_KEY_HEADER]: this.apiKey,
|
|
107
|
-
"Content-Type": "application/json"
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
const errorText = await response.text();
|
|
112
|
-
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
|
94
|
+
try {
|
|
95
|
+
return { success: true, data: JSON.parse(text) };
|
|
96
|
+
} catch {
|
|
97
|
+
return { success: true, data: text };
|
|
113
98
|
}
|
|
114
|
-
const data = await response.json();
|
|
115
|
-
return { success: true, data };
|
|
116
99
|
} catch (error) {
|
|
117
|
-
return { success: false, error: error
|
|
100
|
+
return { success: false, error: getErrorMessage(error) };
|
|
118
101
|
}
|
|
119
102
|
}
|
|
120
103
|
};
|
|
121
104
|
var apiClientInstance = null;
|
|
105
|
+
var analyticsApiClientInstance = null;
|
|
106
|
+
var getApiKey = () => {
|
|
107
|
+
const apiKey = process.env.MCP_API_KEY;
|
|
108
|
+
if (!apiKey) {
|
|
109
|
+
throw new Error("MCP_API_KEY environment variable is not set");
|
|
110
|
+
}
|
|
111
|
+
return apiKey;
|
|
112
|
+
};
|
|
122
113
|
var getApiClient = () => {
|
|
123
114
|
if (!apiClientInstance) {
|
|
124
|
-
|
|
125
|
-
if (!apiKey) {
|
|
126
|
-
throw new Error("MCP_API_KEY environment variable is not set");
|
|
127
|
-
}
|
|
128
|
-
apiClientInstance = new ApiClient(apiKey);
|
|
115
|
+
apiClientInstance = new ApiClient(getApiKey(), API_BASE_URL);
|
|
129
116
|
}
|
|
130
117
|
return apiClientInstance;
|
|
131
118
|
};
|
|
119
|
+
var getAnalyticsApiClient = () => {
|
|
120
|
+
if (!analyticsApiClientInstance) {
|
|
121
|
+
analyticsApiClientInstance = new ApiClient(getApiKey(), ANALYTICS_API_BASE_URL);
|
|
122
|
+
}
|
|
123
|
+
return analyticsApiClientInstance;
|
|
124
|
+
};
|
|
132
125
|
|
|
133
126
|
// src/tools/project.tools.ts
|
|
134
127
|
var registerProjectTools = (server) => {
|
|
@@ -158,7 +151,7 @@ var registerProjectTools = (server) => {
|
|
|
158
151
|
try {
|
|
159
152
|
const resolvedProjectId = getProjectId(project_id);
|
|
160
153
|
const client = getApiClient();
|
|
161
|
-
const result = await client.get(`/project/get/${resolvedProjectId}`);
|
|
154
|
+
const result = await client.get(apiPath`/project/get/${resolvedProjectId}`);
|
|
162
155
|
return {
|
|
163
156
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
164
157
|
};
|
|
@@ -177,7 +170,7 @@ var registerProjectTools = (server) => {
|
|
|
177
170
|
},
|
|
178
171
|
async ({ payment_account_id }) => {
|
|
179
172
|
const client = getApiClient();
|
|
180
|
-
const result = await client.get(`/project/get_list_by_payment_account/${payment_account_id}`);
|
|
173
|
+
const result = await client.get(apiPath`/project/get_list_by_payment_account/${payment_account_id}`);
|
|
181
174
|
return {
|
|
182
175
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
183
176
|
};
|
|
@@ -198,7 +191,7 @@ var registerProjectTools = (server) => {
|
|
|
198
191
|
const body = {};
|
|
199
192
|
if (project_name) body.project_name = project_name;
|
|
200
193
|
if (project_slug) body.project_slug = project_slug;
|
|
201
|
-
const result = await client.put(`/project/update/${resolvedProjectId}`, body);
|
|
194
|
+
const result = await client.put(apiPath`/project/update/${resolvedProjectId}`, body);
|
|
202
195
|
return {
|
|
203
196
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
204
197
|
};
|
|
@@ -219,7 +212,7 @@ var registerProjectTools = (server) => {
|
|
|
219
212
|
try {
|
|
220
213
|
const resolvedProjectId = getProjectId(project_id);
|
|
221
214
|
const client = getApiClient();
|
|
222
|
-
const result = await client.delete(`/project/delete/${resolvedProjectId}`);
|
|
215
|
+
const result = await client.delete(apiPath`/project/delete/${resolvedProjectId}`);
|
|
223
216
|
return {
|
|
224
217
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
225
218
|
};
|
|
@@ -263,18 +256,18 @@ var registerSchemeTools = (server) => {
|
|
|
263
256
|
{
|
|
264
257
|
scheme_id: z2.string().optional().describe("The unique ID of the scheme to update (uses MCP_SCHEME_ID env if not provided)"),
|
|
265
258
|
scheme_name: z2.string().optional().describe("New name for the scheme"),
|
|
266
|
-
|
|
267
|
-
|
|
259
|
+
description: z2.string().optional().describe("New description for the scheme"),
|
|
260
|
+
enabled: z2.boolean().optional().describe("Enable or disable the scheme")
|
|
268
261
|
},
|
|
269
|
-
async ({ scheme_id, scheme_name,
|
|
262
|
+
async ({ scheme_id, scheme_name, description, enabled }) => {
|
|
270
263
|
try {
|
|
271
264
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
272
265
|
const client = getApiClient();
|
|
273
266
|
const body = {};
|
|
274
267
|
if (scheme_name !== void 0) body.scheme_name = scheme_name;
|
|
275
|
-
if (
|
|
276
|
-
if (
|
|
277
|
-
const result = await client.put(`/scheme/update/${resolvedSchemeId}`, body);
|
|
268
|
+
if (description !== void 0) body.description = description;
|
|
269
|
+
if (enabled !== void 0) body.enabled = enabled;
|
|
270
|
+
const result = await client.put(apiPath`/scheme/update/${resolvedSchemeId}`, body);
|
|
278
271
|
return {
|
|
279
272
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
280
273
|
};
|
|
@@ -295,7 +288,7 @@ var registerSchemeTools = (server) => {
|
|
|
295
288
|
try {
|
|
296
289
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
297
290
|
const client = getApiClient();
|
|
298
|
-
const result = await client.get(`/scheme/get/${resolvedSchemeId}`);
|
|
291
|
+
const result = await client.get(apiPath`/scheme/get/${resolvedSchemeId}`);
|
|
299
292
|
return {
|
|
300
293
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
301
294
|
};
|
|
@@ -316,7 +309,7 @@ var registerSchemeTools = (server) => {
|
|
|
316
309
|
try {
|
|
317
310
|
const resolvedProjectId = getProjectId(project_id);
|
|
318
311
|
const client = getApiClient();
|
|
319
|
-
const result = await client.get(`/scheme/project_list/${resolvedProjectId}`);
|
|
312
|
+
const result = await client.get(apiPath`/scheme/project_list/${resolvedProjectId}`);
|
|
320
313
|
return {
|
|
321
314
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
322
315
|
};
|
|
@@ -337,7 +330,7 @@ var registerSchemeTools = (server) => {
|
|
|
337
330
|
try {
|
|
338
331
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
339
332
|
const client = getApiClient();
|
|
340
|
-
const result = await client.get(`/scheme/context_type/${resolvedSchemeId}`);
|
|
333
|
+
const result = await client.get(apiPath`/scheme/context_type/${resolvedSchemeId}`);
|
|
341
334
|
return {
|
|
342
335
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
343
336
|
};
|
|
@@ -358,7 +351,7 @@ var registerSchemeTools = (server) => {
|
|
|
358
351
|
try {
|
|
359
352
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
360
353
|
const client = getApiClient();
|
|
361
|
-
const result = await client.get(`/scheme/swagger_json/${resolvedSchemeId}`);
|
|
354
|
+
const result = await client.get(apiPath`/scheme/swagger_json/${resolvedSchemeId}`);
|
|
362
355
|
return {
|
|
363
356
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
364
357
|
};
|
|
@@ -379,7 +372,7 @@ var registerSchemeTools = (server) => {
|
|
|
379
372
|
try {
|
|
380
373
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
381
374
|
const client = getApiClient();
|
|
382
|
-
const result = await client.get(`/scheme/export/${resolvedSchemeId}`);
|
|
375
|
+
const result = await client.get(apiPath`/scheme/export/${resolvedSchemeId}`);
|
|
383
376
|
return {
|
|
384
377
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
385
378
|
};
|
|
@@ -409,7 +402,7 @@ var registerSchemeTools = (server) => {
|
|
|
409
402
|
content: [{ type: "text", text: JSON.stringify({ success: false, error: "Invalid JSON in nodes_list" }, null, 2) }]
|
|
410
403
|
};
|
|
411
404
|
}
|
|
412
|
-
const result = await client.post(`/scheme/import/${resolvedSchemeId}`, { nodes_list: parsedNodes });
|
|
405
|
+
const result = await client.post(apiPath`/scheme/import/${resolvedSchemeId}`, { nodes_list: parsedNodes });
|
|
413
406
|
return {
|
|
414
407
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
415
408
|
};
|
|
@@ -430,7 +423,7 @@ var registerSchemeTools = (server) => {
|
|
|
430
423
|
try {
|
|
431
424
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
432
425
|
const client = getApiClient();
|
|
433
|
-
const result = await client.delete(`/scheme/delete/${resolvedSchemeId}`);
|
|
426
|
+
const result = await client.delete(apiPath`/scheme/delete/${resolvedSchemeId}`);
|
|
434
427
|
return {
|
|
435
428
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
436
429
|
};
|
|
@@ -450,6 +443,9 @@ var getNodesInfo = async () => {
|
|
|
450
443
|
if (cachedNodesInfo) return cachedNodesInfo;
|
|
451
444
|
const client = getApiClient();
|
|
452
445
|
const response = await client.get("/info/nodes_info");
|
|
446
|
+
if (!response.success || !Array.isArray(response.data?.trigger_types) || !Array.isArray(response.data?.action_types)) {
|
|
447
|
+
throw new Error(`Failed to load available node types: ${response.error || "unexpected response"}`);
|
|
448
|
+
}
|
|
453
449
|
cachedNodesInfo = response.data;
|
|
454
450
|
return cachedNodesInfo;
|
|
455
451
|
};
|
|
@@ -561,7 +557,7 @@ var registerNodeTools = (server) => {
|
|
|
561
557
|
const body = {};
|
|
562
558
|
if (slug !== void 0) body.slug = slug;
|
|
563
559
|
if (description !== void 0) body.description = description;
|
|
564
|
-
const result = await client.put(`/node/update/${node_id}`, body);
|
|
560
|
+
const result = await client.put(apiPath`/node/update/${node_id}`, body);
|
|
565
561
|
return {
|
|
566
562
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
567
563
|
};
|
|
@@ -573,12 +569,14 @@ var registerNodeTools = (server) => {
|
|
|
573
569
|
{
|
|
574
570
|
node_from: z3.string().describe("The source node ID (execution flows from this node)"),
|
|
575
571
|
node_to: z3.string().describe("The target node ID (execution flows to this node)"),
|
|
576
|
-
|
|
572
|
+
connection_index: z3.number().int().min(0).optional().describe('Output of the source node to connect. For CONDITION nodes: 0 is the "true" output, 1 is the "false" output. Default 0'),
|
|
573
|
+
edge_type: z3.enum(["COMMON", "CONDITION", "SWITCH"]).optional().describe("Type of the connection, CONDITION for outputs of condition nodes")
|
|
577
574
|
},
|
|
578
|
-
async ({ node_from, node_to,
|
|
575
|
+
async ({ node_from, node_to, connection_index, edge_type }) => {
|
|
579
576
|
const client = getApiClient();
|
|
580
577
|
const body = { node_from, node_to };
|
|
581
|
-
if (
|
|
578
|
+
if (connection_index !== void 0) body.connection_index = connection_index;
|
|
579
|
+
if (edge_type !== void 0) body.edge_type = edge_type;
|
|
582
580
|
const result = await client.put("/node/connect_nodes", body);
|
|
583
581
|
return {
|
|
584
582
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
@@ -608,7 +606,7 @@ var registerNodeTools = (server) => {
|
|
|
608
606
|
},
|
|
609
607
|
async ({ node_id }) => {
|
|
610
608
|
const client = getApiClient();
|
|
611
|
-
const result = await client.get(`/node/find_existing_button_from/${node_id}`);
|
|
609
|
+
const result = await client.get(apiPath`/node/find_existing_button_from/${node_id}`);
|
|
612
610
|
return {
|
|
613
611
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
614
612
|
};
|
|
@@ -622,7 +620,7 @@ var registerNodeTools = (server) => {
|
|
|
622
620
|
},
|
|
623
621
|
async ({ node_id }) => {
|
|
624
622
|
const client = getApiClient();
|
|
625
|
-
const result = await client.post(`/node/copy_node_create/${node_id}`);
|
|
623
|
+
const result = await client.post(apiPath`/node/copy_node_create/${node_id}`);
|
|
626
624
|
return {
|
|
627
625
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
628
626
|
};
|
|
@@ -638,7 +636,7 @@ var registerNodeTools = (server) => {
|
|
|
638
636
|
try {
|
|
639
637
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
640
638
|
const client = getApiClient();
|
|
641
|
-
const result = await client.get(`/node/scheme_node_edges_list/${resolvedSchemeId}`);
|
|
639
|
+
const result = await client.get(apiPath`/node/scheme_node_edges_list/${resolvedSchemeId}`);
|
|
642
640
|
return {
|
|
643
641
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
644
642
|
};
|
|
@@ -657,7 +655,7 @@ var registerNodeTools = (server) => {
|
|
|
657
655
|
},
|
|
658
656
|
async ({ node_id }) => {
|
|
659
657
|
const client = getApiClient();
|
|
660
|
-
const result = await client.get(`/node/get/${node_id}`);
|
|
658
|
+
const result = await client.get(apiPath`/node/get/${node_id}`);
|
|
661
659
|
return {
|
|
662
660
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
663
661
|
};
|
|
@@ -680,7 +678,7 @@ var registerNodeTools = (server) => {
|
|
|
680
678
|
content: [{ type: "text", text: JSON.stringify({ success: false, error: "Invalid JSON in config" }, null, 2) }]
|
|
681
679
|
};
|
|
682
680
|
}
|
|
683
|
-
const result = await client.put(`/node/update_config/${node_id}`, parsedConfig);
|
|
681
|
+
const result = await client.put(apiPath`/node/update_config/${node_id}`, parsedConfig);
|
|
684
682
|
return {
|
|
685
683
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
686
684
|
};
|
|
@@ -696,7 +694,7 @@ var registerNodeTools = (server) => {
|
|
|
696
694
|
try {
|
|
697
695
|
const resolvedSchemeId = getSchemeId(scheme_id);
|
|
698
696
|
const client = getApiClient();
|
|
699
|
-
const result = await client.get(`/node/scheme_list/${resolvedSchemeId}`);
|
|
697
|
+
const result = await client.get(apiPath`/node/scheme_list/${resolvedSchemeId}`);
|
|
700
698
|
return {
|
|
701
699
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
702
700
|
};
|
|
@@ -715,7 +713,7 @@ var registerNodeTools = (server) => {
|
|
|
715
713
|
},
|
|
716
714
|
async ({ node_id }) => {
|
|
717
715
|
const client = getApiClient();
|
|
718
|
-
const result = await client.delete(`/node/delete/${node_id}`);
|
|
716
|
+
const result = await client.delete(apiPath`/node/delete/${node_id}`);
|
|
719
717
|
return {
|
|
720
718
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
721
719
|
};
|
|
@@ -734,7 +732,7 @@ var registerNodeProcessTools = (server) => {
|
|
|
734
732
|
},
|
|
735
733
|
async ({ node_process_id }) => {
|
|
736
734
|
const client = getApiClient();
|
|
737
|
-
const result = await client.get(`/node-process/get/${node_process_id}`);
|
|
735
|
+
const result = await client.get(apiPath`/node-process/get/${node_process_id}`);
|
|
738
736
|
return {
|
|
739
737
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
740
738
|
};
|
|
@@ -742,7 +740,7 @@ var registerNodeProcessTools = (server) => {
|
|
|
742
740
|
);
|
|
743
741
|
server.tool(
|
|
744
742
|
"node_process_list_filtered",
|
|
745
|
-
"Get filtered list of node processes with pagination",
|
|
743
|
+
"Get filtered list of node processes with pagination. At least one of scheme, node or scheme_process is required",
|
|
746
744
|
{
|
|
747
745
|
scheme: z4.string().optional().describe("Filter by scheme ID"),
|
|
748
746
|
node: z4.string().optional().describe("Filter by node ID"),
|
|
@@ -776,7 +774,7 @@ var registerNodeProcessTools = (server) => {
|
|
|
776
774
|
},
|
|
777
775
|
async ({ node_process_id }) => {
|
|
778
776
|
const client = getApiClient();
|
|
779
|
-
const result = await client.delete(`/node-process/delete/${node_process_id}`);
|
|
777
|
+
const result = await client.delete(apiPath`/node-process/delete/${node_process_id}`);
|
|
780
778
|
return {
|
|
781
779
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
782
780
|
};
|
|
@@ -795,7 +793,7 @@ var registerSchemeProcessTools = (server) => {
|
|
|
795
793
|
},
|
|
796
794
|
async ({ scheme_process_id }) => {
|
|
797
795
|
const client = getApiClient();
|
|
798
|
-
const result = await client.get(`/scheme-process/get/${scheme_process_id}`);
|
|
796
|
+
const result = await client.get(apiPath`/scheme-process/get/${scheme_process_id}`);
|
|
799
797
|
return {
|
|
800
798
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
801
799
|
};
|
|
@@ -803,7 +801,7 @@ var registerSchemeProcessTools = (server) => {
|
|
|
803
801
|
);
|
|
804
802
|
server.tool(
|
|
805
803
|
"scheme_process_list_filtered",
|
|
806
|
-
"Get filtered list of scheme processes (workflow executions) with pagination",
|
|
804
|
+
"Get filtered list of scheme processes (workflow executions) with pagination. At least one of scheme or project is required",
|
|
807
805
|
{
|
|
808
806
|
project: z5.string().optional().describe("Filter by project ID"),
|
|
809
807
|
scheme: z5.string().optional().describe("Filter by scheme ID"),
|
|
@@ -837,7 +835,7 @@ var registerSchemeProcessTools = (server) => {
|
|
|
837
835
|
},
|
|
838
836
|
async ({ scheme_process_id }) => {
|
|
839
837
|
const client = getApiClient();
|
|
840
|
-
const result = await client.delete(`/scheme-process/delete/${scheme_process_id}`);
|
|
838
|
+
const result = await client.delete(apiPath`/scheme-process/delete/${scheme_process_id}`);
|
|
841
839
|
return {
|
|
842
840
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
843
841
|
};
|
|
@@ -856,7 +854,7 @@ var registerPaymentAccountTools = (server) => {
|
|
|
856
854
|
},
|
|
857
855
|
async ({ user_id }) => {
|
|
858
856
|
const client = getApiClient();
|
|
859
|
-
const result = await client.delete(`/payment_account/remove_payment_account/${user_id}`);
|
|
857
|
+
const result = await client.delete(apiPath`/payment_account/remove_payment_account/${user_id}`);
|
|
860
858
|
return {
|
|
861
859
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
862
860
|
};
|
|
@@ -864,22 +862,20 @@ var registerPaymentAccountTools = (server) => {
|
|
|
864
862
|
);
|
|
865
863
|
server.tool(
|
|
866
864
|
"payment_account_update",
|
|
867
|
-
"Update payment account
|
|
865
|
+
"Update payment account settings: name and automatic balance refill",
|
|
868
866
|
{
|
|
869
867
|
user_id: z6.string().describe("The user ID"),
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
phone: z6.string().optional().describe("Phone number")
|
|
868
|
+
payment_account_name: z6.string().optional().describe("New name of the payment account"),
|
|
869
|
+
auto_money_refill_enabled: z6.boolean().optional().describe("Enable or disable automatic balance refill"),
|
|
870
|
+
auto_money_refill_amount: z6.number().optional().describe("Automatic refill amount in USD")
|
|
874
871
|
},
|
|
875
|
-
async ({ user_id,
|
|
872
|
+
async ({ user_id, payment_account_name, auto_money_refill_enabled, auto_money_refill_amount }) => {
|
|
876
873
|
const client = getApiClient();
|
|
877
874
|
const body = {};
|
|
878
|
-
if (
|
|
879
|
-
if (
|
|
880
|
-
if (
|
|
881
|
-
|
|
882
|
-
const result = await client.post(`/payment_account/update_payment_account/${user_id}`, body);
|
|
875
|
+
if (payment_account_name !== void 0) body.payment_account_name = payment_account_name;
|
|
876
|
+
if (auto_money_refill_enabled !== void 0) body.auto_money_refill_enabled = auto_money_refill_enabled;
|
|
877
|
+
if (auto_money_refill_amount !== void 0) body.auto_money_refill_amount = auto_money_refill_amount;
|
|
878
|
+
const result = await client.post(apiPath`/payment_account/update_payment_account/${user_id}`, body);
|
|
883
879
|
return {
|
|
884
880
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
885
881
|
};
|
|
@@ -893,7 +889,7 @@ var registerPaymentAccountTools = (server) => {
|
|
|
893
889
|
},
|
|
894
890
|
async ({ user_id }) => {
|
|
895
891
|
const client = getApiClient();
|
|
896
|
-
const result = await client.get(`/payment_account/get_user_payment_account/${user_id}`);
|
|
892
|
+
const result = await client.get(apiPath`/payment_account/get_user_payment_account/${user_id}`);
|
|
897
893
|
return {
|
|
898
894
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
899
895
|
};
|
|
@@ -907,7 +903,7 @@ var registerPaymentAccountTools = (server) => {
|
|
|
907
903
|
},
|
|
908
904
|
async ({ project_id }) => {
|
|
909
905
|
const client = getApiClient();
|
|
910
|
-
const result = await client.get(`/payment_account/get_project_payment_account/${project_id}`);
|
|
906
|
+
const result = await client.get(apiPath`/payment_account/get_project_payment_account/${project_id}`);
|
|
911
907
|
return {
|
|
912
908
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
913
909
|
};
|
|
@@ -921,17 +917,194 @@ var registerPaymentAccountTools = (server) => {
|
|
|
921
917
|
},
|
|
922
918
|
async ({ payment_account_id }) => {
|
|
923
919
|
const client = getApiClient();
|
|
924
|
-
const result = await client.get(`/payment_account/get_payment_account_transactions_history/${payment_account_id}`);
|
|
920
|
+
const result = await client.get(apiPath`/payment_account/get_payment_account_transactions_history/${payment_account_id}`);
|
|
921
|
+
return {
|
|
922
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
);
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
// src/tools/analytics-export.tools.ts
|
|
929
|
+
import { z as z7 } from "zod";
|
|
930
|
+
var MAX_EVENT_TYPE_FILTERS = 20;
|
|
931
|
+
var MAX_CONDITIONS_PER_FILTER = 20;
|
|
932
|
+
var MAX_CONDITION_VALUES = 50;
|
|
933
|
+
var MAX_CONDITION_VALUE_LENGTH = 200;
|
|
934
|
+
var EXPORT_FLOW_HINT = 'The export runs in the background: export_status goes QUEUED -> RUNNING -> DONE or FAILED. Poll analytics_export_status until DONE or FAILED, not more often than once per ~10 seconds. When DONE, download_url is a direct link valid for 15 minutes (call analytics_export_status again for a fresh one). The file is served gzipped with Content-Encoding: gzip: a browser saves plain CSV or JSONL, from a shell use curl --compressed -o file.csv "<download_url>". Files are deleted 7 days after creation. No rows are returned through MCP, only the status and the link.';
|
|
935
|
+
var ISO_DATE_TIME_ERROR = 'must be an ISO 8601 date-time with a timezone, e.g. 2026-10-01T00:00:00.000Z or 2026-10-01T00:00:00+03:00. Relative values like "last 7 days" are not accepted, compute the exact date-time';
|
|
936
|
+
var isoDateTimeSchema = z7.iso.datetime({ offset: true, error: ISO_DATE_TIME_ERROR });
|
|
937
|
+
var conditionSchema = z7.object({
|
|
938
|
+
param_name: z7.string().max(MAX_CONDITION_VALUE_LENGTH).describe("Property name"),
|
|
939
|
+
param_values: z7.array(z7.string().max(MAX_CONDITION_VALUE_LENGTH)).max(MAX_CONDITION_VALUES).describe("Values to compare with. EQUAL and CONTAINS match any of the values, NOT_EQUAL and NOT_CONTAINS match none of them, GREATER_THAN and LESS_THAN use the first value as a number, IS_SET and IS_NOT_SET ignore the values (pass [])"),
|
|
940
|
+
condition: z7.enum(["EQUAL", "NOT_EQUAL", "CONTAINS", "NOT_CONTAINS", "GREATER_THAN", "LESS_THAN", "IS_SET", "IS_NOT_SET"]).optional().describe("Comparison, EQUAL by default")
|
|
941
|
+
});
|
|
942
|
+
var eventTypeFilterSchema = z7.object({
|
|
943
|
+
event_type_id: z7.string().describe("Event type ID from analytics_event_types_list"),
|
|
944
|
+
event_properties: z7.array(conditionSchema).max(MAX_CONDITIONS_PER_FILTER).optional().describe("Conditions on event properties, all of them must match")
|
|
945
|
+
});
|
|
946
|
+
var userFilterSchema = z7.object({
|
|
947
|
+
analytics_user_ids: z7.array(z7.string()).optional().describe("Analytics user IDs (_id or custom_user_id)"),
|
|
948
|
+
user_properties: z7.array(conditionSchema).max(MAX_CONDITIONS_PER_FILTER).optional().describe("Conditions on user properties, all of them must match"),
|
|
949
|
+
user_performed_event_filters: z7.array(eventTypeFilterSchema).max(MAX_EVENT_TYPE_FILTERS).optional().describe("Only users who performed any of these events")
|
|
950
|
+
});
|
|
951
|
+
var pickUserFilter = (userFilter) => {
|
|
952
|
+
const result = {};
|
|
953
|
+
if (userFilter.analytics_user_ids !== void 0) result.analytics_user_ids = userFilter.analytics_user_ids;
|
|
954
|
+
if (userFilter.user_properties !== void 0) result.user_properties = userFilter.user_properties;
|
|
955
|
+
if (userFilter.user_performed_event_filters !== void 0) result.user_performed_event_filters = userFilter.user_performed_event_filters;
|
|
956
|
+
return result;
|
|
957
|
+
};
|
|
958
|
+
var registerAnalyticsExportTools = (server) => {
|
|
959
|
+
server.tool(
|
|
960
|
+
"analytics_orgs_list",
|
|
961
|
+
'List analytics orgs the API key owner is a member of (_id, org_name). Use the org _id as org_id in the other analytics tools or set it as MCP_ANALYTICS_ORG_ID. In the analytics web app the org ID is the "org" parameter of the page URL',
|
|
962
|
+
{},
|
|
963
|
+
async () => {
|
|
964
|
+
try {
|
|
965
|
+
const mainClient = getApiClient();
|
|
966
|
+
const userResult = await mainClient.get("/user/own");
|
|
967
|
+
if (!userResult.success || !userResult.data?._id) {
|
|
968
|
+
throw new Error(`Failed to get the API key owner: ${userResult.error || "unexpected response"}`);
|
|
969
|
+
}
|
|
970
|
+
const client = getAnalyticsApiClient();
|
|
971
|
+
const result = await client.get(apiPath`/analytics_org_access/get_orgs_of_user/${userResult.data._id}`);
|
|
972
|
+
return {
|
|
973
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
974
|
+
};
|
|
975
|
+
} catch (error) {
|
|
976
|
+
return {
|
|
977
|
+
content: [{ type: "text", text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : "Unknown error" }, null, 2) }]
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
);
|
|
982
|
+
server.tool(
|
|
983
|
+
"analytics_projects_list",
|
|
984
|
+
"List app projects of an analytics org (org_id from analytics_orgs_list or MCP_ANALYTICS_ORG_ID). Use the project _id as app_project_id in analytics_event_types_list and analytics_export_create",
|
|
985
|
+
{
|
|
986
|
+
org_id: z7.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)")
|
|
987
|
+
},
|
|
988
|
+
async ({ org_id }) => {
|
|
989
|
+
try {
|
|
990
|
+
const resolvedOrgId = getAnalyticsOrgId(org_id);
|
|
991
|
+
const client = getAnalyticsApiClient();
|
|
992
|
+
const result = await client.get(apiPath`/analytics_app_projects/get_projects_by_org/${resolvedOrgId}`);
|
|
993
|
+
return {
|
|
994
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
995
|
+
};
|
|
996
|
+
} catch (error) {
|
|
997
|
+
return {
|
|
998
|
+
content: [{ type: "text", text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : "Unknown error" }, null, 2) }]
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
);
|
|
1003
|
+
server.tool(
|
|
1004
|
+
"analytics_event_types_list",
|
|
1005
|
+
"List tracked event types of an analytics app project. Use the event type _id as event_type_id in analytics_export_create filters",
|
|
1006
|
+
{
|
|
1007
|
+
app_project_id: z7.string().describe("The analytics app project ID from analytics_projects_list")
|
|
1008
|
+
},
|
|
1009
|
+
async ({ app_project_id }) => {
|
|
1010
|
+
const client = getAnalyticsApiClient();
|
|
1011
|
+
const result = await client.get(apiPath`/analytics_event_types/get_event_types_by_app_project/${app_project_id}`);
|
|
925
1012
|
return {
|
|
926
1013
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
927
1014
|
};
|
|
928
1015
|
}
|
|
929
1016
|
);
|
|
1017
|
+
server.tool(
|
|
1018
|
+
"analytics_export_create",
|
|
1019
|
+
"Start a file export of analytics data of an org (org_id from analytics_orgs_list or MCP_ANALYTICS_ORG_ID): EVENTS (events of the org or project), USER_EVENTS (events of one user, user_filter.analytics_user_ids must have exactly one ID) or USERS (users with their properties). Up to 1,000,000 rows per file, is_truncated is true when more rows matched. Limits per org: one active export at a time (HTTP 409 analytics_export_already_running), 10 exports per hour (HTTP 429 analytics_export_hourly_limit), exports started with an API key: one per 10 minutes (HTTP 429 analytics_export_api_key_interval). HTTP 400 analytics_export_invalid_filter means the filter does not fit the export kind, HTTP 403 means the API key user is not a member of the org. " + EXPORT_FLOW_HINT,
|
|
1020
|
+
{
|
|
1021
|
+
org_id: z7.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)"),
|
|
1022
|
+
app_project_id: z7.string().optional().describe("The analytics app project ID, all projects of the org if not provided"),
|
|
1023
|
+
export_kind: z7.enum(["EVENTS", "USER_EVENTS", "USERS"]).describe("What to export"),
|
|
1024
|
+
file_format: z7.enum(["CSV", "JSONL"]).optional().describe("File format, CSV by default. JSONL is one JSON object per line"),
|
|
1025
|
+
csv_delimiter: z7.enum([",", ";"]).optional().describe("CSV column delimiter, comma by default"),
|
|
1026
|
+
time_from: isoDateTimeSchema.optional().describe("EVENTS and USER_EVENTS only: events from this time, ISO 8601 date-time with a timezone (e.g. 2026-10-01T00:00:00.000Z)"),
|
|
1027
|
+
time_to: isoDateTimeSchema.optional().describe("EVENTS and USER_EVENTS only: events up to this time, ISO 8601 date-time with a timezone (e.g. 2026-10-08T00:00:00.000Z)"),
|
|
1028
|
+
event_types_filter: z7.array(eventTypeFilterSchema).max(MAX_EVENT_TYPE_FILTERS).optional().describe("EVENTS and USER_EVENTS only: events of any of these types, each type with its own property conditions. All event types if not provided"),
|
|
1029
|
+
user_filter: userFilterSchema.optional().describe("For EVENTS: only events of the matching users. For USER_EVENTS: required, analytics_user_ids with exactly one user ID. For USERS: which users to export, all users if not provided")
|
|
1030
|
+
},
|
|
1031
|
+
async ({ org_id, app_project_id, export_kind, file_format, csv_delimiter, time_from, time_to, event_types_filter, user_filter }) => {
|
|
1032
|
+
try {
|
|
1033
|
+
const resolvedOrgId = getAnalyticsOrgId(org_id);
|
|
1034
|
+
if (export_kind === "USERS" && (time_from || time_to || event_types_filter)) {
|
|
1035
|
+
throw new Error("time_from, time_to and event_types_filter work only for EVENTS and USER_EVENTS exports. For USERS use user_filter.user_performed_event_filters");
|
|
1036
|
+
}
|
|
1037
|
+
if (export_kind === "USER_EVENTS" && user_filter?.analytics_user_ids?.length !== 1) {
|
|
1038
|
+
throw new Error("USER_EVENTS export needs user_filter.analytics_user_ids with exactly one user ID");
|
|
1039
|
+
}
|
|
1040
|
+
const scope = { org_id: resolvedOrgId };
|
|
1041
|
+
if (app_project_id) scope.app_project_id = app_project_id;
|
|
1042
|
+
const body = { ...scope, export_kind };
|
|
1043
|
+
if (file_format) body.file_format = file_format;
|
|
1044
|
+
if (csv_delimiter) body.csv_delimiter = csv_delimiter;
|
|
1045
|
+
if (export_kind === "USERS") {
|
|
1046
|
+
body.users_filter = { ...scope, ...user_filter ? pickUserFilter(user_filter) : {} };
|
|
1047
|
+
} else {
|
|
1048
|
+
const eventsFilter = { ...scope };
|
|
1049
|
+
if (time_from) eventsFilter.time_from = time_from;
|
|
1050
|
+
if (time_to) eventsFilter.time_to = time_to;
|
|
1051
|
+
if (event_types_filter) eventsFilter.event_types_filter = event_types_filter;
|
|
1052
|
+
if (user_filter) eventsFilter.user_filter = { org_id: resolvedOrgId, ...pickUserFilter(user_filter) };
|
|
1053
|
+
body.events_filter = eventsFilter;
|
|
1054
|
+
}
|
|
1055
|
+
const client = getAnalyticsApiClient();
|
|
1056
|
+
const result = await client.post("/analytics_exports/create_export", body);
|
|
1057
|
+
return {
|
|
1058
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
1059
|
+
};
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
return {
|
|
1062
|
+
content: [{ type: "text", text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : "Unknown error" }, null, 2) }]
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
server.tool(
|
|
1068
|
+
"analytics_export_status",
|
|
1069
|
+
"Get the status of an analytics export and its download link. Returns export_job (export_status, rows_count, is_truncated, file_name, file_size_bytes, error_text, expires_time), download_url and download_url_expires_time. download_url is null until export_status is DONE. " + EXPORT_FLOW_HINT,
|
|
1070
|
+
{
|
|
1071
|
+
export_id: z7.string().describe("The export ID (_id returned by analytics_export_create)")
|
|
1072
|
+
},
|
|
1073
|
+
async ({ export_id }) => {
|
|
1074
|
+
const client = getAnalyticsApiClient();
|
|
1075
|
+
const result = await client.get(apiPath`/analytics_exports/get_export/${export_id}`);
|
|
1076
|
+
return {
|
|
1077
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
);
|
|
1081
|
+
server.tool(
|
|
1082
|
+
"analytics_exports_list",
|
|
1083
|
+
"List the 20 newest analytics exports of an org (org_id from analytics_orgs_list or MCP_ANALYTICS_ORG_ID), newest first, without download links. Call analytics_export_status with an export _id to get its download link",
|
|
1084
|
+
{
|
|
1085
|
+
org_id: z7.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)"),
|
|
1086
|
+
app_project_id: z7.string().optional().describe("Only exports of this analytics app project")
|
|
1087
|
+
},
|
|
1088
|
+
async ({ org_id, app_project_id }) => {
|
|
1089
|
+
try {
|
|
1090
|
+
const resolvedOrgId = getAnalyticsOrgId(org_id);
|
|
1091
|
+
const client = getAnalyticsApiClient();
|
|
1092
|
+
const result = await client.get(apiPath`/analytics_exports/get_exports_list/${resolvedOrgId}`, { app_project_id });
|
|
1093
|
+
return {
|
|
1094
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
1095
|
+
};
|
|
1096
|
+
} catch (error) {
|
|
1097
|
+
return {
|
|
1098
|
+
content: [{ type: "text", text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : "Unknown error" }, null, 2) }]
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
);
|
|
930
1103
|
};
|
|
931
1104
|
|
|
932
1105
|
// src/index.ts
|
|
933
1106
|
var SERVER_NAME = "nana800-mcp-server";
|
|
934
|
-
var SERVER_VERSION = "1.
|
|
1107
|
+
var SERVER_VERSION = "1.2.0";
|
|
935
1108
|
var main = async () => {
|
|
936
1109
|
const apiKey = process.env.MCP_API_KEY;
|
|
937
1110
|
if (!apiKey) {
|
|
@@ -949,6 +1122,7 @@ var main = async () => {
|
|
|
949
1122
|
registerNodeProcessTools(server);
|
|
950
1123
|
registerSchemeProcessTools(server);
|
|
951
1124
|
registerPaymentAccountTools(server);
|
|
1125
|
+
registerAnalyticsExportTools(server);
|
|
952
1126
|
const transport = new StdioServerTransport();
|
|
953
1127
|
await server.connect(transport);
|
|
954
1128
|
};
|
package/package.json
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nana800-mcp-server",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "MCP Server for nana800.io Public API - enables AI IDEs to interact with your no-code projects",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://nana800.io",
|
|
6
8
|
"files": [
|
|
7
9
|
"dist"
|
|
8
10
|
],
|
|
9
11
|
"bin": {
|
|
10
|
-
"nana800-mcp": "
|
|
12
|
+
"nana800-mcp": "dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
11
16
|
},
|
|
12
|
-
"main": "./dist/index.js",
|
|
13
17
|
"scripts": {
|
|
14
18
|
"build": "node scripts/build.js",
|
|
15
|
-
"
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"release": "npm publish --access public"
|
|
16
22
|
},
|
|
17
23
|
"dependencies": {
|
|
18
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
19
|
-
"zod": "^
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
25
|
+
"zod": "^4.6.7"
|
|
20
26
|
},
|
|
21
27
|
"devDependencies": {
|
|
22
|
-
"@types/node": "^22.
|
|
23
|
-
"esbuild": "^0.
|
|
24
|
-
"typescript": "^5.
|
|
28
|
+
"@types/node": "^22.20.5",
|
|
29
|
+
"esbuild": "^0.28.2",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
25
31
|
},
|
|
26
32
|
"keywords": [
|
|
27
33
|
"mcp",
|
|
@@ -34,13 +40,5 @@
|
|
|
34
40
|
"low-code",
|
|
35
41
|
"automation",
|
|
36
42
|
"api"
|
|
37
|
-
]
|
|
38
|
-
"license": "MIT",
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "https://github.com/nicenana800/nana800-mcp-server"
|
|
42
|
-
},
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=18.0.0"
|
|
45
|
-
}
|
|
43
|
+
]
|
|
46
44
|
}
|