nana800-mcp-server 1.2.1 → 1.3.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/README.md +78 -4
- package/dist/index.js +988 -26
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -11,9 +11,10 @@ With this server an AI assistant (Claude, Cursor, VS Code and any other MCP clie
|
|
|
11
11
|
- 📤 exports and imports schemes as JSON, reads the OpenAPI document of scheme webhooks
|
|
12
12
|
- 🔍 reads the run history of schemes and of single blocks
|
|
13
13
|
- 💳 reads the payment account and its transactions
|
|
14
|
+
- 📈 builds analytics charts and dashboards from a request in words: lines, bars, funnels, retention, splits by a property, filters, public dashboard links
|
|
14
15
|
- 📊 exports analytics events and users to CSV or JSON Lines files
|
|
15
16
|
|
|
16
|
-
The server runs on your machine over stdio and calls `https://api.nana800.io` and `https://api.analytics.nana800.io` with your API key.
|
|
17
|
+
The server runs on your machine over stdio and calls `https://api.nana800.io` and `https://api.analytics.nana800.io` with your API key. 59 tools, Node.js 18 or newer.
|
|
17
18
|
|
|
18
19
|
## 🔑 Get an API key
|
|
19
20
|
|
|
@@ -119,6 +120,7 @@ MCP_API_KEY=your_api_key npx -y nana800-mcp-server
|
|
|
119
120
|
| `MCP_ANALYTICS_ORG_ID` | No | Default analytics org ID for tools with an optional `org_id`. Get it with `analytics_orgs_list` or from the `org` parameter of the analytics page URL |
|
|
120
121
|
| `MCP_API_URL` | No | API origin, `https://api.nana800.io` by default |
|
|
121
122
|
| `MCP_ANALYTICS_API_URL` | No | Analytics API origin, `https://api.analytics.nana800.io` by default |
|
|
123
|
+
| `MCP_CABINET_URL` | No | Web app origin used in chart and dashboard links, `https://cloud.nana800.io` by default |
|
|
122
124
|
|
|
123
125
|
An ID passed in a tool call always wins over the default. Every API request has a 30 second timeout.
|
|
124
126
|
|
|
@@ -187,13 +189,81 @@ An ID passed in a tool call always wins over the default. Every API request has
|
|
|
187
189
|
| `payment_account_get_transactions` | Get the transaction history |
|
|
188
190
|
| `payment_account_remove` | Remove the payment account from a user |
|
|
189
191
|
|
|
190
|
-
### Analytics
|
|
192
|
+
### Analytics: orgs, projects, events
|
|
191
193
|
|
|
192
194
|
| Tool | What it does |
|
|
193
195
|
|------|--------------|
|
|
194
196
|
| `analytics_orgs_list` | List analytics orgs the API key owner is a member of |
|
|
195
197
|
| `analytics_projects_list` | List app projects of an analytics org |
|
|
196
|
-
| `analytics_event_types_list` | List tracked event types of an app project, for export filters |
|
|
198
|
+
| `analytics_event_types_list` | List tracked event types of an app project, for chart series and export filters |
|
|
199
|
+
| `analytics_event_properties_list` | List property keys of an event type, the most used first, for chart conditions and splits |
|
|
200
|
+
|
|
201
|
+
### Analytics charts
|
|
202
|
+
|
|
203
|
+
| Tool | What it does |
|
|
204
|
+
|------|--------------|
|
|
205
|
+
| `analytics_chart_preview` | Calculate a chart without saving it and return its numbers: totals per series, values per period, funnel steps, retention. Also takes `chart_id` of a saved chart |
|
|
206
|
+
| `analytics_chart_create` | Save a chart (`LINES_CHART`, `BARS`, `FUNNEL`, `RETENTION`) and return `chart_url`; `add_to_dashboard` puts it onto a dashboard in the same call |
|
|
207
|
+
| `analytics_chart_get` | Get a saved chart as an editable definition and its link |
|
|
208
|
+
| `analytics_chart_update` | Change a saved chart: name, series, period, metric, chart type, display settings |
|
|
209
|
+
| `analytics_chart_delete` | Delete a chart and remove it from every dashboard (irreversible) |
|
|
210
|
+
|
|
211
|
+
A chart is described the same way in `analytics_chart_preview`, `analytics_chart_create` and `analytics_chart_update`:
|
|
212
|
+
|
|
213
|
+
| Field | Meaning |
|
|
214
|
+
|-------|---------|
|
|
215
|
+
| `app_project_id` | Analytics project whose events are counted |
|
|
216
|
+
| `chart_variant` | `LINES_CHART` trend, `BARS` bars per period or one total bar per series, `FUNNEL` ordered steps, `RETENTION` start event + return event |
|
|
217
|
+
| `series` | `event_type_id`, `title` (label or funnel step name), `conditions` on event properties, `breakdown_property_key` to split by property values (lines and bars) |
|
|
218
|
+
| `common_conditions` | Conditions added to every series, for example to drop test traffic |
|
|
219
|
+
| `user_conditions` | Conditions on user properties for the whole chart |
|
|
220
|
+
| `metric` | `UNIQ_USERS` (default) or `TOTAL_EVENTS` |
|
|
221
|
+
| `period` | `time_scale` (`HOURLY`, `DAILY`, `WEEKLY`, `MONTHLY`) and `last_periods_count` for a live period (default last 30), or `from_time` + `to_time` for fixed dates |
|
|
222
|
+
| `funnel_conversion_window_seconds` | Funnel: all steps within this time from the first step |
|
|
223
|
+
| `retention_periods_count` | Retention: periods after the start period to track returns |
|
|
224
|
+
| `timezone_offset_minutes` | Day boundaries, minutes east of UTC (Moscow 180) |
|
|
225
|
+
| `display_settings` | `bars_mode` (`GROUPED`, `STACKED`, `TOTAL`), `value_mode`, renamed or colored series, up to 5 formulas like conversion = A / B |
|
|
226
|
+
|
|
227
|
+
The server writes the series where the web chart builder expects them, so every chart made through MCP opens and can be edited in the web app like a chart made by hand.
|
|
228
|
+
|
|
229
|
+
Example: "build a funnel from a view to a purchase for the last 30 days" becomes
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"chart_name": "Funnel: view → purchase",
|
|
234
|
+
"app_project_id": "<project id>",
|
|
235
|
+
"chart_variant": "FUNNEL",
|
|
236
|
+
"series": [
|
|
237
|
+
{ "event_type_id": "<id of page_viewed>", "title": "View" },
|
|
238
|
+
{ "event_type_id": "<id of checkout_started>", "title": "Checkout" },
|
|
239
|
+
{ "event_type_id": "<id of purchase_completed>", "title": "Purchase" }
|
|
240
|
+
],
|
|
241
|
+
"period": { "time_scale": "DAILY", "last_periods_count": 30 },
|
|
242
|
+
"funnel_conversion_window_seconds": 604800,
|
|
243
|
+
"add_to_dashboard": { "dashboard_id": "<dashboard id>", "width_size": 2 }
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Analytics dashboards
|
|
248
|
+
|
|
249
|
+
| Tool | What it does |
|
|
250
|
+
|------|--------------|
|
|
251
|
+
| `analytics_dashboards_list` | List dashboards of an org with web app and public links |
|
|
252
|
+
| `analytics_dashboard_get` | Get a dashboard with its charts in order, widths and links |
|
|
253
|
+
| `analytics_dashboard_create` | Create an empty dashboard |
|
|
254
|
+
| `analytics_dashboard_update` | Rename a dashboard or change its description |
|
|
255
|
+
| `analytics_dashboard_add_chart` | Put a saved chart onto a dashboard at a position with a width, the charts below move down |
|
|
256
|
+
| `analytics_dashboard_set_chart_position` | Move a chart or change its width |
|
|
257
|
+
| `analytics_dashboard_remove_chart` | Take a chart off a dashboard, the chart stays saved |
|
|
258
|
+
| `analytics_dashboard_share_link` | Turn the public link on, reissue it (the old link stops working at once) or turn it off |
|
|
259
|
+
| `analytics_dashboard_delete` | Delete a dashboard, with `delete_charts` also its charts that are not on other dashboards (irreversible) |
|
|
260
|
+
|
|
261
|
+
A dashboard is a grid of 3 columns: `width_size` 1 is a third of a row, 2 is two thirds, 3 is the full row. Keep the sum of widths in a row equal to 3. The public link `https://cloud.nana800.io/share/dashboard/<token>` shows the charts without login, read only; turning it on needs the owner or editor role in the org.
|
|
262
|
+
|
|
263
|
+
### Analytics data export
|
|
264
|
+
|
|
265
|
+
| Tool | What it does |
|
|
266
|
+
|------|--------------|
|
|
197
267
|
| `analytics_export_create` | Start an export of events (`EVENTS`), events of one user (`USER_EVENTS`) or users (`USERS`) to CSV or JSONL |
|
|
198
268
|
| `analytics_export_status` | Get export status (`QUEUED`, `RUNNING`, `DONE`, `FAILED`) and the download link when it is done |
|
|
199
269
|
| `analytics_exports_list` | List the 20 newest exports of an org |
|
|
@@ -227,6 +297,9 @@ curl --compressed -o export.csv "<download_url>"
|
|
|
227
297
|
- "Export scheme X as JSON and import its nodes into scheme Y"
|
|
228
298
|
- "Show the last transactions of my payment account"
|
|
229
299
|
- "Export all purchase events of the last week to CSV and give me the download link"
|
|
300
|
+
- "Build a funnel from a view to a purchase for the last 30 days"
|
|
301
|
+
- "Make a dashboard for my site: visitors per day, traffic channels and a funnel from a visit to a call, turn on the public link"
|
|
302
|
+
- "Which pages bring the most calls? Show it as total bars split by page"
|
|
230
303
|
|
|
231
304
|
## 🔗 Links
|
|
232
305
|
|
|
@@ -239,11 +312,12 @@ curl --compressed -o export.csv "<download_url>"
|
|
|
239
312
|
|
|
240
313
|
## 🇷🇺 На русском
|
|
241
314
|
|
|
242
|
-
**nana800-mcp-server** - MCP-сервер для [nana800.io](https://nana800.io), no-code платформы для серверной логики и автоматизации. Через него ИИ-ассистент (Claude, Cursor, VS Code) создаёт проекты и схемы, добавляет и связывает блоки, смотрит историю запусков, данные платёжного
|
|
315
|
+
**nana800-mcp-server** - MCP-сервер для [nana800.io](https://nana800.io), no-code платформы для серверной логики и автоматизации. Через него ИИ-ассистент (Claude, Cursor, VS Code) создаёт проекты и схемы, добавляет и связывает блоки, смотрит историю запусков, данные платёжного аккаунта, строит графики и дашборды аналитики по просьбе словами и выгружает аналитику в CSV или JSON Lines.
|
|
243
316
|
|
|
244
317
|
- 🔑 Ключ API: [cloud.nana800.io/settings](https://cloud.nana800.io/settings), его нужно передать в переменной `MCP_API_KEY`
|
|
245
318
|
- 🚀 Запуск: `npx -y nana800-mcp-server`, готовые настройки для клиентов выше в разделе Quick start
|
|
246
319
|
- 🖥️ Сервер работает на вашем компьютере и ходит в API nana800 от имени владельца ключа
|
|
320
|
+
- 📈 Графики и дашборды: попросите, например, «построй воронку от просмотра до покупки за 30 дней» или «собери дашборд сайта из трёх графиков и включи публичную ссылку». Ассистент сам найдёт события, проверит цифры предпросмотром, сохранит графики, разложит их на дашборде и пришлёт ссылки на кабинет и публичную страницу
|
|
247
321
|
- ⚠️ Инструменты удаления (`project_delete`, `scheme_delete`, `node_delete` и другие) необратимы
|
|
248
322
|
- 📚 Документация: [nana800.gitbook.io/doc](https://nana800.gitbook.io/doc)
|
|
249
323
|
|
package/dist/index.js
CHANGED
|
@@ -926,27 +926,32 @@ var registerPaymentAccountTools = (server) => {
|
|
|
926
926
|
};
|
|
927
927
|
|
|
928
928
|
// src/tools/analytics-export.tools.ts
|
|
929
|
+
import { z as z8 } from "zod";
|
|
930
|
+
|
|
931
|
+
// src/analytics-schemas.ts
|
|
929
932
|
import { z as z7 } from "zod";
|
|
930
933
|
var MAX_EVENT_TYPE_FILTERS = 20;
|
|
931
934
|
var MAX_CONDITIONS_PER_FILTER = 20;
|
|
932
935
|
var MAX_CONDITION_VALUES = 50;
|
|
933
936
|
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
937
|
var conditionSchema = z7.object({
|
|
938
938
|
param_name: z7.string().max(MAX_CONDITION_VALUE_LENGTH).describe("Property name"),
|
|
939
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")
|
|
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. NOT_EQUAL and NOT_CONTAINS keep events that do not have the property at all")
|
|
941
941
|
});
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
942
|
+
|
|
943
|
+
// src/tools/analytics-export.tools.ts
|
|
944
|
+
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.';
|
|
945
|
+
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';
|
|
946
|
+
var isoDateTimeSchema = z8.iso.datetime({ offset: true, error: ISO_DATE_TIME_ERROR });
|
|
947
|
+
var eventTypeFilterSchema = z8.object({
|
|
948
|
+
event_type_id: z8.string().describe("Event type ID from analytics_event_types_list"),
|
|
949
|
+
event_properties: z8.array(conditionSchema).max(MAX_CONDITIONS_PER_FILTER).optional().describe("Conditions on event properties, all of them must match")
|
|
945
950
|
});
|
|
946
|
-
var userFilterSchema =
|
|
947
|
-
analytics_user_ids:
|
|
948
|
-
user_properties:
|
|
949
|
-
user_performed_event_filters:
|
|
951
|
+
var userFilterSchema = z8.object({
|
|
952
|
+
analytics_user_ids: z8.array(z8.string()).optional().describe("Analytics user IDs (_id or custom_user_id)"),
|
|
953
|
+
user_properties: z8.array(conditionSchema).max(MAX_CONDITIONS_PER_FILTER).optional().describe("Conditions on user properties, all of them must match"),
|
|
954
|
+
user_performed_event_filters: z8.array(eventTypeFilterSchema).max(MAX_EVENT_TYPE_FILTERS).optional().describe("Only users who performed any of these events")
|
|
950
955
|
});
|
|
951
956
|
var pickUserFilter = (userFilter) => {
|
|
952
957
|
const result = {};
|
|
@@ -981,9 +986,9 @@ var registerAnalyticsExportTools = (server) => {
|
|
|
981
986
|
);
|
|
982
987
|
server.tool(
|
|
983
988
|
"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
|
|
989
|
+
"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, analytics_export_create and the chart tools",
|
|
985
990
|
{
|
|
986
|
-
org_id:
|
|
991
|
+
org_id: z8.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)")
|
|
987
992
|
},
|
|
988
993
|
async ({ org_id }) => {
|
|
989
994
|
try {
|
|
@@ -1002,15 +1007,16 @@ var registerAnalyticsExportTools = (server) => {
|
|
|
1002
1007
|
);
|
|
1003
1008
|
server.tool(
|
|
1004
1009
|
"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",
|
|
1010
|
+
"List tracked event types of an analytics app project (_id, analytics_event_name, events_count), the most frequent first. Pick events for a request in words by their names (e.g. a call button: phone_clicked, a purchase: purchase_completed). Use the event type _id as event_type_id in chart series and in analytics_export_create filters",
|
|
1006
1011
|
{
|
|
1007
|
-
app_project_id:
|
|
1012
|
+
app_project_id: z8.string().describe("The analytics app project ID from analytics_projects_list")
|
|
1008
1013
|
},
|
|
1009
1014
|
async ({ app_project_id }) => {
|
|
1010
1015
|
const client = getAnalyticsApiClient();
|
|
1011
1016
|
const result = await client.get(apiPath`/analytics_event_types/get_event_types_by_app_project/${app_project_id}`);
|
|
1017
|
+
const data = result.success ? (result.data || []).map((eventType) => ({ _id: eventType._id, analytics_event_name: eventType.analytics_event_name, events_count: eventType.events_count ?? null })).sort((a, b) => (b.events_count || 0) - (a.events_count || 0)) : void 0;
|
|
1012
1018
|
return {
|
|
1013
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
1019
|
+
content: [{ type: "text", text: JSON.stringify(result.success ? { success: true, data } : result) }]
|
|
1014
1020
|
};
|
|
1015
1021
|
}
|
|
1016
1022
|
);
|
|
@@ -1018,14 +1024,14 @@ var registerAnalyticsExportTools = (server) => {
|
|
|
1018
1024
|
"analytics_export_create",
|
|
1019
1025
|
"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
1026
|
{
|
|
1021
|
-
org_id:
|
|
1022
|
-
app_project_id:
|
|
1023
|
-
export_kind:
|
|
1024
|
-
file_format:
|
|
1025
|
-
csv_delimiter:
|
|
1027
|
+
org_id: z8.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)"),
|
|
1028
|
+
app_project_id: z8.string().optional().describe("The analytics app project ID, all projects of the org if not provided"),
|
|
1029
|
+
export_kind: z8.enum(["EVENTS", "USER_EVENTS", "USERS"]).describe("What to export"),
|
|
1030
|
+
file_format: z8.enum(["CSV", "JSONL"]).optional().describe("File format, CSV by default. JSONL is one JSON object per line"),
|
|
1031
|
+
csv_delimiter: z8.enum([",", ";"]).optional().describe("CSV column delimiter, comma by default"),
|
|
1026
1032
|
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
1033
|
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:
|
|
1034
|
+
event_types_filter: z8.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
1035
|
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
1036
|
},
|
|
1031
1037
|
async ({ org_id, app_project_id, export_kind, file_format, csv_delimiter, time_from, time_to, event_types_filter, user_filter }) => {
|
|
@@ -1068,7 +1074,7 @@ var registerAnalyticsExportTools = (server) => {
|
|
|
1068
1074
|
"analytics_export_status",
|
|
1069
1075
|
"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
1076
|
{
|
|
1071
|
-
export_id:
|
|
1077
|
+
export_id: z8.string().describe("The export ID (_id returned by analytics_export_create)")
|
|
1072
1078
|
},
|
|
1073
1079
|
async ({ export_id }) => {
|
|
1074
1080
|
const client = getAnalyticsApiClient();
|
|
@@ -1082,8 +1088,8 @@ var registerAnalyticsExportTools = (server) => {
|
|
|
1082
1088
|
"analytics_exports_list",
|
|
1083
1089
|
"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
1090
|
{
|
|
1085
|
-
org_id:
|
|
1086
|
-
app_project_id:
|
|
1091
|
+
org_id: z8.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)"),
|
|
1092
|
+
app_project_id: z8.string().optional().describe("Only exports of this analytics app project")
|
|
1087
1093
|
},
|
|
1088
1094
|
async ({ org_id, app_project_id }) => {
|
|
1089
1095
|
try {
|
|
@@ -1102,9 +1108,963 @@ var registerAnalyticsExportTools = (server) => {
|
|
|
1102
1108
|
);
|
|
1103
1109
|
};
|
|
1104
1110
|
|
|
1111
|
+
// src/tools/analytics-chart.tools.ts
|
|
1112
|
+
import { z as z11 } from "zod";
|
|
1113
|
+
|
|
1114
|
+
// src/analytics-chart-builder.ts
|
|
1115
|
+
import { z as z9 } from "zod";
|
|
1116
|
+
var MAX_CHART_SERIES = 20;
|
|
1117
|
+
var MAX_RETENTION_PERIODS_COUNT = 30;
|
|
1118
|
+
var MIN_FUNNEL_CONVERSION_WINDOW_SECONDS = 60;
|
|
1119
|
+
var MAX_FUNNEL_CONVERSION_WINDOW_SECONDS = 366 * 24 * 60 * 60;
|
|
1120
|
+
var MAX_CHART_PERIODS = 1e3;
|
|
1121
|
+
var MAX_SUMMARY_SERIES = 30;
|
|
1122
|
+
var MAX_SUMMARY_PERIODS = 120;
|
|
1123
|
+
var MAX_SUMMARY_COHORTS = 30;
|
|
1124
|
+
var CABINET_URL = (process.env.MCP_CABINET_URL || "https://cloud.nana800.io").replace(/\/+$/, "");
|
|
1125
|
+
var getChartUrl = (chartId, orgId) => `${CABINET_URL}/analytics/chart/${encodeURIComponent(chartId)}?org=${encodeURIComponent(orgId)}`;
|
|
1126
|
+
var getDashboardUrl = (dashboardId, orgId) => `${CABINET_URL}/analytics/dashboard/${encodeURIComponent(dashboardId)}?org=${encodeURIComponent(orgId)}`;
|
|
1127
|
+
var getPublicDashboardUrl = (shareToken) => `${CABINET_URL}/share/dashboard/${encodeURIComponent(shareToken)}`;
|
|
1128
|
+
var CHART_VARIANTS = ["LINES_CHART", "BARS", "FUNNEL", "RETENTION"];
|
|
1129
|
+
var TIME_SCALES = ["HOURLY", "DAILY", "WEEKLY", "MONTHLY"];
|
|
1130
|
+
var METRICS = ["UNIQ_USERS", "TOTAL_EVENTS"];
|
|
1131
|
+
var seriesSchema = z9.object({
|
|
1132
|
+
event_type_id: z9.string().describe("Event type _id from analytics_event_types_list"),
|
|
1133
|
+
title: z9.string().min(1).max(200).describe(
|
|
1134
|
+
'Series label shown on the chart and in the legend, e.g. "\u041F\u043E\u0441\u0435\u0442\u0438\u0442\u0435\u043B\u0438" or "\u041E\u043F\u043B\u0430\u0442\u0438\u043B\u0438". For a FUNNEL it is the step name. With breakdown_property_key the series names become "<title> (<value>)"'
|
|
1135
|
+
),
|
|
1136
|
+
conditions: z9.array(conditionSchema).max(MAX_CONDITIONS_PER_FILTER).optional().describe('Conditions on event properties of this series only, all must match. Example: page_path EQUAL ["/pricing"] to count only views of the pricing page'),
|
|
1137
|
+
breakdown_property_key: z9.string().max(200).optional().describe(
|
|
1138
|
+
'LINES_CHART and BARS only: split this series by the values of an event property (key from analytics_event_properties_list), e.g. "traffic_channel", "utm_source", "device_type". Each value becomes its own series; rare values are joined into an "other" series'
|
|
1139
|
+
)
|
|
1140
|
+
});
|
|
1141
|
+
var periodSchema = z9.object({
|
|
1142
|
+
time_scale: z9.enum(TIME_SCALES).describe("One point (or bar) per hour, day, week or month"),
|
|
1143
|
+
last_periods_count: z9.number().int().min(1).max(MAX_CHART_PERIODS).optional().describe(
|
|
1144
|
+
'Live period: the last N periods including the current one, the chart moves with time. "Last 30 days" = DAILY + 30, "last 12 weeks" = WEEKLY + 12, "last 6 months" = MONTHLY + 6. Default 30 when from_time is not given'
|
|
1145
|
+
),
|
|
1146
|
+
from_time: z9.iso.datetime({ offset: true }).optional().describe("Fixed period start, ISO 8601 with a timezone. Use only when the user asks for exact dates; needs to_time too. The chart then never moves"),
|
|
1147
|
+
to_time: z9.iso.datetime({ offset: true }).optional().describe("Fixed period end, ISO 8601 with a timezone, used together with from_time")
|
|
1148
|
+
}).describe("Time range of the chart. Prefer a live period (last_periods_count) so the chart stays up to date on a dashboard");
|
|
1149
|
+
var chartDefinitionShape = {
|
|
1150
|
+
org_id: z9.string().optional().describe("The analytics org ID from analytics_orgs_list (the analytics_org of the project). Required unless MCP_ANALYTICS_ORG_ID is set"),
|
|
1151
|
+
app_project_id: z9.string().describe("The analytics app project ID from analytics_projects_list. Events are counted only in this project"),
|
|
1152
|
+
chart_variant: z9.enum(CHART_VARIANTS).describe(
|
|
1153
|
+
'LINES_CHART: trend over time. BARS: bars per period, or one total bar per series with display bars_mode TOTAL (good for "which channel / page / device is the biggest"). FUNNEL: conversion through ordered steps (series = steps, 2 to 20). RETENTION: how many users come back (exactly 2 series: the start event, then the return event)'
|
|
1154
|
+
),
|
|
1155
|
+
series: z9.array(seriesSchema).min(1).max(MAX_CHART_SERIES).describe("Series of the chart in order. FUNNEL: steps from the first to the last. RETENTION: [start event, return event]. The same event type may be used several times with different conditions"),
|
|
1156
|
+
common_conditions: z9.array(conditionSchema).max(MAX_CONDITIONS_PER_FILTER).optional().describe(
|
|
1157
|
+
'Conditions added to every series, e.g. to drop test traffic: location_origin NOT_CONTAINS ["localhost","127.0.0.1"]. Stored inside every series, so analytics_chart_get shows them in each series'
|
|
1158
|
+
),
|
|
1159
|
+
user_conditions: z9.array(conditionSchema).max(MAX_CONDITIONS_PER_FILTER).optional().describe('Conditions on user properties for the whole chart, e.g. email NOT_EQUAL ["me@example.com"] to hide the team'),
|
|
1160
|
+
metric: z9.enum(METRICS).optional().describe("UNIQ_USERS (default): unique users per period. TOTAL_EVENTS: number of events per period. FUNNEL and RETENTION always count users"),
|
|
1161
|
+
period: periodSchema.optional(),
|
|
1162
|
+
compare_previous_period: z9.boolean().optional().describe("LINES_CHART and BARS: also count the same number of periods right before the range to compare with"),
|
|
1163
|
+
funnel_conversion_window_seconds: z9.number().int().min(MIN_FUNNEL_CONVERSION_WINDOW_SECONDS).max(MAX_FUNNEL_CONVERSION_WINDOW_SECONDS).optional().describe("FUNNEL only: all steps must be done within this time from the first step, e.g. 86400 = 1 day, 604800 = 7 days. Not limited when not set"),
|
|
1164
|
+
retention_periods_count: z9.number().int().min(1).max(MAX_RETENTION_PERIODS_COUNT).optional().describe("RETENTION only: how many periods after the start period to track returns (DAILY up to 30, WEEKLY up to 26, MONTHLY up to 12). Cohorts are the periods of `period`: keep it up to 90 days, 52 weeks or 24 months"),
|
|
1165
|
+
timezone_offset_minutes: z9.number().int().min(-840).max(840).optional().describe("Timezone of day boundaries, minutes east of UTC: Moscow 180, Kaliningrad 120, UTC 0. UTC when not set")
|
|
1166
|
+
};
|
|
1167
|
+
var chartDefinitionSchema = z9.object(chartDefinitionShape);
|
|
1168
|
+
var seriesSettingsSchema = z9.object({
|
|
1169
|
+
series_name: z9.string().max(200).describe('Series name from the preview result (series[].name), e.g. "\u041A\u0430\u043D\u0430\u043B (search)"'),
|
|
1170
|
+
title: z9.string().max(200).optional().describe("New label shown instead of the series name"),
|
|
1171
|
+
color: z9.string().regex(/^#[0-9a-fA-F]{6}$/).optional().describe("Color as #RRGGBB"),
|
|
1172
|
+
metric: z9.enum(METRICS).optional().describe("Metric of this series only")
|
|
1173
|
+
});
|
|
1174
|
+
var formulaSchema = z9.object({
|
|
1175
|
+
title: z9.string().max(200).describe('Label of the calculated series, e.g. "\u041A\u043E\u043D\u0432\u0435\u0440\u0441\u0438\u044F, %"'),
|
|
1176
|
+
operator: z9.enum(["DIVIDE", "SUBTRACT", "ADD"]).describe("DIVIDE shows A / B in percent"),
|
|
1177
|
+
series_a: z9.string().max(200).describe("Series name A from the preview result"),
|
|
1178
|
+
series_b: z9.string().max(200).describe("Series name B from the preview result")
|
|
1179
|
+
});
|
|
1180
|
+
var displaySettingsSchema = z9.object({
|
|
1181
|
+
bars_mode: z9.enum(["GROUPED", "STACKED", "TOTAL"]).optional().describe("BARS only: GROUPED bars side by side, STACKED bars on top of each other, TOTAL one bar per series for the whole range (labels are cut to 16 characters)"),
|
|
1182
|
+
value_mode: z9.enum(["NORMAL", "CUMULATIVE", "MOVING_AVERAGE"]).optional().describe("LINES_CHART and BARS: values as is, running total, or moving average"),
|
|
1183
|
+
moving_average_window: z9.union([z9.literal(3), z9.literal(7), z9.literal(14), z9.literal(28)]).optional().describe("Window of MOVING_AVERAGE in periods"),
|
|
1184
|
+
series_settings: z9.array(seriesSettingsSchema).max(100).optional().describe('Renames or colors of series, mostly for breakdown values like "\u041A\u0430\u043D\u0430\u043B (search)" -> "\u041F\u043E\u0438\u0441\u043A". Not used by FUNNEL: name the steps with series[].title'),
|
|
1185
|
+
formulas: z9.array(formulaSchema).max(5).optional().describe("Up to 5 calculated series from two series, e.g. conversion = DIVIDE(buyers, visitors). Shown only when both series have data")
|
|
1186
|
+
}).describe("How the chart is drawn on the page. Does not change the numbers");
|
|
1187
|
+
var DEFAULT_LAST_PERIODS_COUNT = 30;
|
|
1188
|
+
var validateChartDefinition = (definition) => {
|
|
1189
|
+
const errors = [];
|
|
1190
|
+
const { chart_variant, series, period } = definition;
|
|
1191
|
+
if (chart_variant === "RETENTION" && series.length !== 2) {
|
|
1192
|
+
errors.push("RETENTION needs exactly 2 series: the start event and the return event");
|
|
1193
|
+
}
|
|
1194
|
+
if (chart_variant === "FUNNEL" && series.length < 2) {
|
|
1195
|
+
errors.push("FUNNEL needs at least 2 series (steps)");
|
|
1196
|
+
}
|
|
1197
|
+
if ((chart_variant === "FUNNEL" || chart_variant === "RETENTION") && series.some((item) => item.breakdown_property_key)) {
|
|
1198
|
+
errors.push(`${chart_variant} can not split series by a property, breakdown_property_key works only for LINES_CHART and BARS`);
|
|
1199
|
+
}
|
|
1200
|
+
if (chart_variant !== "FUNNEL" && definition.funnel_conversion_window_seconds !== void 0) {
|
|
1201
|
+
errors.push("funnel_conversion_window_seconds works only for FUNNEL");
|
|
1202
|
+
}
|
|
1203
|
+
if (chart_variant !== "RETENTION" && definition.retention_periods_count !== void 0) {
|
|
1204
|
+
errors.push("retention_periods_count works only for RETENTION");
|
|
1205
|
+
}
|
|
1206
|
+
if (period && !!period.from_time !== !!period.to_time) {
|
|
1207
|
+
errors.push("period.from_time and period.to_time must be given together");
|
|
1208
|
+
}
|
|
1209
|
+
if (period?.from_time && period.to_time && new Date(period.to_time).getTime() <= new Date(period.from_time).getTime()) {
|
|
1210
|
+
errors.push("period.to_time must be after period.from_time");
|
|
1211
|
+
}
|
|
1212
|
+
if (period?.from_time && period.last_periods_count !== void 0) {
|
|
1213
|
+
errors.push("use either period.last_periods_count (live period) or period.from_time + period.to_time (fixed dates), not both");
|
|
1214
|
+
}
|
|
1215
|
+
return errors;
|
|
1216
|
+
};
|
|
1217
|
+
var withPropertyId = (condition, propertyIds) => {
|
|
1218
|
+
const result = {
|
|
1219
|
+
param_name: condition.param_name,
|
|
1220
|
+
param_values: condition.param_values,
|
|
1221
|
+
condition: condition.condition || "EQUAL"
|
|
1222
|
+
};
|
|
1223
|
+
const propertyId = propertyIds?.[condition.param_name];
|
|
1224
|
+
if (propertyId) result.param_prop_id = propertyId;
|
|
1225
|
+
return result;
|
|
1226
|
+
};
|
|
1227
|
+
var buildChartRequestBody = (definition, orgId, propertyIdsByEventType = {}) => {
|
|
1228
|
+
const warnings = [];
|
|
1229
|
+
const commonConditions = definition.common_conditions || [];
|
|
1230
|
+
const scope = { org_id: orgId, app_project_id: definition.app_project_id };
|
|
1231
|
+
const eventTypesFilter = [];
|
|
1232
|
+
const groupItems = [];
|
|
1233
|
+
definition.series.forEach((series) => {
|
|
1234
|
+
const propertyIds = propertyIdsByEventType[series.event_type_id];
|
|
1235
|
+
const conditions = [...commonConditions, ...series.conditions || []];
|
|
1236
|
+
const eventProperties = conditions.map((condition) => withPropertyId(condition, propertyIds));
|
|
1237
|
+
const breakdownKey = series.breakdown_property_key?.trim() || "";
|
|
1238
|
+
const breakdownPropertyId = breakdownKey ? propertyIds?.[breakdownKey] : void 0;
|
|
1239
|
+
if (propertyIds) {
|
|
1240
|
+
const unknownKeys = [.../* @__PURE__ */ new Set([...conditions.map((condition) => condition.param_name), ...breakdownKey ? [breakdownKey] : []])].filter(
|
|
1241
|
+
(key) => !propertyIds[key]
|
|
1242
|
+
);
|
|
1243
|
+
if (unknownKeys.length) {
|
|
1244
|
+
warnings.push(
|
|
1245
|
+
`Series "${series.title}": event type ${series.event_type_id} never had the properties ${unknownKeys.join(", ")}. Check the keys with analytics_event_properties_list (NOT_EQUAL / NOT_CONTAINS on a missing property keep every event, other conditions match nothing)`
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
const filterItem = {
|
|
1250
|
+
event_type_id: series.event_type_id,
|
|
1251
|
+
event_type_name: series.title,
|
|
1252
|
+
event_properties: eventProperties
|
|
1253
|
+
};
|
|
1254
|
+
if (breakdownKey) {
|
|
1255
|
+
filterItem.breakdown_property_key = breakdownKey;
|
|
1256
|
+
if (breakdownPropertyId) filterItem.breakdown_property_id = breakdownPropertyId;
|
|
1257
|
+
}
|
|
1258
|
+
eventTypesFilter.push(filterItem);
|
|
1259
|
+
groupItems.push({
|
|
1260
|
+
event_type_id: series.event_type_id,
|
|
1261
|
+
event_type_name: series.title,
|
|
1262
|
+
event_property_key: breakdownKey,
|
|
1263
|
+
event_properties: eventProperties
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
const searchEventsInput = { ...scope, event_types_filter: eventTypesFilter };
|
|
1267
|
+
if (definition.user_conditions?.length) {
|
|
1268
|
+
searchEventsInput.user_filter = {
|
|
1269
|
+
...scope,
|
|
1270
|
+
user_properties: definition.user_conditions.map((condition) => withPropertyId(condition, void 0))
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
const period = definition.period;
|
|
1274
|
+
const timeScale = period?.time_scale || "DAILY";
|
|
1275
|
+
const groupPeriodsInput = {
|
|
1276
|
+
time_scale: timeScale,
|
|
1277
|
+
group_rules: {
|
|
1278
|
+
is_all_events_group: false,
|
|
1279
|
+
is_event_types_groups: true,
|
|
1280
|
+
is_event_props_groups: false,
|
|
1281
|
+
event_types_group_items: groupItems,
|
|
1282
|
+
uniques: definition.metric || "UNIQ_USERS"
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
if (period?.from_time && period.to_time) {
|
|
1286
|
+
groupPeriodsInput.is_fixed_time_period = true;
|
|
1287
|
+
groupPeriodsInput.from_time = period.from_time;
|
|
1288
|
+
groupPeriodsInput.to_time = period.to_time;
|
|
1289
|
+
} else {
|
|
1290
|
+
groupPeriodsInput.is_fixed_time_period = false;
|
|
1291
|
+
groupPeriodsInput.slice_last_periods_count = period?.last_periods_count || DEFAULT_LAST_PERIODS_COUNT;
|
|
1292
|
+
}
|
|
1293
|
+
if (definition.compare_previous_period !== void 0) {
|
|
1294
|
+
groupPeriodsInput.is_compare_previous_period = definition.compare_previous_period;
|
|
1295
|
+
}
|
|
1296
|
+
const body = {
|
|
1297
|
+
chart_variant: definition.chart_variant,
|
|
1298
|
+
search_events_input: searchEventsInput,
|
|
1299
|
+
group_periods_input: groupPeriodsInput
|
|
1300
|
+
};
|
|
1301
|
+
if (definition.chart_variant === "FUNNEL") {
|
|
1302
|
+
body.funnel_settings = definition.funnel_conversion_window_seconds ? { conversion_window_seconds: definition.funnel_conversion_window_seconds } : {};
|
|
1303
|
+
}
|
|
1304
|
+
if (definition.chart_variant === "RETENTION") {
|
|
1305
|
+
body.retention_settings = definition.retention_periods_count ? { periods_count: definition.retention_periods_count } : {};
|
|
1306
|
+
}
|
|
1307
|
+
if (definition.timezone_offset_minutes !== void 0) {
|
|
1308
|
+
body.timezone_offset_minutes = definition.timezone_offset_minutes;
|
|
1309
|
+
}
|
|
1310
|
+
return { body, warnings };
|
|
1311
|
+
};
|
|
1312
|
+
var toCondition = (saved) => ({
|
|
1313
|
+
param_name: saved.param_name || "",
|
|
1314
|
+
param_values: saved.param_values || [],
|
|
1315
|
+
condition: saved.condition || "EQUAL"
|
|
1316
|
+
});
|
|
1317
|
+
var compactSavedValue = (value) => {
|
|
1318
|
+
if (Array.isArray(value)) return value.map(compactSavedValue);
|
|
1319
|
+
if (value && typeof value === "object") {
|
|
1320
|
+
const result = {};
|
|
1321
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
1322
|
+
if (item === null || item === void 0 || key === "_id" || key === "__v") return;
|
|
1323
|
+
result[key] = compactSavedValue(item);
|
|
1324
|
+
});
|
|
1325
|
+
return result;
|
|
1326
|
+
}
|
|
1327
|
+
return value;
|
|
1328
|
+
};
|
|
1329
|
+
var savedChartToDefinition = (chart) => {
|
|
1330
|
+
const groupPeriods = chart.group_periods_input || {};
|
|
1331
|
+
const groupItems = groupPeriods.group_rules?.event_types_group_items || [];
|
|
1332
|
+
const series = groupItems.map((item) => {
|
|
1333
|
+
const result = {
|
|
1334
|
+
event_type_id: item.event_type_id || "",
|
|
1335
|
+
title: item.event_type_name || ""
|
|
1336
|
+
};
|
|
1337
|
+
const conditions = (item.event_properties || []).map(toCondition);
|
|
1338
|
+
if (conditions.length) result.conditions = conditions;
|
|
1339
|
+
if (item.event_property_key) result.breakdown_property_key = item.event_property_key;
|
|
1340
|
+
return result;
|
|
1341
|
+
});
|
|
1342
|
+
const period = { time_scale: groupPeriods.time_scale || "DAILY" };
|
|
1343
|
+
if (groupPeriods.is_fixed_time_period && groupPeriods.from_time && groupPeriods.to_time) {
|
|
1344
|
+
period.from_time = groupPeriods.from_time;
|
|
1345
|
+
period.to_time = groupPeriods.to_time;
|
|
1346
|
+
} else {
|
|
1347
|
+
period.last_periods_count = groupPeriods.slice_last_periods_count || DEFAULT_LAST_PERIODS_COUNT;
|
|
1348
|
+
}
|
|
1349
|
+
const definition = {
|
|
1350
|
+
chart_name: chart.chart_name,
|
|
1351
|
+
chart_description: chart.chart_description || void 0,
|
|
1352
|
+
org_id: chart.analytics_org,
|
|
1353
|
+
app_project_id: chart.search_events_input?.app_project_id || "",
|
|
1354
|
+
chart_variant: chart.chart_variant || "LINES_CHART",
|
|
1355
|
+
series,
|
|
1356
|
+
metric: groupPeriods.group_rules?.uniques || "UNIQ_USERS",
|
|
1357
|
+
period
|
|
1358
|
+
};
|
|
1359
|
+
const userConditions = (chart.search_events_input?.user_filter?.user_properties || []).map(toCondition);
|
|
1360
|
+
if (userConditions.length) definition.user_conditions = userConditions;
|
|
1361
|
+
if (groupPeriods.is_compare_previous_period) definition.compare_previous_period = true;
|
|
1362
|
+
if (chart.funnel_settings?.conversion_window_seconds) definition.funnel_conversion_window_seconds = chart.funnel_settings.conversion_window_seconds;
|
|
1363
|
+
if (chart.retention_settings?.periods_count) definition.retention_periods_count = chart.retention_settings.periods_count;
|
|
1364
|
+
if (typeof chart.timezone_offset_minutes === "number") definition.timezone_offset_minutes = chart.timezone_offset_minutes;
|
|
1365
|
+
if (chart.display_settings) definition.display_settings = compactSavedValue(chart.display_settings);
|
|
1366
|
+
return definition;
|
|
1367
|
+
};
|
|
1368
|
+
var summarizeGroup = (group) => {
|
|
1369
|
+
const result = {
|
|
1370
|
+
name: group.group_name,
|
|
1371
|
+
uniq_users: group.uniq_users_count,
|
|
1372
|
+
events: group.tracked_events_count
|
|
1373
|
+
};
|
|
1374
|
+
if (group.breakdown_value !== void 0 && group.breakdown_value !== null) result.breakdown_value = group.breakdown_value;
|
|
1375
|
+
if (group.is_other_values) result.is_other_values = true;
|
|
1376
|
+
return result;
|
|
1377
|
+
};
|
|
1378
|
+
var summarizeChartRender = (render, variant, metric = "UNIQ_USERS") => {
|
|
1379
|
+
const groups = render.summary_event_groups || [];
|
|
1380
|
+
const shownGroups = groups.slice(0, MAX_SUMMARY_SERIES);
|
|
1381
|
+
const summary = {
|
|
1382
|
+
range: { time_scale: render.time_scale, start_time: render.start_time, end_time: render.end_time, periods_count: render.periods?.length || render.retention?.cohorts?.length || 0 },
|
|
1383
|
+
processed_events_count: render.processed_events_count
|
|
1384
|
+
};
|
|
1385
|
+
if (render.is_truncated) summary.is_truncated = true;
|
|
1386
|
+
if (variant === "FUNNEL" && render.funnel) {
|
|
1387
|
+
summary.funnel = {
|
|
1388
|
+
steps: render.funnel.steps.map((step) => ({
|
|
1389
|
+
name: step.step_name,
|
|
1390
|
+
users: step.users_count,
|
|
1391
|
+
conversion_from_previous_percent: step.conversion_from_previous_percent,
|
|
1392
|
+
conversion_from_first_percent: step.conversion_from_first_percent,
|
|
1393
|
+
drop_off: step.drop_off_count,
|
|
1394
|
+
median_time_from_previous_seconds: step.median_time_from_previous_ms === null ? null : Math.round(step.median_time_from_previous_ms / 1e3)
|
|
1395
|
+
})),
|
|
1396
|
+
overall_conversion_percent: render.funnel.overall_conversion_percent,
|
|
1397
|
+
conversion_window_seconds: render.funnel.conversion_window_seconds ?? null
|
|
1398
|
+
};
|
|
1399
|
+
} else if (variant === "RETENTION" && render.retention) {
|
|
1400
|
+
const retention = render.retention;
|
|
1401
|
+
const cohorts = retention.cohorts.filter((cohort) => cohort.users_count > 0);
|
|
1402
|
+
summary.retention = {
|
|
1403
|
+
period_unit: retention.period_unit,
|
|
1404
|
+
start_event: retention.start_event_name,
|
|
1405
|
+
return_event: retention.return_event_name,
|
|
1406
|
+
overall_users_counts: retention.overall_users_counts,
|
|
1407
|
+
overall_retained_percents: retention.overall_retained_percents,
|
|
1408
|
+
cohorts: cohorts.slice(-MAX_SUMMARY_COHORTS).map((cohort) => ({ period: cohort.period_title, users: cohort.users_count, retained_percents: cohort.retained_percents }))
|
|
1409
|
+
};
|
|
1410
|
+
} else {
|
|
1411
|
+
summary.metric = metric;
|
|
1412
|
+
summary.series = shownGroups.map(summarizeGroup);
|
|
1413
|
+
if (groups.length > shownGroups.length) summary.series_not_shown_count = groups.length - shownGroups.length;
|
|
1414
|
+
const periods = (render.periods || []).slice(-MAX_SUMMARY_PERIODS);
|
|
1415
|
+
const valueKey = metric === "TOTAL_EVENTS" ? "tracked_events_count" : "uniq_users_count";
|
|
1416
|
+
summary.values_by_period = {
|
|
1417
|
+
period_titles: periods.map((period) => period.period_title),
|
|
1418
|
+
values: Object.fromEntries(
|
|
1419
|
+
shownGroups.map((group) => [
|
|
1420
|
+
group.group_name,
|
|
1421
|
+
periods.map((period) => period.event_groups.find((item) => item.group_name === group.group_name)?.[valueKey] || 0)
|
|
1422
|
+
])
|
|
1423
|
+
)
|
|
1424
|
+
};
|
|
1425
|
+
if ((render.periods || []).length > periods.length) summary.values_by_period_note = `only the last ${periods.length} periods are shown`;
|
|
1426
|
+
if (render.previous_period) {
|
|
1427
|
+
summary.previous_period = {
|
|
1428
|
+
start_time: render.previous_period.start_time,
|
|
1429
|
+
end_time: render.previous_period.end_time,
|
|
1430
|
+
series: render.previous_period.summary_event_groups.slice(0, MAX_SUMMARY_SERIES).map(summarizeGroup)
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
if (!render.processed_events_count) {
|
|
1435
|
+
summary.hint = "No events matched. Check app_project_id, event_type_id values (analytics_event_types_list), property keys (analytics_event_properties_list) and the period";
|
|
1436
|
+
}
|
|
1437
|
+
return summary;
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
// src/tools/tool-result.ts
|
|
1441
|
+
var toolResult = (data) => ({
|
|
1442
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
1443
|
+
});
|
|
1444
|
+
var toolError = (error) => toolResult({ success: false, error: error instanceof Error ? error.message : "Unknown error" });
|
|
1445
|
+
var unwrap = (response, action) => {
|
|
1446
|
+
if (!response.success) {
|
|
1447
|
+
throw new Error(`${action} failed: ${response.error || "unknown error"}`);
|
|
1448
|
+
}
|
|
1449
|
+
return response.data;
|
|
1450
|
+
};
|
|
1451
|
+
|
|
1452
|
+
// src/tools/analytics-dashboard.tools.ts
|
|
1453
|
+
import { z as z10 } from "zod";
|
|
1454
|
+
var MAX_PARALLEL_CHART_REQUESTS = 8;
|
|
1455
|
+
var LAYOUT_HINT = "Layout: the dashboard is a grid of 3 columns, charts go in the order of their position and wrap into rows. width_size 1 = a third, 2 = two thirds, 3 = a full row. Keep the sum of widths in every row equal to 3 (3, 2+1, 1+2, 1+1+1), otherwise a row has an empty hole. Good widths: a line or bars over time 2 or 3, a funnel 2 or 3 (up to 4 steps fit without scrolling at width 1), TOTAL bars and retention 1 or 2.";
|
|
1456
|
+
var widthSchema = z10.union([z10.literal(1), z10.literal(2), z10.literal(3)]);
|
|
1457
|
+
var sortedCharts = (dashboard) => [...dashboard.dashboard_charts_data_array || []].sort((a, b) => (a.chart_position_data?.order_index ?? 0) - (b.chart_position_data?.order_index ?? 0));
|
|
1458
|
+
var getDashboard = async (dashboardId) => {
|
|
1459
|
+
const client = getAnalyticsApiClient();
|
|
1460
|
+
const dashboard = unwrap(await client.get(apiPath`/analytics_org_dashboards/get_dashboard_by_id/${dashboardId}`), "Get dashboard");
|
|
1461
|
+
if (!dashboard?._id) {
|
|
1462
|
+
throw new Error(`Dashboard ${dashboardId} is not found`);
|
|
1463
|
+
}
|
|
1464
|
+
return dashboard;
|
|
1465
|
+
};
|
|
1466
|
+
var setChartPosition = async (dashboardId, chartId, orderIndex, widthSize) => {
|
|
1467
|
+
const client = getAnalyticsApiClient();
|
|
1468
|
+
unwrap(
|
|
1469
|
+
await client.put("/analytics_org_dashboards/set_chart_position_data", {
|
|
1470
|
+
dashboard_id: dashboardId,
|
|
1471
|
+
chart_id: chartId,
|
|
1472
|
+
chart_position_data: { order_index: orderIndex, width_size: widthSize }
|
|
1473
|
+
}),
|
|
1474
|
+
"Set chart position"
|
|
1475
|
+
);
|
|
1476
|
+
};
|
|
1477
|
+
var applyLayout = async (dashboardId, current, target) => {
|
|
1478
|
+
const currentById = new Map(current.map((record) => [record.chart_id, record.chart_position_data]));
|
|
1479
|
+
for (const [index, item] of target.entries()) {
|
|
1480
|
+
const position = currentById.get(item.chart_id);
|
|
1481
|
+
if (position?.order_index !== index || position?.width_size !== item.width_size) {
|
|
1482
|
+
await setChartPosition(dashboardId, item.chart_id, index, item.width_size);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
var describeLayout = (dashboard) => sortedCharts(dashboard).map((record) => ({
|
|
1487
|
+
chart_id: record.chart_id,
|
|
1488
|
+
position: record.chart_position_data?.order_index ?? 0,
|
|
1489
|
+
width_size: record.chart_position_data?.width_size ?? 1
|
|
1490
|
+
}));
|
|
1491
|
+
var addChartToDashboard = async (dashboardId, chartId, widthSize, position) => {
|
|
1492
|
+
const client = getAnalyticsApiClient();
|
|
1493
|
+
const dashboard = await getDashboard(dashboardId);
|
|
1494
|
+
const current = sortedCharts(dashboard);
|
|
1495
|
+
if (current.some((record) => record.chart_id === chartId)) {
|
|
1496
|
+
throw new Error(`Chart ${chartId} is already on dashboard ${dashboardId}, use analytics_dashboard_set_chart_position to move it`);
|
|
1497
|
+
}
|
|
1498
|
+
const index = position === void 0 ? current.length : Math.min(position, current.length);
|
|
1499
|
+
const orderIndex = index === current.length ? current.length ? Math.max(...current.map((record) => record.chart_position_data?.order_index ?? 0)) + 1 : 0 : index;
|
|
1500
|
+
unwrap(
|
|
1501
|
+
await client.post(apiPath`/analytics_org_dashboards/add_chart_to_dashboard/${dashboardId}`, {
|
|
1502
|
+
chart_id: chartId,
|
|
1503
|
+
chart_position_data: { order_index: orderIndex, width_size: widthSize }
|
|
1504
|
+
}),
|
|
1505
|
+
"Add chart to dashboard"
|
|
1506
|
+
);
|
|
1507
|
+
if (index < current.length) {
|
|
1508
|
+
const target = current.map((record) => ({ chart_id: record.chart_id, width_size: record.chart_position_data?.width_size ?? 1 }));
|
|
1509
|
+
target.splice(index, 0, { chart_id: chartId, width_size: widthSize });
|
|
1510
|
+
const withNew = [...current, { chart_id: chartId, chart_position_data: { order_index: orderIndex, width_size: widthSize } }];
|
|
1511
|
+
await applyLayout(dashboardId, withNew, target);
|
|
1512
|
+
}
|
|
1513
|
+
const orgId = dashboard.analytics_org;
|
|
1514
|
+
return { dashboard_id: dashboardId, dashboard_url: getDashboardUrl(dashboardId, orgId), layout: describeLayout(await getDashboard(dashboardId)) };
|
|
1515
|
+
};
|
|
1516
|
+
var mapLimited = async (items, limit, mapper) => {
|
|
1517
|
+
const results = new Array(items.length);
|
|
1518
|
+
let next = 0;
|
|
1519
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
1520
|
+
while (next < items.length) {
|
|
1521
|
+
const index = next++;
|
|
1522
|
+
results[index] = await mapper(items[index]);
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
await Promise.all(workers);
|
|
1526
|
+
return results;
|
|
1527
|
+
};
|
|
1528
|
+
var registerAnalyticsDashboardTools = (server) => {
|
|
1529
|
+
server.tool(
|
|
1530
|
+
"analytics_dashboards_list",
|
|
1531
|
+
"List dashboards of an analytics org (org_id from analytics_orgs_list or MCP_ANALYTICS_ORG_ID): dashboard_id, name, description, charts_count, dashboard_url (web app) and public_url when the public link is on",
|
|
1532
|
+
{
|
|
1533
|
+
org_id: z10.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)")
|
|
1534
|
+
},
|
|
1535
|
+
async ({ org_id }) => {
|
|
1536
|
+
try {
|
|
1537
|
+
const orgId = getAnalyticsOrgId(org_id);
|
|
1538
|
+
const client = getAnalyticsApiClient();
|
|
1539
|
+
const dashboards = unwrap(await client.get(apiPath`/analytics_org_dashboards/get_dashboards_by_org/${orgId}`), "Get dashboards");
|
|
1540
|
+
return toolResult({
|
|
1541
|
+
success: true,
|
|
1542
|
+
data: (dashboards || []).map((dashboard) => ({
|
|
1543
|
+
dashboard_id: dashboard._id,
|
|
1544
|
+
dashboard_name: dashboard.dashboard_name,
|
|
1545
|
+
dashboard_description: dashboard.dashboard_description || "",
|
|
1546
|
+
charts_count: dashboard.dashboard_charts_data_array?.length || 0,
|
|
1547
|
+
dashboard_url: getDashboardUrl(dashboard._id, orgId),
|
|
1548
|
+
public_url: dashboard.share_token ? getPublicDashboardUrl(dashboard.share_token) : null
|
|
1549
|
+
}))
|
|
1550
|
+
});
|
|
1551
|
+
} catch (error) {
|
|
1552
|
+
return toolError(error);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
1556
|
+
server.tool(
|
|
1557
|
+
"analytics_dashboard_get",
|
|
1558
|
+
"Get a dashboard with its charts in order: chart_id, chart_name, chart_variant, position, width_size, chart_url. Also dashboard_url and public_url when the public link is on",
|
|
1559
|
+
{
|
|
1560
|
+
dashboard_id: z10.string().describe("Dashboard ID")
|
|
1561
|
+
},
|
|
1562
|
+
async ({ dashboard_id }) => {
|
|
1563
|
+
try {
|
|
1564
|
+
const dashboard = await getDashboard(dashboard_id);
|
|
1565
|
+
const orgId = dashboard.analytics_org;
|
|
1566
|
+
const client = getAnalyticsApiClient();
|
|
1567
|
+
const charts = await mapLimited(sortedCharts(dashboard), MAX_PARALLEL_CHART_REQUESTS, async (record) => {
|
|
1568
|
+
const response = await client.get(apiPath`/analytics_charts/get_chart_by_id/${record.chart_id}`);
|
|
1569
|
+
return {
|
|
1570
|
+
chart_id: record.chart_id,
|
|
1571
|
+
chart_name: response.success ? response.data?.chart_name ?? null : null,
|
|
1572
|
+
chart_variant: response.success ? response.data?.chart_variant ?? null : null,
|
|
1573
|
+
position: record.chart_position_data?.order_index ?? 0,
|
|
1574
|
+
width_size: record.chart_position_data?.width_size ?? 1,
|
|
1575
|
+
chart_url: getChartUrl(record.chart_id, orgId),
|
|
1576
|
+
...response.success && response.data ? {} : { error: "chart is not found or not readable" }
|
|
1577
|
+
};
|
|
1578
|
+
});
|
|
1579
|
+
return toolResult({
|
|
1580
|
+
success: true,
|
|
1581
|
+
dashboard_id: dashboard._id,
|
|
1582
|
+
dashboard_name: dashboard.dashboard_name,
|
|
1583
|
+
dashboard_description: dashboard.dashboard_description || "",
|
|
1584
|
+
org_id: orgId,
|
|
1585
|
+
dashboard_url: getDashboardUrl(dashboard._id, orgId),
|
|
1586
|
+
public_url: dashboard.share_token ? getPublicDashboardUrl(dashboard.share_token) : null,
|
|
1587
|
+
charts
|
|
1588
|
+
});
|
|
1589
|
+
} catch (error) {
|
|
1590
|
+
return toolError(error);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
);
|
|
1594
|
+
server.tool(
|
|
1595
|
+
"analytics_dashboard_create",
|
|
1596
|
+
"Create an empty analytics dashboard in an org and return dashboard_id and dashboard_url. Then save charts with analytics_chart_create and add_to_dashboard, or add saved charts with analytics_dashboard_add_chart. " + LAYOUT_HINT,
|
|
1597
|
+
{
|
|
1598
|
+
org_id: z10.string().optional().describe("The analytics org ID from analytics_orgs_list (uses MCP_ANALYTICS_ORG_ID env if not provided)"),
|
|
1599
|
+
dashboard_name: z10.string().min(1).max(200).describe('Dashboard name, e.g. "\u0421\u0430\u0439\u0442 - \u043C\u0435\u0442\u0440\u0438\u043A\u0438"'),
|
|
1600
|
+
dashboard_description: z10.string().max(1e3).optional().describe("One line about what the dashboard shows")
|
|
1601
|
+
},
|
|
1602
|
+
async ({ org_id, dashboard_name, dashboard_description }) => {
|
|
1603
|
+
try {
|
|
1604
|
+
const orgId = getAnalyticsOrgId(org_id);
|
|
1605
|
+
const client = getAnalyticsApiClient();
|
|
1606
|
+
const dashboard = unwrap(
|
|
1607
|
+
await client.post("/analytics_org_dashboards/create_dashboard", {
|
|
1608
|
+
analytics_org: orgId,
|
|
1609
|
+
dashboard_name,
|
|
1610
|
+
...dashboard_description ? { dashboard_description } : {}
|
|
1611
|
+
}),
|
|
1612
|
+
"Create dashboard"
|
|
1613
|
+
);
|
|
1614
|
+
if (!dashboard?._id) {
|
|
1615
|
+
throw new Error("Create dashboard returned no dashboard");
|
|
1616
|
+
}
|
|
1617
|
+
return toolResult({ success: true, dashboard_id: dashboard._id, dashboard_name: dashboard.dashboard_name, dashboard_url: getDashboardUrl(dashboard._id, orgId) });
|
|
1618
|
+
} catch (error) {
|
|
1619
|
+
return toolError(error);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
);
|
|
1623
|
+
server.tool(
|
|
1624
|
+
"analytics_dashboard_update",
|
|
1625
|
+
"Rename a dashboard or change its description",
|
|
1626
|
+
{
|
|
1627
|
+
dashboard_id: z10.string().describe("Dashboard ID"),
|
|
1628
|
+
dashboard_name: z10.string().min(1).max(200).optional().describe("New name"),
|
|
1629
|
+
dashboard_description: z10.string().max(1e3).optional().describe('New description, "" to clear it')
|
|
1630
|
+
},
|
|
1631
|
+
async ({ dashboard_id, dashboard_name, dashboard_description }) => {
|
|
1632
|
+
try {
|
|
1633
|
+
const dashboard = await getDashboard(dashboard_id);
|
|
1634
|
+
const client = getAnalyticsApiClient();
|
|
1635
|
+
unwrap(
|
|
1636
|
+
await client.put(apiPath`/analytics_org_dashboards/update_dashboard/${dashboard_id}`, {
|
|
1637
|
+
analytics_org: dashboard.analytics_org,
|
|
1638
|
+
dashboard_name: dashboard_name ?? dashboard.dashboard_name,
|
|
1639
|
+
dashboard_description: dashboard_description ?? dashboard.dashboard_description ?? ""
|
|
1640
|
+
}),
|
|
1641
|
+
"Update dashboard"
|
|
1642
|
+
);
|
|
1643
|
+
return toolResult({ success: true, dashboard_id, dashboard_url: getDashboardUrl(dashboard_id, dashboard.analytics_org) });
|
|
1644
|
+
} catch (error) {
|
|
1645
|
+
return toolError(error);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
);
|
|
1649
|
+
server.tool(
|
|
1650
|
+
"analytics_dashboard_add_chart",
|
|
1651
|
+
"Put a saved chart onto a dashboard at a position (the end by default) with a width; charts below move down. Returns the new layout. " + LAYOUT_HINT,
|
|
1652
|
+
{
|
|
1653
|
+
dashboard_id: z10.string().describe("Dashboard ID"),
|
|
1654
|
+
chart_id: z10.string().describe("Chart ID from analytics_chart_create or analytics_dashboard_get"),
|
|
1655
|
+
width_size: widthSchema.optional().describe("1 = a third of the row, 2 = two thirds, 3 = full row. Default 1"),
|
|
1656
|
+
position: z10.number().int().min(0).optional().describe("Place counting from 0. At the end when not set")
|
|
1657
|
+
},
|
|
1658
|
+
async ({ dashboard_id, chart_id, width_size, position }) => {
|
|
1659
|
+
try {
|
|
1660
|
+
return toolResult({ success: true, ...await addChartToDashboard(dashboard_id, chart_id, width_size || 1, position) });
|
|
1661
|
+
} catch (error) {
|
|
1662
|
+
return toolError(error);
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
);
|
|
1666
|
+
server.tool(
|
|
1667
|
+
"analytics_dashboard_set_chart_position",
|
|
1668
|
+
"Move a chart on a dashboard and/or change its width. position is the place counting from 0: other charts shift to keep the order. Returns the new layout. " + LAYOUT_HINT,
|
|
1669
|
+
{
|
|
1670
|
+
dashboard_id: z10.string().describe("Dashboard ID"),
|
|
1671
|
+
chart_id: z10.string().describe("Chart ID on this dashboard"),
|
|
1672
|
+
position: z10.number().int().min(0).optional().describe("New place counting from 0, unchanged when not set"),
|
|
1673
|
+
width_size: widthSchema.optional().describe("New width, unchanged when not set")
|
|
1674
|
+
},
|
|
1675
|
+
async ({ dashboard_id, chart_id, position, width_size }) => {
|
|
1676
|
+
try {
|
|
1677
|
+
const dashboard = await getDashboard(dashboard_id);
|
|
1678
|
+
const current = sortedCharts(dashboard);
|
|
1679
|
+
const currentIndex = current.findIndex((record) => record.chart_id === chart_id);
|
|
1680
|
+
if (currentIndex < 0) {
|
|
1681
|
+
throw new Error(`Chart ${chart_id} is not on dashboard ${dashboard_id}, add it with analytics_dashboard_add_chart`);
|
|
1682
|
+
}
|
|
1683
|
+
const target = current.map((record) => ({ chart_id: record.chart_id, width_size: record.chart_position_data?.width_size ?? 1 }));
|
|
1684
|
+
const [moved] = target.splice(currentIndex, 1);
|
|
1685
|
+
if (width_size) moved.width_size = width_size;
|
|
1686
|
+
target.splice(position === void 0 ? currentIndex : Math.min(position, target.length), 0, moved);
|
|
1687
|
+
await applyLayout(dashboard_id, current, target);
|
|
1688
|
+
return toolResult({
|
|
1689
|
+
success: true,
|
|
1690
|
+
dashboard_url: getDashboardUrl(dashboard_id, dashboard.analytics_org),
|
|
1691
|
+
layout: describeLayout(await getDashboard(dashboard_id))
|
|
1692
|
+
});
|
|
1693
|
+
} catch (error) {
|
|
1694
|
+
return toolError(error);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
);
|
|
1698
|
+
server.tool(
|
|
1699
|
+
"analytics_dashboard_remove_chart",
|
|
1700
|
+
"Take a chart off a dashboard. The chart itself stays saved (delete it with analytics_chart_delete)",
|
|
1701
|
+
{
|
|
1702
|
+
dashboard_id: z10.string().describe("Dashboard ID"),
|
|
1703
|
+
chart_id: z10.string().describe("Chart ID")
|
|
1704
|
+
},
|
|
1705
|
+
async ({ dashboard_id, chart_id }) => {
|
|
1706
|
+
try {
|
|
1707
|
+
const client = getAnalyticsApiClient();
|
|
1708
|
+
const dashboard = unwrap(
|
|
1709
|
+
await client.post(apiPath`/analytics_org_dashboards/remove_chart_from_dashboard/${dashboard_id}/${chart_id}`),
|
|
1710
|
+
"Remove chart from dashboard"
|
|
1711
|
+
);
|
|
1712
|
+
return toolResult({ success: true, layout: dashboard ? describeLayout(dashboard) : [] });
|
|
1713
|
+
} catch (error) {
|
|
1714
|
+
return toolError(error);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
);
|
|
1718
|
+
server.tool(
|
|
1719
|
+
"analytics_dashboard_share_link",
|
|
1720
|
+
"Turn the public link of a dashboard on, reissue it or turn it off. Anyone with the public link sees the dashboard charts without login (read only, they can change only the period); it works until it is turned off. enable keeps the current link if it is already on, reissue makes a new link and the old one stops working at once, disable turns it off. Needs the owner or editor role in the org",
|
|
1721
|
+
{
|
|
1722
|
+
dashboard_id: z10.string().describe("Dashboard ID"),
|
|
1723
|
+
action: z10.enum(["enable", "reissue", "disable"]).describe("enable, reissue or disable the public link")
|
|
1724
|
+
},
|
|
1725
|
+
async ({ dashboard_id, action }) => {
|
|
1726
|
+
try {
|
|
1727
|
+
const client = getAnalyticsApiClient();
|
|
1728
|
+
if (action === "enable") {
|
|
1729
|
+
const dashboard = await getDashboard(dashboard_id);
|
|
1730
|
+
if (dashboard.share_token) {
|
|
1731
|
+
return toolResult({ success: true, public_url: getPublicDashboardUrl(dashboard.share_token), dashboard_url: getDashboardUrl(dashboard_id, dashboard.analytics_org) });
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
const result = unwrap(
|
|
1735
|
+
await client.put(apiPath`/analytics_org_dashboards/set_dashboard_share_link/${dashboard_id}`, {
|
|
1736
|
+
is_enabled: action !== "disable",
|
|
1737
|
+
...action === "reissue" ? { is_new_token: true } : {}
|
|
1738
|
+
}),
|
|
1739
|
+
"Set dashboard share link"
|
|
1740
|
+
);
|
|
1741
|
+
return toolResult({ success: true, public_url: result?.share_token ? getPublicDashboardUrl(result.share_token) : null });
|
|
1742
|
+
} catch (error) {
|
|
1743
|
+
return toolError(error);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
);
|
|
1747
|
+
server.tool(
|
|
1748
|
+
"analytics_dashboard_delete",
|
|
1749
|
+
"Delete a dashboard for good. With delete_charts true its charts are deleted too, except charts that are also shown on other dashboards. Irreversible, ask the user first",
|
|
1750
|
+
{
|
|
1751
|
+
dashboard_id: z10.string().describe("Dashboard ID"),
|
|
1752
|
+
delete_charts: z10.boolean().optional().describe("Also delete the charts of the dashboard. Default false: charts stay saved")
|
|
1753
|
+
},
|
|
1754
|
+
async ({ dashboard_id, delete_charts }) => {
|
|
1755
|
+
try {
|
|
1756
|
+
const client = getAnalyticsApiClient();
|
|
1757
|
+
const dashboard = await getDashboard(dashboard_id);
|
|
1758
|
+
const chartIds = (dashboard.dashboard_charts_data_array || []).map((record) => record.chart_id);
|
|
1759
|
+
const result = unwrap(await client.delete(apiPath`/analytics_org_dashboards/delete_dashboard/${dashboard_id}`), "Delete dashboard");
|
|
1760
|
+
const deletedCharts = [];
|
|
1761
|
+
const keptCharts = [];
|
|
1762
|
+
if (delete_charts) {
|
|
1763
|
+
for (const chartId of chartIds) {
|
|
1764
|
+
const others = unwrap(
|
|
1765
|
+
await client.get(apiPath`/analytics_org_dashboards/get_dashboard_where_chart_applied/${chartId}`),
|
|
1766
|
+
"Find dashboards of the chart"
|
|
1767
|
+
);
|
|
1768
|
+
if ((others || []).length) {
|
|
1769
|
+
keptCharts.push(chartId);
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
unwrap(await client.delete(apiPath`/analytics_charts/delete_chart_by_id/${chartId}`), "Delete chart");
|
|
1773
|
+
deletedCharts.push(chartId);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
return toolResult({
|
|
1777
|
+
success: !!result?.success,
|
|
1778
|
+
deleted_charts: deletedCharts,
|
|
1779
|
+
...keptCharts.length ? { kept_charts_used_on_other_dashboards: keptCharts } : {}
|
|
1780
|
+
});
|
|
1781
|
+
} catch (error) {
|
|
1782
|
+
return toolError(error);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
);
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1788
|
+
// src/tools/analytics-chart.tools.ts
|
|
1789
|
+
var CHART_FLOW_HINT = "How to build a chart from a request in words: 1) analytics_orgs_list and analytics_projects_list to get org_id and app_project_id; 2) analytics_event_types_list to find event types by name (page_viewed, purchase_completed...); 3) analytics_event_properties_list for property keys used in conditions and breakdowns; 4) analytics_chart_preview to check the numbers; 5) analytics_chart_create to save it (optionally straight onto a dashboard). Event type ids and property keys must come from those tools, never guess them.";
|
|
1790
|
+
var FUNNEL_EXAMPLE = 'Example, "build a funnel from a view to a purchase for the last 30 days": chart_variant "FUNNEL", series [{event_type_id: "<id of page_viewed>", title: "\u041F\u0440\u043E\u0441\u043C\u043E\u0442\u0440"}, {event_type_id: "<id of checkout_started>", title: "\u041D\u0430\u0447\u0430\u043B \u043E\u043F\u043B\u0430\u0442\u0443"}, {event_type_id: "<id of purchase_completed>", title: "\u041F\u043E\u043A\u0443\u043F\u043A\u0430"}], period {time_scale: "DAILY", last_periods_count: 30}, funnel_conversion_window_seconds 604800 (steps within 7 days). Example of a split: chart_variant "BARS", series [{event_type_id: "<id of page_viewed>", title: "\u041F\u043E\u0441\u0435\u0442\u0438\u0442\u0435\u043B\u0438", breakdown_property_key: "traffic_channel"}], display_settings {bars_mode: "TOTAL"}.';
|
|
1791
|
+
var savedChartFields = ["chart_variant", "search_events_input", "group_periods_input", "funnel_settings", "retention_settings", "timezone_offset_minutes"];
|
|
1792
|
+
var definitionUpdateKeys = [
|
|
1793
|
+
"app_project_id",
|
|
1794
|
+
"chart_variant",
|
|
1795
|
+
"series",
|
|
1796
|
+
"common_conditions",
|
|
1797
|
+
"user_conditions",
|
|
1798
|
+
"metric",
|
|
1799
|
+
"period",
|
|
1800
|
+
"compare_previous_period",
|
|
1801
|
+
"funnel_conversion_window_seconds",
|
|
1802
|
+
"retention_periods_count",
|
|
1803
|
+
"timezone_offset_minutes"
|
|
1804
|
+
];
|
|
1805
|
+
var getPropertyIdsByEventType = async (eventTypeIds) => {
|
|
1806
|
+
const client = getAnalyticsApiClient();
|
|
1807
|
+
const uniqueIds = [...new Set(eventTypeIds)];
|
|
1808
|
+
const responses = await Promise.all(
|
|
1809
|
+
uniqueIds.map((id) => client.get(apiPath`/analytics_property_records/get_properties_by_event_type/${id}`))
|
|
1810
|
+
);
|
|
1811
|
+
const result = {};
|
|
1812
|
+
responses.forEach((response, index) => {
|
|
1813
|
+
if (!response.success || !Array.isArray(response.data)) return;
|
|
1814
|
+
result[uniqueIds[index]] = Object.fromEntries(response.data.map((property) => [property.property_key, property._id]));
|
|
1815
|
+
});
|
|
1816
|
+
return result;
|
|
1817
|
+
};
|
|
1818
|
+
var buildBody = async (definition, orgId) => {
|
|
1819
|
+
const errors = validateChartDefinition(definition);
|
|
1820
|
+
if (errors.length) {
|
|
1821
|
+
throw new Error(errors.join("; "));
|
|
1822
|
+
}
|
|
1823
|
+
const propertyIds = await getPropertyIdsByEventType(definition.series.map((series) => series.event_type_id));
|
|
1824
|
+
return buildChartRequestBody(definition, orgId, propertyIds);
|
|
1825
|
+
};
|
|
1826
|
+
var renderChart = async (body) => {
|
|
1827
|
+
const client = getAnalyticsApiClient();
|
|
1828
|
+
return unwrap(await client.put("/analytics_charts/render_analytics_chart_view_data", body), "Chart render");
|
|
1829
|
+
};
|
|
1830
|
+
var getSavedChart = async (chartId) => {
|
|
1831
|
+
const client = getAnalyticsApiClient();
|
|
1832
|
+
const chart = unwrap(await client.get(apiPath`/analytics_charts/get_chart_by_id/${chartId}`), "Get chart");
|
|
1833
|
+
if (!chart?._id) {
|
|
1834
|
+
throw new Error(`Chart ${chartId} is not found`);
|
|
1835
|
+
}
|
|
1836
|
+
return chart;
|
|
1837
|
+
};
|
|
1838
|
+
var getSavedChartBody = (chart) => {
|
|
1839
|
+
const body = {};
|
|
1840
|
+
savedChartFields.forEach((field) => {
|
|
1841
|
+
const value = chart[field];
|
|
1842
|
+
if (value !== null && value !== void 0) body[field] = compactSavedValue(value);
|
|
1843
|
+
});
|
|
1844
|
+
return body;
|
|
1845
|
+
};
|
|
1846
|
+
var addToDashboardSchema = z11.object({
|
|
1847
|
+
dashboard_id: z11.string().describe("Dashboard ID from analytics_dashboards_list or analytics_dashboard_create"),
|
|
1848
|
+
width_size: z11.union([z11.literal(1), z11.literal(2), z11.literal(3)]).optional().describe("Width in a row of 3 columns: 1 = third, 2 = two thirds, 3 = full row. Default 1"),
|
|
1849
|
+
position: z11.number().int().min(0).optional().describe("Place on the dashboard counting from 0, other charts move down. At the end when not set")
|
|
1850
|
+
}).describe("Put the saved chart onto a dashboard right away");
|
|
1851
|
+
var registerAnalyticsChartTools = (server) => {
|
|
1852
|
+
server.tool(
|
|
1853
|
+
"analytics_event_properties_list",
|
|
1854
|
+
"List property keys ever sent with an event type (property_key, seen_count, last_seen_time), the most used first. Use the keys in series conditions, common_conditions and breakdown_property_key of chart tools. To see the values of a property, preview a BARS chart with breakdown_property_key set to it",
|
|
1855
|
+
{
|
|
1856
|
+
event_type_id: z11.string().describe("Event type ID from analytics_event_types_list")
|
|
1857
|
+
},
|
|
1858
|
+
async ({ event_type_id }) => {
|
|
1859
|
+
try {
|
|
1860
|
+
const client = getAnalyticsApiClient();
|
|
1861
|
+
const properties = unwrap(
|
|
1862
|
+
await client.get(apiPath`/analytics_property_records/get_properties_by_event_type/${event_type_id}`),
|
|
1863
|
+
"Get properties"
|
|
1864
|
+
);
|
|
1865
|
+
const list = (properties || []).map((property) => ({
|
|
1866
|
+
property_key: property.property_key,
|
|
1867
|
+
seen_count: property.seen_count ?? null,
|
|
1868
|
+
last_seen_time: property.last_seen_time ?? null
|
|
1869
|
+
})).sort((a, b) => (b.seen_count || 0) - (a.seen_count || 0));
|
|
1870
|
+
return toolResult({ success: true, data: list });
|
|
1871
|
+
} catch (error) {
|
|
1872
|
+
return toolError(error);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
);
|
|
1876
|
+
server.tool(
|
|
1877
|
+
"analytics_chart_preview",
|
|
1878
|
+
"Calculate a chart without saving it and return its numbers: totals of every series, values per period, funnel steps with conversion, or retention by period. Pass a chart definition (the same fields as analytics_chart_create) or chart_id of a saved chart. Use it before analytics_chart_create to check that the chart has data and the series names for display_settings. " + CHART_FLOW_HINT,
|
|
1879
|
+
{
|
|
1880
|
+
chart_id: z11.string().optional().describe("Saved chart ID to calculate as it is saved. When set, the other fields are ignored"),
|
|
1881
|
+
...Object.fromEntries(Object.entries(chartDefinitionShape).map(([key, schema]) => [key, schema.optional()]))
|
|
1882
|
+
},
|
|
1883
|
+
async (input) => {
|
|
1884
|
+
try {
|
|
1885
|
+
if (typeof input.chart_id === "string" && input.chart_id) {
|
|
1886
|
+
const chart = await getSavedChart(input.chart_id);
|
|
1887
|
+
const render2 = await renderChart(getSavedChartBody(chart));
|
|
1888
|
+
const metric = chart.group_periods_input?.group_rules?.uniques || "UNIQ_USERS";
|
|
1889
|
+
return toolResult({ success: true, chart_name: chart.chart_name, data: summarizeChartRender(render2, chart.chart_variant || "LINES_CHART", metric) });
|
|
1890
|
+
}
|
|
1891
|
+
const definition = z11.object(chartDefinitionShape).parse(input);
|
|
1892
|
+
const orgId = getAnalyticsOrgId(definition.org_id);
|
|
1893
|
+
const { body, warnings } = await buildBody(definition, orgId);
|
|
1894
|
+
const render = await renderChart(body);
|
|
1895
|
+
return toolResult({
|
|
1896
|
+
success: true,
|
|
1897
|
+
...warnings.length ? { warnings } : {},
|
|
1898
|
+
data: summarizeChartRender(render, definition.chart_variant, definition.metric)
|
|
1899
|
+
});
|
|
1900
|
+
} catch (error) {
|
|
1901
|
+
return toolError(error);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
);
|
|
1905
|
+
server.tool(
|
|
1906
|
+
"analytics_chart_create",
|
|
1907
|
+
"Save a new analytics chart: a line, bars, a funnel or retention, with conditions, a split by a property and display settings. Returns chart_id and chart_url (the chart in the web app). Set add_to_dashboard to put it onto a dashboard in the same call. A chart counts a live period by default (last 30 days) and stays up to date. " + CHART_FLOW_HINT + " " + FUNNEL_EXAMPLE,
|
|
1908
|
+
{
|
|
1909
|
+
chart_name: z11.string().min(1).max(200).describe('Chart name shown on the dashboard, short, e.g. "\u0412\u043E\u0440\u043E\u043D\u043A\u0430: \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u2192 \u043F\u043E\u043A\u0443\u043F\u043A\u0430"'),
|
|
1910
|
+
chart_description: z11.string().max(1e3).optional().describe("One line under the name: what the chart counts"),
|
|
1911
|
+
...chartDefinitionShape,
|
|
1912
|
+
display_settings: displaySettingsSchema.optional(),
|
|
1913
|
+
add_to_dashboard: addToDashboardSchema.optional()
|
|
1914
|
+
},
|
|
1915
|
+
async ({ chart_name, chart_description, display_settings, add_to_dashboard, ...definition }) => {
|
|
1916
|
+
try {
|
|
1917
|
+
const orgId = getAnalyticsOrgId(definition.org_id);
|
|
1918
|
+
const { body, warnings } = await buildBody(definition, orgId);
|
|
1919
|
+
const client = getAnalyticsApiClient();
|
|
1920
|
+
const chart = unwrap(
|
|
1921
|
+
await client.post("/analytics_charts/create_chart", {
|
|
1922
|
+
...body,
|
|
1923
|
+
chart_name,
|
|
1924
|
+
...chart_description ? { chart_description } : {},
|
|
1925
|
+
analytics_org: orgId,
|
|
1926
|
+
...display_settings ? { display_settings } : {}
|
|
1927
|
+
}),
|
|
1928
|
+
"Create chart"
|
|
1929
|
+
);
|
|
1930
|
+
if (!chart?._id) {
|
|
1931
|
+
throw new Error("Create chart returned no chart");
|
|
1932
|
+
}
|
|
1933
|
+
const result = {
|
|
1934
|
+
success: true,
|
|
1935
|
+
chart_id: chart._id,
|
|
1936
|
+
chart_name: chart.chart_name,
|
|
1937
|
+
chart_variant: chart.chart_variant,
|
|
1938
|
+
chart_url: getChartUrl(chart._id, orgId)
|
|
1939
|
+
};
|
|
1940
|
+
if (warnings.length) result.warnings = warnings;
|
|
1941
|
+
if (add_to_dashboard) {
|
|
1942
|
+
result.dashboard = await addChartToDashboard(add_to_dashboard.dashboard_id, chart._id, add_to_dashboard.width_size || 1, add_to_dashboard.position);
|
|
1943
|
+
}
|
|
1944
|
+
return toolResult(result);
|
|
1945
|
+
} catch (error) {
|
|
1946
|
+
return toolError(error);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
);
|
|
1950
|
+
server.tool(
|
|
1951
|
+
"analytics_chart_get",
|
|
1952
|
+
"Get a saved chart as a chart definition (the fields of analytics_chart_create: series with their conditions, period, metric, display_settings) and its chart_url. Read it before analytics_chart_update to change one part and send the rest back",
|
|
1953
|
+
{
|
|
1954
|
+
chart_id: z11.string().describe("Chart ID")
|
|
1955
|
+
},
|
|
1956
|
+
async ({ chart_id }) => {
|
|
1957
|
+
try {
|
|
1958
|
+
const chart = await getSavedChart(chart_id);
|
|
1959
|
+
const orgId = chart.analytics_org || "";
|
|
1960
|
+
return toolResult({ success: true, chart_id: chart._id, chart_url: getChartUrl(chart._id, orgId), definition: savedChartToDefinition(chart) });
|
|
1961
|
+
} catch (error) {
|
|
1962
|
+
return toolError(error);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
);
|
|
1966
|
+
server.tool(
|
|
1967
|
+
"analytics_chart_update",
|
|
1968
|
+
"Change a saved chart. Pass only what changes: the name, the description, display_settings (replaced as a whole), the period, the metric or the chart type; the rest stays as saved. series replaces all series; common_conditions and user_conditions need series in the same call (take them from analytics_chart_get). Dashboards with the chart show the change at once",
|
|
1969
|
+
{
|
|
1970
|
+
chart_id: z11.string().describe("Chart ID"),
|
|
1971
|
+
chart_name: z11.string().min(1).max(200).optional().describe("New chart name"),
|
|
1972
|
+
chart_description: z11.string().max(1e3).optional().describe('New description, "" to clear it'),
|
|
1973
|
+
...Object.fromEntries(
|
|
1974
|
+
Object.entries(chartDefinitionShape).filter(([key]) => key !== "org_id").map(([key, schema]) => [key, schema.optional()])
|
|
1975
|
+
),
|
|
1976
|
+
display_settings: displaySettingsSchema.optional()
|
|
1977
|
+
},
|
|
1978
|
+
async (input) => {
|
|
1979
|
+
try {
|
|
1980
|
+
const chartId = String(input.chart_id || "");
|
|
1981
|
+
const chart = await getSavedChart(chartId);
|
|
1982
|
+
const orgId = chart.analytics_org || "";
|
|
1983
|
+
const changedKeys = definitionUpdateKeys.filter((key) => input[key] !== void 0);
|
|
1984
|
+
if ((input.common_conditions !== void 0 || input.user_conditions !== void 0) && input.series === void 0) {
|
|
1985
|
+
throw new Error("common_conditions and user_conditions are stored inside the series: pass series too (take them from analytics_chart_get)");
|
|
1986
|
+
}
|
|
1987
|
+
let body;
|
|
1988
|
+
let warnings = [];
|
|
1989
|
+
if (changedKeys.length) {
|
|
1990
|
+
const saved = savedChartToDefinition(chart);
|
|
1991
|
+
const merged = {
|
|
1992
|
+
app_project_id: saved.app_project_id,
|
|
1993
|
+
chart_variant: saved.chart_variant,
|
|
1994
|
+
series: saved.series,
|
|
1995
|
+
metric: saved.metric,
|
|
1996
|
+
period: saved.period,
|
|
1997
|
+
compare_previous_period: saved.compare_previous_period,
|
|
1998
|
+
funnel_conversion_window_seconds: saved.funnel_conversion_window_seconds,
|
|
1999
|
+
retention_periods_count: saved.retention_periods_count,
|
|
2000
|
+
timezone_offset_minutes: saved.timezone_offset_minutes,
|
|
2001
|
+
user_conditions: saved.user_conditions
|
|
2002
|
+
};
|
|
2003
|
+
changedKeys.forEach((key) => {
|
|
2004
|
+
merged[key] = input[key];
|
|
2005
|
+
});
|
|
2006
|
+
if (merged.chart_variant !== "FUNNEL") delete merged.funnel_conversion_window_seconds;
|
|
2007
|
+
if (merged.chart_variant !== "RETENTION") delete merged.retention_periods_count;
|
|
2008
|
+
const definition = z11.object(chartDefinitionShape).parse(merged);
|
|
2009
|
+
const built = await buildBody(definition, orgId);
|
|
2010
|
+
body = { ...built.body };
|
|
2011
|
+
warnings = built.warnings;
|
|
2012
|
+
} else {
|
|
2013
|
+
body = getSavedChartBody(chart);
|
|
2014
|
+
}
|
|
2015
|
+
const displaySettings = input.display_settings ?? (chart.display_settings ? compactSavedValue(chart.display_settings) : void 0);
|
|
2016
|
+
const description = input.chart_description !== void 0 ? input.chart_description : chart.chart_description;
|
|
2017
|
+
const client = getAnalyticsApiClient();
|
|
2018
|
+
const updated = unwrap(
|
|
2019
|
+
await client.post(apiPath`/analytics_charts/update_chart/${chartId}`, {
|
|
2020
|
+
...body,
|
|
2021
|
+
chart_name: input.chart_name ?? chart.chart_name,
|
|
2022
|
+
...typeof description === "string" ? { chart_description: description } : {},
|
|
2023
|
+
analytics_org: orgId,
|
|
2024
|
+
...displaySettings ? { display_settings: displaySettings } : {}
|
|
2025
|
+
}),
|
|
2026
|
+
"Update chart"
|
|
2027
|
+
);
|
|
2028
|
+
return toolResult({
|
|
2029
|
+
success: true,
|
|
2030
|
+
chart_id: chartId,
|
|
2031
|
+
chart_name: updated?.chart_name,
|
|
2032
|
+
chart_url: getChartUrl(chartId, orgId),
|
|
2033
|
+
...warnings.length ? { warnings } : {}
|
|
2034
|
+
});
|
|
2035
|
+
} catch (error) {
|
|
2036
|
+
return toolError(error);
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
);
|
|
2040
|
+
server.tool(
|
|
2041
|
+
"analytics_chart_delete",
|
|
2042
|
+
"Delete a saved chart for good and remove it from every dashboard where it is shown. Irreversible, ask the user first",
|
|
2043
|
+
{
|
|
2044
|
+
chart_id: z11.string().describe("Chart ID")
|
|
2045
|
+
},
|
|
2046
|
+
async ({ chart_id }) => {
|
|
2047
|
+
try {
|
|
2048
|
+
const client = getAnalyticsApiClient();
|
|
2049
|
+
const dashboards = unwrap(
|
|
2050
|
+
await client.get(apiPath`/analytics_org_dashboards/get_dashboard_where_chart_applied/${chart_id}`),
|
|
2051
|
+
"Find dashboards of the chart"
|
|
2052
|
+
);
|
|
2053
|
+
for (const dashboard of dashboards || []) {
|
|
2054
|
+
unwrap(await client.post(apiPath`/analytics_org_dashboards/remove_chart_from_dashboard/${dashboard._id}/${chart_id}`), "Remove chart from dashboard");
|
|
2055
|
+
}
|
|
2056
|
+
const result = unwrap(await client.delete(apiPath`/analytics_charts/delete_chart_by_id/${chart_id}`), "Delete chart");
|
|
2057
|
+
return toolResult({ success: !!result?.success, removed_from_dashboards: (dashboards || []).map((dashboard) => dashboard._id) });
|
|
2058
|
+
} catch (error) {
|
|
2059
|
+
return toolError(error);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
);
|
|
2063
|
+
};
|
|
2064
|
+
|
|
1105
2065
|
// src/index.ts
|
|
1106
2066
|
var SERVER_NAME = "nana800-mcp-server";
|
|
1107
|
-
var SERVER_VERSION = "1.
|
|
2067
|
+
var SERVER_VERSION = "1.3.0";
|
|
1108
2068
|
var main = async () => {
|
|
1109
2069
|
const apiKey = process.env.MCP_API_KEY;
|
|
1110
2070
|
if (!apiKey) {
|
|
@@ -1123,6 +2083,8 @@ var main = async () => {
|
|
|
1123
2083
|
registerSchemeProcessTools(server);
|
|
1124
2084
|
registerPaymentAccountTools(server);
|
|
1125
2085
|
registerAnalyticsExportTools(server);
|
|
2086
|
+
registerAnalyticsChartTools(server);
|
|
2087
|
+
registerAnalyticsDashboardTools(server);
|
|
1126
2088
|
const transport = new StdioServerTransport();
|
|
1127
2089
|
await server.connect(transport);
|
|
1128
2090
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nana800-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"mcpName": "io.nana800/mcp-server",
|
|
5
5
|
"description": "MCP Server for nana800.io Public API - enables AI IDEs to interact with your no-code projects",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://nana800.io",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/interhub/nana800-mcp-server.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/interhub/nana800-mcp-server/issues"
|
|
15
|
+
},
|
|
9
16
|
"files": [
|
|
10
17
|
"dist"
|
|
11
18
|
],
|
|
@@ -18,6 +25,7 @@
|
|
|
18
25
|
"scripts": {
|
|
19
26
|
"build": "node scripts/build.js",
|
|
20
27
|
"typecheck": "tsc --noEmit",
|
|
28
|
+
"test": "node scripts/test.js",
|
|
21
29
|
"prepublishOnly": "npm run build",
|
|
22
30
|
"release": "npm publish --access public"
|
|
23
31
|
},
|