portkey-admin-mcp 0.3.5 → 0.3.7
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 +6 -6
- package/build/index.js +1142 -1694
- package/build/server.js +1202 -1730
- package/package.json +3 -3
package/build/index.js
CHANGED
|
@@ -190,15 +190,19 @@ var BaseService = class {
|
|
|
190
190
|
apiKey;
|
|
191
191
|
baseUrl;
|
|
192
192
|
timeout = 3e4;
|
|
193
|
-
constructor(apiKeyOverride) {
|
|
193
|
+
constructor(apiKeyOverride, baseUrlOverride) {
|
|
194
194
|
const apiKey = apiKeyOverride ?? process.env.PORTKEY_API_KEY;
|
|
195
195
|
if (!apiKey) {
|
|
196
196
|
throw new Error("PORTKEY_API_KEY environment variable is not set");
|
|
197
197
|
}
|
|
198
198
|
this.apiKey = apiKey;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
if (baseUrlOverride !== void 0) {
|
|
200
|
+
this.baseUrl = baseUrlOverride;
|
|
201
|
+
} else {
|
|
202
|
+
const baseUrl = process.env.PORTKEY_BASE_URL ?? DEFAULT_BASE_URL;
|
|
203
|
+
validateUrl(baseUrl);
|
|
204
|
+
this.baseUrl = baseUrl;
|
|
205
|
+
}
|
|
202
206
|
}
|
|
203
207
|
encodePathSegment(value) {
|
|
204
208
|
return encodeURIComponent(value);
|
|
@@ -261,7 +265,7 @@ var BaseService = class {
|
|
|
261
265
|
if (options.allowNoContent && response.status === 204) {
|
|
262
266
|
return {};
|
|
263
267
|
}
|
|
264
|
-
return response.json();
|
|
268
|
+
return await response.json();
|
|
265
269
|
} catch (error) {
|
|
266
270
|
const duration_ms = Date.now() - startTime;
|
|
267
271
|
if (!(error instanceof FetchError)) {
|
|
@@ -515,8 +519,11 @@ var ConfigsService = class extends BaseService {
|
|
|
515
519
|
config: JSON.parse(response.config || "{}")
|
|
516
520
|
};
|
|
517
521
|
}
|
|
518
|
-
async listConfigs() {
|
|
519
|
-
return this.get("/configs"
|
|
522
|
+
async listConfigs(params) {
|
|
523
|
+
return this.get("/configs", {
|
|
524
|
+
page_size: params?.page_size,
|
|
525
|
+
current_page: params?.current_page
|
|
526
|
+
});
|
|
520
527
|
}
|
|
521
528
|
async getConfig(slug) {
|
|
522
529
|
const response = await this.get(
|
|
@@ -596,6 +603,7 @@ var GuardrailsService = class extends BaseService {
|
|
|
596
603
|
// src/services/health.service.ts
|
|
597
604
|
var CACHE_TTL_MS = 1e4;
|
|
598
605
|
var HealthService = class extends BaseService {
|
|
606
|
+
timeout = 5e3;
|
|
599
607
|
cachedHealth = null;
|
|
600
608
|
/**
|
|
601
609
|
* Ping the Portkey API to check health
|
|
@@ -614,7 +622,7 @@ var HealthService = class extends BaseService {
|
|
|
614
622
|
}
|
|
615
623
|
const startTime = Date.now();
|
|
616
624
|
try {
|
|
617
|
-
await this.
|
|
625
|
+
await this.get("/configs");
|
|
618
626
|
const latency_ms = Date.now() - startTime;
|
|
619
627
|
const result = {
|
|
620
628
|
status: "ok",
|
|
@@ -631,35 +639,6 @@ var HealthService = class extends BaseService {
|
|
|
631
639
|
throw new Error(`Health check failed: ${errorMessage} (${latency_ms}ms)`);
|
|
632
640
|
}
|
|
633
641
|
}
|
|
634
|
-
/**
|
|
635
|
-
* Internal method to call GET with custom timeout
|
|
636
|
-
*/
|
|
637
|
-
async getWithTimeout(path, timeout) {
|
|
638
|
-
const url = `${this.baseUrl}${path}`;
|
|
639
|
-
const controller = new AbortController();
|
|
640
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
641
|
-
try {
|
|
642
|
-
const response = await fetch(url, {
|
|
643
|
-
method: "GET",
|
|
644
|
-
headers: {
|
|
645
|
-
"x-portkey-api-key": this.apiKey,
|
|
646
|
-
Accept: "application/json"
|
|
647
|
-
},
|
|
648
|
-
signal: controller.signal
|
|
649
|
-
});
|
|
650
|
-
if (!response.ok) {
|
|
651
|
-
throw new Error(`HTTP ${response.status}`);
|
|
652
|
-
}
|
|
653
|
-
return response.json();
|
|
654
|
-
} catch (error) {
|
|
655
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
656
|
-
throw new Error(`Request timed out after ${timeout}ms`);
|
|
657
|
-
}
|
|
658
|
-
throw error;
|
|
659
|
-
} finally {
|
|
660
|
-
clearTimeout(timeoutId);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
642
|
};
|
|
664
643
|
|
|
665
644
|
// src/services/integrations.service.ts
|
|
@@ -741,8 +720,11 @@ var IntegrationsService = class extends BaseService {
|
|
|
741
720
|
// src/services/keys.service.ts
|
|
742
721
|
var KeysService = class extends BaseService {
|
|
743
722
|
// Virtual Keys
|
|
744
|
-
async listVirtualKeys() {
|
|
745
|
-
return this.get("/virtual-keys"
|
|
723
|
+
async listVirtualKeys(params) {
|
|
724
|
+
return this.get("/virtual-keys", {
|
|
725
|
+
page_size: params?.page_size,
|
|
726
|
+
current_page: params?.current_page
|
|
727
|
+
});
|
|
746
728
|
}
|
|
747
729
|
// Phase 2: Virtual Keys CRUD
|
|
748
730
|
async createVirtualKey(data) {
|
|
@@ -1064,9 +1046,13 @@ var McpServersService = class extends BaseService {
|
|
|
1064
1046
|
{}
|
|
1065
1047
|
);
|
|
1066
1048
|
}
|
|
1067
|
-
async listMcpServerCapabilities(id) {
|
|
1049
|
+
async listMcpServerCapabilities(id, params) {
|
|
1068
1050
|
return this.get(
|
|
1069
|
-
`/mcp-servers/${this.encodePathSegment(id)}/capabilities
|
|
1051
|
+
`/mcp-servers/${this.encodePathSegment(id)}/capabilities`,
|
|
1052
|
+
{
|
|
1053
|
+
current_page: params?.current_page,
|
|
1054
|
+
page_size: params?.page_size
|
|
1055
|
+
}
|
|
1070
1056
|
);
|
|
1071
1057
|
}
|
|
1072
1058
|
async updateMcpServerCapabilities(id, data) {
|
|
@@ -1076,9 +1062,13 @@ var McpServersService = class extends BaseService {
|
|
|
1076
1062
|
);
|
|
1077
1063
|
return { success: true };
|
|
1078
1064
|
}
|
|
1079
|
-
async listMcpServerUserAccess(id) {
|
|
1065
|
+
async listMcpServerUserAccess(id, params) {
|
|
1080
1066
|
return this.get(
|
|
1081
|
-
`/mcp-servers/${this.encodePathSegment(id)}/user-access
|
|
1067
|
+
`/mcp-servers/${this.encodePathSegment(id)}/user-access`,
|
|
1068
|
+
{
|
|
1069
|
+
current_page: params?.current_page,
|
|
1070
|
+
page_size: params?.page_size
|
|
1071
|
+
}
|
|
1082
1072
|
);
|
|
1083
1073
|
}
|
|
1084
1074
|
async updateMcpServerUserAccess(id, data) {
|
|
@@ -1262,7 +1252,8 @@ var PromptsService = class extends BaseService {
|
|
|
1262
1252
|
const { dry_run = false, app, env } = data;
|
|
1263
1253
|
const existingPrompts = await this.listPrompts({
|
|
1264
1254
|
collection_id: data.collection_id,
|
|
1265
|
-
search: data.name
|
|
1255
|
+
search: data.name,
|
|
1256
|
+
page_size: 10
|
|
1266
1257
|
});
|
|
1267
1258
|
const existingPrompt = existingPrompts.data.find(
|
|
1268
1259
|
(p) => p.name.toLowerCase() === data.name.toLowerCase()
|
|
@@ -1369,7 +1360,8 @@ var PromptsService = class extends BaseService {
|
|
|
1369
1360
|
const targetName = data.target_name || sourcePrompt.name.replace(/-(dev|staging|prod)$/, "") + `-${data.target_env}`;
|
|
1370
1361
|
const existingTargets = await this.listPrompts({
|
|
1371
1362
|
collection_id: data.target_collection_id,
|
|
1372
|
-
search: targetName
|
|
1363
|
+
search: targetName,
|
|
1364
|
+
page_size: 10
|
|
1373
1365
|
});
|
|
1374
1366
|
const existingTarget = existingTargets.data.find(
|
|
1375
1367
|
(p) => p.name.toLowerCase() === targetName.toLowerCase()
|
|
@@ -1499,8 +1491,11 @@ var TracingService = class extends BaseService {
|
|
|
1499
1491
|
|
|
1500
1492
|
// src/services/users.service.ts
|
|
1501
1493
|
var UsersService = class extends BaseService {
|
|
1502
|
-
async listUsers() {
|
|
1503
|
-
return this.get("/admin/users"
|
|
1494
|
+
async listUsers(params) {
|
|
1495
|
+
return this.get("/admin/users", {
|
|
1496
|
+
page_size: params?.page_size,
|
|
1497
|
+
current_page: params?.current_page
|
|
1498
|
+
});
|
|
1504
1499
|
}
|
|
1505
1500
|
async inviteUser(data) {
|
|
1506
1501
|
return this.post("/admin/users/invites", data);
|
|
@@ -1549,8 +1544,11 @@ var UsersService = class extends BaseService {
|
|
|
1549
1544
|
return { success: true };
|
|
1550
1545
|
}
|
|
1551
1546
|
// Phase 1: User Invites CRUD
|
|
1552
|
-
async listUserInvites() {
|
|
1553
|
-
return this.get("/admin/users/invites"
|
|
1547
|
+
async listUserInvites(params) {
|
|
1548
|
+
return this.get("/admin/users/invites", {
|
|
1549
|
+
page_size: params?.page_size,
|
|
1550
|
+
current_page: params?.current_page
|
|
1551
|
+
});
|
|
1554
1552
|
}
|
|
1555
1553
|
async getUserInvite(inviteId) {
|
|
1556
1554
|
return this.get(
|
|
@@ -1627,6 +1625,7 @@ var WorkspacesService = class extends BaseService {
|
|
|
1627
1625
|
};
|
|
1628
1626
|
|
|
1629
1627
|
// src/services/index.ts
|
|
1628
|
+
import crypto2 from "node:crypto";
|
|
1630
1629
|
function resolvePortkeyApiKey(apiKey) {
|
|
1631
1630
|
const resolvedApiKey = apiKey ?? process.env.PORTKEY_API_KEY;
|
|
1632
1631
|
if (!resolvedApiKey) {
|
|
@@ -1637,23 +1636,13 @@ function resolvePortkeyApiKey(apiKey) {
|
|
|
1637
1636
|
return resolvedApiKey;
|
|
1638
1637
|
}
|
|
1639
1638
|
function getSharedServiceCacheKey(apiKey) {
|
|
1639
|
+
const keyDigest = crypto2.createHash("sha256").update(resolvePortkeyApiKey(apiKey)).digest("hex");
|
|
1640
1640
|
return JSON.stringify({
|
|
1641
|
-
apiKey:
|
|
1641
|
+
apiKey: keyDigest,
|
|
1642
1642
|
baseUrl: process.env.PORTKEY_BASE_URL?.trim() || ""
|
|
1643
1643
|
});
|
|
1644
1644
|
}
|
|
1645
1645
|
var sharedPortkeyServices = /* @__PURE__ */ new Map();
|
|
1646
|
-
var sharedHealthServices = /* @__PURE__ */ new Map();
|
|
1647
|
-
function getSharedHealthService(apiKey) {
|
|
1648
|
-
const cacheKey = getSharedServiceCacheKey(apiKey);
|
|
1649
|
-
const cached = sharedHealthServices.get(cacheKey);
|
|
1650
|
-
if (cached) {
|
|
1651
|
-
return cached;
|
|
1652
|
-
}
|
|
1653
|
-
const service = new HealthService(resolvePortkeyApiKey(apiKey));
|
|
1654
|
-
sharedHealthServices.set(cacheKey, service);
|
|
1655
|
-
return service;
|
|
1656
|
-
}
|
|
1657
1646
|
var PortkeyService = class {
|
|
1658
1647
|
users;
|
|
1659
1648
|
workspaces;
|
|
@@ -1676,25 +1665,33 @@ var PortkeyService = class {
|
|
|
1676
1665
|
health;
|
|
1677
1666
|
constructor(apiKey) {
|
|
1678
1667
|
const resolvedApiKey = resolvePortkeyApiKey(apiKey);
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
this.
|
|
1682
|
-
this.
|
|
1683
|
-
this.
|
|
1684
|
-
this.
|
|
1685
|
-
this.
|
|
1686
|
-
this.
|
|
1687
|
-
this.
|
|
1688
|
-
this.
|
|
1689
|
-
this.
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
this.
|
|
1694
|
-
this.
|
|
1695
|
-
this.
|
|
1696
|
-
this.
|
|
1697
|
-
this.
|
|
1668
|
+
const resolvedBaseUrl = process.env.PORTKEY_BASE_URL ?? "https://api.portkey.ai/v1";
|
|
1669
|
+
validateUrl(resolvedBaseUrl);
|
|
1670
|
+
this.users = new UsersService(resolvedApiKey, resolvedBaseUrl);
|
|
1671
|
+
this.workspaces = new WorkspacesService(resolvedApiKey, resolvedBaseUrl);
|
|
1672
|
+
this.configs = new ConfigsService(resolvedApiKey, resolvedBaseUrl);
|
|
1673
|
+
this.keys = new KeysService(resolvedApiKey, resolvedBaseUrl);
|
|
1674
|
+
this.collections = new CollectionsService(resolvedApiKey, resolvedBaseUrl);
|
|
1675
|
+
this.prompts = new PromptsService(resolvedApiKey, resolvedBaseUrl);
|
|
1676
|
+
this.analytics = new AnalyticsService(resolvedApiKey, resolvedBaseUrl);
|
|
1677
|
+
this.guardrails = new GuardrailsService(resolvedApiKey, resolvedBaseUrl);
|
|
1678
|
+
this.integrations = new IntegrationsService(
|
|
1679
|
+
resolvedApiKey,
|
|
1680
|
+
resolvedBaseUrl
|
|
1681
|
+
);
|
|
1682
|
+
this.limits = new LimitsService(resolvedApiKey, resolvedBaseUrl);
|
|
1683
|
+
this.audit = new AuditService(resolvedApiKey, resolvedBaseUrl);
|
|
1684
|
+
this.labels = new LabelsService(resolvedApiKey, resolvedBaseUrl);
|
|
1685
|
+
this.partials = new PartialsService(resolvedApiKey, resolvedBaseUrl);
|
|
1686
|
+
this.tracing = new TracingService(resolvedApiKey, resolvedBaseUrl);
|
|
1687
|
+
this.logging = new LoggingService(resolvedApiKey, resolvedBaseUrl);
|
|
1688
|
+
this.providers = new ProvidersService(resolvedApiKey, resolvedBaseUrl);
|
|
1689
|
+
this.mcpIntegrations = new McpIntegrationsService(
|
|
1690
|
+
resolvedApiKey,
|
|
1691
|
+
resolvedBaseUrl
|
|
1692
|
+
);
|
|
1693
|
+
this.mcpServers = new McpServersService(resolvedApiKey, resolvedBaseUrl);
|
|
1694
|
+
this.health = new HealthService(resolvedApiKey, resolvedBaseUrl);
|
|
1698
1695
|
}
|
|
1699
1696
|
};
|
|
1700
1697
|
function getSharedPortkeyService(apiKey) {
|
|
@@ -1711,6 +1708,11 @@ function getSharedPortkeyService(apiKey) {
|
|
|
1711
1708
|
// src/tools/index.ts
|
|
1712
1709
|
import { z as z20 } from "zod";
|
|
1713
1710
|
|
|
1711
|
+
// src/lib/type-guards.ts
|
|
1712
|
+
function isRecord(value) {
|
|
1713
|
+
return typeof value === "object" && value !== null;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1714
1716
|
// src/tools/analytics.tools.ts
|
|
1715
1717
|
import { z } from "zod";
|
|
1716
1718
|
var baseAnalyticsSchema = {
|
|
@@ -1786,41 +1788,6 @@ var baseAnalyticsSchema = {
|
|
|
1786
1788
|
),
|
|
1787
1789
|
prompt_slug: z.string().optional().describe("Filter by prompt slug")
|
|
1788
1790
|
};
|
|
1789
|
-
var requestAnalyticsSchema = {
|
|
1790
|
-
...baseAnalyticsSchema,
|
|
1791
|
-
status_codes: z.array(z.string()).optional().describe(
|
|
1792
|
-
"Structured alias for status_code. Use an array of HTTP status codes; normalized to the legacy comma-separated Portkey query param."
|
|
1793
|
-
),
|
|
1794
|
-
virtual_key_slugs: z.array(z.string()).optional().describe(
|
|
1795
|
-
"Structured alias for virtual_keys. Use an array of virtual key slugs; normalized to the legacy comma-separated Portkey query param."
|
|
1796
|
-
),
|
|
1797
|
-
config_slugs: z.array(z.string()).optional().describe(
|
|
1798
|
-
"Structured alias for configs. Use an array of config slugs; normalized to the legacy comma-separated Portkey query param."
|
|
1799
|
-
),
|
|
1800
|
-
api_key_ids: z.preprocess((value) => {
|
|
1801
|
-
if (value == null) {
|
|
1802
|
-
return value;
|
|
1803
|
-
}
|
|
1804
|
-
if (Array.isArray(value)) {
|
|
1805
|
-
return value.map((item) => String(item)).join(",");
|
|
1806
|
-
}
|
|
1807
|
-
return value;
|
|
1808
|
-
}, z.string().optional()).describe(
|
|
1809
|
-
"API key UUIDs. Accepts the legacy comma-separated string or a structured array; normalized to the legacy Portkey query param before the request is sent."
|
|
1810
|
-
),
|
|
1811
|
-
trace_ids: z.array(z.string()).optional().describe(
|
|
1812
|
-
"Structured alias for trace_id. Use an array of trace IDs; normalized to the legacy comma-separated Portkey query param."
|
|
1813
|
-
),
|
|
1814
|
-
span_ids: z.array(z.string()).optional().describe(
|
|
1815
|
-
"Structured alias for span_id. Use an array of span IDs; normalized to the legacy comma-separated Portkey query param."
|
|
1816
|
-
),
|
|
1817
|
-
provider_models: z.array(z.string()).optional().describe(
|
|
1818
|
-
"Structured alias for ai_org_model. Use provider__model strings in an array; normalized to the legacy comma-separated Portkey query param."
|
|
1819
|
-
),
|
|
1820
|
-
metadata_filter: z.record(z.string(), z.unknown()).optional().describe(
|
|
1821
|
-
"Structured alias for metadata. Use an object such as { env: 'prod' }; normalized to a JSON string before the request is sent."
|
|
1822
|
-
)
|
|
1823
|
-
};
|
|
1824
1791
|
var paginatedAnalyticsSchema = {
|
|
1825
1792
|
...baseAnalyticsSchema,
|
|
1826
1793
|
current_page: z.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
@@ -1945,9 +1912,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
1945
1912
|
average_cost_per_request: analytics.summary.avg
|
|
1946
1913
|
},
|
|
1947
1914
|
dataPoints
|
|
1948
|
-
)
|
|
1949
|
-
null,
|
|
1950
|
-
2
|
|
1915
|
+
)
|
|
1951
1916
|
)
|
|
1952
1917
|
}
|
|
1953
1918
|
]
|
|
@@ -1957,7 +1922,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
1957
1922
|
server.tool(
|
|
1958
1923
|
"get_request_analytics",
|
|
1959
1924
|
"Get request-volume time-series data with summary.total_requests, summary.successful_requests, summary.failed_requests, and per-bucket total/success/failed counts. Use this for traffic and reliability trends; use get_error_analytics when you only need error counts.",
|
|
1960
|
-
|
|
1925
|
+
baseAnalyticsSchema,
|
|
1961
1926
|
async (params) => {
|
|
1962
1927
|
const analytics = await service.analytics.getRequestAnalytics(
|
|
1963
1928
|
normalizeAnalyticsParams(params)
|
|
@@ -1980,9 +1945,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
1980
1945
|
failed_requests: analytics.summary.failed
|
|
1981
1946
|
},
|
|
1982
1947
|
dataPoints
|
|
1983
|
-
)
|
|
1984
|
-
null,
|
|
1985
|
-
2
|
|
1948
|
+
)
|
|
1986
1949
|
)
|
|
1987
1950
|
}
|
|
1988
1951
|
]
|
|
@@ -2015,9 +1978,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2015
1978
|
completion_tokens: analytics.summary.completion
|
|
2016
1979
|
},
|
|
2017
1980
|
dataPoints
|
|
2018
|
-
)
|
|
2019
|
-
null,
|
|
2020
|
-
2
|
|
1981
|
+
)
|
|
2021
1982
|
)
|
|
2022
1983
|
}
|
|
2023
1984
|
]
|
|
@@ -2052,9 +2013,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2052
2013
|
p99_latency_ms: analytics.summary.p99
|
|
2053
2014
|
},
|
|
2054
2015
|
dataPoints
|
|
2055
|
-
)
|
|
2056
|
-
null,
|
|
2057
|
-
2
|
|
2016
|
+
)
|
|
2058
2017
|
)
|
|
2059
2018
|
}
|
|
2060
2019
|
]
|
|
@@ -2083,9 +2042,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2083
2042
|
total_errors: analytics.summary.total
|
|
2084
2043
|
},
|
|
2085
2044
|
dataPoints
|
|
2086
|
-
)
|
|
2087
|
-
null,
|
|
2088
|
-
2
|
|
2045
|
+
)
|
|
2089
2046
|
)
|
|
2090
2047
|
}
|
|
2091
2048
|
]
|
|
@@ -2114,9 +2071,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2114
2071
|
error_rate_percent: analytics.summary.rate
|
|
2115
2072
|
},
|
|
2116
2073
|
dataPoints
|
|
2117
|
-
)
|
|
2118
|
-
null,
|
|
2119
|
-
2
|
|
2074
|
+
)
|
|
2120
2075
|
)
|
|
2121
2076
|
}
|
|
2122
2077
|
]
|
|
@@ -2147,9 +2102,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2147
2102
|
avg_latency: analytics.summary.avg
|
|
2148
2103
|
},
|
|
2149
2104
|
dataPoints
|
|
2150
|
-
)
|
|
2151
|
-
null,
|
|
2152
|
-
2
|
|
2105
|
+
)
|
|
2153
2106
|
)
|
|
2154
2107
|
}
|
|
2155
2108
|
]
|
|
@@ -2182,9 +2135,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2182
2135
|
total_misses: analytics.summary.total_misses
|
|
2183
2136
|
},
|
|
2184
2137
|
dataPoints
|
|
2185
|
-
)
|
|
2186
|
-
null,
|
|
2187
|
-
2
|
|
2138
|
+
)
|
|
2188
2139
|
)
|
|
2189
2140
|
}
|
|
2190
2141
|
]
|
|
@@ -2215,9 +2166,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2215
2166
|
total_new_users: analytics.summary.total_new_users
|
|
2216
2167
|
},
|
|
2217
2168
|
dataPoints
|
|
2218
|
-
)
|
|
2219
|
-
null,
|
|
2220
|
-
2
|
|
2169
|
+
)
|
|
2221
2170
|
)
|
|
2222
2171
|
}
|
|
2223
2172
|
]
|
|
@@ -2236,11 +2185,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2236
2185
|
content: [
|
|
2237
2186
|
{
|
|
2238
2187
|
type: "text",
|
|
2239
|
-
text: JSON.stringify(
|
|
2240
|
-
formatGenericGraphAnalytics(analytics),
|
|
2241
|
-
null,
|
|
2242
|
-
2
|
|
2243
|
-
)
|
|
2188
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2244
2189
|
}
|
|
2245
2190
|
]
|
|
2246
2191
|
};
|
|
@@ -2258,11 +2203,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2258
2203
|
content: [
|
|
2259
2204
|
{
|
|
2260
2205
|
type: "text",
|
|
2261
|
-
text: JSON.stringify(
|
|
2262
|
-
formatGenericGraphAnalytics(analytics),
|
|
2263
|
-
null,
|
|
2264
|
-
2
|
|
2265
|
-
)
|
|
2206
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2266
2207
|
}
|
|
2267
2208
|
]
|
|
2268
2209
|
};
|
|
@@ -2280,11 +2221,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2280
2221
|
content: [
|
|
2281
2222
|
{
|
|
2282
2223
|
type: "text",
|
|
2283
|
-
text: JSON.stringify(
|
|
2284
|
-
formatGenericGraphAnalytics(analytics),
|
|
2285
|
-
null,
|
|
2286
|
-
2
|
|
2287
|
-
)
|
|
2224
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2288
2225
|
}
|
|
2289
2226
|
]
|
|
2290
2227
|
};
|
|
@@ -2302,11 +2239,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2302
2239
|
content: [
|
|
2303
2240
|
{
|
|
2304
2241
|
type: "text",
|
|
2305
|
-
text: JSON.stringify(
|
|
2306
|
-
formatGenericGraphAnalytics(analytics),
|
|
2307
|
-
null,
|
|
2308
|
-
2
|
|
2309
|
-
)
|
|
2242
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2310
2243
|
}
|
|
2311
2244
|
]
|
|
2312
2245
|
};
|
|
@@ -2324,11 +2257,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2324
2257
|
content: [
|
|
2325
2258
|
{
|
|
2326
2259
|
type: "text",
|
|
2327
|
-
text: JSON.stringify(
|
|
2328
|
-
formatGenericGraphAnalytics(analytics),
|
|
2329
|
-
null,
|
|
2330
|
-
2
|
|
2331
|
-
)
|
|
2260
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2332
2261
|
}
|
|
2333
2262
|
]
|
|
2334
2263
|
};
|
|
@@ -2346,11 +2275,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2346
2275
|
content: [
|
|
2347
2276
|
{
|
|
2348
2277
|
type: "text",
|
|
2349
|
-
text: JSON.stringify(
|
|
2350
|
-
formatGenericGraphAnalytics(analytics),
|
|
2351
|
-
null,
|
|
2352
|
-
2
|
|
2353
|
-
)
|
|
2278
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2354
2279
|
}
|
|
2355
2280
|
]
|
|
2356
2281
|
};
|
|
@@ -2368,11 +2293,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2368
2293
|
content: [
|
|
2369
2294
|
{
|
|
2370
2295
|
type: "text",
|
|
2371
|
-
text: JSON.stringify(
|
|
2372
|
-
formatGenericGraphAnalytics(analytics),
|
|
2373
|
-
null,
|
|
2374
|
-
2
|
|
2375
|
-
)
|
|
2296
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2376
2297
|
}
|
|
2377
2298
|
]
|
|
2378
2299
|
};
|
|
@@ -2390,11 +2311,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2390
2311
|
content: [
|
|
2391
2312
|
{
|
|
2392
2313
|
type: "text",
|
|
2393
|
-
text: JSON.stringify(
|
|
2394
|
-
formatGenericGraphAnalytics(analytics),
|
|
2395
|
-
null,
|
|
2396
|
-
2
|
|
2397
|
-
)
|
|
2314
|
+
text: JSON.stringify(formatGenericGraphAnalytics(analytics))
|
|
2398
2315
|
}
|
|
2399
2316
|
]
|
|
2400
2317
|
};
|
|
@@ -2412,11 +2329,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2412
2329
|
content: [
|
|
2413
2330
|
{
|
|
2414
2331
|
type: "text",
|
|
2415
|
-
text: JSON.stringify(
|
|
2416
|
-
formatGroupedAnalytics(analytics, "users"),
|
|
2417
|
-
null,
|
|
2418
|
-
2
|
|
2419
|
-
)
|
|
2332
|
+
text: JSON.stringify(formatGroupedAnalytics(analytics, "users"))
|
|
2420
2333
|
}
|
|
2421
2334
|
]
|
|
2422
2335
|
};
|
|
@@ -2434,11 +2347,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2434
2347
|
content: [
|
|
2435
2348
|
{
|
|
2436
2349
|
type: "text",
|
|
2437
|
-
text: JSON.stringify(
|
|
2438
|
-
formatGroupedAnalytics(analytics, "models"),
|
|
2439
|
-
null,
|
|
2440
|
-
2
|
|
2441
|
-
)
|
|
2350
|
+
text: JSON.stringify(formatGroupedAnalytics(analytics, "models"))
|
|
2442
2351
|
}
|
|
2443
2352
|
]
|
|
2444
2353
|
};
|
|
@@ -2459,9 +2368,7 @@ function registerAnalyticsTools(server, service) {
|
|
|
2459
2368
|
{
|
|
2460
2369
|
type: "text",
|
|
2461
2370
|
text: JSON.stringify(
|
|
2462
|
-
formatGroupedAnalytics(analytics, "metadata_groups")
|
|
2463
|
-
null,
|
|
2464
|
-
2
|
|
2371
|
+
formatGroupedAnalytics(analytics, "metadata_groups")
|
|
2465
2372
|
)
|
|
2466
2373
|
}
|
|
2467
2374
|
]
|
|
@@ -2514,31 +2421,27 @@ function registerAuditTools(server, service) {
|
|
|
2514
2421
|
content: [
|
|
2515
2422
|
{
|
|
2516
2423
|
type: "text",
|
|
2517
|
-
text: JSON.stringify(
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
},
|
|
2539
|
-
null,
|
|
2540
|
-
2
|
|
2541
|
-
)
|
|
2424
|
+
text: JSON.stringify({
|
|
2425
|
+
total: result.total,
|
|
2426
|
+
current_page: result.current_page,
|
|
2427
|
+
page_size: result.page_size,
|
|
2428
|
+
audit_logs: result.data.map((log) => ({
|
|
2429
|
+
id: log.id,
|
|
2430
|
+
action: log.action,
|
|
2431
|
+
actor_id: log.actor_id,
|
|
2432
|
+
actor_email: log.actor_email,
|
|
2433
|
+
actor_name: log.actor_name,
|
|
2434
|
+
resource_type: log.resource_type,
|
|
2435
|
+
resource_id: log.resource_id,
|
|
2436
|
+
resource_name: log.resource_name,
|
|
2437
|
+
workspace_id: log.workspace_id,
|
|
2438
|
+
organisation_id: log.organisation_id,
|
|
2439
|
+
metadata: log.metadata,
|
|
2440
|
+
ip_address: log.ip_address,
|
|
2441
|
+
user_agent: log.user_agent,
|
|
2442
|
+
created_at: log.created_at
|
|
2443
|
+
}))
|
|
2444
|
+
})
|
|
2542
2445
|
}
|
|
2543
2446
|
]
|
|
2544
2447
|
};
|
|
@@ -2584,21 +2487,17 @@ function registerCollectionsTools(server, service) {
|
|
|
2584
2487
|
content: [
|
|
2585
2488
|
{
|
|
2586
2489
|
type: "text",
|
|
2587
|
-
text: JSON.stringify(
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
},
|
|
2599
|
-
null,
|
|
2600
|
-
2
|
|
2601
|
-
)
|
|
2490
|
+
text: JSON.stringify({
|
|
2491
|
+
total: collections.total,
|
|
2492
|
+
collections: collections.data.map((collection) => ({
|
|
2493
|
+
id: collection.id,
|
|
2494
|
+
name: collection.name,
|
|
2495
|
+
slug: collection.slug,
|
|
2496
|
+
workspace_id: collection.workspace_id,
|
|
2497
|
+
created_at: collection.created_at,
|
|
2498
|
+
last_updated_at: collection.last_updated_at
|
|
2499
|
+
}))
|
|
2500
|
+
})
|
|
2602
2501
|
}
|
|
2603
2502
|
]
|
|
2604
2503
|
};
|
|
@@ -2614,15 +2513,11 @@ function registerCollectionsTools(server, service) {
|
|
|
2614
2513
|
content: [
|
|
2615
2514
|
{
|
|
2616
2515
|
type: "text",
|
|
2617
|
-
text: JSON.stringify(
|
|
2618
|
-
{
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
},
|
|
2623
|
-
null,
|
|
2624
|
-
2
|
|
2625
|
-
)
|
|
2516
|
+
text: JSON.stringify({
|
|
2517
|
+
message: `Successfully created collection "${params.name}"`,
|
|
2518
|
+
id: result.id,
|
|
2519
|
+
slug: result.slug
|
|
2520
|
+
})
|
|
2626
2521
|
}
|
|
2627
2522
|
]
|
|
2628
2523
|
};
|
|
@@ -2640,18 +2535,14 @@ function registerCollectionsTools(server, service) {
|
|
|
2640
2535
|
content: [
|
|
2641
2536
|
{
|
|
2642
2537
|
type: "text",
|
|
2643
|
-
text: JSON.stringify(
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
},
|
|
2652
|
-
null,
|
|
2653
|
-
2
|
|
2654
|
-
)
|
|
2538
|
+
text: JSON.stringify({
|
|
2539
|
+
id: collection.id,
|
|
2540
|
+
name: collection.name,
|
|
2541
|
+
slug: collection.slug,
|
|
2542
|
+
workspace_id: collection.workspace_id,
|
|
2543
|
+
created_at: collection.created_at,
|
|
2544
|
+
last_updated_at: collection.last_updated_at
|
|
2545
|
+
})
|
|
2655
2546
|
}
|
|
2656
2547
|
]
|
|
2657
2548
|
};
|
|
@@ -2670,14 +2561,10 @@ function registerCollectionsTools(server, service) {
|
|
|
2670
2561
|
content: [
|
|
2671
2562
|
{
|
|
2672
2563
|
type: "text",
|
|
2673
|
-
text: JSON.stringify(
|
|
2674
|
-
{
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
},
|
|
2678
|
-
null,
|
|
2679
|
-
2
|
|
2680
|
-
)
|
|
2564
|
+
text: JSON.stringify({
|
|
2565
|
+
message: `Successfully updated collection "${params.collection_id}"`,
|
|
2566
|
+
success: true
|
|
2567
|
+
})
|
|
2681
2568
|
}
|
|
2682
2569
|
]
|
|
2683
2570
|
};
|
|
@@ -2695,14 +2582,10 @@ function registerCollectionsTools(server, service) {
|
|
|
2695
2582
|
content: [
|
|
2696
2583
|
{
|
|
2697
2584
|
type: "text",
|
|
2698
|
-
text: JSON.stringify(
|
|
2699
|
-
{
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
},
|
|
2703
|
-
null,
|
|
2704
|
-
2
|
|
2705
|
-
)
|
|
2585
|
+
text: JSON.stringify({
|
|
2586
|
+
message: `Successfully deleted collection "${params.collection_id}"`,
|
|
2587
|
+
success: result.success
|
|
2588
|
+
})
|
|
2706
2589
|
}
|
|
2707
2590
|
]
|
|
2708
2591
|
};
|
|
@@ -2713,7 +2596,10 @@ function registerCollectionsTools(server, service) {
|
|
|
2713
2596
|
// src/tools/configs.tools.ts
|
|
2714
2597
|
import { z as z4 } from "zod";
|
|
2715
2598
|
var CONFIGS_TOOL_SCHEMAS = {
|
|
2716
|
-
listConfigs: {
|
|
2599
|
+
listConfigs: {
|
|
2600
|
+
current_page: z4.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
2601
|
+
page_size: z4.coerce.number().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
2602
|
+
},
|
|
2717
2603
|
getConfig: {
|
|
2718
2604
|
slug: z4.string().describe(
|
|
2719
2605
|
"The unique identifier (slug) of the configuration to retrieve. This can be found in the configuration's URL or from the list_configs tool response"
|
|
@@ -2761,6 +2647,19 @@ var CONFIGS_TOOL_SCHEMAS = {
|
|
|
2761
2647
|
slug: z4.string().describe("Configuration slug to list versions for")
|
|
2762
2648
|
}
|
|
2763
2649
|
};
|
|
2650
|
+
var configPayloadSchema = z4.object({
|
|
2651
|
+
cache_mode: z4.enum(["simple", "semantic"]).optional(),
|
|
2652
|
+
cache_max_age: z4.coerce.number().positive().optional(),
|
|
2653
|
+
retry_attempts: z4.coerce.number().positive().max(5).optional(),
|
|
2654
|
+
retry_on_status_codes: z4.array(z4.coerce.number()).optional(),
|
|
2655
|
+
strategy_mode: z4.enum(["loadbalance", "fallback"]).optional(),
|
|
2656
|
+
targets: z4.array(
|
|
2657
|
+
z4.object({
|
|
2658
|
+
provider: z4.string().optional(),
|
|
2659
|
+
virtual_key: z4.string().optional()
|
|
2660
|
+
})
|
|
2661
|
+
).optional()
|
|
2662
|
+
});
|
|
2764
2663
|
function buildConfigPayload(params) {
|
|
2765
2664
|
const cache = params.cache_mode !== void 0 || params.cache_max_age !== void 0 ? {
|
|
2766
2665
|
...params.cache_mode !== void 0 ? { mode: params.cache_mode } : {},
|
|
@@ -2785,31 +2684,30 @@ function registerConfigsTools(server, service) {
|
|
|
2785
2684
|
"list_configs",
|
|
2786
2685
|
"List configs in the org with id, slug, name, status, workspace, and timestamps. Use this summary view to find a slug; use get_config for the full routing, cache, retry, and target settings before updating or deleting.",
|
|
2787
2686
|
CONFIGS_TOOL_SCHEMAS.listConfigs,
|
|
2788
|
-
async () => {
|
|
2789
|
-
const configs = await service.configs.listConfigs(
|
|
2687
|
+
async (params) => {
|
|
2688
|
+
const configs = await service.configs.listConfigs({
|
|
2689
|
+
current_page: params.current_page,
|
|
2690
|
+
page_size: params.page_size
|
|
2691
|
+
});
|
|
2790
2692
|
return {
|
|
2791
2693
|
content: [
|
|
2792
2694
|
{
|
|
2793
2695
|
type: "text",
|
|
2794
|
-
text: JSON.stringify(
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
},
|
|
2810
|
-
null,
|
|
2811
|
-
2
|
|
2812
|
-
)
|
|
2696
|
+
text: JSON.stringify({
|
|
2697
|
+
total: configs.total,
|
|
2698
|
+
configurations: (configs.data ?? []).map((config) => ({
|
|
2699
|
+
id: config.id,
|
|
2700
|
+
name: config.name,
|
|
2701
|
+
slug: config.slug,
|
|
2702
|
+
workspace_id: config.workspace_id,
|
|
2703
|
+
status: config.status,
|
|
2704
|
+
is_default: config.is_default,
|
|
2705
|
+
created_at: config.created_at,
|
|
2706
|
+
last_updated_at: config.last_updated_at,
|
|
2707
|
+
owner_id: config.owner_id,
|
|
2708
|
+
updated_by: config.updated_by
|
|
2709
|
+
}))
|
|
2710
|
+
})
|
|
2813
2711
|
}
|
|
2814
2712
|
]
|
|
2815
2713
|
};
|
|
@@ -2825,35 +2723,31 @@ function registerConfigsTools(server, service) {
|
|
|
2825
2723
|
content: [
|
|
2826
2724
|
{
|
|
2827
2725
|
type: "text",
|
|
2828
|
-
text: JSON.stringify(
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
},
|
|
2854
|
-
null,
|
|
2855
|
-
2
|
|
2856
|
-
)
|
|
2726
|
+
text: JSON.stringify({
|
|
2727
|
+
id: response.id,
|
|
2728
|
+
slug: response.slug,
|
|
2729
|
+
name: response.name,
|
|
2730
|
+
status: response.status,
|
|
2731
|
+
config: {
|
|
2732
|
+
cache: response.config.cache && {
|
|
2733
|
+
mode: response.config.cache.mode,
|
|
2734
|
+
max_age: response.config.cache.max_age
|
|
2735
|
+
},
|
|
2736
|
+
retry: response.config.retry && {
|
|
2737
|
+
attempts: response.config.retry.attempts,
|
|
2738
|
+
on_status_codes: response.config.retry.on_status_codes
|
|
2739
|
+
},
|
|
2740
|
+
strategy: response.config.strategy && {
|
|
2741
|
+
mode: response.config.strategy.mode
|
|
2742
|
+
},
|
|
2743
|
+
targets: response.config.targets?.map(
|
|
2744
|
+
(target) => ({
|
|
2745
|
+
provider: target.provider,
|
|
2746
|
+
virtual_key: target.virtual_key
|
|
2747
|
+
})
|
|
2748
|
+
)
|
|
2749
|
+
}
|
|
2750
|
+
})
|
|
2857
2751
|
}
|
|
2858
2752
|
]
|
|
2859
2753
|
};
|
|
@@ -2885,15 +2779,11 @@ function registerConfigsTools(server, service) {
|
|
|
2885
2779
|
content: [
|
|
2886
2780
|
{
|
|
2887
2781
|
type: "text",
|
|
2888
|
-
text: JSON.stringify(
|
|
2889
|
-
{
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
},
|
|
2894
|
-
null,
|
|
2895
|
-
2
|
|
2896
|
-
)
|
|
2782
|
+
text: JSON.stringify({
|
|
2783
|
+
message: `Successfully created configuration "${params.name}"`,
|
|
2784
|
+
id: result.id,
|
|
2785
|
+
version_id: result.version_id
|
|
2786
|
+
})
|
|
2897
2787
|
}
|
|
2898
2788
|
]
|
|
2899
2789
|
};
|
|
@@ -2919,16 +2809,12 @@ function registerConfigsTools(server, service) {
|
|
|
2919
2809
|
content: [
|
|
2920
2810
|
{
|
|
2921
2811
|
type: "text",
|
|
2922
|
-
text: JSON.stringify(
|
|
2923
|
-
{
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
},
|
|
2929
|
-
null,
|
|
2930
|
-
2
|
|
2931
|
-
)
|
|
2812
|
+
text: JSON.stringify({
|
|
2813
|
+
message: `Successfully updated configuration "${params.slug}"`,
|
|
2814
|
+
id: result.id,
|
|
2815
|
+
slug: result.slug,
|
|
2816
|
+
config: result.config
|
|
2817
|
+
})
|
|
2932
2818
|
}
|
|
2933
2819
|
]
|
|
2934
2820
|
};
|
|
@@ -2944,14 +2830,10 @@ function registerConfigsTools(server, service) {
|
|
|
2944
2830
|
content: [
|
|
2945
2831
|
{
|
|
2946
2832
|
type: "text",
|
|
2947
|
-
text: JSON.stringify(
|
|
2948
|
-
{
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
},
|
|
2952
|
-
null,
|
|
2953
|
-
2
|
|
2954
|
-
)
|
|
2833
|
+
text: JSON.stringify({
|
|
2834
|
+
message: `Successfully deleted configuration "${params.slug}"`,
|
|
2835
|
+
success: result.success
|
|
2836
|
+
})
|
|
2955
2837
|
}
|
|
2956
2838
|
]
|
|
2957
2839
|
};
|
|
@@ -2967,20 +2849,16 @@ function registerConfigsTools(server, service) {
|
|
|
2967
2849
|
content: [
|
|
2968
2850
|
{
|
|
2969
2851
|
type: "text",
|
|
2970
|
-
text: JSON.stringify(
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
},
|
|
2981
|
-
null,
|
|
2982
|
-
2
|
|
2983
|
-
)
|
|
2852
|
+
text: JSON.stringify({
|
|
2853
|
+
total: result.total,
|
|
2854
|
+
versions: (result.data ?? []).map((version) => ({
|
|
2855
|
+
id: version.id,
|
|
2856
|
+
version: version.version,
|
|
2857
|
+
config: version.config,
|
|
2858
|
+
created_at: version.created_at,
|
|
2859
|
+
created_by: version.created_by
|
|
2860
|
+
}))
|
|
2861
|
+
})
|
|
2984
2862
|
}
|
|
2985
2863
|
]
|
|
2986
2864
|
};
|
|
@@ -3049,25 +2927,21 @@ function registerGuardrailsTools(server, service) {
|
|
|
3049
2927
|
content: [
|
|
3050
2928
|
{
|
|
3051
2929
|
type: "text",
|
|
3052
|
-
text: JSON.stringify(
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
},
|
|
3068
|
-
null,
|
|
3069
|
-
2
|
|
3070
|
-
)
|
|
2930
|
+
text: JSON.stringify({
|
|
2931
|
+
total: result.total,
|
|
2932
|
+
guardrails: result.data.map((guardrail) => ({
|
|
2933
|
+
id: guardrail.id,
|
|
2934
|
+
name: guardrail.name,
|
|
2935
|
+
slug: guardrail.slug,
|
|
2936
|
+
status: guardrail.status,
|
|
2937
|
+
workspace_id: guardrail.workspace_id,
|
|
2938
|
+
organisation_id: guardrail.organisation_id,
|
|
2939
|
+
created_at: guardrail.created_at,
|
|
2940
|
+
last_updated_at: guardrail.last_updated_at,
|
|
2941
|
+
owner_id: guardrail.owner_id,
|
|
2942
|
+
updated_by: guardrail.updated_by
|
|
2943
|
+
}))
|
|
2944
|
+
})
|
|
3071
2945
|
}
|
|
3072
2946
|
]
|
|
3073
2947
|
};
|
|
@@ -3085,24 +2959,20 @@ function registerGuardrailsTools(server, service) {
|
|
|
3085
2959
|
content: [
|
|
3086
2960
|
{
|
|
3087
2961
|
type: "text",
|
|
3088
|
-
text: JSON.stringify(
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
},
|
|
3103
|
-
null,
|
|
3104
|
-
2
|
|
3105
|
-
)
|
|
2962
|
+
text: JSON.stringify({
|
|
2963
|
+
id: guardrail.id,
|
|
2964
|
+
name: guardrail.name,
|
|
2965
|
+
slug: guardrail.slug,
|
|
2966
|
+
status: guardrail.status,
|
|
2967
|
+
workspace_id: guardrail.workspace_id,
|
|
2968
|
+
organisation_id: guardrail.organisation_id,
|
|
2969
|
+
checks: guardrail.checks,
|
|
2970
|
+
actions: guardrail.actions,
|
|
2971
|
+
created_at: guardrail.created_at,
|
|
2972
|
+
last_updated_at: guardrail.last_updated_at,
|
|
2973
|
+
owner_id: guardrail.owner_id,
|
|
2974
|
+
updated_by: guardrail.updated_by
|
|
2975
|
+
})
|
|
3106
2976
|
}
|
|
3107
2977
|
]
|
|
3108
2978
|
};
|
|
@@ -3124,16 +2994,12 @@ function registerGuardrailsTools(server, service) {
|
|
|
3124
2994
|
content: [
|
|
3125
2995
|
{
|
|
3126
2996
|
type: "text",
|
|
3127
|
-
text: JSON.stringify(
|
|
3128
|
-
{
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
},
|
|
3134
|
-
null,
|
|
3135
|
-
2
|
|
3136
|
-
)
|
|
2997
|
+
text: JSON.stringify({
|
|
2998
|
+
message: `Successfully created guardrail "${params.name}"`,
|
|
2999
|
+
id: result.id,
|
|
3000
|
+
slug: result.slug,
|
|
3001
|
+
version_id: result.version_id
|
|
3002
|
+
})
|
|
3137
3003
|
}
|
|
3138
3004
|
]
|
|
3139
3005
|
};
|
|
@@ -3162,16 +3028,12 @@ function registerGuardrailsTools(server, service) {
|
|
|
3162
3028
|
content: [
|
|
3163
3029
|
{
|
|
3164
3030
|
type: "text",
|
|
3165
|
-
text: JSON.stringify(
|
|
3166
|
-
{
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
},
|
|
3172
|
-
null,
|
|
3173
|
-
2
|
|
3174
|
-
)
|
|
3031
|
+
text: JSON.stringify({
|
|
3032
|
+
message: `Successfully updated guardrail "${params.guardrail_id}"`,
|
|
3033
|
+
id: result.id,
|
|
3034
|
+
slug: result.slug,
|
|
3035
|
+
version_id: result.version_id
|
|
3036
|
+
})
|
|
3175
3037
|
}
|
|
3176
3038
|
]
|
|
3177
3039
|
};
|
|
@@ -3189,14 +3051,10 @@ function registerGuardrailsTools(server, service) {
|
|
|
3189
3051
|
content: [
|
|
3190
3052
|
{
|
|
3191
3053
|
type: "text",
|
|
3192
|
-
text: JSON.stringify(
|
|
3193
|
-
{
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
},
|
|
3197
|
-
null,
|
|
3198
|
-
2
|
|
3199
|
-
)
|
|
3054
|
+
text: JSON.stringify({
|
|
3055
|
+
message: `Successfully deleted guardrail "${params.guardrail_id}"`,
|
|
3056
|
+
success: result.success
|
|
3057
|
+
})
|
|
3200
3058
|
}
|
|
3201
3059
|
]
|
|
3202
3060
|
};
|
|
@@ -3339,6 +3197,28 @@ var INTEGRATIONS_TOOL_SCHEMAS = {
|
|
|
3339
3197
|
).describe("Array of workspace configurations to update")
|
|
3340
3198
|
}
|
|
3341
3199
|
};
|
|
3200
|
+
function buildIntegrationConfigurations(params) {
|
|
3201
|
+
const configurations = {};
|
|
3202
|
+
if (params.api_version !== void 0)
|
|
3203
|
+
configurations.api_version = params.api_version;
|
|
3204
|
+
if (params.resource_name !== void 0)
|
|
3205
|
+
configurations.resource_name = params.resource_name;
|
|
3206
|
+
if (params.deployment_name !== void 0)
|
|
3207
|
+
configurations.deployment_name = params.deployment_name;
|
|
3208
|
+
if (params.aws_region !== void 0)
|
|
3209
|
+
configurations.aws_region = params.aws_region;
|
|
3210
|
+
if (params.aws_access_key_id !== void 0)
|
|
3211
|
+
configurations.aws_access_key_id = params.aws_access_key_id;
|
|
3212
|
+
if (params.aws_secret_access_key !== void 0)
|
|
3213
|
+
configurations.aws_secret_access_key = params.aws_secret_access_key;
|
|
3214
|
+
if (params.vertex_project_id !== void 0)
|
|
3215
|
+
configurations.vertex_project_id = params.vertex_project_id;
|
|
3216
|
+
if (params.vertex_region !== void 0)
|
|
3217
|
+
configurations.vertex_region = params.vertex_region;
|
|
3218
|
+
if (params.custom_host !== void 0)
|
|
3219
|
+
configurations.custom_host = params.custom_host;
|
|
3220
|
+
return Object.keys(configurations).length > 0 ? configurations : void 0;
|
|
3221
|
+
}
|
|
3342
3222
|
function registerIntegrationsTools(server, service) {
|
|
3343
3223
|
server.tool(
|
|
3344
3224
|
"list_integrations",
|
|
@@ -3355,24 +3235,20 @@ function registerIntegrationsTools(server, service) {
|
|
|
3355
3235
|
content: [
|
|
3356
3236
|
{
|
|
3357
3237
|
type: "text",
|
|
3358
|
-
text: JSON.stringify(
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
},
|
|
3373
|
-
null,
|
|
3374
|
-
2
|
|
3375
|
-
)
|
|
3238
|
+
text: JSON.stringify({
|
|
3239
|
+
total: integrations.total,
|
|
3240
|
+
integrations: integrations.data.map((integration) => ({
|
|
3241
|
+
id: integration.id,
|
|
3242
|
+
name: integration.name,
|
|
3243
|
+
slug: integration.slug,
|
|
3244
|
+
ai_provider_id: integration.ai_provider_id,
|
|
3245
|
+
status: integration.status,
|
|
3246
|
+
description: integration.description,
|
|
3247
|
+
organisation_id: integration.organisation_id,
|
|
3248
|
+
created_at: integration.created_at,
|
|
3249
|
+
last_updated_at: integration.last_updated_at
|
|
3250
|
+
}))
|
|
3251
|
+
})
|
|
3376
3252
|
}
|
|
3377
3253
|
]
|
|
3378
3254
|
};
|
|
@@ -3383,22 +3259,6 @@ function registerIntegrationsTools(server, service) {
|
|
|
3383
3259
|
"Create an org-level provider integration. Some backends need provider-specific fields, and the new integration becomes the source for downstream providers and workspace access. Returns the new integration id and slug.",
|
|
3384
3260
|
INTEGRATIONS_TOOL_SCHEMAS.createIntegration,
|
|
3385
3261
|
async (params) => {
|
|
3386
|
-
const configurations = {};
|
|
3387
|
-
if (params.api_version) configurations.api_version = params.api_version;
|
|
3388
|
-
if (params.resource_name)
|
|
3389
|
-
configurations.resource_name = params.resource_name;
|
|
3390
|
-
if (params.deployment_name)
|
|
3391
|
-
configurations.deployment_name = params.deployment_name;
|
|
3392
|
-
if (params.aws_region) configurations.aws_region = params.aws_region;
|
|
3393
|
-
if (params.aws_access_key_id)
|
|
3394
|
-
configurations.aws_access_key_id = params.aws_access_key_id;
|
|
3395
|
-
if (params.aws_secret_access_key)
|
|
3396
|
-
configurations.aws_secret_access_key = params.aws_secret_access_key;
|
|
3397
|
-
if (params.vertex_project_id)
|
|
3398
|
-
configurations.vertex_project_id = params.vertex_project_id;
|
|
3399
|
-
if (params.vertex_region)
|
|
3400
|
-
configurations.vertex_region = params.vertex_region;
|
|
3401
|
-
if (params.custom_host) configurations.custom_host = params.custom_host;
|
|
3402
3262
|
const result = await service.integrations.createIntegration({
|
|
3403
3263
|
name: params.name,
|
|
3404
3264
|
ai_provider_id: params.ai_provider_id,
|
|
@@ -3406,21 +3266,17 @@ function registerIntegrationsTools(server, service) {
|
|
|
3406
3266
|
key: params.key,
|
|
3407
3267
|
description: params.description,
|
|
3408
3268
|
workspace_id: params.workspace_id,
|
|
3409
|
-
configurations:
|
|
3269
|
+
configurations: buildIntegrationConfigurations(params)
|
|
3410
3270
|
});
|
|
3411
3271
|
return {
|
|
3412
3272
|
content: [
|
|
3413
3273
|
{
|
|
3414
3274
|
type: "text",
|
|
3415
|
-
text: JSON.stringify(
|
|
3416
|
-
{
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
},
|
|
3421
|
-
null,
|
|
3422
|
-
2
|
|
3423
|
-
)
|
|
3275
|
+
text: JSON.stringify({
|
|
3276
|
+
message: `Successfully created integration "${params.name}"`,
|
|
3277
|
+
id: result.id,
|
|
3278
|
+
slug: result.slug
|
|
3279
|
+
})
|
|
3424
3280
|
}
|
|
3425
3281
|
]
|
|
3426
3282
|
};
|
|
@@ -3438,26 +3294,22 @@ function registerIntegrationsTools(server, service) {
|
|
|
3438
3294
|
content: [
|
|
3439
3295
|
{
|
|
3440
3296
|
type: "text",
|
|
3441
|
-
text: JSON.stringify(
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
},
|
|
3458
|
-
null,
|
|
3459
|
-
2
|
|
3460
|
-
)
|
|
3297
|
+
text: JSON.stringify({
|
|
3298
|
+
id: integration.id,
|
|
3299
|
+
name: integration.name,
|
|
3300
|
+
slug: integration.slug,
|
|
3301
|
+
ai_provider_id: integration.ai_provider_id,
|
|
3302
|
+
status: integration.status,
|
|
3303
|
+
description: integration.description,
|
|
3304
|
+
organisation_id: integration.organisation_id,
|
|
3305
|
+
masked_key: integration.masked_key,
|
|
3306
|
+
configurations: integration.configurations,
|
|
3307
|
+
global_workspace_access_settings: integration.global_workspace_access_settings,
|
|
3308
|
+
allow_all_models: integration.allow_all_models,
|
|
3309
|
+
workspace_count: integration.workspace_count,
|
|
3310
|
+
created_at: integration.created_at,
|
|
3311
|
+
last_updated_at: integration.last_updated_at
|
|
3312
|
+
})
|
|
3461
3313
|
}
|
|
3462
3314
|
]
|
|
3463
3315
|
};
|
|
@@ -3468,43 +3320,20 @@ function registerIntegrationsTools(server, service) {
|
|
|
3468
3320
|
"Update an integration's name, key, or provider-specific config. Key and config changes take effect immediately and can disrupt dependent providers or live requests.",
|
|
3469
3321
|
INTEGRATIONS_TOOL_SCHEMAS.updateIntegration,
|
|
3470
3322
|
async (params) => {
|
|
3471
|
-
const configurations = {};
|
|
3472
|
-
if (params.api_version !== void 0)
|
|
3473
|
-
configurations.api_version = params.api_version;
|
|
3474
|
-
if (params.resource_name !== void 0)
|
|
3475
|
-
configurations.resource_name = params.resource_name;
|
|
3476
|
-
if (params.deployment_name !== void 0)
|
|
3477
|
-
configurations.deployment_name = params.deployment_name;
|
|
3478
|
-
if (params.aws_region !== void 0)
|
|
3479
|
-
configurations.aws_region = params.aws_region;
|
|
3480
|
-
if (params.aws_access_key_id !== void 0)
|
|
3481
|
-
configurations.aws_access_key_id = params.aws_access_key_id;
|
|
3482
|
-
if (params.aws_secret_access_key !== void 0)
|
|
3483
|
-
configurations.aws_secret_access_key = params.aws_secret_access_key;
|
|
3484
|
-
if (params.vertex_project_id !== void 0)
|
|
3485
|
-
configurations.vertex_project_id = params.vertex_project_id;
|
|
3486
|
-
if (params.vertex_region !== void 0)
|
|
3487
|
-
configurations.vertex_region = params.vertex_region;
|
|
3488
|
-
if (params.custom_host !== void 0)
|
|
3489
|
-
configurations.custom_host = params.custom_host;
|
|
3490
3323
|
const result = await service.integrations.updateIntegration(params.slug, {
|
|
3491
3324
|
name: params.name,
|
|
3492
3325
|
key: params.key,
|
|
3493
3326
|
description: params.description,
|
|
3494
|
-
configurations:
|
|
3327
|
+
configurations: buildIntegrationConfigurations(params)
|
|
3495
3328
|
});
|
|
3496
3329
|
return {
|
|
3497
3330
|
content: [
|
|
3498
3331
|
{
|
|
3499
3332
|
type: "text",
|
|
3500
|
-
text: JSON.stringify(
|
|
3501
|
-
{
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
},
|
|
3505
|
-
null,
|
|
3506
|
-
2
|
|
3507
|
-
)
|
|
3333
|
+
text: JSON.stringify({
|
|
3334
|
+
message: `Successfully updated integration "${params.slug}"`,
|
|
3335
|
+
success: result.success
|
|
3336
|
+
})
|
|
3508
3337
|
}
|
|
3509
3338
|
]
|
|
3510
3339
|
};
|
|
@@ -3520,14 +3349,10 @@ function registerIntegrationsTools(server, service) {
|
|
|
3520
3349
|
content: [
|
|
3521
3350
|
{
|
|
3522
3351
|
type: "text",
|
|
3523
|
-
text: JSON.stringify(
|
|
3524
|
-
{
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
},
|
|
3528
|
-
null,
|
|
3529
|
-
2
|
|
3530
|
-
)
|
|
3352
|
+
text: JSON.stringify({
|
|
3353
|
+
message: `Successfully deleted integration "${params.slug}"`,
|
|
3354
|
+
success: result.success
|
|
3355
|
+
})
|
|
3531
3356
|
}
|
|
3532
3357
|
]
|
|
3533
3358
|
};
|
|
@@ -3549,23 +3374,19 @@ function registerIntegrationsTools(server, service) {
|
|
|
3549
3374
|
content: [
|
|
3550
3375
|
{
|
|
3551
3376
|
type: "text",
|
|
3552
|
-
text: JSON.stringify(
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
},
|
|
3566
|
-
null,
|
|
3567
|
-
2
|
|
3568
|
-
)
|
|
3377
|
+
text: JSON.stringify({
|
|
3378
|
+
total: models.total,
|
|
3379
|
+
integration_slug: params.slug,
|
|
3380
|
+
models: models.data.map((model) => ({
|
|
3381
|
+
id: model.id,
|
|
3382
|
+
model_id: model.model_id,
|
|
3383
|
+
model_name: model.model_name,
|
|
3384
|
+
enabled: model.enabled,
|
|
3385
|
+
custom: model.custom,
|
|
3386
|
+
created_at: model.created_at,
|
|
3387
|
+
last_updated_at: model.last_updated_at
|
|
3388
|
+
}))
|
|
3389
|
+
})
|
|
3569
3390
|
}
|
|
3570
3391
|
]
|
|
3571
3392
|
};
|
|
@@ -3586,15 +3407,11 @@ function registerIntegrationsTools(server, service) {
|
|
|
3586
3407
|
content: [
|
|
3587
3408
|
{
|
|
3588
3409
|
type: "text",
|
|
3589
|
-
text: JSON.stringify(
|
|
3590
|
-
{
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
},
|
|
3595
|
-
null,
|
|
3596
|
-
2
|
|
3597
|
-
)
|
|
3410
|
+
text: JSON.stringify({
|
|
3411
|
+
message: `Successfully updated models for integration "${params.slug}"`,
|
|
3412
|
+
success: result.success,
|
|
3413
|
+
models_updated: params.models.length
|
|
3414
|
+
})
|
|
3598
3415
|
}
|
|
3599
3416
|
]
|
|
3600
3417
|
};
|
|
@@ -3613,14 +3430,10 @@ function registerIntegrationsTools(server, service) {
|
|
|
3613
3430
|
content: [
|
|
3614
3431
|
{
|
|
3615
3432
|
type: "text",
|
|
3616
|
-
text: JSON.stringify(
|
|
3617
|
-
{
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
},
|
|
3621
|
-
null,
|
|
3622
|
-
2
|
|
3623
|
-
)
|
|
3433
|
+
text: JSON.stringify({
|
|
3434
|
+
message: `Successfully deleted model "${params.model_slug}" from integration "${params.slug}"`,
|
|
3435
|
+
success: result.success
|
|
3436
|
+
})
|
|
3624
3437
|
}
|
|
3625
3438
|
]
|
|
3626
3439
|
};
|
|
@@ -3642,24 +3455,20 @@ function registerIntegrationsTools(server, service) {
|
|
|
3642
3455
|
content: [
|
|
3643
3456
|
{
|
|
3644
3457
|
type: "text",
|
|
3645
|
-
text: JSON.stringify(
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
},
|
|
3660
|
-
null,
|
|
3661
|
-
2
|
|
3662
|
-
)
|
|
3458
|
+
text: JSON.stringify({
|
|
3459
|
+
total: workspaces.total,
|
|
3460
|
+
integration_slug: params.slug,
|
|
3461
|
+
workspaces: workspaces.data.map((ws) => ({
|
|
3462
|
+
id: ws.id,
|
|
3463
|
+
workspace_id: ws.workspace_id,
|
|
3464
|
+
workspace_name: ws.workspace_name,
|
|
3465
|
+
enabled: ws.enabled,
|
|
3466
|
+
usage_limits: ws.usage_limits,
|
|
3467
|
+
rate_limits: ws.rate_limits,
|
|
3468
|
+
created_at: ws.created_at,
|
|
3469
|
+
last_updated_at: ws.last_updated_at
|
|
3470
|
+
}))
|
|
3471
|
+
})
|
|
3663
3472
|
}
|
|
3664
3473
|
]
|
|
3665
3474
|
};
|
|
@@ -3691,15 +3500,11 @@ function registerIntegrationsTools(server, service) {
|
|
|
3691
3500
|
content: [
|
|
3692
3501
|
{
|
|
3693
3502
|
type: "text",
|
|
3694
|
-
text: JSON.stringify(
|
|
3695
|
-
{
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
},
|
|
3700
|
-
null,
|
|
3701
|
-
2
|
|
3702
|
-
)
|
|
3503
|
+
text: JSON.stringify({
|
|
3504
|
+
message: `Successfully updated workspace access for integration "${params.slug}"`,
|
|
3505
|
+
success: result.success,
|
|
3506
|
+
workspaces_updated: params.workspaces.length
|
|
3507
|
+
})
|
|
3703
3508
|
}
|
|
3704
3509
|
]
|
|
3705
3510
|
};
|
|
@@ -3710,7 +3515,10 @@ function registerIntegrationsTools(server, service) {
|
|
|
3710
3515
|
// src/tools/keys.tools.ts
|
|
3711
3516
|
import { z as z7 } from "zod";
|
|
3712
3517
|
var KEYS_TOOL_SCHEMAS = {
|
|
3713
|
-
listVirtualKeys: {
|
|
3518
|
+
listVirtualKeys: {
|
|
3519
|
+
current_page: z7.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
3520
|
+
page_size: z7.coerce.number().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
3521
|
+
},
|
|
3714
3522
|
createVirtualKey: {
|
|
3715
3523
|
name: z7.string().describe("Display name for the virtual key"),
|
|
3716
3524
|
provider: z7.string().describe(
|
|
@@ -3792,43 +3600,58 @@ var KEYS_TOOL_SCHEMAS = {
|
|
|
3792
3600
|
id: z7.string().uuid().describe("The UUID of the API key to delete")
|
|
3793
3601
|
}
|
|
3794
3602
|
};
|
|
3795
|
-
|
|
3603
|
+
var createApiKeySchema = z7.object(KEYS_TOOL_SCHEMAS.createApiKey).superRefine((value, ctx) => {
|
|
3604
|
+
if (value.type === "workspace" && !value.workspace_id) {
|
|
3605
|
+
ctx.addIssue({
|
|
3606
|
+
code: z7.ZodIssueCode.custom,
|
|
3607
|
+
path: ["workspace_id"],
|
|
3608
|
+
message: "workspace_id is required when type is 'workspace'"
|
|
3609
|
+
});
|
|
3610
|
+
}
|
|
3611
|
+
if (value.sub_type === "user" && !value.user_id) {
|
|
3612
|
+
ctx.addIssue({
|
|
3613
|
+
code: z7.ZodIssueCode.custom,
|
|
3614
|
+
path: ["user_id"],
|
|
3615
|
+
message: "user_id is required when sub_type is 'user'"
|
|
3616
|
+
});
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
function registerKeysTools(server, service) {
|
|
3796
3620
|
server.tool(
|
|
3797
3621
|
"list_virtual_keys",
|
|
3798
3622
|
"List provider API keys stored as virtual keys in your Portkey org. Use this to find slugs before wiring prompts/configs or auditing limits. Returns total plus name, slug, status, usage limits, rate limits, reset state, and model config.",
|
|
3799
3623
|
KEYS_TOOL_SCHEMAS.listVirtualKeys,
|
|
3800
|
-
async () => {
|
|
3801
|
-
const virtualKeys = await service.keys.listVirtualKeys(
|
|
3624
|
+
async (params) => {
|
|
3625
|
+
const virtualKeys = await service.keys.listVirtualKeys({
|
|
3626
|
+
current_page: params.current_page,
|
|
3627
|
+
page_size: params.page_size
|
|
3628
|
+
});
|
|
3802
3629
|
return {
|
|
3803
3630
|
content: [
|
|
3804
3631
|
{
|
|
3805
3632
|
type: "text",
|
|
3806
|
-
text: JSON.stringify(
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
},
|
|
3829
|
-
null,
|
|
3830
|
-
2
|
|
3831
|
-
)
|
|
3633
|
+
text: JSON.stringify({
|
|
3634
|
+
total: virtualKeys.total,
|
|
3635
|
+
virtual_keys: virtualKeys.data.map((key) => ({
|
|
3636
|
+
name: key.name,
|
|
3637
|
+
slug: key.slug,
|
|
3638
|
+
status: key.status,
|
|
3639
|
+
note: key.note,
|
|
3640
|
+
usage_limits: key.usage_limits ? {
|
|
3641
|
+
credit_limit: key.usage_limits.credit_limit,
|
|
3642
|
+
alert_threshold: key.usage_limits.alert_threshold,
|
|
3643
|
+
periodic_reset: key.usage_limits.periodic_reset
|
|
3644
|
+
} : null,
|
|
3645
|
+
rate_limits: key.rate_limits?.map((limit) => ({
|
|
3646
|
+
type: limit.type,
|
|
3647
|
+
unit: limit.unit,
|
|
3648
|
+
value: limit.value
|
|
3649
|
+
})) ?? null,
|
|
3650
|
+
reset_usage: key.reset_usage,
|
|
3651
|
+
created_at: key.created_at,
|
|
3652
|
+
model_config: key.model_config
|
|
3653
|
+
}))
|
|
3654
|
+
})
|
|
3832
3655
|
}
|
|
3833
3656
|
]
|
|
3834
3657
|
};
|
|
@@ -3859,15 +3682,11 @@ function registerKeysTools(server, service) {
|
|
|
3859
3682
|
content: [
|
|
3860
3683
|
{
|
|
3861
3684
|
type: "text",
|
|
3862
|
-
text: JSON.stringify(
|
|
3863
|
-
{
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
},
|
|
3868
|
-
null,
|
|
3869
|
-
2
|
|
3870
|
-
)
|
|
3685
|
+
text: JSON.stringify({
|
|
3686
|
+
message: `Successfully created virtual key "${params.name}"`,
|
|
3687
|
+
success: result.success,
|
|
3688
|
+
slug
|
|
3689
|
+
})
|
|
3871
3690
|
}
|
|
3872
3691
|
]
|
|
3873
3692
|
};
|
|
@@ -3883,29 +3702,25 @@ function registerKeysTools(server, service) {
|
|
|
3883
3702
|
content: [
|
|
3884
3703
|
{
|
|
3885
3704
|
type: "text",
|
|
3886
|
-
text: JSON.stringify(
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
},
|
|
3906
|
-
null,
|
|
3907
|
-
2
|
|
3908
|
-
)
|
|
3705
|
+
text: JSON.stringify({
|
|
3706
|
+
name: virtualKey.name,
|
|
3707
|
+
slug: virtualKey.slug,
|
|
3708
|
+
status: virtualKey.status,
|
|
3709
|
+
note: virtualKey.note,
|
|
3710
|
+
usage_limits: virtualKey.usage_limits ? {
|
|
3711
|
+
credit_limit: virtualKey.usage_limits.credit_limit,
|
|
3712
|
+
alert_threshold: virtualKey.usage_limits.alert_threshold,
|
|
3713
|
+
periodic_reset: virtualKey.usage_limits.periodic_reset
|
|
3714
|
+
} : null,
|
|
3715
|
+
rate_limits: virtualKey.rate_limits?.map((limit) => ({
|
|
3716
|
+
type: limit.type,
|
|
3717
|
+
unit: limit.unit,
|
|
3718
|
+
value: limit.value
|
|
3719
|
+
})) ?? null,
|
|
3720
|
+
reset_usage: virtualKey.reset_usage,
|
|
3721
|
+
created_at: virtualKey.created_at,
|
|
3722
|
+
model_config: virtualKey.model_config
|
|
3723
|
+
})
|
|
3909
3724
|
}
|
|
3910
3725
|
]
|
|
3911
3726
|
};
|
|
@@ -3930,16 +3745,12 @@ function registerKeysTools(server, service) {
|
|
|
3930
3745
|
content: [
|
|
3931
3746
|
{
|
|
3932
3747
|
type: "text",
|
|
3933
|
-
text: JSON.stringify(
|
|
3934
|
-
{
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
},
|
|
3940
|
-
null,
|
|
3941
|
-
2
|
|
3942
|
-
)
|
|
3748
|
+
text: JSON.stringify({
|
|
3749
|
+
message: `Successfully updated virtual key "${params.slug}"`,
|
|
3750
|
+
name: result.name,
|
|
3751
|
+
slug: result.slug,
|
|
3752
|
+
status: result.status
|
|
3753
|
+
})
|
|
3943
3754
|
}
|
|
3944
3755
|
]
|
|
3945
3756
|
};
|
|
@@ -3955,14 +3766,10 @@ function registerKeysTools(server, service) {
|
|
|
3955
3766
|
content: [
|
|
3956
3767
|
{
|
|
3957
3768
|
type: "text",
|
|
3958
|
-
text: JSON.stringify(
|
|
3959
|
-
{
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
},
|
|
3963
|
-
null,
|
|
3964
|
-
2
|
|
3965
|
-
)
|
|
3769
|
+
text: JSON.stringify({
|
|
3770
|
+
message: `Successfully deleted virtual key "${params.slug}"`,
|
|
3771
|
+
success: result.success
|
|
3772
|
+
})
|
|
3966
3773
|
}
|
|
3967
3774
|
]
|
|
3968
3775
|
};
|
|
@@ -3970,70 +3777,45 @@ function registerKeysTools(server, service) {
|
|
|
3970
3777
|
);
|
|
3971
3778
|
server.tool(
|
|
3972
3779
|
"create_api_key",
|
|
3973
|
-
"Create a Portkey API key for auth. Org keys grant broader access; workspace keys are scoped. The secret is
|
|
3780
|
+
"Create a Portkey API key for auth. Org keys grant broader access; workspace keys are scoped. WARNING: The key secret is returned ONCE in the tool result and will be visible in MCP transcripts and LLM context \u2014 store it securely immediately. Using the key grants access immediately according to its scopes, defaults, and limits. Workspace keys require workspace_id and user keys require user_id.",
|
|
3974
3781
|
KEYS_TOOL_SCHEMAS.createApiKey,
|
|
3975
3782
|
async (params) => {
|
|
3976
|
-
|
|
3977
|
-
return {
|
|
3978
|
-
content: [
|
|
3979
|
-
{
|
|
3980
|
-
type: "text",
|
|
3981
|
-
text: "Error creating API key: workspace_id is required for workspace-type keys"
|
|
3982
|
-
}
|
|
3983
|
-
],
|
|
3984
|
-
isError: true
|
|
3985
|
-
};
|
|
3986
|
-
}
|
|
3987
|
-
if (params.sub_type === "user" && !params.user_id) {
|
|
3988
|
-
return {
|
|
3989
|
-
content: [
|
|
3990
|
-
{
|
|
3991
|
-
type: "text",
|
|
3992
|
-
text: "Error creating API key: user_id is required for user sub-type keys"
|
|
3993
|
-
}
|
|
3994
|
-
],
|
|
3995
|
-
isError: true
|
|
3996
|
-
};
|
|
3997
|
-
}
|
|
3783
|
+
const validated = createApiKeySchema.parse(params);
|
|
3998
3784
|
const result = await service.keys.createApiKey(
|
|
3999
|
-
|
|
4000
|
-
|
|
3785
|
+
validated.type,
|
|
3786
|
+
validated.sub_type,
|
|
4001
3787
|
{
|
|
4002
|
-
name:
|
|
4003
|
-
description:
|
|
4004
|
-
workspace_id:
|
|
4005
|
-
user_id:
|
|
4006
|
-
scopes:
|
|
3788
|
+
name: validated.name,
|
|
3789
|
+
description: validated.description,
|
|
3790
|
+
workspace_id: validated.workspace_id,
|
|
3791
|
+
user_id: validated.user_id,
|
|
3792
|
+
scopes: validated.scopes,
|
|
4007
3793
|
usage_limits: buildUsageLimits({
|
|
4008
|
-
credit_limit:
|
|
4009
|
-
alert_threshold:
|
|
3794
|
+
credit_limit: validated.credit_limit,
|
|
3795
|
+
alert_threshold: validated.alert_threshold
|
|
4010
3796
|
}),
|
|
4011
|
-
rate_limits: buildRateLimitsRpm(
|
|
3797
|
+
rate_limits: buildRateLimitsRpm(validated.rate_limit_rpm),
|
|
4012
3798
|
defaults: (() => {
|
|
4013
3799
|
const d = {};
|
|
4014
|
-
if (
|
|
4015
|
-
d.config_id =
|
|
4016
|
-
if (
|
|
4017
|
-
d.metadata =
|
|
3800
|
+
if (validated.default_config_id !== void 0)
|
|
3801
|
+
d.config_id = validated.default_config_id;
|
|
3802
|
+
if (validated.default_metadata !== void 0)
|
|
3803
|
+
d.metadata = validated.default_metadata;
|
|
4018
3804
|
return Object.keys(d).length > 0 ? d : void 0;
|
|
4019
3805
|
})(),
|
|
4020
|
-
alert_emails:
|
|
4021
|
-
expires_at:
|
|
3806
|
+
alert_emails: validated.alert_emails,
|
|
3807
|
+
expires_at: validated.expires_at
|
|
4022
3808
|
}
|
|
4023
3809
|
);
|
|
4024
3810
|
return {
|
|
4025
3811
|
content: [
|
|
4026
3812
|
{
|
|
4027
3813
|
type: "text",
|
|
4028
|
-
text: JSON.stringify(
|
|
4029
|
-
{
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
},
|
|
4034
|
-
null,
|
|
4035
|
-
2
|
|
4036
|
-
)
|
|
3814
|
+
text: JSON.stringify({
|
|
3815
|
+
message: `Successfully created API key "${validated.name}"`,
|
|
3816
|
+
id: result.id,
|
|
3817
|
+
key: result.key
|
|
3818
|
+
})
|
|
4037
3819
|
}
|
|
4038
3820
|
]
|
|
4039
3821
|
};
|
|
@@ -4053,40 +3835,36 @@ function registerKeysTools(server, service) {
|
|
|
4053
3835
|
content: [
|
|
4054
3836
|
{
|
|
4055
3837
|
type: "text",
|
|
4056
|
-
text: JSON.stringify(
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
},
|
|
4087
|
-
null,
|
|
4088
|
-
2
|
|
4089
|
-
)
|
|
3838
|
+
text: JSON.stringify({
|
|
3839
|
+
total: apiKeys.total,
|
|
3840
|
+
api_keys: apiKeys.data.map((key) => ({
|
|
3841
|
+
id: key.id,
|
|
3842
|
+
name: key.name,
|
|
3843
|
+
description: key.description,
|
|
3844
|
+
type: key.type,
|
|
3845
|
+
status: key.status,
|
|
3846
|
+
organisation_id: key.organisation_id,
|
|
3847
|
+
workspace_id: key.workspace_id,
|
|
3848
|
+
user_id: key.user_id,
|
|
3849
|
+
scopes: key.scopes,
|
|
3850
|
+
usage_limits: key.usage_limits ? {
|
|
3851
|
+
credit_limit: key.usage_limits.credit_limit,
|
|
3852
|
+
alert_threshold: key.usage_limits.alert_threshold,
|
|
3853
|
+
periodic_reset: key.usage_limits.periodic_reset
|
|
3854
|
+
} : null,
|
|
3855
|
+
rate_limits: key.rate_limits?.map((limit) => ({
|
|
3856
|
+
type: limit.type,
|
|
3857
|
+
unit: limit.unit,
|
|
3858
|
+
value: limit.value
|
|
3859
|
+
})) ?? null,
|
|
3860
|
+
defaults: key.defaults,
|
|
3861
|
+
alert_emails: key.alert_emails,
|
|
3862
|
+
expires_at: key.expires_at,
|
|
3863
|
+
created_at: key.created_at,
|
|
3864
|
+
last_updated_at: key.last_updated_at,
|
|
3865
|
+
creation_mode: key.creation_mode
|
|
3866
|
+
}))
|
|
3867
|
+
})
|
|
4090
3868
|
}
|
|
4091
3869
|
]
|
|
4092
3870
|
};
|
|
@@ -4102,38 +3880,34 @@ function registerKeysTools(server, service) {
|
|
|
4102
3880
|
content: [
|
|
4103
3881
|
{
|
|
4104
3882
|
type: "text",
|
|
4105
|
-
text: JSON.stringify(
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
},
|
|
4134
|
-
null,
|
|
4135
|
-
2
|
|
4136
|
-
)
|
|
3883
|
+
text: JSON.stringify({
|
|
3884
|
+
id: apiKey.id,
|
|
3885
|
+
name: apiKey.name,
|
|
3886
|
+
description: apiKey.description,
|
|
3887
|
+
type: apiKey.type,
|
|
3888
|
+
status: apiKey.status,
|
|
3889
|
+
organisation_id: apiKey.organisation_id,
|
|
3890
|
+
workspace_id: apiKey.workspace_id,
|
|
3891
|
+
user_id: apiKey.user_id,
|
|
3892
|
+
scopes: apiKey.scopes,
|
|
3893
|
+
usage_limits: apiKey.usage_limits ? {
|
|
3894
|
+
credit_limit: apiKey.usage_limits.credit_limit,
|
|
3895
|
+
alert_threshold: apiKey.usage_limits.alert_threshold,
|
|
3896
|
+
periodic_reset: apiKey.usage_limits.periodic_reset
|
|
3897
|
+
} : null,
|
|
3898
|
+
rate_limits: apiKey.rate_limits?.map((limit) => ({
|
|
3899
|
+
type: limit.type,
|
|
3900
|
+
unit: limit.unit,
|
|
3901
|
+
value: limit.value
|
|
3902
|
+
})) ?? null,
|
|
3903
|
+
defaults: apiKey.defaults,
|
|
3904
|
+
alert_emails: apiKey.alert_emails,
|
|
3905
|
+
expires_at: apiKey.expires_at,
|
|
3906
|
+
reset_usage: apiKey.reset_usage,
|
|
3907
|
+
created_at: apiKey.created_at,
|
|
3908
|
+
last_updated_at: apiKey.last_updated_at,
|
|
3909
|
+
creation_mode: apiKey.creation_mode
|
|
3910
|
+
})
|
|
4137
3911
|
}
|
|
4138
3912
|
]
|
|
4139
3913
|
};
|
|
@@ -4164,14 +3938,10 @@ function registerKeysTools(server, service) {
|
|
|
4164
3938
|
content: [
|
|
4165
3939
|
{
|
|
4166
3940
|
type: "text",
|
|
4167
|
-
text: JSON.stringify(
|
|
4168
|
-
{
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
},
|
|
4172
|
-
null,
|
|
4173
|
-
2
|
|
4174
|
-
)
|
|
3941
|
+
text: JSON.stringify({
|
|
3942
|
+
message: `Successfully updated API key "${params.id}"`,
|
|
3943
|
+
success: result.success
|
|
3944
|
+
})
|
|
4175
3945
|
}
|
|
4176
3946
|
]
|
|
4177
3947
|
};
|
|
@@ -4187,14 +3957,10 @@ function registerKeysTools(server, service) {
|
|
|
4187
3957
|
content: [
|
|
4188
3958
|
{
|
|
4189
3959
|
type: "text",
|
|
4190
|
-
text: JSON.stringify(
|
|
4191
|
-
{
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
},
|
|
4195
|
-
null,
|
|
4196
|
-
2
|
|
4197
|
-
)
|
|
3960
|
+
text: JSON.stringify({
|
|
3961
|
+
message: `Successfully deleted API key "${params.id}"`,
|
|
3962
|
+
success: result.success
|
|
3963
|
+
})
|
|
4198
3964
|
}
|
|
4199
3965
|
]
|
|
4200
3966
|
};
|
|
@@ -4264,14 +4030,10 @@ function registerLabelsTools(server, service) {
|
|
|
4264
4030
|
content: [
|
|
4265
4031
|
{
|
|
4266
4032
|
type: "text",
|
|
4267
|
-
text: JSON.stringify(
|
|
4268
|
-
{
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
},
|
|
4272
|
-
null,
|
|
4273
|
-
2
|
|
4274
|
-
)
|
|
4033
|
+
text: JSON.stringify({
|
|
4034
|
+
message: `Successfully created label "${params.name}"`,
|
|
4035
|
+
id: result.id
|
|
4036
|
+
})
|
|
4275
4037
|
}
|
|
4276
4038
|
]
|
|
4277
4039
|
};
|
|
@@ -4287,23 +4049,19 @@ function registerLabelsTools(server, service) {
|
|
|
4287
4049
|
content: [
|
|
4288
4050
|
{
|
|
4289
4051
|
type: "text",
|
|
4290
|
-
text: JSON.stringify(
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
},
|
|
4304
|
-
null,
|
|
4305
|
-
2
|
|
4306
|
-
)
|
|
4052
|
+
text: JSON.stringify({
|
|
4053
|
+
total: result.total,
|
|
4054
|
+
labels: result.data.map((label) => ({
|
|
4055
|
+
id: label.id,
|
|
4056
|
+
name: label.name,
|
|
4057
|
+
description: label.description,
|
|
4058
|
+
color_code: label.color_code,
|
|
4059
|
+
is_universal: label.is_universal,
|
|
4060
|
+
status: label.status,
|
|
4061
|
+
created_at: label.created_at,
|
|
4062
|
+
last_updated_at: label.last_updated_at
|
|
4063
|
+
}))
|
|
4064
|
+
})
|
|
4307
4065
|
}
|
|
4308
4066
|
]
|
|
4309
4067
|
};
|
|
@@ -4322,22 +4080,18 @@ function registerLabelsTools(server, service) {
|
|
|
4322
4080
|
content: [
|
|
4323
4081
|
{
|
|
4324
4082
|
type: "text",
|
|
4325
|
-
text: JSON.stringify(
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
},
|
|
4338
|
-
null,
|
|
4339
|
-
2
|
|
4340
|
-
)
|
|
4083
|
+
text: JSON.stringify({
|
|
4084
|
+
id: label.id,
|
|
4085
|
+
name: label.name,
|
|
4086
|
+
description: label.description,
|
|
4087
|
+
color_code: label.color_code,
|
|
4088
|
+
organisation_id: label.organisation_id,
|
|
4089
|
+
workspace_id: label.workspace_id,
|
|
4090
|
+
is_universal: label.is_universal,
|
|
4091
|
+
status: label.status,
|
|
4092
|
+
created_at: label.created_at,
|
|
4093
|
+
last_updated_at: label.last_updated_at
|
|
4094
|
+
})
|
|
4341
4095
|
}
|
|
4342
4096
|
]
|
|
4343
4097
|
};
|
|
@@ -4354,14 +4108,10 @@ function registerLabelsTools(server, service) {
|
|
|
4354
4108
|
content: [
|
|
4355
4109
|
{
|
|
4356
4110
|
type: "text",
|
|
4357
|
-
text: JSON.stringify(
|
|
4358
|
-
{
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
},
|
|
4362
|
-
null,
|
|
4363
|
-
2
|
|
4364
|
-
)
|
|
4111
|
+
text: JSON.stringify({
|
|
4112
|
+
message: `Successfully updated label "${label_id}"`,
|
|
4113
|
+
success: true
|
|
4114
|
+
})
|
|
4365
4115
|
}
|
|
4366
4116
|
]
|
|
4367
4117
|
};
|
|
@@ -4377,14 +4127,10 @@ function registerLabelsTools(server, service) {
|
|
|
4377
4127
|
content: [
|
|
4378
4128
|
{
|
|
4379
4129
|
type: "text",
|
|
4380
|
-
text: JSON.stringify(
|
|
4381
|
-
{
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
},
|
|
4385
|
-
null,
|
|
4386
|
-
2
|
|
4387
|
-
)
|
|
4130
|
+
text: JSON.stringify({
|
|
4131
|
+
message: `Successfully deleted label "${params.label_id}"`,
|
|
4132
|
+
success: true
|
|
4133
|
+
})
|
|
4388
4134
|
}
|
|
4389
4135
|
]
|
|
4390
4136
|
};
|
|
@@ -4529,14 +4275,10 @@ function registerLimitsTools(server, service) {
|
|
|
4529
4275
|
content: [
|
|
4530
4276
|
{
|
|
4531
4277
|
type: "text",
|
|
4532
|
-
text: JSON.stringify(
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
},
|
|
4537
|
-
null,
|
|
4538
|
-
2
|
|
4539
|
-
)
|
|
4278
|
+
text: JSON.stringify({
|
|
4279
|
+
total: result.total,
|
|
4280
|
+
rate_limits: result.data.map(formatRateLimit)
|
|
4281
|
+
})
|
|
4540
4282
|
}
|
|
4541
4283
|
]
|
|
4542
4284
|
};
|
|
@@ -4552,7 +4294,7 @@ function registerLimitsTools(server, service) {
|
|
|
4552
4294
|
content: [
|
|
4553
4295
|
{
|
|
4554
4296
|
type: "text",
|
|
4555
|
-
text: JSON.stringify(formatRateLimit(result)
|
|
4297
|
+
text: JSON.stringify(formatRateLimit(result))
|
|
4556
4298
|
}
|
|
4557
4299
|
]
|
|
4558
4300
|
};
|
|
@@ -4577,14 +4319,10 @@ function registerLimitsTools(server, service) {
|
|
|
4577
4319
|
content: [
|
|
4578
4320
|
{
|
|
4579
4321
|
type: "text",
|
|
4580
|
-
text: JSON.stringify(
|
|
4581
|
-
{
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
},
|
|
4585
|
-
null,
|
|
4586
|
-
2
|
|
4587
|
-
)
|
|
4322
|
+
text: JSON.stringify({
|
|
4323
|
+
message: `Successfully created rate limit${params.name ? ` "${params.name}"` : ""}`,
|
|
4324
|
+
rate_limit: formatRateLimit(result)
|
|
4325
|
+
})
|
|
4588
4326
|
}
|
|
4589
4327
|
]
|
|
4590
4328
|
};
|
|
@@ -4604,14 +4342,10 @@ function registerLimitsTools(server, service) {
|
|
|
4604
4342
|
content: [
|
|
4605
4343
|
{
|
|
4606
4344
|
type: "text",
|
|
4607
|
-
text: JSON.stringify(
|
|
4608
|
-
{
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
},
|
|
4612
|
-
null,
|
|
4613
|
-
2
|
|
4614
|
-
)
|
|
4345
|
+
text: JSON.stringify({
|
|
4346
|
+
message: `Successfully updated rate limit "${params.id}"`,
|
|
4347
|
+
rate_limit: formatRateLimit(result)
|
|
4348
|
+
})
|
|
4615
4349
|
}
|
|
4616
4350
|
]
|
|
4617
4351
|
};
|
|
@@ -4627,14 +4361,10 @@ function registerLimitsTools(server, service) {
|
|
|
4627
4361
|
content: [
|
|
4628
4362
|
{
|
|
4629
4363
|
type: "text",
|
|
4630
|
-
text: JSON.stringify(
|
|
4631
|
-
{
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
},
|
|
4635
|
-
null,
|
|
4636
|
-
2
|
|
4637
|
-
)
|
|
4364
|
+
text: JSON.stringify({
|
|
4365
|
+
message: `Successfully deleted rate limit "${params.id}"`,
|
|
4366
|
+
success: true
|
|
4367
|
+
})
|
|
4638
4368
|
}
|
|
4639
4369
|
]
|
|
4640
4370
|
};
|
|
@@ -4650,14 +4380,10 @@ function registerLimitsTools(server, service) {
|
|
|
4650
4380
|
content: [
|
|
4651
4381
|
{
|
|
4652
4382
|
type: "text",
|
|
4653
|
-
text: JSON.stringify(
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
},
|
|
4658
|
-
null,
|
|
4659
|
-
2
|
|
4660
|
-
)
|
|
4383
|
+
text: JSON.stringify({
|
|
4384
|
+
total: result.total,
|
|
4385
|
+
usage_limits: result.data.map(formatUsageLimit)
|
|
4386
|
+
})
|
|
4661
4387
|
}
|
|
4662
4388
|
]
|
|
4663
4389
|
};
|
|
@@ -4673,7 +4399,7 @@ function registerLimitsTools(server, service) {
|
|
|
4673
4399
|
content: [
|
|
4674
4400
|
{
|
|
4675
4401
|
type: "text",
|
|
4676
|
-
text: JSON.stringify(formatUsageLimit(result)
|
|
4402
|
+
text: JSON.stringify(formatUsageLimit(result))
|
|
4677
4403
|
}
|
|
4678
4404
|
]
|
|
4679
4405
|
};
|
|
@@ -4699,14 +4425,10 @@ function registerLimitsTools(server, service) {
|
|
|
4699
4425
|
content: [
|
|
4700
4426
|
{
|
|
4701
4427
|
type: "text",
|
|
4702
|
-
text: JSON.stringify(
|
|
4703
|
-
{
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
},
|
|
4707
|
-
null,
|
|
4708
|
-
2
|
|
4709
|
-
)
|
|
4428
|
+
text: JSON.stringify({
|
|
4429
|
+
message: `Successfully created usage limit${params.name ? ` "${params.name}"` : ""}`,
|
|
4430
|
+
usage_limit: formatUsageLimit(result)
|
|
4431
|
+
})
|
|
4710
4432
|
}
|
|
4711
4433
|
]
|
|
4712
4434
|
};
|
|
@@ -4728,14 +4450,10 @@ function registerLimitsTools(server, service) {
|
|
|
4728
4450
|
content: [
|
|
4729
4451
|
{
|
|
4730
4452
|
type: "text",
|
|
4731
|
-
text: JSON.stringify(
|
|
4732
|
-
{
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
},
|
|
4736
|
-
null,
|
|
4737
|
-
2
|
|
4738
|
-
)
|
|
4453
|
+
text: JSON.stringify({
|
|
4454
|
+
message: `Successfully updated usage limit "${params.id}"`,
|
|
4455
|
+
usage_limit: formatUsageLimit(result)
|
|
4456
|
+
})
|
|
4739
4457
|
}
|
|
4740
4458
|
]
|
|
4741
4459
|
};
|
|
@@ -4751,14 +4469,10 @@ function registerLimitsTools(server, service) {
|
|
|
4751
4469
|
content: [
|
|
4752
4470
|
{
|
|
4753
4471
|
type: "text",
|
|
4754
|
-
text: JSON.stringify(
|
|
4755
|
-
{
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
},
|
|
4759
|
-
null,
|
|
4760
|
-
2
|
|
4761
|
-
)
|
|
4472
|
+
text: JSON.stringify({
|
|
4473
|
+
message: `Successfully deleted usage limit "${params.id}"`,
|
|
4474
|
+
success: true
|
|
4475
|
+
})
|
|
4762
4476
|
}
|
|
4763
4477
|
]
|
|
4764
4478
|
};
|
|
@@ -4776,14 +4490,10 @@ function registerLimitsTools(server, service) {
|
|
|
4776
4490
|
content: [
|
|
4777
4491
|
{
|
|
4778
4492
|
type: "text",
|
|
4779
|
-
text: JSON.stringify(
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
},
|
|
4784
|
-
null,
|
|
4785
|
-
2
|
|
4786
|
-
)
|
|
4493
|
+
text: JSON.stringify({
|
|
4494
|
+
total: result.total,
|
|
4495
|
+
entities: result.data.map(formatUsageLimitEntity)
|
|
4496
|
+
})
|
|
4787
4497
|
}
|
|
4788
4498
|
]
|
|
4789
4499
|
};
|
|
@@ -4802,14 +4512,10 @@ function registerLimitsTools(server, service) {
|
|
|
4802
4512
|
content: [
|
|
4803
4513
|
{
|
|
4804
4514
|
type: "text",
|
|
4805
|
-
text: JSON.stringify(
|
|
4806
|
-
{
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
},
|
|
4810
|
-
null,
|
|
4811
|
-
2
|
|
4812
|
-
)
|
|
4515
|
+
text: JSON.stringify({
|
|
4516
|
+
message: `Successfully reset usage for entity "${params.entity_id}" on limit "${params.limit_id}"`,
|
|
4517
|
+
success: true
|
|
4518
|
+
})
|
|
4813
4519
|
}
|
|
4814
4520
|
]
|
|
4815
4521
|
};
|
|
@@ -4941,14 +4647,10 @@ function registerLoggingTools(server, service) {
|
|
|
4941
4647
|
content: [
|
|
4942
4648
|
{
|
|
4943
4649
|
type: "text",
|
|
4944
|
-
text: JSON.stringify(
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
},
|
|
4949
|
-
null,
|
|
4950
|
-
2
|
|
4951
|
-
)
|
|
4650
|
+
text: JSON.stringify({
|
|
4651
|
+
message: "Successfully inserted log entry",
|
|
4652
|
+
success: result.success
|
|
4653
|
+
})
|
|
4952
4654
|
}
|
|
4953
4655
|
]
|
|
4954
4656
|
};
|
|
@@ -4977,16 +4679,12 @@ function registerLoggingTools(server, service) {
|
|
|
4977
4679
|
content: [
|
|
4978
4680
|
{
|
|
4979
4681
|
type: "text",
|
|
4980
|
-
text: JSON.stringify(
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
},
|
|
4987
|
-
null,
|
|
4988
|
-
2
|
|
4989
|
-
)
|
|
4682
|
+
text: JSON.stringify({
|
|
4683
|
+
message: "Successfully created log export",
|
|
4684
|
+
id: result.id,
|
|
4685
|
+
total: result.total,
|
|
4686
|
+
object: result.object
|
|
4687
|
+
})
|
|
4990
4688
|
}
|
|
4991
4689
|
]
|
|
4992
4690
|
};
|
|
@@ -5004,24 +4702,20 @@ function registerLoggingTools(server, service) {
|
|
|
5004
4702
|
content: [
|
|
5005
4703
|
{
|
|
5006
4704
|
type: "text",
|
|
5007
|
-
text: JSON.stringify(
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
},
|
|
5022
|
-
null,
|
|
5023
|
-
2
|
|
5024
|
-
)
|
|
4705
|
+
text: JSON.stringify({
|
|
4706
|
+
total: result.total,
|
|
4707
|
+
exports: result.data.map((exp) => ({
|
|
4708
|
+
id: exp.id,
|
|
4709
|
+
status: exp.status,
|
|
4710
|
+
description: exp.description,
|
|
4711
|
+
filters: exp.filters,
|
|
4712
|
+
requested_data: exp.requested_data,
|
|
4713
|
+
workspace_id: exp.workspace_id,
|
|
4714
|
+
created_at: exp.created_at,
|
|
4715
|
+
last_updated_at: exp.last_updated_at,
|
|
4716
|
+
created_by: exp.created_by
|
|
4717
|
+
}))
|
|
4718
|
+
})
|
|
5025
4719
|
}
|
|
5026
4720
|
]
|
|
5027
4721
|
};
|
|
@@ -5037,22 +4731,18 @@ function registerLoggingTools(server, service) {
|
|
|
5037
4731
|
content: [
|
|
5038
4732
|
{
|
|
5039
4733
|
type: "text",
|
|
5040
|
-
text: JSON.stringify(
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
},
|
|
5053
|
-
null,
|
|
5054
|
-
2
|
|
5055
|
-
)
|
|
4734
|
+
text: JSON.stringify({
|
|
4735
|
+
id: result.id,
|
|
4736
|
+
status: result.status,
|
|
4737
|
+
description: result.description,
|
|
4738
|
+
filters: result.filters,
|
|
4739
|
+
requested_data: result.requested_data,
|
|
4740
|
+
organisation_id: result.organisation_id,
|
|
4741
|
+
workspace_id: result.workspace_id,
|
|
4742
|
+
created_at: result.created_at,
|
|
4743
|
+
last_updated_at: result.last_updated_at,
|
|
4744
|
+
created_by: result.created_by
|
|
4745
|
+
})
|
|
5056
4746
|
}
|
|
5057
4747
|
]
|
|
5058
4748
|
};
|
|
@@ -5068,15 +4758,11 @@ function registerLoggingTools(server, service) {
|
|
|
5068
4758
|
content: [
|
|
5069
4759
|
{
|
|
5070
4760
|
type: "text",
|
|
5071
|
-
text: JSON.stringify(
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
},
|
|
5077
|
-
null,
|
|
5078
|
-
2
|
|
5079
|
-
)
|
|
4761
|
+
text: JSON.stringify({
|
|
4762
|
+
message: result.message,
|
|
4763
|
+
export_id: params.export_id,
|
|
4764
|
+
status: "started"
|
|
4765
|
+
})
|
|
5080
4766
|
}
|
|
5081
4767
|
]
|
|
5082
4768
|
};
|
|
@@ -5092,15 +4778,11 @@ function registerLoggingTools(server, service) {
|
|
|
5092
4778
|
content: [
|
|
5093
4779
|
{
|
|
5094
4780
|
type: "text",
|
|
5095
|
-
text: JSON.stringify(
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
},
|
|
5101
|
-
null,
|
|
5102
|
-
2
|
|
5103
|
-
)
|
|
4781
|
+
text: JSON.stringify({
|
|
4782
|
+
message: result.message,
|
|
4783
|
+
export_id: params.export_id,
|
|
4784
|
+
status: "cancelled"
|
|
4785
|
+
})
|
|
5104
4786
|
}
|
|
5105
4787
|
]
|
|
5106
4788
|
};
|
|
@@ -5116,15 +4798,11 @@ function registerLoggingTools(server, service) {
|
|
|
5116
4798
|
content: [
|
|
5117
4799
|
{
|
|
5118
4800
|
type: "text",
|
|
5119
|
-
text: JSON.stringify(
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
},
|
|
5125
|
-
null,
|
|
5126
|
-
2
|
|
5127
|
-
)
|
|
4801
|
+
text: JSON.stringify({
|
|
4802
|
+
message: "Download URL generated successfully",
|
|
4803
|
+
export_id: params.export_id,
|
|
4804
|
+
signed_url: result.signed_url
|
|
4805
|
+
})
|
|
5128
4806
|
}
|
|
5129
4807
|
]
|
|
5130
4808
|
};
|
|
@@ -5155,16 +4833,12 @@ function registerLoggingTools(server, service) {
|
|
|
5155
4833
|
content: [
|
|
5156
4834
|
{
|
|
5157
4835
|
type: "text",
|
|
5158
|
-
text: JSON.stringify(
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
},
|
|
5165
|
-
null,
|
|
5166
|
-
2
|
|
5167
|
-
)
|
|
4836
|
+
text: JSON.stringify({
|
|
4837
|
+
message: "Successfully updated log export",
|
|
4838
|
+
id: result.id,
|
|
4839
|
+
total: result.total,
|
|
4840
|
+
object: result.object
|
|
4841
|
+
})
|
|
5168
4842
|
}
|
|
5169
4843
|
]
|
|
5170
4844
|
};
|
|
@@ -5244,12 +4918,12 @@ var MCP_INTEGRATIONS_TOOL_SCHEMAS = {
|
|
|
5244
4918
|
).min(1).describe("Array of workspace access updates")
|
|
5245
4919
|
}
|
|
5246
4920
|
};
|
|
5247
|
-
function
|
|
4921
|
+
function isRecord2(value) {
|
|
5248
4922
|
return typeof value === "object" && value !== null;
|
|
5249
4923
|
}
|
|
5250
4924
|
function getCustomHeaderNames(configurations) {
|
|
5251
4925
|
const customHeaders = configurations?.custom_headers;
|
|
5252
|
-
return
|
|
4926
|
+
return isRecord2(customHeaders) ? Object.keys(customHeaders) : void 0;
|
|
5253
4927
|
}
|
|
5254
4928
|
function formatMcpIntegration(integration) {
|
|
5255
4929
|
return {
|
|
@@ -5307,15 +4981,11 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5307
4981
|
content: [
|
|
5308
4982
|
{
|
|
5309
4983
|
type: "text",
|
|
5310
|
-
text: JSON.stringify(
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
},
|
|
5316
|
-
null,
|
|
5317
|
-
2
|
|
5318
|
-
)
|
|
4984
|
+
text: JSON.stringify({
|
|
4985
|
+
total: result.total,
|
|
4986
|
+
has_more: result.has_more,
|
|
4987
|
+
integrations: result.data.map(formatMcpIntegration)
|
|
4988
|
+
})
|
|
5319
4989
|
}
|
|
5320
4990
|
]
|
|
5321
4991
|
};
|
|
@@ -5346,15 +5016,11 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5346
5016
|
content: [
|
|
5347
5017
|
{
|
|
5348
5018
|
type: "text",
|
|
5349
|
-
text: JSON.stringify(
|
|
5350
|
-
{
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
},
|
|
5355
|
-
null,
|
|
5356
|
-
2
|
|
5357
|
-
)
|
|
5019
|
+
text: JSON.stringify({
|
|
5020
|
+
message: `Successfully created MCP integration "${params.name}"`,
|
|
5021
|
+
id: result.id,
|
|
5022
|
+
slug: result.slug
|
|
5023
|
+
})
|
|
5358
5024
|
}
|
|
5359
5025
|
]
|
|
5360
5026
|
};
|
|
@@ -5372,7 +5038,7 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5372
5038
|
content: [
|
|
5373
5039
|
{
|
|
5374
5040
|
type: "text",
|
|
5375
|
-
text: JSON.stringify(formatMcpIntegration(integration)
|
|
5041
|
+
text: JSON.stringify(formatMcpIntegration(integration))
|
|
5376
5042
|
}
|
|
5377
5043
|
]
|
|
5378
5044
|
};
|
|
@@ -5392,14 +5058,10 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5392
5058
|
content: [
|
|
5393
5059
|
{
|
|
5394
5060
|
type: "text",
|
|
5395
|
-
text: JSON.stringify(
|
|
5396
|
-
{
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
},
|
|
5400
|
-
null,
|
|
5401
|
-
2
|
|
5402
|
-
)
|
|
5061
|
+
text: JSON.stringify({
|
|
5062
|
+
message: `Successfully updated MCP integration "${id}"`,
|
|
5063
|
+
success: true
|
|
5064
|
+
})
|
|
5403
5065
|
}
|
|
5404
5066
|
]
|
|
5405
5067
|
};
|
|
@@ -5415,14 +5077,10 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5415
5077
|
content: [
|
|
5416
5078
|
{
|
|
5417
5079
|
type: "text",
|
|
5418
|
-
text: JSON.stringify(
|
|
5419
|
-
{
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
},
|
|
5423
|
-
null,
|
|
5424
|
-
2
|
|
5425
|
-
)
|
|
5080
|
+
text: JSON.stringify({
|
|
5081
|
+
message: `Successfully deleted MCP integration "${params.id}"`,
|
|
5082
|
+
success: true
|
|
5083
|
+
})
|
|
5426
5084
|
}
|
|
5427
5085
|
]
|
|
5428
5086
|
};
|
|
@@ -5440,11 +5098,7 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5440
5098
|
content: [
|
|
5441
5099
|
{
|
|
5442
5100
|
type: "text",
|
|
5443
|
-
text: JSON.stringify(
|
|
5444
|
-
formatMcpIntegrationMetadata(metadata),
|
|
5445
|
-
null,
|
|
5446
|
-
2
|
|
5447
|
-
)
|
|
5101
|
+
text: JSON.stringify(formatMcpIntegrationMetadata(metadata))
|
|
5448
5102
|
}
|
|
5449
5103
|
]
|
|
5450
5104
|
};
|
|
@@ -5460,11 +5114,10 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5460
5114
|
content: [
|
|
5461
5115
|
{
|
|
5462
5116
|
type: "text",
|
|
5463
|
-
text: JSON.stringify(
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
)
|
|
5117
|
+
text: JSON.stringify({
|
|
5118
|
+
total: result.total,
|
|
5119
|
+
capabilities: result.data
|
|
5120
|
+
})
|
|
5468
5121
|
}
|
|
5469
5122
|
]
|
|
5470
5123
|
};
|
|
@@ -5485,14 +5138,10 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5485
5138
|
content: [
|
|
5486
5139
|
{
|
|
5487
5140
|
type: "text",
|
|
5488
|
-
text: JSON.stringify(
|
|
5489
|
-
{
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
},
|
|
5493
|
-
null,
|
|
5494
|
-
2
|
|
5495
|
-
)
|
|
5141
|
+
text: JSON.stringify({
|
|
5142
|
+
message: `Successfully updated capabilities for MCP integration "${params.id}"`,
|
|
5143
|
+
success: true
|
|
5144
|
+
})
|
|
5496
5145
|
}
|
|
5497
5146
|
]
|
|
5498
5147
|
};
|
|
@@ -5510,17 +5159,11 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5510
5159
|
content: [
|
|
5511
5160
|
{
|
|
5512
5161
|
type: "text",
|
|
5513
|
-
text: JSON.stringify(
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
formatMcpIntegrationWorkspace
|
|
5519
|
-
)
|
|
5520
|
-
},
|
|
5521
|
-
null,
|
|
5522
|
-
2
|
|
5523
|
-
)
|
|
5162
|
+
text: JSON.stringify({
|
|
5163
|
+
global_workspace_access: result.global_workspace_access,
|
|
5164
|
+
workspace_count: result.workspaces.length,
|
|
5165
|
+
workspaces: result.workspaces.map(formatMcpIntegrationWorkspace)
|
|
5166
|
+
})
|
|
5524
5167
|
}
|
|
5525
5168
|
]
|
|
5526
5169
|
};
|
|
@@ -5538,14 +5181,10 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5538
5181
|
content: [
|
|
5539
5182
|
{
|
|
5540
5183
|
type: "text",
|
|
5541
|
-
text: JSON.stringify(
|
|
5542
|
-
{
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
},
|
|
5546
|
-
null,
|
|
5547
|
-
2
|
|
5548
|
-
)
|
|
5184
|
+
text: JSON.stringify({
|
|
5185
|
+
message: `Successfully updated workspace access for MCP integration "${params.id}"`,
|
|
5186
|
+
success: true
|
|
5187
|
+
})
|
|
5549
5188
|
}
|
|
5550
5189
|
]
|
|
5551
5190
|
};
|
|
@@ -5555,6 +5194,13 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5555
5194
|
|
|
5556
5195
|
// src/tools/mcp-servers.tools.ts
|
|
5557
5196
|
import { z as z12 } from "zod";
|
|
5197
|
+
|
|
5198
|
+
// src/tools/utils.ts
|
|
5199
|
+
function formatFullName(firstName, lastName) {
|
|
5200
|
+
return [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
5201
|
+
}
|
|
5202
|
+
|
|
5203
|
+
// src/tools/mcp-servers.tools.ts
|
|
5558
5204
|
var MCP_SERVERS_TOOL_SCHEMAS = {
|
|
5559
5205
|
listMcpServers: {
|
|
5560
5206
|
current_page: z12.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
@@ -5582,7 +5228,9 @@ var MCP_SERVERS_TOOL_SCHEMAS = {
|
|
|
5582
5228
|
id: z12.string().describe("The MCP server ID or slug to test")
|
|
5583
5229
|
},
|
|
5584
5230
|
listMcpServerCapabilities: {
|
|
5585
|
-
id: z12.string().describe("The MCP server ID or slug")
|
|
5231
|
+
id: z12.string().describe("The MCP server ID or slug"),
|
|
5232
|
+
current_page: z12.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
5233
|
+
page_size: z12.coerce.number().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
5586
5234
|
},
|
|
5587
5235
|
updateMcpServerCapabilities: {
|
|
5588
5236
|
id: z12.string().describe("The MCP server ID or slug"),
|
|
@@ -5595,7 +5243,9 @@ var MCP_SERVERS_TOOL_SCHEMAS = {
|
|
|
5595
5243
|
).min(1).describe("Array of capability updates")
|
|
5596
5244
|
},
|
|
5597
5245
|
listMcpServerUserAccess: {
|
|
5598
|
-
id: z12.string().describe("The MCP server ID or slug")
|
|
5246
|
+
id: z12.string().describe("The MCP server ID or slug"),
|
|
5247
|
+
current_page: z12.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
5248
|
+
page_size: z12.coerce.number().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
5599
5249
|
},
|
|
5600
5250
|
updateMcpServerUserAccess: {
|
|
5601
5251
|
id: z12.string().describe("The MCP server ID or slug"),
|
|
@@ -5607,9 +5257,6 @@ var MCP_SERVERS_TOOL_SCHEMAS = {
|
|
|
5607
5257
|
).min(1).describe("Array of user access updates")
|
|
5608
5258
|
}
|
|
5609
5259
|
};
|
|
5610
|
-
function formatFullName(firstName, lastName) {
|
|
5611
|
-
return [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
5612
|
-
}
|
|
5613
5260
|
function formatMcpServer(server) {
|
|
5614
5261
|
return {
|
|
5615
5262
|
id: server.id,
|
|
@@ -5651,14 +5298,10 @@ function registerMcpServersTools(server, service) {
|
|
|
5651
5298
|
content: [
|
|
5652
5299
|
{
|
|
5653
5300
|
type: "text",
|
|
5654
|
-
text: JSON.stringify(
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
},
|
|
5659
|
-
null,
|
|
5660
|
-
2
|
|
5661
|
-
)
|
|
5301
|
+
text: JSON.stringify({
|
|
5302
|
+
total: result.total,
|
|
5303
|
+
servers: result.data.map(formatMcpServer)
|
|
5304
|
+
})
|
|
5662
5305
|
}
|
|
5663
5306
|
]
|
|
5664
5307
|
};
|
|
@@ -5674,15 +5317,11 @@ function registerMcpServersTools(server, service) {
|
|
|
5674
5317
|
content: [
|
|
5675
5318
|
{
|
|
5676
5319
|
type: "text",
|
|
5677
|
-
text: JSON.stringify(
|
|
5678
|
-
{
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
},
|
|
5683
|
-
null,
|
|
5684
|
-
2
|
|
5685
|
-
)
|
|
5320
|
+
text: JSON.stringify({
|
|
5321
|
+
message: `Successfully created MCP server "${params.name}"`,
|
|
5322
|
+
id: result.id,
|
|
5323
|
+
slug: result.slug
|
|
5324
|
+
})
|
|
5686
5325
|
}
|
|
5687
5326
|
]
|
|
5688
5327
|
};
|
|
@@ -5698,7 +5337,7 @@ function registerMcpServersTools(server, service) {
|
|
|
5698
5337
|
content: [
|
|
5699
5338
|
{
|
|
5700
5339
|
type: "text",
|
|
5701
|
-
text: JSON.stringify(formatMcpServer(mcpServer)
|
|
5340
|
+
text: JSON.stringify(formatMcpServer(mcpServer))
|
|
5702
5341
|
}
|
|
5703
5342
|
]
|
|
5704
5343
|
};
|
|
@@ -5715,14 +5354,10 @@ function registerMcpServersTools(server, service) {
|
|
|
5715
5354
|
content: [
|
|
5716
5355
|
{
|
|
5717
5356
|
type: "text",
|
|
5718
|
-
text: JSON.stringify(
|
|
5719
|
-
{
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
},
|
|
5723
|
-
null,
|
|
5724
|
-
2
|
|
5725
|
-
)
|
|
5357
|
+
text: JSON.stringify({
|
|
5358
|
+
message: `Successfully updated MCP server "${id}"`,
|
|
5359
|
+
success: true
|
|
5360
|
+
})
|
|
5726
5361
|
}
|
|
5727
5362
|
]
|
|
5728
5363
|
};
|
|
@@ -5738,14 +5373,10 @@ function registerMcpServersTools(server, service) {
|
|
|
5738
5373
|
content: [
|
|
5739
5374
|
{
|
|
5740
5375
|
type: "text",
|
|
5741
|
-
text: JSON.stringify(
|
|
5742
|
-
{
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
},
|
|
5746
|
-
null,
|
|
5747
|
-
2
|
|
5748
|
-
)
|
|
5376
|
+
text: JSON.stringify({
|
|
5377
|
+
message: `Successfully deleted MCP server "${params.id}"`,
|
|
5378
|
+
success: true
|
|
5379
|
+
})
|
|
5749
5380
|
}
|
|
5750
5381
|
]
|
|
5751
5382
|
};
|
|
@@ -5761,7 +5392,7 @@ function registerMcpServersTools(server, service) {
|
|
|
5761
5392
|
content: [
|
|
5762
5393
|
{
|
|
5763
5394
|
type: "text",
|
|
5764
|
-
text: JSON.stringify(formatMcpServerTest(result)
|
|
5395
|
+
text: JSON.stringify(formatMcpServerTest(result))
|
|
5765
5396
|
}
|
|
5766
5397
|
]
|
|
5767
5398
|
};
|
|
@@ -5773,17 +5404,21 @@ function registerMcpServersTools(server, service) {
|
|
|
5773
5404
|
MCP_SERVERS_TOOL_SCHEMAS.listMcpServerCapabilities,
|
|
5774
5405
|
async (params) => {
|
|
5775
5406
|
const result = await service.mcpServers.listMcpServerCapabilities(
|
|
5776
|
-
params.id
|
|
5407
|
+
params.id,
|
|
5408
|
+
{
|
|
5409
|
+
current_page: params.current_page,
|
|
5410
|
+
page_size: params.page_size
|
|
5411
|
+
}
|
|
5777
5412
|
);
|
|
5778
5413
|
return {
|
|
5779
5414
|
content: [
|
|
5780
5415
|
{
|
|
5781
5416
|
type: "text",
|
|
5782
|
-
text: JSON.stringify(
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
)
|
|
5417
|
+
text: JSON.stringify({
|
|
5418
|
+
total: result.total,
|
|
5419
|
+
has_more: result.has_more,
|
|
5420
|
+
capabilities: result.data
|
|
5421
|
+
})
|
|
5787
5422
|
}
|
|
5788
5423
|
]
|
|
5789
5424
|
};
|
|
@@ -5801,14 +5436,10 @@ function registerMcpServersTools(server, service) {
|
|
|
5801
5436
|
content: [
|
|
5802
5437
|
{
|
|
5803
5438
|
type: "text",
|
|
5804
|
-
text: JSON.stringify(
|
|
5805
|
-
{
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
},
|
|
5809
|
-
null,
|
|
5810
|
-
2
|
|
5811
|
-
)
|
|
5439
|
+
text: JSON.stringify({
|
|
5440
|
+
message: `Successfully updated capabilities for MCP server "${params.id}"`,
|
|
5441
|
+
success: true
|
|
5442
|
+
})
|
|
5812
5443
|
}
|
|
5813
5444
|
]
|
|
5814
5445
|
};
|
|
@@ -5820,21 +5451,22 @@ function registerMcpServersTools(server, service) {
|
|
|
5820
5451
|
MCP_SERVERS_TOOL_SCHEMAS.listMcpServerUserAccess,
|
|
5821
5452
|
async (params) => {
|
|
5822
5453
|
const result = await service.mcpServers.listMcpServerUserAccess(
|
|
5823
|
-
params.id
|
|
5454
|
+
params.id,
|
|
5455
|
+
{
|
|
5456
|
+
current_page: params.current_page,
|
|
5457
|
+
page_size: params.page_size
|
|
5458
|
+
}
|
|
5824
5459
|
);
|
|
5825
5460
|
return {
|
|
5826
5461
|
content: [
|
|
5827
5462
|
{
|
|
5828
5463
|
type: "text",
|
|
5829
|
-
text: JSON.stringify(
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
null,
|
|
5836
|
-
2
|
|
5837
|
-
)
|
|
5464
|
+
text: JSON.stringify({
|
|
5465
|
+
default_user_access: result.default_user_access,
|
|
5466
|
+
total: result.total,
|
|
5467
|
+
has_more: result.has_more,
|
|
5468
|
+
users: result.data.map(formatMcpServerUserAccess)
|
|
5469
|
+
})
|
|
5838
5470
|
}
|
|
5839
5471
|
]
|
|
5840
5472
|
};
|
|
@@ -5852,14 +5484,10 @@ function registerMcpServersTools(server, service) {
|
|
|
5852
5484
|
content: [
|
|
5853
5485
|
{
|
|
5854
5486
|
type: "text",
|
|
5855
|
-
text: JSON.stringify(
|
|
5856
|
-
{
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
},
|
|
5860
|
-
null,
|
|
5861
|
-
2
|
|
5862
|
-
)
|
|
5487
|
+
text: JSON.stringify({
|
|
5488
|
+
message: `Successfully updated user access for MCP server "${params.id}"`,
|
|
5489
|
+
success: true
|
|
5490
|
+
})
|
|
5863
5491
|
}
|
|
5864
5492
|
]
|
|
5865
5493
|
};
|
|
@@ -5920,16 +5548,12 @@ function registerPartialsTools(server, service) {
|
|
|
5920
5548
|
content: [
|
|
5921
5549
|
{
|
|
5922
5550
|
type: "text",
|
|
5923
|
-
text: JSON.stringify(
|
|
5924
|
-
{
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
},
|
|
5930
|
-
null,
|
|
5931
|
-
2
|
|
5932
|
-
)
|
|
5551
|
+
text: JSON.stringify({
|
|
5552
|
+
message: `Successfully created prompt partial "${params.name}"`,
|
|
5553
|
+
id: result.id,
|
|
5554
|
+
slug: result.slug,
|
|
5555
|
+
version_id: result.version_id
|
|
5556
|
+
})
|
|
5933
5557
|
}
|
|
5934
5558
|
]
|
|
5935
5559
|
};
|
|
@@ -5945,22 +5569,18 @@ function registerPartialsTools(server, service) {
|
|
|
5945
5569
|
content: [
|
|
5946
5570
|
{
|
|
5947
5571
|
type: "text",
|
|
5948
|
-
text: JSON.stringify(
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
},
|
|
5961
|
-
null,
|
|
5962
|
-
2
|
|
5963
|
-
)
|
|
5572
|
+
text: JSON.stringify({
|
|
5573
|
+
total: partials.length,
|
|
5574
|
+
partials: partials.map((p) => ({
|
|
5575
|
+
id: p.id,
|
|
5576
|
+
slug: p.slug,
|
|
5577
|
+
name: p.name,
|
|
5578
|
+
collection_id: p.collection_id,
|
|
5579
|
+
status: p.status,
|
|
5580
|
+
created_at: p.created_at,
|
|
5581
|
+
last_updated_at: p.last_updated_at
|
|
5582
|
+
}))
|
|
5583
|
+
})
|
|
5964
5584
|
}
|
|
5965
5585
|
]
|
|
5966
5586
|
};
|
|
@@ -5978,23 +5598,19 @@ function registerPartialsTools(server, service) {
|
|
|
5978
5598
|
content: [
|
|
5979
5599
|
{
|
|
5980
5600
|
type: "text",
|
|
5981
|
-
text: JSON.stringify(
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
},
|
|
5995
|
-
null,
|
|
5996
|
-
2
|
|
5997
|
-
)
|
|
5601
|
+
text: JSON.stringify({
|
|
5602
|
+
id: partial.id,
|
|
5603
|
+
slug: partial.slug,
|
|
5604
|
+
name: partial.name,
|
|
5605
|
+
collection_id: partial.collection_id,
|
|
5606
|
+
string: partial.string,
|
|
5607
|
+
version: partial.version,
|
|
5608
|
+
version_description: partial.version_description,
|
|
5609
|
+
prompt_partial_version_id: partial.prompt_partial_version_id,
|
|
5610
|
+
status: partial.status,
|
|
5611
|
+
created_at: partial.created_at,
|
|
5612
|
+
last_updated_at: partial.last_updated_at
|
|
5613
|
+
})
|
|
5998
5614
|
}
|
|
5999
5615
|
]
|
|
6000
5616
|
};
|
|
@@ -6014,14 +5630,10 @@ function registerPartialsTools(server, service) {
|
|
|
6014
5630
|
content: [
|
|
6015
5631
|
{
|
|
6016
5632
|
type: "text",
|
|
6017
|
-
text: JSON.stringify(
|
|
6018
|
-
{
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
},
|
|
6022
|
-
null,
|
|
6023
|
-
2
|
|
6024
|
-
)
|
|
5633
|
+
text: JSON.stringify({
|
|
5634
|
+
message: `Successfully updated prompt partial "${prompt_partial_id}"`,
|
|
5635
|
+
prompt_partial_version_id: result.prompt_partial_version_id
|
|
5636
|
+
})
|
|
6025
5637
|
}
|
|
6026
5638
|
]
|
|
6027
5639
|
};
|
|
@@ -6037,14 +5649,10 @@ function registerPartialsTools(server, service) {
|
|
|
6037
5649
|
content: [
|
|
6038
5650
|
{
|
|
6039
5651
|
type: "text",
|
|
6040
|
-
text: JSON.stringify(
|
|
6041
|
-
{
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
},
|
|
6045
|
-
null,
|
|
6046
|
-
2
|
|
6047
|
-
)
|
|
5652
|
+
text: JSON.stringify({
|
|
5653
|
+
message: `Successfully deleted prompt partial "${params.prompt_partial_id}"`,
|
|
5654
|
+
success: true
|
|
5655
|
+
})
|
|
6048
5656
|
}
|
|
6049
5657
|
]
|
|
6050
5658
|
};
|
|
@@ -6062,24 +5670,20 @@ function registerPartialsTools(server, service) {
|
|
|
6062
5670
|
content: [
|
|
6063
5671
|
{
|
|
6064
5672
|
type: "text",
|
|
6065
|
-
text: JSON.stringify(
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
},
|
|
6080
|
-
null,
|
|
6081
|
-
2
|
|
6082
|
-
)
|
|
5673
|
+
text: JSON.stringify({
|
|
5674
|
+
prompt_partial_id: params.prompt_partial_id,
|
|
5675
|
+
total_versions: versions.length,
|
|
5676
|
+
versions: versions.map((v) => ({
|
|
5677
|
+
prompt_partial_id: v.prompt_partial_id,
|
|
5678
|
+
prompt_partial_version_id: v.prompt_partial_version_id,
|
|
5679
|
+
slug: v.slug,
|
|
5680
|
+
version: v.version,
|
|
5681
|
+
description: v.description,
|
|
5682
|
+
status: v.prompt_version_status,
|
|
5683
|
+
created_at: v.created_at,
|
|
5684
|
+
content_preview: v.string.length > 200 ? `${v.string.substring(0, 200)}...` : v.string
|
|
5685
|
+
}))
|
|
5686
|
+
})
|
|
6083
5687
|
}
|
|
6084
5688
|
]
|
|
6085
5689
|
};
|
|
@@ -6097,16 +5701,12 @@ function registerPartialsTools(server, service) {
|
|
|
6097
5701
|
content: [
|
|
6098
5702
|
{
|
|
6099
5703
|
type: "text",
|
|
6100
|
-
text: JSON.stringify(
|
|
6101
|
-
{
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
},
|
|
6107
|
-
null,
|
|
6108
|
-
2
|
|
6109
|
-
)
|
|
5704
|
+
text: JSON.stringify({
|
|
5705
|
+
message: `Successfully published version ${params.version} as default for partial "${params.prompt_partial_id}"`,
|
|
5706
|
+
prompt_partial_id: params.prompt_partial_id,
|
|
5707
|
+
published_version: params.version,
|
|
5708
|
+
success: true
|
|
5709
|
+
})
|
|
6110
5710
|
}
|
|
6111
5711
|
]
|
|
6112
5712
|
};
|
|
@@ -6482,16 +6082,12 @@ function registerPromptsTools(server, service) {
|
|
|
6482
6082
|
content: [
|
|
6483
6083
|
{
|
|
6484
6084
|
type: "text",
|
|
6485
|
-
text: JSON.stringify(
|
|
6486
|
-
{
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
},
|
|
6492
|
-
null,
|
|
6493
|
-
2
|
|
6494
|
-
)
|
|
6085
|
+
text: JSON.stringify({
|
|
6086
|
+
message: `Successfully created prompt "${params.name}"`,
|
|
6087
|
+
id: result.id,
|
|
6088
|
+
slug: result.slug,
|
|
6089
|
+
version_id: result.version_id
|
|
6090
|
+
})
|
|
6495
6091
|
}
|
|
6496
6092
|
]
|
|
6497
6093
|
};
|
|
@@ -6507,11 +6103,7 @@ function registerPromptsTools(server, service) {
|
|
|
6507
6103
|
content: [
|
|
6508
6104
|
{
|
|
6509
6105
|
type: "text",
|
|
6510
|
-
text: JSON.stringify(
|
|
6511
|
-
formatPromptListResponse(prompts, params),
|
|
6512
|
-
null,
|
|
6513
|
-
2
|
|
6514
|
-
)
|
|
6106
|
+
text: JSON.stringify(formatPromptListResponse(prompts, params))
|
|
6515
6107
|
}
|
|
6516
6108
|
]
|
|
6517
6109
|
};
|
|
@@ -6543,37 +6135,33 @@ function registerPromptsTools(server, service) {
|
|
|
6543
6135
|
content: [
|
|
6544
6136
|
{
|
|
6545
6137
|
type: "text",
|
|
6546
|
-
text: JSON.stringify(
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
},
|
|
6574
|
-
null,
|
|
6575
|
-
2
|
|
6576
|
-
)
|
|
6138
|
+
text: JSON.stringify({
|
|
6139
|
+
id: prompt.id,
|
|
6140
|
+
name: prompt.name,
|
|
6141
|
+
slug: prompt.slug,
|
|
6142
|
+
collection_id: prompt.collection_id,
|
|
6143
|
+
created_at: prompt.created_at,
|
|
6144
|
+
last_updated_at: prompt.last_updated_at,
|
|
6145
|
+
current_version: prompt.current_version ? {
|
|
6146
|
+
id: prompt.current_version.id,
|
|
6147
|
+
version_number: prompt.current_version.version_number,
|
|
6148
|
+
description: prompt.current_version.version_description,
|
|
6149
|
+
model: prompt.current_version.model,
|
|
6150
|
+
template_format: templateFormat,
|
|
6151
|
+
template: templateString,
|
|
6152
|
+
parameters: prompt.current_version.parameters,
|
|
6153
|
+
metadata: prompt.current_version.template_metadata,
|
|
6154
|
+
has_tools: !!prompt.current_version.tools?.length,
|
|
6155
|
+
has_functions: !!prompt.current_version.functions?.length
|
|
6156
|
+
} : null,
|
|
6157
|
+
version_count: (prompt.versions || []).length,
|
|
6158
|
+
versions: (prompt.versions || []).map((v) => ({
|
|
6159
|
+
id: v.id,
|
|
6160
|
+
version_number: v.version_number,
|
|
6161
|
+
description: v.version_description,
|
|
6162
|
+
created_at: v.created_at
|
|
6163
|
+
}))
|
|
6164
|
+
})
|
|
6577
6165
|
}
|
|
6578
6166
|
]
|
|
6579
6167
|
};
|
|
@@ -6629,16 +6217,12 @@ function registerPromptsTools(server, service) {
|
|
|
6629
6217
|
content: [
|
|
6630
6218
|
{
|
|
6631
6219
|
type: "text",
|
|
6632
|
-
text: JSON.stringify(
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
},
|
|
6639
|
-
null,
|
|
6640
|
-
2
|
|
6641
|
-
)
|
|
6220
|
+
text: JSON.stringify({
|
|
6221
|
+
message: "Successfully updated prompt",
|
|
6222
|
+
id: result.id,
|
|
6223
|
+
slug: result.slug,
|
|
6224
|
+
new_version_id: result.prompt_version_id
|
|
6225
|
+
})
|
|
6642
6226
|
}
|
|
6643
6227
|
]
|
|
6644
6228
|
};
|
|
@@ -6654,14 +6238,10 @@ function registerPromptsTools(server, service) {
|
|
|
6654
6238
|
content: [
|
|
6655
6239
|
{
|
|
6656
6240
|
type: "text",
|
|
6657
|
-
text: JSON.stringify(
|
|
6658
|
-
{
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
},
|
|
6662
|
-
null,
|
|
6663
|
-
2
|
|
6664
|
-
)
|
|
6241
|
+
text: JSON.stringify({
|
|
6242
|
+
message: `Successfully deleted prompt "${params.prompt_id}"`,
|
|
6243
|
+
success: true
|
|
6244
|
+
})
|
|
6665
6245
|
}
|
|
6666
6246
|
]
|
|
6667
6247
|
};
|
|
@@ -6679,16 +6259,12 @@ function registerPromptsTools(server, service) {
|
|
|
6679
6259
|
content: [
|
|
6680
6260
|
{
|
|
6681
6261
|
type: "text",
|
|
6682
|
-
text: JSON.stringify(
|
|
6683
|
-
{
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
},
|
|
6689
|
-
null,
|
|
6690
|
-
2
|
|
6691
|
-
)
|
|
6262
|
+
text: JSON.stringify({
|
|
6263
|
+
message: `Successfully published version ${params.version} of prompt "${params.prompt_id}"`,
|
|
6264
|
+
prompt_id: params.prompt_id,
|
|
6265
|
+
published_version: params.version,
|
|
6266
|
+
success: true
|
|
6267
|
+
})
|
|
6692
6268
|
}
|
|
6693
6269
|
]
|
|
6694
6270
|
};
|
|
@@ -6706,27 +6282,23 @@ function registerPromptsTools(server, service) {
|
|
|
6706
6282
|
content: [
|
|
6707
6283
|
{
|
|
6708
6284
|
type: "text",
|
|
6709
|
-
text: JSON.stringify(
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
},
|
|
6727
|
-
null,
|
|
6728
|
-
2
|
|
6729
|
-
)
|
|
6285
|
+
text: JSON.stringify({
|
|
6286
|
+
prompt_id: params.prompt_id,
|
|
6287
|
+
total_versions: versions.length,
|
|
6288
|
+
versions: versions.map((v) => ({
|
|
6289
|
+
id: v.id,
|
|
6290
|
+
version_number: v.prompt_version,
|
|
6291
|
+
description: v.prompt_description,
|
|
6292
|
+
status: v.status,
|
|
6293
|
+
label_id: v.label_id,
|
|
6294
|
+
created_at: v.created_at,
|
|
6295
|
+
template_preview: (() => {
|
|
6296
|
+
const tmpl = v.prompt_template;
|
|
6297
|
+
const str = typeof tmpl === "string" ? tmpl : typeof tmpl === "object" && tmpl !== null && "string" in tmpl ? tmpl.string : JSON.stringify(tmpl);
|
|
6298
|
+
return str.substring(0, 200) + (str.length > 200 ? "..." : "");
|
|
6299
|
+
})()
|
|
6300
|
+
}))
|
|
6301
|
+
})
|
|
6730
6302
|
}
|
|
6731
6303
|
]
|
|
6732
6304
|
};
|
|
@@ -6745,20 +6317,16 @@ function registerPromptsTools(server, service) {
|
|
|
6745
6317
|
content: [
|
|
6746
6318
|
{
|
|
6747
6319
|
type: "text",
|
|
6748
|
-
text: JSON.stringify(
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
},
|
|
6759
|
-
null,
|
|
6760
|
-
2
|
|
6761
|
-
)
|
|
6320
|
+
text: JSON.stringify({
|
|
6321
|
+
success: result.success,
|
|
6322
|
+
rendered_messages: result.data.messages,
|
|
6323
|
+
model: result.data.model,
|
|
6324
|
+
hyperparameters: {
|
|
6325
|
+
max_tokens: result.data.max_tokens,
|
|
6326
|
+
temperature: result.data.temperature,
|
|
6327
|
+
top_p: result.data.top_p
|
|
6328
|
+
}
|
|
6329
|
+
})
|
|
6762
6330
|
}
|
|
6763
6331
|
]
|
|
6764
6332
|
};
|
|
@@ -6783,21 +6351,17 @@ function registerPromptsTools(server, service) {
|
|
|
6783
6351
|
content: [
|
|
6784
6352
|
{
|
|
6785
6353
|
type: "text",
|
|
6786
|
-
text: JSON.stringify(
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
},
|
|
6798
|
-
null,
|
|
6799
|
-
2
|
|
6800
|
-
)
|
|
6354
|
+
text: JSON.stringify({
|
|
6355
|
+
id: result.id,
|
|
6356
|
+
model: result.model,
|
|
6357
|
+
response: choice?.message?.content ?? null,
|
|
6358
|
+
finish_reason: choice?.finish_reason ?? null,
|
|
6359
|
+
usage: result.usage ? {
|
|
6360
|
+
prompt_tokens: result.usage.prompt_tokens,
|
|
6361
|
+
completion_tokens: result.usage.completion_tokens,
|
|
6362
|
+
total_tokens: result.usage.total_tokens
|
|
6363
|
+
} : null
|
|
6364
|
+
})
|
|
6801
6365
|
}
|
|
6802
6366
|
]
|
|
6803
6367
|
};
|
|
@@ -6840,18 +6404,14 @@ function registerPromptsTools(server, service) {
|
|
|
6840
6404
|
content: [
|
|
6841
6405
|
{
|
|
6842
6406
|
type: "text",
|
|
6843
|
-
text: JSON.stringify(
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
},
|
|
6852
|
-
null,
|
|
6853
|
-
2
|
|
6854
|
-
)
|
|
6407
|
+
text: JSON.stringify({
|
|
6408
|
+
action: result.action,
|
|
6409
|
+
dry_run: result.dry_run,
|
|
6410
|
+
message: result.message,
|
|
6411
|
+
prompt_id: result.prompt_id ?? void 0,
|
|
6412
|
+
slug: result.slug ?? void 0,
|
|
6413
|
+
version_id: result.version_id ?? void 0
|
|
6414
|
+
})
|
|
6855
6415
|
}
|
|
6856
6416
|
]
|
|
6857
6417
|
};
|
|
@@ -6873,23 +6433,19 @@ function registerPromptsTools(server, service) {
|
|
|
6873
6433
|
content: [
|
|
6874
6434
|
{
|
|
6875
6435
|
type: "text",
|
|
6876
|
-
text: JSON.stringify(
|
|
6877
|
-
{
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
version_id: result.source_version_id
|
|
6882
|
-
},
|
|
6883
|
-
target: {
|
|
6884
|
-
prompt_id: result.target_prompt_id,
|
|
6885
|
-
version_id: result.target_version_id,
|
|
6886
|
-
action: result.action
|
|
6887
|
-
},
|
|
6888
|
-
promoted_at: result.promoted_at
|
|
6436
|
+
text: JSON.stringify({
|
|
6437
|
+
message: `Successfully promoted prompt to ${params.target_env}`,
|
|
6438
|
+
source: {
|
|
6439
|
+
prompt_id: result.source_prompt_id,
|
|
6440
|
+
version_id: result.source_version_id
|
|
6889
6441
|
},
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6442
|
+
target: {
|
|
6443
|
+
prompt_id: result.target_prompt_id,
|
|
6444
|
+
version_id: result.target_version_id,
|
|
6445
|
+
action: result.action
|
|
6446
|
+
},
|
|
6447
|
+
promoted_at: result.promoted_at
|
|
6448
|
+
})
|
|
6893
6449
|
}
|
|
6894
6450
|
]
|
|
6895
6451
|
};
|
|
@@ -6905,16 +6461,12 @@ function registerPromptsTools(server, service) {
|
|
|
6905
6461
|
content: [
|
|
6906
6462
|
{
|
|
6907
6463
|
type: "text",
|
|
6908
|
-
text: JSON.stringify(
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
},
|
|
6915
|
-
null,
|
|
6916
|
-
2
|
|
6917
|
-
)
|
|
6464
|
+
text: JSON.stringify({
|
|
6465
|
+
valid: result.valid,
|
|
6466
|
+
errors: result.errors,
|
|
6467
|
+
warnings: result.warnings,
|
|
6468
|
+
metadata: params
|
|
6469
|
+
})
|
|
6918
6470
|
}
|
|
6919
6471
|
]
|
|
6920
6472
|
};
|
|
@@ -6933,7 +6485,7 @@ function registerPromptsTools(server, service) {
|
|
|
6933
6485
|
content: [
|
|
6934
6486
|
{
|
|
6935
6487
|
type: "text",
|
|
6936
|
-
text: JSON.stringify(formatPromptVersion(version)
|
|
6488
|
+
text: JSON.stringify(formatPromptVersion(version))
|
|
6937
6489
|
}
|
|
6938
6490
|
]
|
|
6939
6491
|
};
|
|
@@ -6944,17 +6496,6 @@ function registerPromptsTools(server, service) {
|
|
|
6944
6496
|
"Update a specific prompt version's label assignment. This only assigns or removes a label, and null clears the label after you look up ids with list_prompt_labels.",
|
|
6945
6497
|
PROMPTS_TOOL_SCHEMAS.updatePromptVersion,
|
|
6946
6498
|
async (params) => {
|
|
6947
|
-
if (params.label_id === void 0) {
|
|
6948
|
-
return {
|
|
6949
|
-
content: [
|
|
6950
|
-
{
|
|
6951
|
-
type: "text",
|
|
6952
|
-
text: "Error: label_id is required \u2014 pass a label ID to assign, or null to remove the label"
|
|
6953
|
-
}
|
|
6954
|
-
],
|
|
6955
|
-
isError: true
|
|
6956
|
-
};
|
|
6957
|
-
}
|
|
6958
6499
|
await service.prompts.updatePromptVersion(
|
|
6959
6500
|
params.prompt_id,
|
|
6960
6501
|
params.version_id,
|
|
@@ -6966,14 +6507,10 @@ function registerPromptsTools(server, service) {
|
|
|
6966
6507
|
content: [
|
|
6967
6508
|
{
|
|
6968
6509
|
type: "text",
|
|
6969
|
-
text: JSON.stringify(
|
|
6970
|
-
{
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
},
|
|
6974
|
-
null,
|
|
6975
|
-
2
|
|
6976
|
-
)
|
|
6510
|
+
text: JSON.stringify({
|
|
6511
|
+
message: `Successfully updated version "${params.version_id}" of prompt "${params.prompt_id}"`,
|
|
6512
|
+
success: true
|
|
6513
|
+
})
|
|
6977
6514
|
}
|
|
6978
6515
|
]
|
|
6979
6516
|
};
|
|
@@ -7061,33 +6598,29 @@ function registerProvidersTools(server, service) {
|
|
|
7061
6598
|
content: [
|
|
7062
6599
|
{
|
|
7063
6600
|
type: "text",
|
|
7064
|
-
text: JSON.stringify(
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
},
|
|
7088
|
-
null,
|
|
7089
|
-
2
|
|
7090
|
-
)
|
|
6601
|
+
text: JSON.stringify({
|
|
6602
|
+
total: providers.total,
|
|
6603
|
+
providers: providers.data.map((provider) => ({
|
|
6604
|
+
name: provider.name,
|
|
6605
|
+
slug: provider.slug,
|
|
6606
|
+
integration_id: provider.integration_id,
|
|
6607
|
+
status: provider.status,
|
|
6608
|
+
note: provider.note,
|
|
6609
|
+
usage_limits: provider.usage_limits ? {
|
|
6610
|
+
credit_limit: provider.usage_limits.credit_limit,
|
|
6611
|
+
alert_threshold: provider.usage_limits.alert_threshold,
|
|
6612
|
+
periodic_reset: provider.usage_limits.periodic_reset
|
|
6613
|
+
} : null,
|
|
6614
|
+
rate_limits: provider.rate_limits?.map((limit) => ({
|
|
6615
|
+
type: limit.type,
|
|
6616
|
+
unit: limit.unit,
|
|
6617
|
+
value: limit.value
|
|
6618
|
+
})) ?? null,
|
|
6619
|
+
reset_usage: provider.reset_usage,
|
|
6620
|
+
expires_at: provider.expires_at,
|
|
6621
|
+
created_at: provider.created_at
|
|
6622
|
+
}))
|
|
6623
|
+
})
|
|
7091
6624
|
}
|
|
7092
6625
|
]
|
|
7093
6626
|
};
|
|
@@ -7120,15 +6653,11 @@ function registerProvidersTools(server, service) {
|
|
|
7120
6653
|
content: [
|
|
7121
6654
|
{
|
|
7122
6655
|
type: "text",
|
|
7123
|
-
text: JSON.stringify(
|
|
7124
|
-
{
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
},
|
|
7129
|
-
null,
|
|
7130
|
-
2
|
|
7131
|
-
)
|
|
6656
|
+
text: JSON.stringify({
|
|
6657
|
+
message: `Successfully created provider "${params.name}"`,
|
|
6658
|
+
id: result.id,
|
|
6659
|
+
slug: result.slug
|
|
6660
|
+
})
|
|
7132
6661
|
}
|
|
7133
6662
|
]
|
|
7134
6663
|
};
|
|
@@ -7147,30 +6676,26 @@ function registerProvidersTools(server, service) {
|
|
|
7147
6676
|
content: [
|
|
7148
6677
|
{
|
|
7149
6678
|
type: "text",
|
|
7150
|
-
text: JSON.stringify(
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
},
|
|
7171
|
-
null,
|
|
7172
|
-
2
|
|
7173
|
-
)
|
|
6679
|
+
text: JSON.stringify({
|
|
6680
|
+
name: provider.name,
|
|
6681
|
+
slug: provider.slug,
|
|
6682
|
+
integration_id: provider.integration_id,
|
|
6683
|
+
status: provider.status,
|
|
6684
|
+
note: provider.note,
|
|
6685
|
+
usage_limits: provider.usage_limits ? {
|
|
6686
|
+
credit_limit: provider.usage_limits.credit_limit,
|
|
6687
|
+
alert_threshold: provider.usage_limits.alert_threshold,
|
|
6688
|
+
periodic_reset: provider.usage_limits.periodic_reset
|
|
6689
|
+
} : null,
|
|
6690
|
+
rate_limits: provider.rate_limits?.map((limit) => ({
|
|
6691
|
+
type: limit.type,
|
|
6692
|
+
unit: limit.unit,
|
|
6693
|
+
value: limit.value
|
|
6694
|
+
})) ?? null,
|
|
6695
|
+
reset_usage: provider.reset_usage,
|
|
6696
|
+
expires_at: provider.expires_at,
|
|
6697
|
+
created_at: provider.created_at
|
|
6698
|
+
})
|
|
7174
6699
|
}
|
|
7175
6700
|
]
|
|
7176
6701
|
};
|
|
@@ -7205,15 +6730,11 @@ function registerProvidersTools(server, service) {
|
|
|
7205
6730
|
content: [
|
|
7206
6731
|
{
|
|
7207
6732
|
type: "text",
|
|
7208
|
-
text: JSON.stringify(
|
|
7209
|
-
{
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
},
|
|
7214
|
-
null,
|
|
7215
|
-
2
|
|
7216
|
-
)
|
|
6733
|
+
text: JSON.stringify({
|
|
6734
|
+
message: `Successfully updated provider "${params.slug}"`,
|
|
6735
|
+
id: result.id,
|
|
6736
|
+
slug: result.slug
|
|
6737
|
+
})
|
|
7217
6738
|
}
|
|
7218
6739
|
]
|
|
7219
6740
|
};
|
|
@@ -7229,14 +6750,10 @@ function registerProvidersTools(server, service) {
|
|
|
7229
6750
|
content: [
|
|
7230
6751
|
{
|
|
7231
6752
|
type: "text",
|
|
7232
|
-
text: JSON.stringify(
|
|
7233
|
-
{
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
},
|
|
7237
|
-
null,
|
|
7238
|
-
2
|
|
7239
|
-
)
|
|
6753
|
+
text: JSON.stringify({
|
|
6754
|
+
message: `Successfully deleted provider "${params.slug}"`,
|
|
6755
|
+
success: true
|
|
6756
|
+
})
|
|
7240
6757
|
}
|
|
7241
6758
|
]
|
|
7242
6759
|
};
|
|
@@ -7286,15 +6803,11 @@ function registerTracingTools(server, service) {
|
|
|
7286
6803
|
content: [
|
|
7287
6804
|
{
|
|
7288
6805
|
type: "text",
|
|
7289
|
-
text: JSON.stringify(
|
|
7290
|
-
{
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
},
|
|
7295
|
-
null,
|
|
7296
|
-
2
|
|
7297
|
-
)
|
|
6806
|
+
text: JSON.stringify({
|
|
6807
|
+
message: `Successfully created feedback for trace "${params.trace_id}"`,
|
|
6808
|
+
status: result.status,
|
|
6809
|
+
feedback_ids: result.feedback_ids
|
|
6810
|
+
})
|
|
7298
6811
|
}
|
|
7299
6812
|
]
|
|
7300
6813
|
};
|
|
@@ -7314,15 +6827,11 @@ function registerTracingTools(server, service) {
|
|
|
7314
6827
|
content: [
|
|
7315
6828
|
{
|
|
7316
6829
|
type: "text",
|
|
7317
|
-
text: JSON.stringify(
|
|
7318
|
-
{
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
},
|
|
7323
|
-
null,
|
|
7324
|
-
2
|
|
7325
|
-
)
|
|
6830
|
+
text: JSON.stringify({
|
|
6831
|
+
message: `Successfully updated feedback "${params.id}"`,
|
|
6832
|
+
status: result.status,
|
|
6833
|
+
feedback_ids: result.feedback_ids
|
|
6834
|
+
})
|
|
7326
6835
|
}
|
|
7327
6836
|
]
|
|
7328
6837
|
};
|
|
@@ -7333,7 +6842,10 @@ function registerTracingTools(server, service) {
|
|
|
7333
6842
|
// src/tools/users.tools.ts
|
|
7334
6843
|
import { z as z18 } from "zod";
|
|
7335
6844
|
var USERS_TOOL_SCHEMAS = {
|
|
7336
|
-
listAllUsers: {
|
|
6845
|
+
listAllUsers: {
|
|
6846
|
+
current_page: z18.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
6847
|
+
page_size: z18.coerce.number().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
6848
|
+
},
|
|
7337
6849
|
inviteUser: {
|
|
7338
6850
|
email: z18.string().email().describe("Email address of the user to invite"),
|
|
7339
6851
|
role: z18.enum(["admin", "member"]).describe(
|
|
@@ -7387,7 +6899,10 @@ var USERS_TOOL_SCHEMAS = {
|
|
|
7387
6899
|
deleteUser: {
|
|
7388
6900
|
user_id: z18.string().describe("The user ID to delete")
|
|
7389
6901
|
},
|
|
7390
|
-
listUserInvites: {
|
|
6902
|
+
listUserInvites: {
|
|
6903
|
+
current_page: z18.coerce.number().positive().optional().describe("Page number for pagination"),
|
|
6904
|
+
page_size: z18.coerce.number().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
6905
|
+
},
|
|
7391
6906
|
getUserInvite: {
|
|
7392
6907
|
invite_id: z18.string().describe("The invite ID to retrieve")
|
|
7393
6908
|
},
|
|
@@ -7398,13 +6913,10 @@ var USERS_TOOL_SCHEMAS = {
|
|
|
7398
6913
|
invite_id: z18.string().describe("The invite ID to resend")
|
|
7399
6914
|
}
|
|
7400
6915
|
};
|
|
7401
|
-
function formatFullName2(firstName, lastName) {
|
|
7402
|
-
return [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
7403
|
-
}
|
|
7404
6916
|
function formatUser(user) {
|
|
7405
6917
|
return {
|
|
7406
6918
|
id: user.id,
|
|
7407
|
-
name:
|
|
6919
|
+
name: formatFullName(user.first_name, user.last_name),
|
|
7408
6920
|
email: user.email,
|
|
7409
6921
|
role: user.role,
|
|
7410
6922
|
created_at: user.created_at,
|
|
@@ -7433,20 +6945,19 @@ function registerUsersTools(server, service) {
|
|
|
7433
6945
|
"list_all_users",
|
|
7434
6946
|
"List accepted org users with id, name, email, role, and timestamps. Use this to find a user_id before get_user, update_user, delete_user, or add_workspace_member; use list_user_invites for pending invitations.",
|
|
7435
6947
|
USERS_TOOL_SCHEMAS.listAllUsers,
|
|
7436
|
-
async () => {
|
|
7437
|
-
const users = await service.users.listUsers(
|
|
6948
|
+
async (params) => {
|
|
6949
|
+
const users = await service.users.listUsers({
|
|
6950
|
+
current_page: params.current_page,
|
|
6951
|
+
page_size: params.page_size
|
|
6952
|
+
});
|
|
7438
6953
|
return {
|
|
7439
6954
|
content: [
|
|
7440
6955
|
{
|
|
7441
6956
|
type: "text",
|
|
7442
|
-
text: JSON.stringify(
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
},
|
|
7447
|
-
null,
|
|
7448
|
-
2
|
|
7449
|
-
)
|
|
6957
|
+
text: JSON.stringify({
|
|
6958
|
+
total: users.total,
|
|
6959
|
+
users: users.data.map(formatUser)
|
|
6960
|
+
})
|
|
7450
6961
|
}
|
|
7451
6962
|
]
|
|
7452
6963
|
};
|
|
@@ -7462,15 +6973,11 @@ function registerUsersTools(server, service) {
|
|
|
7462
6973
|
content: [
|
|
7463
6974
|
{
|
|
7464
6975
|
type: "text",
|
|
7465
|
-
text: JSON.stringify(
|
|
7466
|
-
{
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
},
|
|
7471
|
-
null,
|
|
7472
|
-
2
|
|
7473
|
-
)
|
|
6976
|
+
text: JSON.stringify({
|
|
6977
|
+
message: `Successfully invited ${params.email} as ${params.role}`,
|
|
6978
|
+
invite_id: result.id,
|
|
6979
|
+
invite_link: result.invite_link
|
|
6980
|
+
})
|
|
7474
6981
|
}
|
|
7475
6982
|
]
|
|
7476
6983
|
};
|
|
@@ -7486,14 +6993,10 @@ function registerUsersTools(server, service) {
|
|
|
7486
6993
|
content: [
|
|
7487
6994
|
{
|
|
7488
6995
|
type: "text",
|
|
7489
|
-
text: JSON.stringify(
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
},
|
|
7494
|
-
null,
|
|
7495
|
-
2
|
|
7496
|
-
)
|
|
6996
|
+
text: JSON.stringify({
|
|
6997
|
+
total_users: stats.total,
|
|
6998
|
+
users: stats.data.map(formatUserAnalyticsGroup)
|
|
6999
|
+
})
|
|
7497
7000
|
}
|
|
7498
7001
|
]
|
|
7499
7002
|
};
|
|
@@ -7509,7 +7012,7 @@ function registerUsersTools(server, service) {
|
|
|
7509
7012
|
content: [
|
|
7510
7013
|
{
|
|
7511
7014
|
type: "text",
|
|
7512
|
-
text: JSON.stringify(formatUser(user)
|
|
7015
|
+
text: JSON.stringify(formatUser(user))
|
|
7513
7016
|
}
|
|
7514
7017
|
]
|
|
7515
7018
|
};
|
|
@@ -7526,14 +7029,10 @@ function registerUsersTools(server, service) {
|
|
|
7526
7029
|
content: [
|
|
7527
7030
|
{
|
|
7528
7031
|
type: "text",
|
|
7529
|
-
text: JSON.stringify(
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
},
|
|
7534
|
-
null,
|
|
7535
|
-
2
|
|
7536
|
-
)
|
|
7032
|
+
text: JSON.stringify({
|
|
7033
|
+
message: "Successfully updated user",
|
|
7034
|
+
user: formatUser(user)
|
|
7035
|
+
})
|
|
7537
7036
|
}
|
|
7538
7037
|
]
|
|
7539
7038
|
};
|
|
@@ -7549,14 +7048,10 @@ function registerUsersTools(server, service) {
|
|
|
7549
7048
|
content: [
|
|
7550
7049
|
{
|
|
7551
7050
|
type: "text",
|
|
7552
|
-
text: JSON.stringify(
|
|
7553
|
-
{
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
},
|
|
7557
|
-
null,
|
|
7558
|
-
2
|
|
7559
|
-
)
|
|
7051
|
+
text: JSON.stringify({
|
|
7052
|
+
message: `Successfully deleted user ${params.user_id}`,
|
|
7053
|
+
success: true
|
|
7054
|
+
})
|
|
7560
7055
|
}
|
|
7561
7056
|
]
|
|
7562
7057
|
};
|
|
@@ -7566,20 +7061,19 @@ function registerUsersTools(server, service) {
|
|
|
7566
7061
|
"list_user_invites",
|
|
7567
7062
|
"List pending and sent invitations with id, email, role, status, and expiry. Use this to check invite state; use list_all_users for users who already accepted.",
|
|
7568
7063
|
USERS_TOOL_SCHEMAS.listUserInvites,
|
|
7569
|
-
async () => {
|
|
7570
|
-
const invites = await service.users.listUserInvites(
|
|
7064
|
+
async (params) => {
|
|
7065
|
+
const invites = await service.users.listUserInvites({
|
|
7066
|
+
current_page: params.current_page,
|
|
7067
|
+
page_size: params.page_size
|
|
7068
|
+
});
|
|
7571
7069
|
return {
|
|
7572
7070
|
content: [
|
|
7573
7071
|
{
|
|
7574
7072
|
type: "text",
|
|
7575
|
-
text: JSON.stringify(
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
},
|
|
7580
|
-
null,
|
|
7581
|
-
2
|
|
7582
|
-
)
|
|
7073
|
+
text: JSON.stringify({
|
|
7074
|
+
total: invites.total,
|
|
7075
|
+
invites: invites.data.map(formatUserInvite)
|
|
7076
|
+
})
|
|
7583
7077
|
}
|
|
7584
7078
|
]
|
|
7585
7079
|
};
|
|
@@ -7595,7 +7089,7 @@ function registerUsersTools(server, service) {
|
|
|
7595
7089
|
content: [
|
|
7596
7090
|
{
|
|
7597
7091
|
type: "text",
|
|
7598
|
-
text: JSON.stringify(formatUserInvite(invite)
|
|
7092
|
+
text: JSON.stringify(formatUserInvite(invite))
|
|
7599
7093
|
}
|
|
7600
7094
|
]
|
|
7601
7095
|
};
|
|
@@ -7611,14 +7105,10 @@ function registerUsersTools(server, service) {
|
|
|
7611
7105
|
content: [
|
|
7612
7106
|
{
|
|
7613
7107
|
type: "text",
|
|
7614
|
-
text: JSON.stringify(
|
|
7615
|
-
{
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
},
|
|
7619
|
-
null,
|
|
7620
|
-
2
|
|
7621
|
-
)
|
|
7108
|
+
text: JSON.stringify({
|
|
7109
|
+
message: `Successfully deleted invite ${params.invite_id}`,
|
|
7110
|
+
success: true
|
|
7111
|
+
})
|
|
7622
7112
|
}
|
|
7623
7113
|
]
|
|
7624
7114
|
};
|
|
@@ -7634,14 +7124,10 @@ function registerUsersTools(server, service) {
|
|
|
7634
7124
|
content: [
|
|
7635
7125
|
{
|
|
7636
7126
|
type: "text",
|
|
7637
|
-
text: JSON.stringify(
|
|
7638
|
-
{
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
},
|
|
7642
|
-
null,
|
|
7643
|
-
2
|
|
7644
|
-
)
|
|
7127
|
+
text: JSON.stringify({
|
|
7128
|
+
message: `Successfully resent invite ${params.invite_id}`,
|
|
7129
|
+
success: true
|
|
7130
|
+
})
|
|
7645
7131
|
}
|
|
7646
7132
|
]
|
|
7647
7133
|
};
|
|
@@ -7707,9 +7193,6 @@ var WORKSPACES_TOOL_SCHEMAS = {
|
|
|
7707
7193
|
user_id: z19.string().describe("The user ID to remove")
|
|
7708
7194
|
}
|
|
7709
7195
|
};
|
|
7710
|
-
function formatFullName3(firstName, lastName) {
|
|
7711
|
-
return [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
7712
|
-
}
|
|
7713
7196
|
function formatWorkspaceDefaults(defaults) {
|
|
7714
7197
|
if (!defaults) {
|
|
7715
7198
|
return null;
|
|
@@ -7733,7 +7216,7 @@ function formatWorkspaceSummary(workspace) {
|
|
|
7733
7216
|
function formatWorkspaceMember(user) {
|
|
7734
7217
|
return {
|
|
7735
7218
|
id: user.id,
|
|
7736
|
-
name:
|
|
7219
|
+
name: formatFullName(user.first_name, user.last_name),
|
|
7737
7220
|
organization_role: user.org_role,
|
|
7738
7221
|
workspace_role: user.role,
|
|
7739
7222
|
status: user.status,
|
|
@@ -7764,14 +7247,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7764
7247
|
content: [
|
|
7765
7248
|
{
|
|
7766
7249
|
type: "text",
|
|
7767
|
-
text: JSON.stringify(
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
},
|
|
7772
|
-
null,
|
|
7773
|
-
2
|
|
7774
|
-
)
|
|
7250
|
+
text: JSON.stringify({
|
|
7251
|
+
total: workspaces.total,
|
|
7252
|
+
workspaces: workspaces.data.map(formatWorkspaceSummary)
|
|
7253
|
+
})
|
|
7775
7254
|
}
|
|
7776
7255
|
]
|
|
7777
7256
|
};
|
|
@@ -7789,7 +7268,7 @@ function registerWorkspacesTools(server, service) {
|
|
|
7789
7268
|
content: [
|
|
7790
7269
|
{
|
|
7791
7270
|
type: "text",
|
|
7792
|
-
text: JSON.stringify(formatWorkspaceDetail(workspace)
|
|
7271
|
+
text: JSON.stringify(formatWorkspaceDetail(workspace))
|
|
7793
7272
|
}
|
|
7794
7273
|
]
|
|
7795
7274
|
};
|
|
@@ -7813,14 +7292,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7813
7292
|
content: [
|
|
7814
7293
|
{
|
|
7815
7294
|
type: "text",
|
|
7816
|
-
text: JSON.stringify(
|
|
7817
|
-
{
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
},
|
|
7821
|
-
null,
|
|
7822
|
-
2
|
|
7823
|
-
)
|
|
7295
|
+
text: JSON.stringify({
|
|
7296
|
+
message: `Successfully created workspace "${params.name}"`,
|
|
7297
|
+
workspace: formatWorkspaceSummary(workspace)
|
|
7298
|
+
})
|
|
7824
7299
|
}
|
|
7825
7300
|
]
|
|
7826
7301
|
};
|
|
@@ -7843,14 +7318,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7843
7318
|
content: [
|
|
7844
7319
|
{
|
|
7845
7320
|
type: "text",
|
|
7846
|
-
text: JSON.stringify(
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
},
|
|
7851
|
-
null,
|
|
7852
|
-
2
|
|
7853
|
-
)
|
|
7321
|
+
text: JSON.stringify({
|
|
7322
|
+
message: "Successfully updated workspace",
|
|
7323
|
+
workspace: formatWorkspaceSummary(workspace)
|
|
7324
|
+
})
|
|
7854
7325
|
}
|
|
7855
7326
|
]
|
|
7856
7327
|
};
|
|
@@ -7866,14 +7337,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7866
7337
|
content: [
|
|
7867
7338
|
{
|
|
7868
7339
|
type: "text",
|
|
7869
|
-
text: JSON.stringify(
|
|
7870
|
-
{
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
},
|
|
7874
|
-
null,
|
|
7875
|
-
2
|
|
7876
|
-
)
|
|
7340
|
+
text: JSON.stringify({
|
|
7341
|
+
message: `Successfully deleted workspace ${params.workspace_id}`,
|
|
7342
|
+
success: true
|
|
7343
|
+
})
|
|
7877
7344
|
}
|
|
7878
7345
|
]
|
|
7879
7346
|
};
|
|
@@ -7895,14 +7362,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7895
7362
|
content: [
|
|
7896
7363
|
{
|
|
7897
7364
|
type: "text",
|
|
7898
|
-
text: JSON.stringify(
|
|
7899
|
-
{
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
},
|
|
7903
|
-
null,
|
|
7904
|
-
2
|
|
7905
|
-
)
|
|
7365
|
+
text: JSON.stringify({
|
|
7366
|
+
message: `Successfully added user to workspace as ${params.role}`,
|
|
7367
|
+
member: formatWorkspaceMember(member)
|
|
7368
|
+
})
|
|
7906
7369
|
}
|
|
7907
7370
|
]
|
|
7908
7371
|
};
|
|
@@ -7920,14 +7383,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7920
7383
|
content: [
|
|
7921
7384
|
{
|
|
7922
7385
|
type: "text",
|
|
7923
|
-
text: JSON.stringify(
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
},
|
|
7928
|
-
null,
|
|
7929
|
-
2
|
|
7930
|
-
)
|
|
7386
|
+
text: JSON.stringify({
|
|
7387
|
+
total: members.total,
|
|
7388
|
+
members: members.data.map(formatWorkspaceMember)
|
|
7389
|
+
})
|
|
7931
7390
|
}
|
|
7932
7391
|
]
|
|
7933
7392
|
};
|
|
@@ -7946,7 +7405,7 @@ function registerWorkspacesTools(server, service) {
|
|
|
7946
7405
|
content: [
|
|
7947
7406
|
{
|
|
7948
7407
|
type: "text",
|
|
7949
|
-
text: JSON.stringify(formatWorkspaceMember(member)
|
|
7408
|
+
text: JSON.stringify(formatWorkspaceMember(member))
|
|
7950
7409
|
}
|
|
7951
7410
|
]
|
|
7952
7411
|
};
|
|
@@ -7968,14 +7427,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7968
7427
|
content: [
|
|
7969
7428
|
{
|
|
7970
7429
|
type: "text",
|
|
7971
|
-
text: JSON.stringify(
|
|
7972
|
-
{
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
},
|
|
7976
|
-
null,
|
|
7977
|
-
2
|
|
7978
|
-
)
|
|
7430
|
+
text: JSON.stringify({
|
|
7431
|
+
message: `Successfully updated member role to ${params.role}`,
|
|
7432
|
+
member: formatWorkspaceMember(member)
|
|
7433
|
+
})
|
|
7979
7434
|
}
|
|
7980
7435
|
]
|
|
7981
7436
|
};
|
|
@@ -7994,14 +7449,10 @@ function registerWorkspacesTools(server, service) {
|
|
|
7994
7449
|
content: [
|
|
7995
7450
|
{
|
|
7996
7451
|
type: "text",
|
|
7997
|
-
text: JSON.stringify(
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
},
|
|
8002
|
-
null,
|
|
8003
|
-
2
|
|
8004
|
-
)
|
|
7452
|
+
text: JSON.stringify({
|
|
7453
|
+
message: `Successfully removed user from workspace`,
|
|
7454
|
+
success: true
|
|
7455
|
+
})
|
|
8005
7456
|
}
|
|
8006
7457
|
]
|
|
8007
7458
|
};
|
|
@@ -8095,7 +7546,7 @@ var ENTERPRISE_GATED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
8095
7546
|
]);
|
|
8096
7547
|
var ENTERPRISE_GATED_DESCRIPTION_NOTE = "Enterprise-gated. Returns 403 on non-Enterprise Portkey plans.";
|
|
8097
7548
|
function isToolAnnotationsLike(value) {
|
|
8098
|
-
if (!
|
|
7549
|
+
if (!isRecord(value)) {
|
|
8099
7550
|
return false;
|
|
8100
7551
|
}
|
|
8101
7552
|
const keys = Object.keys(value);
|
|
@@ -8155,17 +7606,14 @@ var STANDARD_TOOL_OUTPUT_SCHEMA = {
|
|
|
8155
7606
|
details: z20.unknown().optional().describe("Optional structured error details")
|
|
8156
7607
|
}).optional().describe("Structured error payload when ok is false")
|
|
8157
7608
|
};
|
|
8158
|
-
function isRecord2(value) {
|
|
8159
|
-
return typeof value === "object" && value !== null;
|
|
8160
|
-
}
|
|
8161
7609
|
function isStandardToolEnvelope(value) {
|
|
8162
|
-
if (!
|
|
7610
|
+
if (!isRecord(value) || typeof value.ok !== "boolean") {
|
|
8163
7611
|
return false;
|
|
8164
7612
|
}
|
|
8165
7613
|
if (value.ok) {
|
|
8166
7614
|
return "data" in value;
|
|
8167
7615
|
}
|
|
8168
|
-
return
|
|
7616
|
+
return isRecord(value.error) && typeof value.error.message === "string";
|
|
8169
7617
|
}
|
|
8170
7618
|
function tryParseJson(text) {
|
|
8171
7619
|
try {
|
|
@@ -8195,13 +7643,13 @@ function getErrorDetails(result) {
|
|
|
8195
7643
|
if (parsed === void 0) {
|
|
8196
7644
|
return { message: text };
|
|
8197
7645
|
}
|
|
8198
|
-
if (
|
|
7646
|
+
if (isRecord(parsed) && typeof parsed.message === "string") {
|
|
8199
7647
|
return { message: parsed.message, details: parsed };
|
|
8200
7648
|
}
|
|
8201
7649
|
return { message: text, details: parsed };
|
|
8202
7650
|
}
|
|
8203
7651
|
function formatToolEnvelope(envelope) {
|
|
8204
|
-
return JSON.stringify(envelope
|
|
7652
|
+
return JSON.stringify(envelope);
|
|
8205
7653
|
}
|
|
8206
7654
|
function normalizeToolResult(result) {
|
|
8207
7655
|
const envelope = isStandardToolEnvelope(result.structuredContent) ? result.structuredContent : result.isError ? {
|