@codegame.dev/careerflow-mcp 1.5.1 → 1.6.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.
|
@@ -11,16 +11,50 @@ import { companyIdSchema, resolveCompanyId, safeHandler, textResult } from "../h
|
|
|
11
11
|
*/
|
|
12
12
|
const MAX_SQL_LENGTH = 8000;
|
|
13
13
|
export function registerCompanySqlTools(server, client) {
|
|
14
|
+
server.registerTool("list_company_sql_schema", {
|
|
15
|
+
title: "List company SQL schema",
|
|
16
|
+
description: "The catalog of v_ai_* views run_company_sql can query. Call with no `views` " +
|
|
17
|
+
"to list every view name and its column count, then call again with the two or " +
|
|
18
|
+
"three views you need to get their columns and types. " +
|
|
19
|
+
"Always check the schema before writing a query — view and column names are not " +
|
|
20
|
+
"guessable from the table names you may know, and a wrong name just fails the query.",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
company_id: companyIdSchema,
|
|
23
|
+
views: z
|
|
24
|
+
.array(z.string())
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('View names to describe, e.g. ["v_ai_kanban_tasks"]. Omit to list all views without columns.')
|
|
27
|
+
}
|
|
28
|
+
}, safeHandler(async (args) => {
|
|
29
|
+
const companyId = resolveCompanyId(client, args.company_id);
|
|
30
|
+
const response = await client.post("ai/sql-schema", {
|
|
31
|
+
company_id: companyId,
|
|
32
|
+
views: args.views
|
|
33
|
+
});
|
|
34
|
+
const data = response.data;
|
|
35
|
+
const body = {
|
|
36
|
+
company_id: data.company_id,
|
|
37
|
+
view_count: data.view_count,
|
|
38
|
+
views: data.views
|
|
39
|
+
};
|
|
40
|
+
if (!args.views?.length) {
|
|
41
|
+
body.note = "Column lists omitted. Call again with `views` to get the columns of the ones you need.";
|
|
42
|
+
}
|
|
43
|
+
return textResult(body);
|
|
44
|
+
}));
|
|
14
45
|
server.registerTool("run_company_sql", {
|
|
15
46
|
title: "Run company SQL",
|
|
16
47
|
description: "Run one read-only SELECT against the company's v_ai_* reporting views " +
|
|
17
48
|
"(tasks, projects, CRM deals/contacts/activities, chats, surveys, users, …). " +
|
|
18
49
|
"Supports JOIN/GROUP BY/SUM/COUNT/window functions. Rules: " +
|
|
19
50
|
"(1) only reference tables named v_ai_* — base tables do not exist for you; " +
|
|
20
|
-
"(2)
|
|
21
|
-
"(3)
|
|
22
|
-
"(4)
|
|
51
|
+
"(2) call list_company_sql_schema first for the exact view and column names; " +
|
|
52
|
+
"(3) aliasing is optional but recommended for joins, e.g. `FROM v_ai_kanban_tasks t`; " +
|
|
53
|
+
"(4) one statement, SELECT or WITH…SELECT only; " +
|
|
54
|
+
"(5) add a LIMIT (hard cap 200 rows). " +
|
|
23
55
|
"Company scoping is automatic — never filter by company yourself. " +
|
|
56
|
+
"A rejected query reports the database's own reason (e.g. an unknown column) — " +
|
|
57
|
+
"read it and check list_company_sql_schema rather than guessing a second time. " +
|
|
24
58
|
"The caller must be the company owner or full-access.",
|
|
25
59
|
inputSchema: {
|
|
26
60
|
company_id: companyIdSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company-sql.js","sourceRoot":"","sources":["../../src/tools/company-sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1F;;;;;;;;GAQG;AAEH,MAAM,cAAc,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"company-sql.js","sourceRoot":"","sources":["../../src/tools/company-sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1F;;;;;;;;GAQG;AAEH,MAAM,cAAc,GAAG,IAAI,CAAA;AAe3B,MAAM,UAAU,uBAAuB,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