@opencx/mcp 1.12.4 → 1.13.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/dist/schema.d.ts +169 -78
- package/dist/schema.d.ts.map +1 -1
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +30 -23
- package/dist/tools/reports.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/tools/reports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/tools/reports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA4BrD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,QA8C1E"}
|
package/dist/tools/reports.js
CHANGED
|
@@ -1,48 +1,55 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ApiError, jsonContent } from '../api-client.js';
|
|
3
|
-
// Keep in sync with the backend
|
|
4
|
-
//
|
|
5
|
-
// them. Add/rename a
|
|
3
|
+
// Keep in sync with the backend reports ClickHouse migrations
|
|
4
|
+
// (`backend/src/reports-clickhouse/reports-clickhouse.migrations.ts`), which
|
|
5
|
+
// create these views and grant `report_reader` SELECT on them. Add/rename a
|
|
6
6
|
// report view → update this list too, or the model is told about a view that
|
|
7
7
|
// doesn't exist (or never learns about a new one).
|
|
8
8
|
const REPORT_VIEWS = [
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
9
|
+
'report_sessions',
|
|
10
|
+
'report_messages',
|
|
11
|
+
'report_session_metrics',
|
|
12
|
+
'report_session_tags',
|
|
13
|
+
'report_csat',
|
|
14
|
+
'report_sla',
|
|
15
|
+
'report_contacts',
|
|
16
|
+
'report_human_agents',
|
|
17
|
+
'report_agent_status',
|
|
18
|
+
'report_agent_teams',
|
|
19
|
+
'report_agent_open_sessions',
|
|
20
|
+
'report_groups',
|
|
21
|
+
'report_group_users',
|
|
22
|
+
'report_resource_usage',
|
|
23
|
+
'report_handoff_reasons',
|
|
24
|
+
'report_handoff_reason_categories',
|
|
25
|
+
'report_contact_reasons',
|
|
26
|
+
'report_contact_reason_runs',
|
|
22
27
|
].join(', ');
|
|
23
28
|
export function registerReportTools(server, client) {
|
|
24
|
-
server.registerTool('
|
|
29
|
+
server.registerTool('run_analytics_query', {
|
|
25
30
|
description: 'Run a read-only SQL query for AD-HOC analytics that the purpose-built tools cannot answer ' +
|
|
26
31
|
'(custom cross-cuts, joins, aggregations over sessions/messages/CSAT/SLA/agents/contacts/tags). ' +
|
|
27
32
|
'Prefer the dedicated tools first (sessions, CSAT, SLA analytics, handoff analytics, impact ' +
|
|
28
33
|
'report, insights) — only reach for this when none of them fit. Queries run read-only and are ' +
|
|
29
|
-
'scoped to the current organization automatically (never add org filters).
|
|
34
|
+
'scoped to the current organization automatically (never add org filters). Column values are ' +
|
|
35
|
+
"RAW (e.g. main_status = 'open', sentiment = 'angry'), never humanized labels. Available views: " +
|
|
30
36
|
REPORT_VIEWS +
|
|
31
|
-
'. Load the "report-query" skill for each view’s columns and example queries.',
|
|
37
|
+
'. Load the "report-query" skill for each view’s columns, exact enum values, and example queries.',
|
|
32
38
|
inputSchema: {
|
|
33
39
|
sql: z
|
|
34
40
|
.string()
|
|
35
|
-
.describe('A single read-only SELECT/WITH query over the report_*
|
|
36
|
-
'
|
|
41
|
+
.describe('A single read-only SELECT/WITH query over the report_* views (ClickHouse SQL dialect: ' +
|
|
42
|
+
'countIf, quantile(0.5)(...), toStartOfWeek, now() - INTERVAL 30 DAY). The org scope is ' +
|
|
43
|
+
'applied server-side — do NOT filter by org_id and do NOT add SETTINGS. On error the ' +
|
|
37
44
|
'message is returned so you can correct the query and retry.'),
|
|
38
45
|
parameters: z
|
|
39
46
|
.array(z.union([z.string(), z.number(), z.boolean(), z.null()]))
|
|
40
47
|
.optional()
|
|
41
|
-
.describe('Optional positional bind values for
|
|
48
|
+
.describe('Optional positional bind values for ? placeholders. Inlining literals is fine too.'),
|
|
42
49
|
},
|
|
43
50
|
}, async (params) => {
|
|
44
51
|
try {
|
|
45
|
-
const { data } = await client.POST('/reports/
|
|
52
|
+
const { data } = await client.POST('/reports/analytics', {
|
|
46
53
|
body: { sql: params.sql, parameters: params.parameters ?? [] },
|
|
47
54
|
});
|
|
48
55
|
return jsonContent(data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.js","sourceRoot":"","sources":["../../src/tools/reports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGzD,
|
|
1
|
+
{"version":3,"file":"reports.js","sourceRoot":"","sources":["../../src/tools/reports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGzD,8DAA8D;AAC9D,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,mDAAmD;AACnD,MAAM,YAAY,GAAG;IACnB,iBAAiB;IACjB,iBAAiB;IACjB,wBAAwB;IACxB,qBAAqB;IACrB,aAAa;IACb,YAAY;IACZ,iBAAi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