portkey-admin-mcp 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ENDPOINTS.md +638 -0
- package/README.md +14 -11
- package/build/index.js +1537 -684
- package/build/server.js +1537 -684
- package/docs/PRISMA_AIRS_INTEROPERABILITY.md +66 -0
- package/docs/VERCEL_DEPLOYMENT.md +192 -0
- package/package.json +13 -6
package/build/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
6
6
|
// src/lib/mcp-server.ts
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
8
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
-
import { z as
|
|
9
|
+
import { z as z24 } from "zod";
|
|
10
10
|
|
|
11
11
|
// src/services/base.service.ts
|
|
12
12
|
import crypto from "node:crypto";
|
|
@@ -119,6 +119,7 @@ var Logger = {
|
|
|
119
119
|
|
|
120
120
|
// src/services/base.service.ts
|
|
121
121
|
var DEFAULT_BASE_URL = "https://api.portkey.ai/v1";
|
|
122
|
+
var DEFAULT_PUBLIC_BASE_URL = "https://api.portkey.ai";
|
|
122
123
|
var PRIVATE_BASE_URL_OVERRIDE_HINT = "Set PORTKEY_ALLOW_PRIVATE_BASE_URL=true to allow self-hosted gateways on loopback or private networks.";
|
|
123
124
|
var INSECURE_HTTP_OVERRIDE_HINT = "Set PORTKEY_ALLOW_INSECURE_HTTP=true only for a trusted self-hosted gateway when TLS is unavailable.";
|
|
124
125
|
function isPrivateOrLocalHost(hostname) {
|
|
@@ -213,14 +214,12 @@ var BaseService = class {
|
|
|
213
214
|
encodePathSegment(value) {
|
|
214
215
|
return encodeURIComponent(value);
|
|
215
216
|
}
|
|
216
|
-
buildUrl(path, params) {
|
|
217
|
-
return `${
|
|
217
|
+
buildUrl(path, params, baseUrl = this.baseUrl) {
|
|
218
|
+
return `${baseUrl}${path}${buildQueryString(params)}`;
|
|
218
219
|
}
|
|
219
|
-
buildHeaders(method) {
|
|
220
|
-
const headers = {
|
|
221
|
-
|
|
222
|
-
Accept: "application/json"
|
|
223
|
-
};
|
|
220
|
+
buildHeaders(method, authenticate = true) {
|
|
221
|
+
const headers = { Accept: "application/json" };
|
|
222
|
+
if (authenticate) headers["x-portkey-api-key"] = this.apiKey;
|
|
224
223
|
if (method === "POST" || method === "PUT") {
|
|
225
224
|
headers["Content-Type"] = "application/json";
|
|
226
225
|
}
|
|
@@ -231,7 +230,7 @@ var BaseService = class {
|
|
|
231
230
|
}
|
|
232
231
|
async executeRequest(method, path, options = {}) {
|
|
233
232
|
const requestId = crypto.randomUUID();
|
|
234
|
-
const url = this.buildUrl(path, options.params);
|
|
233
|
+
const url = this.buildUrl(path, options.params, options.baseUrl);
|
|
235
234
|
const startTime = Date.now();
|
|
236
235
|
Logger.debug("HTTP request started", {
|
|
237
236
|
requestId,
|
|
@@ -245,7 +244,7 @@ var BaseService = class {
|
|
|
245
244
|
const response = await fetchWithTimeout(url, {
|
|
246
245
|
method,
|
|
247
246
|
redirect: "manual",
|
|
248
|
-
headers: this.buildHeaders(method),
|
|
247
|
+
headers: this.buildHeaders(method, options.authenticate),
|
|
249
248
|
body: this.serializeBody(options.body),
|
|
250
249
|
timeout: this.timeout
|
|
251
250
|
});
|
|
@@ -290,14 +289,25 @@ var BaseService = class {
|
|
|
290
289
|
async get(path, params) {
|
|
291
290
|
return this.executeRequest("GET", path, { params });
|
|
292
291
|
}
|
|
292
|
+
/** Read an unauthenticated Portkey public-catalog endpoint outside /v1. */
|
|
293
|
+
async getPublic(path, params) {
|
|
294
|
+
return this.executeRequest("GET", path, {
|
|
295
|
+
params,
|
|
296
|
+
baseUrl: DEFAULT_PUBLIC_BASE_URL,
|
|
297
|
+
authenticate: false
|
|
298
|
+
});
|
|
299
|
+
}
|
|
293
300
|
async post(path, body) {
|
|
294
301
|
return this.executeRequest("POST", path, { body });
|
|
295
302
|
}
|
|
296
303
|
async put(path, body) {
|
|
297
304
|
return this.executeRequest("PUT", path, { body });
|
|
298
305
|
}
|
|
299
|
-
async delete(path) {
|
|
300
|
-
return this.executeRequest("DELETE", path, {
|
|
306
|
+
async delete(path, params) {
|
|
307
|
+
return this.executeRequest("DELETE", path, {
|
|
308
|
+
params,
|
|
309
|
+
allowNoContent: true
|
|
310
|
+
});
|
|
301
311
|
}
|
|
302
312
|
};
|
|
303
313
|
|
|
@@ -564,6 +574,33 @@ var ConfigsService = class extends BaseService {
|
|
|
564
574
|
|
|
565
575
|
// src/services/guardrails.service.ts
|
|
566
576
|
var GuardrailsService = class extends BaseService {
|
|
577
|
+
/** Get the organisation-wide input and output guardrail defaults. */
|
|
578
|
+
async getOrganisationDefaults() {
|
|
579
|
+
return this.get(
|
|
580
|
+
"/admin/organisation/defaults"
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
/** Replace either or both organisation-wide guardrail default lists. */
|
|
584
|
+
async updateOrganisationDefaults(data) {
|
|
585
|
+
return this.put(
|
|
586
|
+
"/admin/organisation/defaults",
|
|
587
|
+
data
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
/** List workspace exclusions for input or output organisation guardrails. */
|
|
591
|
+
async listWorkspaceExclusions(direction, params) {
|
|
592
|
+
return this.get(
|
|
593
|
+
`/workspace-exclusions/${direction}-guardrails`,
|
|
594
|
+
params
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
/** Update workspace exclusions for input or output organisation guardrails. */
|
|
598
|
+
async updateWorkspaceExclusions(direction, data) {
|
|
599
|
+
return this.put(
|
|
600
|
+
`/workspace-exclusions/${direction}-guardrails`,
|
|
601
|
+
data
|
|
602
|
+
);
|
|
603
|
+
}
|
|
567
604
|
/**
|
|
568
605
|
* List all guardrails with optional filtering
|
|
569
606
|
*/
|
|
@@ -650,6 +687,12 @@ var HealthService = class extends BaseService {
|
|
|
650
687
|
|
|
651
688
|
// src/services/integrations.service.ts
|
|
652
689
|
var IntegrationsService = class extends BaseService {
|
|
690
|
+
// Get current public catalog pricing (USD cents per token/unit).
|
|
691
|
+
async getModelPricing(provider, model) {
|
|
692
|
+
return this.getPublic(
|
|
693
|
+
`/model-configs/pricing/${this.encodePathSegment(provider)}/${this.encodePathSegment(model)}`
|
|
694
|
+
);
|
|
695
|
+
}
|
|
653
696
|
// List all integrations
|
|
654
697
|
async listIntegrations(params) {
|
|
655
698
|
return this.get("/integrations", {
|
|
@@ -681,13 +724,16 @@ var IntegrationsService = class extends BaseService {
|
|
|
681
724
|
}
|
|
682
725
|
// List models for an integration
|
|
683
726
|
async listIntegrationModels(slug, params) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
727
|
+
const response = await this.get(`/integrations/${this.encodePathSegment(slug)}/models`, {
|
|
728
|
+
current_page: params?.current_page,
|
|
729
|
+
page_size: params?.page_size
|
|
730
|
+
});
|
|
731
|
+
const data = response.data ?? response.models ?? [];
|
|
732
|
+
return {
|
|
733
|
+
object: response.object ?? "list",
|
|
734
|
+
total: response.total ?? data.length,
|
|
735
|
+
data
|
|
736
|
+
};
|
|
691
737
|
}
|
|
692
738
|
// Update models for an integration
|
|
693
739
|
async updateIntegrationModels(slug, data) {
|
|
@@ -706,13 +752,16 @@ var IntegrationsService = class extends BaseService {
|
|
|
706
752
|
}
|
|
707
753
|
// List workspaces for an integration
|
|
708
754
|
async listIntegrationWorkspaces(slug, params) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
755
|
+
const response = await this.get(`/integrations/${this.encodePathSegment(slug)}/workspaces`, {
|
|
756
|
+
current_page: params?.current_page,
|
|
757
|
+
page_size: params?.page_size
|
|
758
|
+
});
|
|
759
|
+
const data = response.data ?? response.workspaces ?? [];
|
|
760
|
+
return {
|
|
761
|
+
object: response.object ?? "list",
|
|
762
|
+
total: response.total ?? data.length,
|
|
763
|
+
data
|
|
764
|
+
};
|
|
716
765
|
}
|
|
717
766
|
// Update workspaces for an integration
|
|
718
767
|
async updateIntegrationWorkspaces(slug, data) {
|
|
@@ -913,6 +962,20 @@ var LimitsService = class extends BaseService {
|
|
|
913
962
|
|
|
914
963
|
// src/services/logging.service.ts
|
|
915
964
|
var LoggingService = class extends BaseService {
|
|
965
|
+
/** Get one gateway log by ID. */
|
|
966
|
+
async getLog(logId, params) {
|
|
967
|
+
return this.get(
|
|
968
|
+
`/logs/${this.encodePathSegment(logId)}`,
|
|
969
|
+
params
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
/** Get organisation-managed export field restrictions for a workspace. */
|
|
973
|
+
async getLogExportFieldRestrictions(params) {
|
|
974
|
+
return this.get(
|
|
975
|
+
"/logs/exports/field-restrictions",
|
|
976
|
+
params
|
|
977
|
+
);
|
|
978
|
+
}
|
|
916
979
|
/**
|
|
917
980
|
* Insert a log entry (or multiple entries) into Portkey
|
|
918
981
|
*/
|
|
@@ -1032,6 +1095,19 @@ var McpIntegrationsService = class extends BaseService {
|
|
|
1032
1095
|
|
|
1033
1096
|
// src/services/mcp-servers.service.ts
|
|
1034
1097
|
var McpServersService = class extends BaseService {
|
|
1098
|
+
async listMcpServerConnections(id, params) {
|
|
1099
|
+
return this.get(
|
|
1100
|
+
`/mcp-servers/${this.encodePathSegment(id)}/connections`,
|
|
1101
|
+
params
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
async disconnectMcpServerConnection(id, params) {
|
|
1105
|
+
await this.delete(
|
|
1106
|
+
`/mcp-servers/${this.encodePathSegment(id)}/connections`,
|
|
1107
|
+
params
|
|
1108
|
+
);
|
|
1109
|
+
return { success: true };
|
|
1110
|
+
}
|
|
1035
1111
|
async listMcpServers(params) {
|
|
1036
1112
|
return this.get("/mcp-servers", {
|
|
1037
1113
|
current_page: params?.current_page,
|
|
@@ -1609,6 +1685,22 @@ var UsersService = class extends BaseService {
|
|
|
1609
1685
|
|
|
1610
1686
|
// src/services/workspaces.service.ts
|
|
1611
1687
|
var WorkspacesService = class extends BaseService {
|
|
1688
|
+
async listScimWorkspaceMappings(params) {
|
|
1689
|
+
return this.get(
|
|
1690
|
+
"/scim/workspaces",
|
|
1691
|
+
params
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
async createScimWorkspaceMapping(data) {
|
|
1695
|
+
return this.post("/scim/workspaces", data);
|
|
1696
|
+
}
|
|
1697
|
+
async deleteScimWorkspaceMapping(mappingId) {
|
|
1698
|
+
await this.delete(`/scim/workspaces/${this.encodePathSegment(mappingId)}`);
|
|
1699
|
+
return { success: true };
|
|
1700
|
+
}
|
|
1701
|
+
async listScimGroups(params) {
|
|
1702
|
+
return this.get("/scim/groups", params);
|
|
1703
|
+
}
|
|
1612
1704
|
async listWorkspaces(params) {
|
|
1613
1705
|
return this.get("/admin/workspaces", params);
|
|
1614
1706
|
}
|
|
@@ -1755,7 +1847,7 @@ function getSharedPortkeyService(apiKey) {
|
|
|
1755
1847
|
}
|
|
1756
1848
|
|
|
1757
1849
|
// src/tools/index.ts
|
|
1758
|
-
import { z as
|
|
1850
|
+
import { z as z23 } from "zod";
|
|
1759
1851
|
|
|
1760
1852
|
// src/lib/type-guards.ts
|
|
1761
1853
|
function isRecord(value) {
|
|
@@ -2684,6 +2776,12 @@ function registerCollectionsTools(server, service) {
|
|
|
2684
2776
|
|
|
2685
2777
|
// src/tools/configs.tools.ts
|
|
2686
2778
|
import { z as z5 } from "zod";
|
|
2779
|
+
var configTargetSchema = z5.object({
|
|
2780
|
+
provider: z5.string().optional().describe("Provider slug to route requests to"),
|
|
2781
|
+
virtual_key: z5.string().optional().describe("Virtual key slug to use for this routing target")
|
|
2782
|
+
}).refine((target) => target.provider || target.virtual_key, {
|
|
2783
|
+
message: "Each target must have at least provider or virtual_key"
|
|
2784
|
+
});
|
|
2687
2785
|
var CONFIGS_TOOL_SCHEMAS = {
|
|
2688
2786
|
listConfigs: {
|
|
2689
2787
|
current_page: z5.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
@@ -2702,14 +2800,7 @@ var CONFIGS_TOOL_SCHEMAS = {
|
|
|
2702
2800
|
retry_attempts: z5.coerce.number().positive().max(5).optional().describe("Number of retry attempts (1-5)"),
|
|
2703
2801
|
retry_on_status_codes: z5.array(z5.coerce.number()).optional().describe("HTTP status codes to retry on (e.g., [429, 500, 502, 503])"),
|
|
2704
2802
|
strategy_mode: z5.enum(["loadbalance", "fallback"]).optional().describe("Routing strategy: 'loadbalance' or 'fallback'"),
|
|
2705
|
-
targets: z5.array(
|
|
2706
|
-
z5.object({
|
|
2707
|
-
provider: z5.string().optional(),
|
|
2708
|
-
virtual_key: z5.string().optional()
|
|
2709
|
-
}).refine((t) => t.provider || t.virtual_key, {
|
|
2710
|
-
message: "Each target must have at least provider or virtual_key"
|
|
2711
|
-
})
|
|
2712
|
-
).optional().describe("Array of target providers with virtual keys")
|
|
2803
|
+
targets: z5.array(configTargetSchema).optional().describe("Array of target providers with virtual keys")
|
|
2713
2804
|
},
|
|
2714
2805
|
updateConfig: {
|
|
2715
2806
|
slug: z5.string().describe("Configuration slug to update"),
|
|
@@ -2720,14 +2811,7 @@ var CONFIGS_TOOL_SCHEMAS = {
|
|
|
2720
2811
|
retry_attempts: z5.coerce.number().positive().max(5).optional().describe("Number of retry attempts (1-5)"),
|
|
2721
2812
|
retry_on_status_codes: z5.array(z5.coerce.number()).optional().describe("HTTP status codes to retry on"),
|
|
2722
2813
|
strategy_mode: z5.enum(["loadbalance", "fallback"]).optional().describe("Routing strategy"),
|
|
2723
|
-
targets: z5.array(
|
|
2724
|
-
z5.object({
|
|
2725
|
-
provider: z5.string().optional(),
|
|
2726
|
-
virtual_key: z5.string().optional()
|
|
2727
|
-
}).refine((t) => t.provider || t.virtual_key, {
|
|
2728
|
-
message: "Each target must have at least provider or virtual_key"
|
|
2729
|
-
})
|
|
2730
|
-
).optional().describe("Array of target providers")
|
|
2814
|
+
targets: z5.array(configTargetSchema).optional().describe("Array of target providers")
|
|
2731
2815
|
},
|
|
2732
2816
|
deleteConfig: {
|
|
2733
2817
|
slug: z5.string().describe("Configuration slug to delete")
|
|
@@ -2742,12 +2826,7 @@ var configPayloadSchema = z5.object({
|
|
|
2742
2826
|
retry_attempts: z5.coerce.number().positive().max(5).optional(),
|
|
2743
2827
|
retry_on_status_codes: z5.array(z5.coerce.number()).optional(),
|
|
2744
2828
|
strategy_mode: z5.enum(["loadbalance", "fallback"]).optional(),
|
|
2745
|
-
targets: z5.array(
|
|
2746
|
-
z5.object({
|
|
2747
|
-
provider: z5.string().optional(),
|
|
2748
|
-
virtual_key: z5.string().optional()
|
|
2749
|
-
})
|
|
2750
|
-
).optional()
|
|
2829
|
+
targets: z5.array(configTargetSchema).optional()
|
|
2751
2830
|
});
|
|
2752
2831
|
function buildConfigPayload(params) {
|
|
2753
2832
|
const cache = params.cache_mode !== void 0 || params.cache_max_age !== void 0 ? {
|
|
@@ -2982,7 +3061,12 @@ var guardrailActionSchema = z6.object({
|
|
|
2982
3061
|
on_fail_action: z6.string().optional().describe("Simple action on failure (e.g., 'block')"),
|
|
2983
3062
|
message: z6.string().optional().describe("Message to return when guardrail triggers")
|
|
2984
3063
|
});
|
|
3064
|
+
var workspaceGuardrailExclusionSchema = z6.object({
|
|
3065
|
+
workspace_id: z6.string().describe("Workspace ID whose exclusion state changes"),
|
|
3066
|
+
excluded: z6.boolean().describe("True to exclude this workspace; false to restore enforcement")
|
|
3067
|
+
});
|
|
2985
3068
|
var GUARDRAILS_TOOL_SCHEMAS = {
|
|
3069
|
+
getOrganisationDefaults: {},
|
|
2986
3070
|
listGuardrails: {
|
|
2987
3071
|
workspace_id: z6.string().optional().describe("Filter guardrails by workspace ID"),
|
|
2988
3072
|
organisation_id: z6.string().optional().describe("Filter guardrails by organization ID"),
|
|
@@ -3009,9 +3093,157 @@ var GUARDRAILS_TOOL_SCHEMAS = {
|
|
|
3009
3093
|
},
|
|
3010
3094
|
deleteGuardrail: {
|
|
3011
3095
|
guardrail_id: z6.string().describe("The guardrail UUID or slug to delete")
|
|
3096
|
+
},
|
|
3097
|
+
updateOrganisationDefaults: {
|
|
3098
|
+
input_guardrails: z6.array(z6.string()).optional().describe("Ordered guardrail IDs or slugs to enforce on model input"),
|
|
3099
|
+
output_guardrails: z6.array(z6.string()).optional().describe("Ordered guardrail IDs or slugs to enforce on model output")
|
|
3100
|
+
},
|
|
3101
|
+
listWorkspaceExclusions: {
|
|
3102
|
+
organisation_id: z6.string().describe("Organisation ID whose workspace exclusions should be listed")
|
|
3103
|
+
},
|
|
3104
|
+
updateWorkspaceExclusions: {
|
|
3105
|
+
organisation_id: z6.string().describe("Organisation ID whose workspace exclusions should be updated"),
|
|
3106
|
+
workspaces: z6.array(workspaceGuardrailExclusionSchema).min(1).describe("Workspace exclusion states to apply"),
|
|
3107
|
+
override_existing: z6.boolean().optional().describe("Replace existing exclusion states instead of merging changes")
|
|
3012
3108
|
}
|
|
3013
3109
|
};
|
|
3110
|
+
var GET_ORGANISATION_DEFAULTS_ANNOTATIONS = {
|
|
3111
|
+
title: "Get Organisation Guardrail Defaults",
|
|
3112
|
+
readOnlyHint: true,
|
|
3113
|
+
destructiveHint: false,
|
|
3114
|
+
idempotentHint: true,
|
|
3115
|
+
openWorldHint: true
|
|
3116
|
+
};
|
|
3014
3117
|
function registerGuardrailsTools(server, service) {
|
|
3118
|
+
server.tool(
|
|
3119
|
+
"get_organisation_defaults",
|
|
3120
|
+
"Get the organisation-wide input and output guardrails that workspaces inherit by default. Use this before update_organisation_defaults or when auditing baseline enforcement; it does not include per-workspace exclusions, which are available from the directional exclusion list tools. Requires an organisation service API key with organisation_settings.read scope.",
|
|
3121
|
+
GUARDRAILS_TOOL_SCHEMAS.getOrganisationDefaults,
|
|
3122
|
+
GET_ORGANISATION_DEFAULTS_ANNOTATIONS,
|
|
3123
|
+
async () => ({
|
|
3124
|
+
content: [
|
|
3125
|
+
{
|
|
3126
|
+
type: "text",
|
|
3127
|
+
text: JSON.stringify(
|
|
3128
|
+
await service.guardrails.getOrganisationDefaults()
|
|
3129
|
+
)
|
|
3130
|
+
}
|
|
3131
|
+
]
|
|
3132
|
+
})
|
|
3133
|
+
);
|
|
3134
|
+
server.tool(
|
|
3135
|
+
"update_organisation_defaults",
|
|
3136
|
+
"Replace the organisation-wide default input and/or output guardrail lists inherited by workspaces. Only supplied directions change, but enforcement updates immediately across non-excluded workspaces; inspect get_organisation_defaults and the directional workspace exclusions first. Repeating the same lists is safe. Requires an organisation service API key with organisation_settings.update scope.",
|
|
3137
|
+
GUARDRAILS_TOOL_SCHEMAS.updateOrganisationDefaults,
|
|
3138
|
+
{
|
|
3139
|
+
title: "Update Organisation Guardrail Defaults",
|
|
3140
|
+
readOnlyHint: false,
|
|
3141
|
+
destructiveHint: false,
|
|
3142
|
+
idempotentHint: true,
|
|
3143
|
+
openWorldHint: true
|
|
3144
|
+
},
|
|
3145
|
+
async (params) => ({
|
|
3146
|
+
content: [
|
|
3147
|
+
{
|
|
3148
|
+
type: "text",
|
|
3149
|
+
text: JSON.stringify(
|
|
3150
|
+
await service.guardrails.updateOrganisationDefaults(params)
|
|
3151
|
+
)
|
|
3152
|
+
}
|
|
3153
|
+
]
|
|
3154
|
+
})
|
|
3155
|
+
);
|
|
3156
|
+
server.tool(
|
|
3157
|
+
"list_input_guardrail_workspace_exclusions",
|
|
3158
|
+
"List workspaces excluded from organisation-wide input guardrails for one organisation. Use this to audit exceptions or establish the current state before the matching update tool; it reads input exclusions only and does not return the organisation's default guardrail list. Requires an organisation service API key with organisation_exclusions.list scope.",
|
|
3159
|
+
GUARDRAILS_TOOL_SCHEMAS.listWorkspaceExclusions,
|
|
3160
|
+
{
|
|
3161
|
+
title: "List Input Guardrail Workspace Exclusions",
|
|
3162
|
+
readOnlyHint: true,
|
|
3163
|
+
destructiveHint: false,
|
|
3164
|
+
idempotentHint: true,
|
|
3165
|
+
openWorldHint: true
|
|
3166
|
+
},
|
|
3167
|
+
async (params) => ({
|
|
3168
|
+
content: [
|
|
3169
|
+
{
|
|
3170
|
+
type: "text",
|
|
3171
|
+
text: JSON.stringify(
|
|
3172
|
+
await service.guardrails.listWorkspaceExclusions("input", params)
|
|
3173
|
+
)
|
|
3174
|
+
}
|
|
3175
|
+
]
|
|
3176
|
+
})
|
|
3177
|
+
);
|
|
3178
|
+
server.tool(
|
|
3179
|
+
"update_input_guardrail_workspace_exclusions",
|
|
3180
|
+
"Set workspace exclusions from organisation-wide input guardrails. Each entry excludes or restores one workspace; override_existing replaces prior states while the default merge behavior preserves unmentioned workspaces. Review the matching list tool first because enforcement changes immediately. Repeating the same states is safe. Requires an organisation service API key with organisation_exclusions.update scope.",
|
|
3181
|
+
GUARDRAILS_TOOL_SCHEMAS.updateWorkspaceExclusions,
|
|
3182
|
+
{
|
|
3183
|
+
title: "Update Input Guardrail Workspace Exclusions",
|
|
3184
|
+
readOnlyHint: false,
|
|
3185
|
+
destructiveHint: true,
|
|
3186
|
+
idempotentHint: true,
|
|
3187
|
+
openWorldHint: true
|
|
3188
|
+
},
|
|
3189
|
+
async (params) => ({
|
|
3190
|
+
content: [
|
|
3191
|
+
{
|
|
3192
|
+
type: "text",
|
|
3193
|
+
text: JSON.stringify(
|
|
3194
|
+
await service.guardrails.updateWorkspaceExclusions("input", params)
|
|
3195
|
+
)
|
|
3196
|
+
}
|
|
3197
|
+
]
|
|
3198
|
+
})
|
|
3199
|
+
);
|
|
3200
|
+
server.tool(
|
|
3201
|
+
"list_output_guardrail_workspace_exclusions",
|
|
3202
|
+
"List workspaces excluded from organisation-wide output guardrails for one organisation. Use this to audit exceptions or establish the current state before the matching update tool; it reads output exclusions only and does not return the organisation's default guardrail list. Requires an organisation service API key with organisation_exclusions.list scope.",
|
|
3203
|
+
GUARDRAILS_TOOL_SCHEMAS.listWorkspaceExclusions,
|
|
3204
|
+
{
|
|
3205
|
+
title: "List Output Guardrail Workspace Exclusions",
|
|
3206
|
+
readOnlyHint: true,
|
|
3207
|
+
destructiveHint: false,
|
|
3208
|
+
idempotentHint: true,
|
|
3209
|
+
openWorldHint: true
|
|
3210
|
+
},
|
|
3211
|
+
async (params) => ({
|
|
3212
|
+
content: [
|
|
3213
|
+
{
|
|
3214
|
+
type: "text",
|
|
3215
|
+
text: JSON.stringify(
|
|
3216
|
+
await service.guardrails.listWorkspaceExclusions("output", params)
|
|
3217
|
+
)
|
|
3218
|
+
}
|
|
3219
|
+
]
|
|
3220
|
+
})
|
|
3221
|
+
);
|
|
3222
|
+
server.tool(
|
|
3223
|
+
"update_output_guardrail_workspace_exclusions",
|
|
3224
|
+
"Set workspace exclusions from organisation-wide output guardrails. Each entry excludes or restores one workspace; override_existing replaces prior states while the default merge behavior preserves unmentioned workspaces. Review the matching list tool first because enforcement changes immediately. Repeating the same states is safe. Requires an organisation service API key with organisation_exclusions.update scope.",
|
|
3225
|
+
GUARDRAILS_TOOL_SCHEMAS.updateWorkspaceExclusions,
|
|
3226
|
+
{
|
|
3227
|
+
title: "Update Output Guardrail Workspace Exclusions",
|
|
3228
|
+
readOnlyHint: false,
|
|
3229
|
+
destructiveHint: true,
|
|
3230
|
+
idempotentHint: true,
|
|
3231
|
+
openWorldHint: true
|
|
3232
|
+
},
|
|
3233
|
+
async (params) => ({
|
|
3234
|
+
content: [
|
|
3235
|
+
{
|
|
3236
|
+
type: "text",
|
|
3237
|
+
text: JSON.stringify(
|
|
3238
|
+
await service.guardrails.updateWorkspaceExclusions(
|
|
3239
|
+
"output",
|
|
3240
|
+
params
|
|
3241
|
+
)
|
|
3242
|
+
)
|
|
3243
|
+
}
|
|
3244
|
+
]
|
|
3245
|
+
})
|
|
3246
|
+
);
|
|
3015
3247
|
server.tool(
|
|
3016
3248
|
"list_guardrails",
|
|
3017
3249
|
"List guardrails in the org with id, slug, status, ownership, and optional workspace/org filters. Use this to find IDs and slugs before get_guardrail, update_guardrail, or delete_guardrail.",
|
|
@@ -3158,7 +3390,7 @@ function registerGuardrailsTools(server, service) {
|
|
|
3158
3390
|
}
|
|
3159
3391
|
|
|
3160
3392
|
// src/tools/integrations.tools.ts
|
|
3161
|
-
import { z as
|
|
3393
|
+
import { z as z8 } from "zod";
|
|
3162
3394
|
|
|
3163
3395
|
// src/lib/limits.ts
|
|
3164
3396
|
var PERIODIC_RESET_DEFAULT = "monthly";
|
|
@@ -3200,96 +3432,257 @@ function buildRateLimits(params) {
|
|
|
3200
3432
|
];
|
|
3201
3433
|
}
|
|
3202
3434
|
|
|
3435
|
+
// src/tools/secret-mapping.schemas.ts
|
|
3436
|
+
import { z as z7 } from "zod";
|
|
3437
|
+
function createSecretMappingSchema({
|
|
3438
|
+
allowKeyTarget,
|
|
3439
|
+
targetFieldDescription,
|
|
3440
|
+
secretReferenceDescription,
|
|
3441
|
+
valueFormatDescription
|
|
3442
|
+
}) {
|
|
3443
|
+
return z7.object({
|
|
3444
|
+
target_field: z7.string().refine(
|
|
3445
|
+
(value) => allowKeyTarget && value === "key" || value.startsWith("configurations."),
|
|
3446
|
+
allowKeyTarget ? "target_field must be 'key' or start with 'configurations.'" : "target_field must start with 'configurations.'"
|
|
3447
|
+
).describe(targetFieldDescription),
|
|
3448
|
+
secret_reference_id: z7.string().describe(secretReferenceDescription),
|
|
3449
|
+
secret_key: z7.string().nullable().optional().describe("Optional key to select from a multi-value secret"),
|
|
3450
|
+
value_format: z7.enum(["string", "json"]).nullable().optional().describe(valueFormatDescription)
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
function uniqueSecretMappingsSchema(itemSchema) {
|
|
3454
|
+
return z7.array(itemSchema).superRefine((mappings, context) => {
|
|
3455
|
+
const firstIndexByTarget = /* @__PURE__ */ new Map();
|
|
3456
|
+
for (const [index, mapping] of mappings.entries()) {
|
|
3457
|
+
const firstIndex = firstIndexByTarget.get(mapping.target_field);
|
|
3458
|
+
if (firstIndex !== void 0) {
|
|
3459
|
+
context.addIssue({
|
|
3460
|
+
code: "custom",
|
|
3461
|
+
path: [index, "target_field"],
|
|
3462
|
+
message: `target_field must be unique; also used at index ${firstIndex}`
|
|
3463
|
+
});
|
|
3464
|
+
} else {
|
|
3465
|
+
firstIndexByTarget.set(mapping.target_field, index);
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3470
|
+
|
|
3203
3471
|
// src/tools/integrations.tools.ts
|
|
3472
|
+
var integrationSecretMappingSchema = createSecretMappingSchema({
|
|
3473
|
+
allowKeyTarget: true,
|
|
3474
|
+
targetFieldDescription: "Integration field populated at runtime: key or configurations.<field>",
|
|
3475
|
+
secretReferenceDescription: "Secret Reference UUID or slug accessible to the workspace",
|
|
3476
|
+
valueFormatDescription: "Treat the resolved value as a plain string or parsed JSON"
|
|
3477
|
+
});
|
|
3478
|
+
var integrationSecretMappingsSchema = uniqueSecretMappingsSchema(
|
|
3479
|
+
integrationSecretMappingSchema
|
|
3480
|
+
);
|
|
3481
|
+
var nullableMultiplier = (description) => z8.coerce.number().nonnegative().nullable().optional().describe(description);
|
|
3482
|
+
var pricingMultiplierSchema = z8.object({
|
|
3483
|
+
default: nullableMultiplier(
|
|
3484
|
+
"Fallback multiplier for pricing units; 1 is unchanged, 0.8 is a 20% discount"
|
|
3485
|
+
),
|
|
3486
|
+
request_token: nullableMultiplier("Input token price multiplier"),
|
|
3487
|
+
response_token: nullableMultiplier("Output token price multiplier"),
|
|
3488
|
+
cache_read_input_token: nullableMultiplier(
|
|
3489
|
+
"Cache-read input token price multiplier"
|
|
3490
|
+
),
|
|
3491
|
+
cache_write_input_token: nullableMultiplier(
|
|
3492
|
+
"Cache-write input token price multiplier"
|
|
3493
|
+
),
|
|
3494
|
+
cache_read_audio_input_token: nullableMultiplier(
|
|
3495
|
+
"Cache-read audio input token price multiplier"
|
|
3496
|
+
),
|
|
3497
|
+
request_audio_token: nullableMultiplier("Audio input token price multiplier"),
|
|
3498
|
+
response_audio_token: nullableMultiplier(
|
|
3499
|
+
"Audio output token price multiplier"
|
|
3500
|
+
),
|
|
3501
|
+
reasoning_token: nullableMultiplier("Reasoning token price multiplier"),
|
|
3502
|
+
prediction_accepted_token: nullableMultiplier(
|
|
3503
|
+
"Accepted predicted-output token price multiplier"
|
|
3504
|
+
),
|
|
3505
|
+
prediction_rejected_token: nullableMultiplier(
|
|
3506
|
+
"Rejected predicted-output token price multiplier"
|
|
3507
|
+
),
|
|
3508
|
+
request_image_token: nullableMultiplier("Image input token price multiplier"),
|
|
3509
|
+
response_image_token: nullableMultiplier(
|
|
3510
|
+
"Image output token price multiplier"
|
|
3511
|
+
),
|
|
3512
|
+
request_text_token: nullableMultiplier("Text input token price multiplier"),
|
|
3513
|
+
response_text_token: nullableMultiplier("Text output token price multiplier"),
|
|
3514
|
+
cache_read_image_input_token: nullableMultiplier(
|
|
3515
|
+
"Cache-read image input token price multiplier"
|
|
3516
|
+
),
|
|
3517
|
+
cache_read_text_input_token: nullableMultiplier(
|
|
3518
|
+
"Cache-read text input token price multiplier"
|
|
3519
|
+
),
|
|
3520
|
+
cache_write_text_input_token: nullableMultiplier(
|
|
3521
|
+
"Cache-write text input token price multiplier"
|
|
3522
|
+
),
|
|
3523
|
+
cache_write_image_input_token: nullableMultiplier(
|
|
3524
|
+
"Cache-write image input token price multiplier"
|
|
3525
|
+
),
|
|
3526
|
+
image: z8.object({
|
|
3527
|
+
default: nullableMultiplier("Default image-generation price multiplier")
|
|
3528
|
+
}).nullable().optional().describe("Image-generation pricing multipliers"),
|
|
3529
|
+
additional_units: z8.record(z8.string(), z8.coerce.number().nonnegative().nullable()).nullable().optional().describe(
|
|
3530
|
+
"Multipliers keyed by Portkey pricing unit, such as web_search or file_search"
|
|
3531
|
+
)
|
|
3532
|
+
});
|
|
3533
|
+
var pricingAdjustmentsSchema = z8.object({
|
|
3534
|
+
multiplier: pricingMultiplierSchema.optional().describe("Per-unit multipliers applied over Portkey catalog pricing")
|
|
3535
|
+
}).nullable();
|
|
3536
|
+
var modelConfigurationsSchema = z8.object({
|
|
3537
|
+
custom_host: z8.string().url().optional().describe("Custom upstream URL used only for this model"),
|
|
3538
|
+
custom_headers: z8.record(z8.string(), z8.string()).optional().describe("Headers sent only for this model; values may contain secrets")
|
|
3539
|
+
});
|
|
3540
|
+
var tokenPricingSchema = z8.object({
|
|
3541
|
+
price: z8.coerce.number().nonnegative().describe("Static price per token in the integration pricing unit")
|
|
3542
|
+
});
|
|
3543
|
+
var integrationModelPricingSchema = z8.object({
|
|
3544
|
+
type: z8.literal("static").describe("Static per-token pricing configuration"),
|
|
3545
|
+
pay_as_you_go: z8.object({
|
|
3546
|
+
request_token: tokenPricingSchema.optional().describe("Input token pricing"),
|
|
3547
|
+
response_token: tokenPricingSchema.optional().describe("Output token pricing")
|
|
3548
|
+
}).optional().describe("Pay-as-you-go rates for this integration model")
|
|
3549
|
+
});
|
|
3204
3550
|
var INTEGRATIONS_TOOL_SCHEMAS = {
|
|
3551
|
+
getModelPricing: {
|
|
3552
|
+
provider: z8.string().describe(
|
|
3553
|
+
"Lowercase Portkey provider identifier, such as openai, anthropic, bedrock, or x-ai"
|
|
3554
|
+
),
|
|
3555
|
+
model: z8.string().describe("Exact provider model identifier, such as gpt-4o")
|
|
3556
|
+
},
|
|
3205
3557
|
listIntegrations: {
|
|
3206
|
-
current_page:
|
|
3207
|
-
page_size:
|
|
3208
|
-
workspace_id:
|
|
3209
|
-
type:
|
|
3558
|
+
current_page: z8.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
3559
|
+
page_size: z8.coerce.number().int().positive().max(100).optional().describe("Number of results per page (default 100, max 100)"),
|
|
3560
|
+
workspace_id: z8.string().optional().describe("Filter integrations accessible by a specific workspace"),
|
|
3561
|
+
type: z8.enum(["workspace", "organisation", "all"]).optional().describe(
|
|
3210
3562
|
"Filter by integration type: 'workspace', 'organisation', or 'all' (default)"
|
|
3211
3563
|
)
|
|
3212
3564
|
},
|
|
3213
3565
|
createIntegration: {
|
|
3214
|
-
name:
|
|
3215
|
-
ai_provider_id:
|
|
3566
|
+
name: z8.string().describe("Human-readable name for the integration"),
|
|
3567
|
+
ai_provider_id: z8.string().describe(
|
|
3216
3568
|
"ID of the AI provider (e.g., 'openai', 'anthropic', 'azure-openai', 'aws-bedrock', 'vertex-ai')"
|
|
3217
3569
|
),
|
|
3218
|
-
slug:
|
|
3570
|
+
slug: z8.string().optional().describe(
|
|
3219
3571
|
"URL-friendly identifier (auto-generated from name if not provided)"
|
|
3220
3572
|
),
|
|
3221
|
-
key:
|
|
3222
|
-
description:
|
|
3223
|
-
workspace_id:
|
|
3224
|
-
api_version:
|
|
3225
|
-
resource_name:
|
|
3226
|
-
deployment_name:
|
|
3227
|
-
aws_region:
|
|
3228
|
-
aws_access_key_id:
|
|
3229
|
-
aws_secret_access_key:
|
|
3230
|
-
vertex_project_id:
|
|
3231
|
-
vertex_region:
|
|
3232
|
-
custom_host:
|
|
3573
|
+
key: z8.string().optional().describe("API key for the provider (if required)"),
|
|
3574
|
+
description: z8.string().optional().describe("Optional description of the integration"),
|
|
3575
|
+
workspace_id: z8.string().optional().describe("Workspace ID for workspace-scoped integrations"),
|
|
3576
|
+
api_version: z8.string().optional().describe("API version (for Azure OpenAI)"),
|
|
3577
|
+
resource_name: z8.string().optional().describe("Resource name (for Azure OpenAI)"),
|
|
3578
|
+
deployment_name: z8.string().optional().describe("Deployment name (for Azure OpenAI)"),
|
|
3579
|
+
aws_region: z8.string().optional().describe("AWS region (for AWS Bedrock)"),
|
|
3580
|
+
aws_access_key_id: z8.string().optional().describe("AWS access key ID (for AWS Bedrock)"),
|
|
3581
|
+
aws_secret_access_key: z8.string().optional().describe("AWS secret access key (for AWS Bedrock)"),
|
|
3582
|
+
vertex_project_id: z8.string().optional().describe("GCP project ID (for Vertex AI)"),
|
|
3583
|
+
vertex_region: z8.string().optional().describe("GCP region (for Vertex AI)"),
|
|
3584
|
+
custom_host: z8.string().optional().describe("Custom base URL for the provider"),
|
|
3585
|
+
create_default_provider: z8.boolean().optional().describe(
|
|
3586
|
+
"Create a provider automatically for a workspace-scoped integration; defaults to true"
|
|
3587
|
+
),
|
|
3588
|
+
default_provider_slug: z8.string().max(255).regex(/^[a-zA-Z0-9_-]+$/).optional().describe("Custom slug for the automatically created workspace provider"),
|
|
3589
|
+
secret_mappings: integrationSecretMappingsSchema.optional().describe(
|
|
3590
|
+
"Unique runtime Secret Reference mappings; mapping key allows the key field to be omitted"
|
|
3591
|
+
),
|
|
3592
|
+
pricing_adjustments: pricingAdjustmentsSchema.optional().describe(
|
|
3593
|
+
"Negotiated discount or markup multipliers for cost accounting"
|
|
3594
|
+
)
|
|
3233
3595
|
},
|
|
3234
3596
|
getIntegration: {
|
|
3235
|
-
slug:
|
|
3597
|
+
slug: z8.string().describe("The unique slug identifier of the integration to retrieve")
|
|
3236
3598
|
},
|
|
3237
3599
|
updateIntegration: {
|
|
3238
|
-
slug:
|
|
3239
|
-
name:
|
|
3240
|
-
key:
|
|
3241
|
-
description:
|
|
3242
|
-
api_version:
|
|
3243
|
-
resource_name:
|
|
3244
|
-
deployment_name:
|
|
3245
|
-
aws_region:
|
|
3246
|
-
aws_access_key_id:
|
|
3247
|
-
aws_secret_access_key:
|
|
3248
|
-
vertex_project_id:
|
|
3249
|
-
vertex_region:
|
|
3250
|
-
custom_host:
|
|
3600
|
+
slug: z8.string().describe("The slug of the integration to update"),
|
|
3601
|
+
name: z8.string().optional().describe("New human-readable name for the integration"),
|
|
3602
|
+
key: z8.string().optional().describe("New API key for the provider"),
|
|
3603
|
+
description: z8.string().optional().describe("New description for the integration"),
|
|
3604
|
+
api_version: z8.string().optional().describe("New API version (for Azure OpenAI)"),
|
|
3605
|
+
resource_name: z8.string().optional().describe("New resource name (for Azure OpenAI)"),
|
|
3606
|
+
deployment_name: z8.string().optional().describe("New deployment name (for Azure OpenAI)"),
|
|
3607
|
+
aws_region: z8.string().optional().describe("New AWS region (for AWS Bedrock)"),
|
|
3608
|
+
aws_access_key_id: z8.string().optional().describe("New AWS access key ID (for AWS Bedrock)"),
|
|
3609
|
+
aws_secret_access_key: z8.string().optional().describe("New AWS secret access key (for AWS Bedrock)"),
|
|
3610
|
+
vertex_project_id: z8.string().optional().describe("New GCP project ID (for Vertex AI)"),
|
|
3611
|
+
vertex_region: z8.string().optional().describe("New GCP region (for Vertex AI)"),
|
|
3612
|
+
custom_host: z8.string().optional().describe("New custom base URL for the provider"),
|
|
3613
|
+
secret_mappings: integrationSecretMappingsSchema.optional().describe(
|
|
3614
|
+
"Replacement runtime Secret Reference mappings; each target_field must be unique"
|
|
3615
|
+
),
|
|
3616
|
+
pricing_adjustments: pricingAdjustmentsSchema.optional().describe(
|
|
3617
|
+
"Replacement cost multiplier configuration, or null to clear adjustments"
|
|
3618
|
+
)
|
|
3251
3619
|
},
|
|
3252
3620
|
deleteIntegration: {
|
|
3253
|
-
slug:
|
|
3621
|
+
slug: z8.string().describe("The slug of the integration to delete")
|
|
3254
3622
|
},
|
|
3255
3623
|
listIntegrationModels: {
|
|
3256
|
-
slug:
|
|
3257
|
-
current_page:
|
|
3258
|
-
page_size:
|
|
3624
|
+
slug: z8.string().describe("The slug of the integration"),
|
|
3625
|
+
current_page: z8.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
3626
|
+
page_size: z8.coerce.number().int().positive().max(100).optional().describe("Number of results per page")
|
|
3259
3627
|
},
|
|
3260
3628
|
updateIntegrationModels: {
|
|
3261
|
-
slug:
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3629
|
+
slug: z8.string().describe("The slug of the integration"),
|
|
3630
|
+
allow_all_models: z8.boolean().optional().describe(
|
|
3631
|
+
"Whether newly available provider models are enabled by default"
|
|
3632
|
+
),
|
|
3633
|
+
models: z8.array(
|
|
3634
|
+
z8.object({
|
|
3635
|
+
slug: z8.string().describe("The model slug identifier"),
|
|
3636
|
+
model_name: z8.string().optional().describe(
|
|
3266
3637
|
"Display name for the model (required for custom models)"
|
|
3267
3638
|
),
|
|
3268
|
-
enabled:
|
|
3269
|
-
is_custom:
|
|
3639
|
+
enabled: z8.boolean().describe("Whether the model is enabled"),
|
|
3640
|
+
is_custom: z8.boolean().optional().describe("Whether this is a custom model (default: false)"),
|
|
3641
|
+
is_finetune: z8.boolean().optional().describe("Whether this entry is a fine-tuned model"),
|
|
3642
|
+
base_model_slug: z8.string().optional().describe("Base model slug for a fine-tuned model"),
|
|
3643
|
+
configurations: modelConfigurationsSchema.optional().describe("Per-model custom upstream host and headers"),
|
|
3644
|
+
pricing_config: integrationModelPricingSchema.optional().describe("Static custom pricing for this integration model")
|
|
3270
3645
|
})
|
|
3271
3646
|
).describe("Array of model configurations to update")
|
|
3272
3647
|
},
|
|
3273
3648
|
deleteIntegrationModel: {
|
|
3274
|
-
slug:
|
|
3275
|
-
model_slug:
|
|
3649
|
+
slug: z8.string().describe("The slug of the integration"),
|
|
3650
|
+
model_slug: z8.string().describe("The slug of the model to delete")
|
|
3276
3651
|
},
|
|
3277
3652
|
listIntegrationWorkspaces: {
|
|
3278
|
-
slug:
|
|
3279
|
-
current_page:
|
|
3280
|
-
page_size:
|
|
3653
|
+
slug: z8.string().describe("The slug of the integration"),
|
|
3654
|
+
current_page: z8.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
3655
|
+
page_size: z8.coerce.number().int().positive().max(100).optional().describe("Number of results per page")
|
|
3281
3656
|
},
|
|
3282
3657
|
updateIntegrationWorkspaces: {
|
|
3283
|
-
slug:
|
|
3284
|
-
workspaces:
|
|
3285
|
-
|
|
3286
|
-
id:
|
|
3287
|
-
enabled:
|
|
3288
|
-
credit_limit:
|
|
3289
|
-
alert_threshold:
|
|
3290
|
-
rate_limit_rpm:
|
|
3658
|
+
slug: z8.string().describe("The slug of the integration"),
|
|
3659
|
+
workspaces: z8.array(
|
|
3660
|
+
z8.object({
|
|
3661
|
+
id: z8.string().describe("The workspace ID"),
|
|
3662
|
+
enabled: z8.boolean().describe("Whether the workspace has access to this integration"),
|
|
3663
|
+
credit_limit: z8.coerce.number().positive().optional().describe("Credit limit for this workspace"),
|
|
3664
|
+
alert_threshold: z8.coerce.number().min(0).max(100).optional().describe("Alert threshold percentage (0-100)"),
|
|
3665
|
+
rate_limit_rpm: z8.coerce.number().positive().optional().describe("Rate limit in requests per minute"),
|
|
3666
|
+
reset_usage: z8.boolean().optional().describe("Reset exhausted usage status to active"),
|
|
3667
|
+
create_default_provider: z8.boolean().optional().describe(
|
|
3668
|
+
"Override whether a provider is auto-created for this workspace"
|
|
3669
|
+
),
|
|
3670
|
+
default_provider_slug: z8.string().optional().describe(
|
|
3671
|
+
"Override the auto-created provider slug for this workspace"
|
|
3672
|
+
)
|
|
3291
3673
|
})
|
|
3292
|
-
).describe("Array of workspace configurations to update")
|
|
3674
|
+
).describe("Array of workspace configurations to update"),
|
|
3675
|
+
global_workspace_access_enabled: z8.boolean().optional().describe(
|
|
3676
|
+
"Enable or disable access for all current and future workspaces"
|
|
3677
|
+
),
|
|
3678
|
+
global_credit_limit: z8.coerce.number().positive().optional().describe(
|
|
3679
|
+
"Global cost credit limit applied with global workspace access"
|
|
3680
|
+
),
|
|
3681
|
+
global_alert_threshold: z8.coerce.number().nonnegative().max(100).optional().describe("Global cost alert threshold applied to workspace access"),
|
|
3682
|
+
global_rate_limit_rpm: z8.coerce.number().positive().optional().describe("Global requests-per-minute limit for workspace access"),
|
|
3683
|
+
override_existing_workspace_access: z8.boolean().optional().describe("Apply global settings over existing per-workspace access"),
|
|
3684
|
+
create_default_provider: z8.boolean().optional().describe("Auto-create providers when granting workspace access"),
|
|
3685
|
+
default_provider_slug: z8.string().optional().describe("Default slug for providers auto-created in workspaces")
|
|
3293
3686
|
}
|
|
3294
3687
|
};
|
|
3295
3688
|
function buildIntegrationConfigurations(params) {
|
|
@@ -3315,6 +3708,31 @@ function buildIntegrationConfigurations(params) {
|
|
|
3315
3708
|
return Object.keys(configurations).length > 0 ? configurations : void 0;
|
|
3316
3709
|
}
|
|
3317
3710
|
function registerIntegrationsTools(server, service) {
|
|
3711
|
+
server.tool(
|
|
3712
|
+
"get_model_pricing",
|
|
3713
|
+
"Get Portkey's current public pricing configuration for one exact provider/model pair. Prices are returned in USD cents per token or provider-specific unit and may include cache, audio, image, fine-tuning, and calculation metadata. Use this read-only catalog lookup before setting integration pricing_adjustments or custom-model pricing; it does not return your negotiated integration multiplier or require Portkey authentication.",
|
|
3714
|
+
INTEGRATIONS_TOOL_SCHEMAS.getModelPricing,
|
|
3715
|
+
{
|
|
3716
|
+
title: "Get Model Pricing",
|
|
3717
|
+
readOnlyHint: true,
|
|
3718
|
+
destructiveHint: false,
|
|
3719
|
+
idempotentHint: true,
|
|
3720
|
+
openWorldHint: true
|
|
3721
|
+
},
|
|
3722
|
+
async (params) => ({
|
|
3723
|
+
content: [
|
|
3724
|
+
{
|
|
3725
|
+
type: "text",
|
|
3726
|
+
text: JSON.stringify(
|
|
3727
|
+
await service.integrations.getModelPricing(
|
|
3728
|
+
params.provider,
|
|
3729
|
+
params.model
|
|
3730
|
+
)
|
|
3731
|
+
)
|
|
3732
|
+
}
|
|
3733
|
+
]
|
|
3734
|
+
})
|
|
3735
|
+
);
|
|
3318
3736
|
server.tool(
|
|
3319
3737
|
"list_integrations",
|
|
3320
3738
|
"List org-level AI provider connections with optional workspace or type filters. Use this to find integration slugs before model or workspace updates. Returns total plus id, name, slug, provider, status, description, workspace counts, and config summary.",
|
|
@@ -3351,13 +3769,14 @@ function registerIntegrationsTools(server, service) {
|
|
|
3351
3769
|
);
|
|
3352
3770
|
server.tool(
|
|
3353
3771
|
"create_integration",
|
|
3354
|
-
"Create an
|
|
3772
|
+
"Create an AI-provider integration that becomes the source for workspace providers. ai_provider_id identifies the backend; provider-specific fields configure Azure, Bedrock, Vertex, or custom hosts. For workspace-scoped integrations, create_default_provider controls automatic provider creation. key is write-only, but secret_mappings can resolve it or configuration fields from Secret References at runtime. pricing_adjustments apply negotiated discounts or markups to cost accounting. Use update_integration_models and update_integration_workspaces after creation; returns the new integration id and slug.",
|
|
3355
3773
|
INTEGRATIONS_TOOL_SCHEMAS.createIntegration,
|
|
3356
3774
|
{
|
|
3775
|
+
title: "Create AI Provider Integration",
|
|
3357
3776
|
readOnlyHint: false,
|
|
3358
3777
|
destructiveHint: false,
|
|
3359
3778
|
idempotentHint: false,
|
|
3360
|
-
openWorldHint:
|
|
3779
|
+
openWorldHint: true
|
|
3361
3780
|
},
|
|
3362
3781
|
async (params) => {
|
|
3363
3782
|
const result = await service.integrations.createIntegration({
|
|
@@ -3367,7 +3786,11 @@ function registerIntegrationsTools(server, service) {
|
|
|
3367
3786
|
key: params.key,
|
|
3368
3787
|
description: params.description,
|
|
3369
3788
|
workspace_id: params.workspace_id,
|
|
3370
|
-
configurations: buildIntegrationConfigurations(params)
|
|
3789
|
+
configurations: buildIntegrationConfigurations(params),
|
|
3790
|
+
...params.create_default_provider !== void 0 ? { create_default_provider: params.create_default_provider } : {},
|
|
3791
|
+
...params.default_provider_slug !== void 0 ? { default_provider_slug: params.default_provider_slug } : {},
|
|
3792
|
+
...params.secret_mappings !== void 0 ? { secret_mappings: params.secret_mappings } : {},
|
|
3793
|
+
...params.pricing_adjustments !== void 0 ? { pricing_adjustments: params.pricing_adjustments } : {}
|
|
3371
3794
|
});
|
|
3372
3795
|
return {
|
|
3373
3796
|
content: [
|
|
@@ -3408,6 +3831,8 @@ function registerIntegrationsTools(server, service) {
|
|
|
3408
3831
|
global_workspace_access_settings: integration.global_workspace_access_settings,
|
|
3409
3832
|
allow_all_models: integration.allow_all_models,
|
|
3410
3833
|
workspace_count: integration.workspace_count,
|
|
3834
|
+
secret_mappings: integration.secret_mappings,
|
|
3835
|
+
pricing_adjustments: integration.pricing_adjustments,
|
|
3411
3836
|
created_at: integration.created_at,
|
|
3412
3837
|
last_updated_at: integration.last_updated_at
|
|
3413
3838
|
})
|
|
@@ -3418,20 +3843,23 @@ function registerIntegrationsTools(server, service) {
|
|
|
3418
3843
|
);
|
|
3419
3844
|
server.tool(
|
|
3420
3845
|
"update_integration",
|
|
3421
|
-
"Update an
|
|
3846
|
+
"Update an integration's name, description, API key, provider config, Secret Reference mappings, or pricing adjustments by slug. Only provided fields change; key, secret mapping, and config changes take effect immediately and can disrupt dependent providers or live requests, while pricing multipliers change cost analytics and budget accounting. Review get_integration first. Model availability and workspace access remain separate in update_integration_models and update_integration_workspaces.",
|
|
3422
3847
|
INTEGRATIONS_TOOL_SCHEMAS.updateIntegration,
|
|
3423
3848
|
{
|
|
3849
|
+
title: "Update AI Provider Integration",
|
|
3424
3850
|
readOnlyHint: false,
|
|
3425
3851
|
destructiveHint: true,
|
|
3426
3852
|
idempotentHint: true,
|
|
3427
|
-
openWorldHint:
|
|
3853
|
+
openWorldHint: true
|
|
3428
3854
|
},
|
|
3429
3855
|
async (params) => {
|
|
3430
3856
|
const result = await service.integrations.updateIntegration(params.slug, {
|
|
3431
3857
|
name: params.name,
|
|
3432
3858
|
key: params.key,
|
|
3433
3859
|
description: params.description,
|
|
3434
|
-
configurations: buildIntegrationConfigurations(params)
|
|
3860
|
+
configurations: buildIntegrationConfigurations(params),
|
|
3861
|
+
secret_mappings: params.secret_mappings,
|
|
3862
|
+
pricing_adjustments: params.pricing_adjustments
|
|
3435
3863
|
});
|
|
3436
3864
|
return {
|
|
3437
3865
|
content: [
|
|
@@ -3486,10 +3914,14 @@ function registerIntegrationsTools(server, service) {
|
|
|
3486
3914
|
integration_slug: params.slug,
|
|
3487
3915
|
models: models.data.map((model) => ({
|
|
3488
3916
|
id: model.id,
|
|
3489
|
-
|
|
3490
|
-
|
|
3917
|
+
slug: model.slug ?? model.model_id,
|
|
3918
|
+
name: model.name ?? model.model_name,
|
|
3491
3919
|
enabled: model.enabled,
|
|
3492
|
-
|
|
3920
|
+
is_custom: model.is_custom ?? model.custom,
|
|
3921
|
+
is_finetune: model.is_finetune,
|
|
3922
|
+
base_model_slug: model.base_model_slug,
|
|
3923
|
+
configurations: model.configurations,
|
|
3924
|
+
pricing_config: model.pricing_config,
|
|
3493
3925
|
created_at: model.created_at,
|
|
3494
3926
|
last_updated_at: model.last_updated_at
|
|
3495
3927
|
}))
|
|
@@ -3501,13 +3933,21 @@ function registerIntegrationsTools(server, service) {
|
|
|
3501
3933
|
);
|
|
3502
3934
|
server.tool(
|
|
3503
3935
|
"update_integration_models",
|
|
3504
|
-
"
|
|
3936
|
+
"Bulk enable or disable integration models, register custom or fine-tuned models, set per-model hosts and headers, and attach static token pricing. allow_all_models controls whether future provider models start enabled. These changes affect every workspace using the integration; inspect list_integration_models first and use get_model_pricing when deriving custom rates. Returns success and the number of models updated.",
|
|
3505
3937
|
INTEGRATIONS_TOOL_SCHEMAS.updateIntegrationModels,
|
|
3938
|
+
{
|
|
3939
|
+
title: "Update Integration Models",
|
|
3940
|
+
readOnlyHint: false,
|
|
3941
|
+
destructiveHint: true,
|
|
3942
|
+
idempotentHint: true,
|
|
3943
|
+
openWorldHint: true
|
|
3944
|
+
},
|
|
3506
3945
|
async (params) => {
|
|
3507
3946
|
const result = await service.integrations.updateIntegrationModels(
|
|
3508
3947
|
params.slug,
|
|
3509
3948
|
{
|
|
3510
|
-
models: params.models
|
|
3949
|
+
models: params.models,
|
|
3950
|
+
allow_all_models: params.allow_all_models
|
|
3511
3951
|
}
|
|
3512
3952
|
);
|
|
3513
3953
|
return {
|
|
@@ -3567,7 +4007,7 @@ function registerIntegrationsTools(server, service) {
|
|
|
3567
4007
|
integration_slug: params.slug,
|
|
3568
4008
|
workspaces: workspaces.data.map((ws) => ({
|
|
3569
4009
|
id: ws.id,
|
|
3570
|
-
workspace_id: ws.workspace_id,
|
|
4010
|
+
workspace_id: ws.workspace_id ?? ws.id,
|
|
3571
4011
|
workspace_name: ws.workspace_name,
|
|
3572
4012
|
enabled: ws.enabled,
|
|
3573
4013
|
usage_limits: ws.usage_limits,
|
|
@@ -3583,9 +4023,41 @@ function registerIntegrationsTools(server, service) {
|
|
|
3583
4023
|
);
|
|
3584
4024
|
server.tool(
|
|
3585
4025
|
"update_integration_workspaces",
|
|
3586
|
-
"Control
|
|
4026
|
+
"Control per-workspace and global access to an integration, including cost/rate limits, usage resets, and automatic default-provider creation. global_workspace_access_enabled affects current and future workspaces; override_existing_workspace_access determines whether it replaces explicit workspace settings. Per-workspace default-provider fields override top-level values. Review list_integration_workspaces first because access and limits change downstream usage immediately.",
|
|
3587
4027
|
INTEGRATIONS_TOOL_SCHEMAS.updateIntegrationWorkspaces,
|
|
4028
|
+
{
|
|
4029
|
+
title: "Update Integration Workspace Access",
|
|
4030
|
+
readOnlyHint: false,
|
|
4031
|
+
destructiveHint: true,
|
|
4032
|
+
idempotentHint: true,
|
|
4033
|
+
openWorldHint: true
|
|
4034
|
+
},
|
|
3588
4035
|
async (params) => {
|
|
4036
|
+
const hasGlobalLimits = params.global_credit_limit !== void 0 || params.global_alert_threshold !== void 0 || params.global_rate_limit_rpm !== void 0;
|
|
4037
|
+
if (hasGlobalLimits && params.global_workspace_access_enabled === void 0) {
|
|
4038
|
+
return {
|
|
4039
|
+
content: [
|
|
4040
|
+
{
|
|
4041
|
+
type: "text",
|
|
4042
|
+
text: "global_workspace_access_enabled is required when setting global limits."
|
|
4043
|
+
}
|
|
4044
|
+
],
|
|
4045
|
+
isError: true
|
|
4046
|
+
};
|
|
4047
|
+
}
|
|
4048
|
+
const globalUsageLimits = params.global_credit_limit !== void 0 || params.global_alert_threshold !== void 0 ? [
|
|
4049
|
+
{
|
|
4050
|
+
type: "cost",
|
|
4051
|
+
credit_limit: params.global_credit_limit,
|
|
4052
|
+
alert_threshold: params.global_alert_threshold
|
|
4053
|
+
}
|
|
4054
|
+
] : void 0;
|
|
4055
|
+
const globalRateLimits = buildRateLimitsRpm(params.global_rate_limit_rpm);
|
|
4056
|
+
const globalWorkspaceAccess = params.global_workspace_access_enabled !== void 0 ? {
|
|
4057
|
+
enabled: params.global_workspace_access_enabled,
|
|
4058
|
+
usage_limits: globalUsageLimits,
|
|
4059
|
+
rate_limits: globalRateLimits
|
|
4060
|
+
} : void 0;
|
|
3589
4061
|
const result = await service.integrations.updateIntegrationWorkspaces(
|
|
3590
4062
|
params.slug,
|
|
3591
4063
|
{
|
|
@@ -3598,9 +4070,16 @@ function registerIntegrationsTools(server, service) {
|
|
|
3598
4070
|
id: ws.id,
|
|
3599
4071
|
enabled: ws.enabled,
|
|
3600
4072
|
usage_limits: usageLimits ? [usageLimits] : void 0,
|
|
3601
|
-
rate_limits: buildRateLimitsRpm(ws.rate_limit_rpm)
|
|
4073
|
+
rate_limits: buildRateLimitsRpm(ws.rate_limit_rpm),
|
|
4074
|
+
reset_usage: ws.reset_usage,
|
|
4075
|
+
create_default_provider: ws.create_default_provider,
|
|
4076
|
+
default_provider_slug: ws.default_provider_slug
|
|
3602
4077
|
};
|
|
3603
|
-
})
|
|
4078
|
+
}),
|
|
4079
|
+
global_workspace_access: globalWorkspaceAccess,
|
|
4080
|
+
override_existing_workspace_access: params.override_existing_workspace_access,
|
|
4081
|
+
create_default_provider: params.create_default_provider,
|
|
4082
|
+
default_provider_slug: params.default_provider_slug
|
|
3604
4083
|
}
|
|
3605
4084
|
);
|
|
3606
4085
|
return {
|
|
@@ -3620,110 +4099,110 @@ function registerIntegrationsTools(server, service) {
|
|
|
3620
4099
|
}
|
|
3621
4100
|
|
|
3622
4101
|
// src/tools/keys.tools.ts
|
|
3623
|
-
import { z as
|
|
4102
|
+
import { z as z9 } from "zod";
|
|
3624
4103
|
var KEYS_TOOL_SCHEMAS = {
|
|
3625
4104
|
listVirtualKeys: {
|
|
3626
|
-
current_page:
|
|
3627
|
-
page_size:
|
|
4105
|
+
current_page: z9.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
4106
|
+
page_size: z9.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
3628
4107
|
},
|
|
3629
4108
|
createVirtualKey: {
|
|
3630
|
-
name:
|
|
3631
|
-
provider:
|
|
4109
|
+
name: z9.string().describe("Display name for the virtual key"),
|
|
4110
|
+
provider: z9.string().describe(
|
|
3632
4111
|
"Provider slug (e.g., 'openai', 'anthropic', 'azure-openai', 'google')"
|
|
3633
4112
|
),
|
|
3634
|
-
key:
|
|
3635
|
-
note:
|
|
3636
|
-
workspace_id:
|
|
3637
|
-
api_version:
|
|
3638
|
-
resource_name:
|
|
3639
|
-
deployment_name:
|
|
3640
|
-
credit_limit:
|
|
3641
|
-
alert_threshold:
|
|
4113
|
+
key: z9.string().describe("The actual provider API key to store"),
|
|
4114
|
+
note: z9.string().optional().describe("Optional note or description for this key"),
|
|
4115
|
+
workspace_id: z9.string().optional().describe("Workspace ID to create the key in"),
|
|
4116
|
+
api_version: z9.string().optional().describe("API version (for Azure OpenAI)"),
|
|
4117
|
+
resource_name: z9.string().optional().describe("Resource name (for Azure OpenAI)"),
|
|
4118
|
+
deployment_name: z9.string().optional().describe("Deployment name (for Azure OpenAI)"),
|
|
4119
|
+
credit_limit: z9.coerce.number().positive().optional().describe("Maximum usage cost threshold"),
|
|
4120
|
+
alert_threshold: z9.coerce.number().min(0).max(100).optional().describe(
|
|
3642
4121
|
"Percentage of credit_limit at which to send alert emails (0-100)"
|
|
3643
4122
|
),
|
|
3644
|
-
rate_limit_rpm:
|
|
4123
|
+
rate_limit_rpm: z9.coerce.number().positive().optional().describe("Requests per minute limit")
|
|
3645
4124
|
},
|
|
3646
4125
|
getVirtualKey: {
|
|
3647
|
-
slug:
|
|
4126
|
+
slug: z9.string().describe("The unique slug identifier of the virtual key to retrieve")
|
|
3648
4127
|
},
|
|
3649
4128
|
updateVirtualKey: {
|
|
3650
|
-
slug:
|
|
3651
|
-
name:
|
|
3652
|
-
key:
|
|
3653
|
-
note:
|
|
3654
|
-
credit_limit:
|
|
3655
|
-
alert_threshold:
|
|
3656
|
-
rate_limit_rpm:
|
|
4129
|
+
slug: z9.string().describe("The slug of the virtual key to update"),
|
|
4130
|
+
name: z9.string().optional().describe("New display name for the key"),
|
|
4131
|
+
key: z9.string().optional().describe("New provider API key value"),
|
|
4132
|
+
note: z9.string().optional().describe("New note or description"),
|
|
4133
|
+
credit_limit: z9.coerce.number().positive().optional().describe("New credit limit for usage"),
|
|
4134
|
+
alert_threshold: z9.coerce.number().min(0).max(100).optional().describe("New alert threshold percentage (0-100)"),
|
|
4135
|
+
rate_limit_rpm: z9.coerce.number().positive().optional().describe("New rate limit in requests per minute")
|
|
3657
4136
|
},
|
|
3658
4137
|
deleteVirtualKey: {
|
|
3659
|
-
slug:
|
|
4138
|
+
slug: z9.string().describe("The slug of the virtual key to delete")
|
|
3660
4139
|
},
|
|
3661
4140
|
createApiKey: {
|
|
3662
|
-
type:
|
|
4141
|
+
type: z9.enum(["organisation", "workspace"]).describe(
|
|
3663
4142
|
"Key type: 'organisation' for org-wide access or 'workspace' for workspace-scoped"
|
|
3664
4143
|
),
|
|
3665
|
-
sub_type:
|
|
4144
|
+
sub_type: z9.enum(["user", "service"]).describe(
|
|
3666
4145
|
"Sub-type: 'user' for user-associated keys or 'service' for service accounts"
|
|
3667
4146
|
),
|
|
3668
|
-
name:
|
|
3669
|
-
description:
|
|
3670
|
-
workspace_id:
|
|
3671
|
-
user_id:
|
|
3672
|
-
scopes:
|
|
4147
|
+
name: z9.string().describe("Display name for the API key"),
|
|
4148
|
+
description: z9.string().optional().describe("Optional description for the key"),
|
|
4149
|
+
workspace_id: z9.string().optional().describe("Workspace ID (required for workspace-type keys)"),
|
|
4150
|
+
user_id: z9.string().optional().describe("User ID (required for user sub-type keys)"),
|
|
4151
|
+
scopes: z9.array(z9.string()).describe(
|
|
3673
4152
|
"Permission scopes for the key (e.g., ['logs.read', 'analytics.read'])"
|
|
3674
4153
|
),
|
|
3675
|
-
credit_limit:
|
|
3676
|
-
alert_threshold:
|
|
3677
|
-
rate_limit_rpm:
|
|
3678
|
-
default_config_id:
|
|
3679
|
-
default_metadata:
|
|
3680
|
-
alert_emails:
|
|
3681
|
-
expires_at:
|
|
4154
|
+
credit_limit: z9.coerce.number().positive().optional().describe("Credit limit for usage"),
|
|
4155
|
+
alert_threshold: z9.coerce.number().min(0).max(100).optional().describe("Alert threshold percentage (0-100)"),
|
|
4156
|
+
rate_limit_rpm: z9.coerce.number().positive().optional().describe("Rate limit in requests per minute"),
|
|
4157
|
+
default_config_id: z9.string().optional().describe("Default configuration ID to use with this key"),
|
|
4158
|
+
default_metadata: z9.record(z9.string(), z9.string()).optional().describe("Default metadata key-value pairs"),
|
|
4159
|
+
alert_emails: z9.array(z9.string()).optional().describe("Email addresses for alerts"),
|
|
4160
|
+
expires_at: z9.string().optional().describe("Expiration date in ISO 8601 format")
|
|
3682
4161
|
},
|
|
3683
4162
|
listApiKeys: {
|
|
3684
|
-
page_size:
|
|
3685
|
-
current_page:
|
|
3686
|
-
workspace_id:
|
|
4163
|
+
page_size: z9.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)"),
|
|
4164
|
+
current_page: z9.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
4165
|
+
workspace_id: z9.string().optional().describe("Filter by workspace ID")
|
|
3687
4166
|
},
|
|
3688
4167
|
getApiKey: {
|
|
3689
|
-
id:
|
|
4168
|
+
id: z9.string().uuid().describe("The UUID of the API key to retrieve")
|
|
3690
4169
|
},
|
|
3691
4170
|
updateApiKey: {
|
|
3692
|
-
id:
|
|
3693
|
-
name:
|
|
3694
|
-
description:
|
|
3695
|
-
scopes:
|
|
3696
|
-
credit_limit:
|
|
3697
|
-
alert_threshold:
|
|
3698
|
-
rate_limit_rpm:
|
|
3699
|
-
default_config_id:
|
|
3700
|
-
default_metadata:
|
|
3701
|
-
alert_emails:
|
|
3702
|
-
expires_at:
|
|
4171
|
+
id: z9.string().uuid().describe("The UUID of the API key to update"),
|
|
4172
|
+
name: z9.string().optional().describe("New display name for the key"),
|
|
4173
|
+
description: z9.string().optional().describe("New description for the key"),
|
|
4174
|
+
scopes: z9.array(z9.string()).optional().describe("New permission scopes for the key"),
|
|
4175
|
+
credit_limit: z9.coerce.number().positive().optional().describe("New credit limit for usage"),
|
|
4176
|
+
alert_threshold: z9.coerce.number().min(0).max(100).optional().describe("New alert threshold percentage (0-100)"),
|
|
4177
|
+
rate_limit_rpm: z9.coerce.number().positive().optional().describe("New rate limit in requests per minute"),
|
|
4178
|
+
default_config_id: z9.string().optional().describe("New default configuration ID"),
|
|
4179
|
+
default_metadata: z9.record(z9.string(), z9.string()).optional().describe("New default metadata key-value pairs"),
|
|
4180
|
+
alert_emails: z9.array(z9.string()).optional().describe("New email addresses for alerts"),
|
|
4181
|
+
expires_at: z9.string().nullable().optional().describe(
|
|
3703
4182
|
"New expiration date in ISO 8601 format, or null to remove expiration"
|
|
3704
4183
|
)
|
|
3705
4184
|
},
|
|
3706
4185
|
rotateApiKey: {
|
|
3707
|
-
id:
|
|
3708
|
-
key_transition_period_ms:
|
|
4186
|
+
id: z9.string().uuid().describe("API key UUID obtained from list_api_keys"),
|
|
4187
|
+
key_transition_period_ms: z9.coerce.number().int().min(18e5).optional().describe(
|
|
3709
4188
|
"Overlap in milliseconds while the previous key remains valid; minimum 1,800,000 (30 minutes), for example 3,600,000 for 1 hour"
|
|
3710
4189
|
)
|
|
3711
4190
|
},
|
|
3712
4191
|
deleteApiKey: {
|
|
3713
|
-
id:
|
|
4192
|
+
id: z9.string().uuid().describe("The UUID of the API key to delete")
|
|
3714
4193
|
}
|
|
3715
4194
|
};
|
|
3716
|
-
var createApiKeySchema =
|
|
4195
|
+
var createApiKeySchema = z9.object(KEYS_TOOL_SCHEMAS.createApiKey).superRefine((value, ctx) => {
|
|
3717
4196
|
if (value.type === "workspace" && !value.workspace_id) {
|
|
3718
4197
|
ctx.addIssue({
|
|
3719
|
-
code:
|
|
4198
|
+
code: z9.ZodIssueCode.custom,
|
|
3720
4199
|
path: ["workspace_id"],
|
|
3721
4200
|
message: "workspace_id is required when type is 'workspace'"
|
|
3722
4201
|
});
|
|
3723
4202
|
}
|
|
3724
4203
|
if (value.sub_type === "user" && !value.user_id) {
|
|
3725
4204
|
ctx.addIssue({
|
|
3726
|
-
code:
|
|
4205
|
+
code: z9.ZodIssueCode.custom,
|
|
3727
4206
|
path: ["user_id"],
|
|
3728
4207
|
message: "user_id is required when sub_type is 'user'"
|
|
3729
4208
|
});
|
|
@@ -4113,37 +4592,37 @@ function registerKeysTools(server, service) {
|
|
|
4113
4592
|
}
|
|
4114
4593
|
|
|
4115
4594
|
// src/tools/labels.tools.ts
|
|
4116
|
-
import { z as
|
|
4595
|
+
import { z as z10 } from "zod";
|
|
4117
4596
|
var LABELS_TOOL_SCHEMAS = {
|
|
4118
4597
|
createPromptLabel: {
|
|
4119
|
-
name:
|
|
4120
|
-
organisation_id:
|
|
4121
|
-
workspace_id:
|
|
4122
|
-
description:
|
|
4123
|
-
color_code:
|
|
4598
|
+
name: z10.string().describe("Name of the label"),
|
|
4599
|
+
organisation_id: z10.string().optional().describe("Organisation ID to create the label in"),
|
|
4600
|
+
workspace_id: z10.string().optional().describe("Workspace ID to create the label in"),
|
|
4601
|
+
description: z10.string().optional().describe("Description of the label"),
|
|
4602
|
+
color_code: z10.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(
|
|
4124
4603
|
"Hex format, e.g. '#FF5733'. Optional \u2014 omit for default color."
|
|
4125
4604
|
)
|
|
4126
4605
|
},
|
|
4127
4606
|
listPromptLabels: {
|
|
4128
|
-
organisation_id:
|
|
4129
|
-
workspace_id:
|
|
4130
|
-
search:
|
|
4131
|
-
current_page:
|
|
4132
|
-
page_size:
|
|
4607
|
+
organisation_id: z10.string().optional().describe("Filter by organisation ID"),
|
|
4608
|
+
workspace_id: z10.string().optional().describe("Filter by workspace ID"),
|
|
4609
|
+
search: z10.string().optional().describe("Search labels by name"),
|
|
4610
|
+
current_page: z10.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
4611
|
+
page_size: z10.coerce.number().int().positive().max(100).optional().describe("Results per page (max 100)")
|
|
4133
4612
|
},
|
|
4134
4613
|
getPromptLabel: {
|
|
4135
|
-
label_id:
|
|
4136
|
-
organisation_id:
|
|
4137
|
-
workspace_id:
|
|
4614
|
+
label_id: z10.string().describe("Label ID to retrieve"),
|
|
4615
|
+
organisation_id: z10.string().optional().describe("Organisation ID for filtering"),
|
|
4616
|
+
workspace_id: z10.string().optional().describe("Workspace ID for filtering")
|
|
4138
4617
|
},
|
|
4139
4618
|
updatePromptLabel: {
|
|
4140
|
-
label_id:
|
|
4141
|
-
name:
|
|
4142
|
-
description:
|
|
4143
|
-
color_code:
|
|
4619
|
+
label_id: z10.string().describe("Label ID to update"),
|
|
4620
|
+
name: z10.string().optional().describe("New name for the label"),
|
|
4621
|
+
description: z10.string().optional().describe("New description"),
|
|
4622
|
+
color_code: z10.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe("New hex color code (e.g., '#FF5733')")
|
|
4144
4623
|
},
|
|
4145
4624
|
deletePromptLabel: {
|
|
4146
|
-
label_id:
|
|
4625
|
+
label_id: z10.string().describe("Label ID to delete")
|
|
4147
4626
|
}
|
|
4148
4627
|
};
|
|
4149
4628
|
function registerLabelsTools(server, service) {
|
|
@@ -4283,86 +4762,86 @@ function registerLabelsTools(server, service) {
|
|
|
4283
4762
|
}
|
|
4284
4763
|
|
|
4285
4764
|
// src/tools/limits.tools.ts
|
|
4286
|
-
import { z as
|
|
4287
|
-
var conditionSchema =
|
|
4288
|
-
field:
|
|
4765
|
+
import { z as z11 } from "zod";
|
|
4766
|
+
var conditionSchema = z11.object({
|
|
4767
|
+
field: z11.string().describe(
|
|
4289
4768
|
"The field to match on (e.g., 'virtual_key', 'api_key', 'user_id', 'metadata.key')"
|
|
4290
4769
|
),
|
|
4291
|
-
operator:
|
|
4292
|
-
value:
|
|
4770
|
+
operator: z11.string().describe("The comparison operator (e.g., 'is', 'contains', 'is_not')"),
|
|
4771
|
+
value: z11.string().describe("The value to match against")
|
|
4293
4772
|
});
|
|
4294
4773
|
var LIMITS_TOOL_SCHEMAS = {
|
|
4295
4774
|
listRateLimits: {
|
|
4296
|
-
workspace_id:
|
|
4775
|
+
workspace_id: z11.string().optional().describe("Filter rate limits by workspace ID")
|
|
4297
4776
|
},
|
|
4298
4777
|
getRateLimit: {
|
|
4299
|
-
id:
|
|
4778
|
+
id: z11.string().describe("The unique identifier of the rate limit")
|
|
4300
4779
|
},
|
|
4301
4780
|
createRateLimit: {
|
|
4302
|
-
conditions:
|
|
4781
|
+
conditions: z11.array(conditionSchema).describe(
|
|
4303
4782
|
"Array of conditions that determine which requests this rate limit applies to"
|
|
4304
4783
|
),
|
|
4305
|
-
group_by:
|
|
4784
|
+
group_by: z11.array(z11.string()).describe(
|
|
4306
4785
|
"Array of fields to group the rate limit by (e.g., ['virtual_key'], ['api_key', 'user_id'])"
|
|
4307
4786
|
),
|
|
4308
|
-
type:
|
|
4309
|
-
unit:
|
|
4787
|
+
type: z11.enum(["requests", "tokens"]).describe("What to rate limit: 'requests' or 'tokens'"),
|
|
4788
|
+
unit: z11.enum(["rpm", "rph", "rpd"]).describe(
|
|
4310
4789
|
"Time unit: 'rpm' (per minute), 'rph' (per hour), or 'rpd' (per day)"
|
|
4311
4790
|
),
|
|
4312
|
-
value:
|
|
4313
|
-
name:
|
|
4314
|
-
workspace_id:
|
|
4315
|
-
organisation_id:
|
|
4791
|
+
value: z11.coerce.number().positive().describe("The maximum allowed value per unit (e.g., 100 rpm)"),
|
|
4792
|
+
name: z11.string().optional().describe("Optional name for the rate limit"),
|
|
4793
|
+
workspace_id: z11.string().optional().describe("Workspace ID to scope the limit to"),
|
|
4794
|
+
organisation_id: z11.string().optional().describe("Organisation ID to scope the limit to")
|
|
4316
4795
|
},
|
|
4317
4796
|
updateRateLimit: {
|
|
4318
|
-
id:
|
|
4319
|
-
name:
|
|
4320
|
-
unit:
|
|
4797
|
+
id: z11.string().describe("The unique identifier of the rate limit"),
|
|
4798
|
+
name: z11.string().optional().describe("New name for the rate limit"),
|
|
4799
|
+
unit: z11.enum(["rpm", "rph", "rpd"]).optional().describe(
|
|
4321
4800
|
"New time unit: 'rpm' (per minute), 'rph' (per hour), or 'rpd' (per day)"
|
|
4322
4801
|
),
|
|
4323
|
-
value:
|
|
4802
|
+
value: z11.coerce.number().positive().optional().describe("New maximum allowed value per unit")
|
|
4324
4803
|
},
|
|
4325
4804
|
deleteRateLimit: {
|
|
4326
|
-
id:
|
|
4805
|
+
id: z11.string().describe("The unique identifier of the rate limit")
|
|
4327
4806
|
},
|
|
4328
4807
|
listUsageLimits: {
|
|
4329
|
-
workspace_id:
|
|
4808
|
+
workspace_id: z11.string().optional().describe("Filter usage limits by workspace ID")
|
|
4330
4809
|
},
|
|
4331
4810
|
getUsageLimit: {
|
|
4332
|
-
id:
|
|
4811
|
+
id: z11.string().describe("The unique identifier of the usage limit")
|
|
4333
4812
|
},
|
|
4334
4813
|
createUsageLimit: {
|
|
4335
|
-
conditions:
|
|
4814
|
+
conditions: z11.array(conditionSchema).describe(
|
|
4336
4815
|
"Array of conditions that determine which requests this usage limit applies to"
|
|
4337
4816
|
),
|
|
4338
|
-
group_by:
|
|
4817
|
+
group_by: z11.array(z11.string()).describe(
|
|
4339
4818
|
"Array of fields to group the usage limit by (e.g., ['virtual_key'], ['api_key', 'user_id'])"
|
|
4340
4819
|
),
|
|
4341
|
-
type:
|
|
4342
|
-
credit_limit:
|
|
4343
|
-
name:
|
|
4344
|
-
alert_threshold:
|
|
4345
|
-
periodic_reset:
|
|
4346
|
-
workspace_id:
|
|
4347
|
-
organisation_id:
|
|
4820
|
+
type: z11.enum(["cost", "tokens"]).describe("What to limit: 'cost' (in dollars) or 'tokens'"),
|
|
4821
|
+
credit_limit: z11.coerce.number().positive().describe("The maximum allowed usage (cost in dollars or token count)"),
|
|
4822
|
+
name: z11.string().optional().describe("Optional name for the usage limit"),
|
|
4823
|
+
alert_threshold: z11.coerce.number().optional().describe("Percentage threshold (0-100) at which to send an alert"),
|
|
4824
|
+
periodic_reset: z11.enum(["monthly", "weekly"]).optional().describe("Automatically reset usage counters on this schedule"),
|
|
4825
|
+
workspace_id: z11.string().optional().describe("Workspace ID to scope the limit to"),
|
|
4826
|
+
organisation_id: z11.string().optional().describe("Organisation ID to scope the limit to")
|
|
4348
4827
|
},
|
|
4349
4828
|
updateUsageLimit: {
|
|
4350
|
-
id:
|
|
4351
|
-
name:
|
|
4352
|
-
credit_limit:
|
|
4353
|
-
alert_threshold:
|
|
4354
|
-
periodic_reset:
|
|
4355
|
-
reset_usage_for_value:
|
|
4829
|
+
id: z11.string().describe("The unique identifier of the usage limit"),
|
|
4830
|
+
name: z11.string().optional().describe("New name for the usage limit"),
|
|
4831
|
+
credit_limit: z11.coerce.number().positive().optional().describe("New maximum allowed usage value"),
|
|
4832
|
+
alert_threshold: z11.coerce.number().optional().describe("New alert threshold percentage (0-100)"),
|
|
4833
|
+
periodic_reset: z11.enum(["monthly", "weekly"]).optional().describe("New periodic reset schedule"),
|
|
4834
|
+
reset_usage_for_value: z11.string().optional().describe("Reset usage counters for a specific group_by value")
|
|
4356
4835
|
},
|
|
4357
4836
|
deleteUsageLimit: {
|
|
4358
|
-
id:
|
|
4837
|
+
id: z11.string().describe("The unique identifier of the usage limit")
|
|
4359
4838
|
},
|
|
4360
4839
|
listUsageLimitEntities: {
|
|
4361
|
-
limit_id:
|
|
4840
|
+
limit_id: z11.string().describe("Usage limit policy ID")
|
|
4362
4841
|
},
|
|
4363
4842
|
resetUsageLimitEntity: {
|
|
4364
|
-
limit_id:
|
|
4365
|
-
entity_id:
|
|
4843
|
+
limit_id: z11.string().describe("Usage limit policy ID"),
|
|
4844
|
+
entity_id: z11.string().describe("Entity ID to reset usage for")
|
|
4366
4845
|
}
|
|
4367
4846
|
};
|
|
4368
4847
|
function formatRateLimit(limit) {
|
|
@@ -4668,8 +5147,8 @@ function registerLimitsTools(server, service) {
|
|
|
4668
5147
|
}
|
|
4669
5148
|
|
|
4670
5149
|
// src/tools/logging.tools.ts
|
|
4671
|
-
import { z as
|
|
4672
|
-
var logExportFieldSchema =
|
|
5150
|
+
import { z as z12 } from "zod";
|
|
5151
|
+
var logExportFieldSchema = z12.enum([
|
|
4673
5152
|
"id",
|
|
4674
5153
|
"trace_id",
|
|
4675
5154
|
"created_at",
|
|
@@ -4691,71 +5170,132 @@ var logExportFieldSchema = z11.enum([
|
|
|
4691
5170
|
"prompt_slug",
|
|
4692
5171
|
"metadata"
|
|
4693
5172
|
]);
|
|
5173
|
+
var getLogInputSchema = z12.object({
|
|
5174
|
+
log_id: z12.string().describe("Gateway log ID to retrieve"),
|
|
5175
|
+
path_format: z12.enum(["v1", "v2"]).optional().describe("Log storage path format; defaults to v1"),
|
|
5176
|
+
created_at: z12.iso.datetime({ offset: true }).optional().describe("Log creation timestamp in ISO 8601 format; required for v2"),
|
|
5177
|
+
type: z12.enum(["hooks"]).optional().describe("Set to hooks when retrieving a hook execution log")
|
|
5178
|
+
}).superRefine((input, context) => {
|
|
5179
|
+
if (input.path_format === "v2" && input.created_at === void 0) {
|
|
5180
|
+
context.addIssue({
|
|
5181
|
+
code: "custom",
|
|
5182
|
+
path: ["created_at"],
|
|
5183
|
+
message: "created_at is required when path_format is v2"
|
|
5184
|
+
});
|
|
5185
|
+
}
|
|
5186
|
+
});
|
|
4694
5187
|
var LOGGING_TOOL_SCHEMAS = {
|
|
5188
|
+
getLogExportFieldRestrictions: {
|
|
5189
|
+
workspace_id: z12.string().describe("Workspace ID whose export field restrictions should be read")
|
|
5190
|
+
},
|
|
4695
5191
|
insertLog: {
|
|
4696
|
-
request_url:
|
|
4697
|
-
request_provider:
|
|
4698
|
-
request_method:
|
|
4699
|
-
request_headers:
|
|
4700
|
-
request_body:
|
|
4701
|
-
response_status:
|
|
4702
|
-
response_headers:
|
|
4703
|
-
response_body:
|
|
4704
|
-
response_time:
|
|
4705
|
-
streaming_mode:
|
|
4706
|
-
metadata_organization:
|
|
4707
|
-
metadata_user:
|
|
4708
|
-
metadata_trace_id:
|
|
4709
|
-
metadata_span_id:
|
|
4710
|
-
metadata_span_name:
|
|
4711
|
-
metadata_parent_span_id:
|
|
4712
|
-
metadata_custom:
|
|
5192
|
+
request_url: z12.string().optional().describe("The endpoint URL being called"),
|
|
5193
|
+
request_provider: z12.string().optional().describe("AI provider name (e.g., 'openai', 'anthropic')"),
|
|
5194
|
+
request_method: z12.string().optional().default("post").describe("HTTP method used (defaults to 'post')"),
|
|
5195
|
+
request_headers: z12.record(z12.string(), z12.string()).optional().describe("Request headers as key-value pairs"),
|
|
5196
|
+
request_body: z12.record(z12.string(), z12.unknown()).optional().describe("Request payload/body"),
|
|
5197
|
+
response_status: z12.coerce.number().optional().default(200).describe("HTTP response status code (defaults to 200)"),
|
|
5198
|
+
response_headers: z12.record(z12.string(), z12.string()).optional().describe("Response headers as key-value pairs"),
|
|
5199
|
+
response_body: z12.record(z12.string(), z12.unknown()).optional().describe("Response payload/body"),
|
|
5200
|
+
response_time: z12.coerce.number().optional().describe("Response latency in milliseconds"),
|
|
5201
|
+
streaming_mode: z12.boolean().optional().default(false).describe("Whether the response was streamed"),
|
|
5202
|
+
metadata_organization: z12.string().optional().describe("Organization identifier for the log"),
|
|
5203
|
+
metadata_user: z12.string().optional().describe("User identifier for the log"),
|
|
5204
|
+
metadata_trace_id: z12.string().optional().describe("Trace ID for distributed tracing"),
|
|
5205
|
+
metadata_span_id: z12.string().optional().describe("Span ID for tracing"),
|
|
5206
|
+
metadata_span_name: z12.string().optional().describe("Span name for tracing"),
|
|
5207
|
+
metadata_parent_span_id: z12.string().optional().describe("Parent span ID for tracing"),
|
|
5208
|
+
metadata_custom: z12.record(z12.string(), z12.unknown()).optional().describe("Additional custom metadata key-value pairs")
|
|
4713
5209
|
},
|
|
4714
5210
|
createLogExport: {
|
|
4715
|
-
workspace_id:
|
|
4716
|
-
description:
|
|
4717
|
-
time_min:
|
|
5211
|
+
workspace_id: z12.string().optional().describe("Workspace ID for the export"),
|
|
5212
|
+
description: z12.string().optional().describe("Human-readable description for the export job"),
|
|
5213
|
+
time_min: z12.string().describe(
|
|
4718
5214
|
"Minimum time filter in date format (e.g., '2024-01-01' or ISO 8601)"
|
|
4719
5215
|
),
|
|
4720
|
-
time_max:
|
|
5216
|
+
time_max: z12.string().describe(
|
|
4721
5217
|
"Maximum time filter in date format (e.g., '2024-01-31' or ISO 8601)"
|
|
4722
5218
|
),
|
|
4723
|
-
cost_min:
|
|
4724
|
-
cost_max:
|
|
4725
|
-
total_units_min:
|
|
4726
|
-
total_units_max:
|
|
4727
|
-
ai_model:
|
|
4728
|
-
requested_fields:
|
|
5219
|
+
cost_min: z12.coerce.number().optional().describe("Minimum cost filter"),
|
|
5220
|
+
cost_max: z12.coerce.number().optional().describe("Maximum cost filter"),
|
|
5221
|
+
total_units_min: z12.coerce.number().optional().describe("Minimum total units (tokens) filter"),
|
|
5222
|
+
total_units_max: z12.coerce.number().optional().describe("Maximum total units (tokens) filter"),
|
|
5223
|
+
ai_model: z12.array(z12.string()).optional().describe("Filter by specific AI model names"),
|
|
5224
|
+
requested_fields: z12.array(logExportFieldSchema).describe(
|
|
4729
5225
|
"Fields to include in export: id, trace_id, created_at, request, response, is_success, ai_org, ai_model, req_units, res_units, total_units, request_url, cost, cost_currency, response_time, response_status_code, mode, config, prompt_slug, metadata"
|
|
4730
5226
|
)
|
|
4731
5227
|
},
|
|
4732
5228
|
listLogExports: {
|
|
4733
|
-
workspace_id:
|
|
5229
|
+
workspace_id: z12.string().describe("Workspace ID to list exports for (required)")
|
|
4734
5230
|
},
|
|
4735
5231
|
getLogExport: {
|
|
4736
|
-
export_id:
|
|
5232
|
+
export_id: z12.string().describe("The unique ID of the log export")
|
|
4737
5233
|
},
|
|
4738
5234
|
startLogExport: {
|
|
4739
|
-
export_id:
|
|
5235
|
+
export_id: z12.string().describe("The unique ID of the log export to start")
|
|
4740
5236
|
},
|
|
4741
5237
|
cancelLogExport: {
|
|
4742
|
-
export_id:
|
|
5238
|
+
export_id: z12.string().describe("The unique ID of the log export to cancel")
|
|
4743
5239
|
},
|
|
4744
5240
|
downloadLogExport: {
|
|
4745
|
-
export_id:
|
|
5241
|
+
export_id: z12.string().describe("The unique ID of the log export to download")
|
|
4746
5242
|
},
|
|
4747
5243
|
updateLogExport: {
|
|
4748
|
-
export_id:
|
|
4749
|
-
workspace_id:
|
|
4750
|
-
time_of_generation_max:
|
|
5244
|
+
export_id: z12.string().describe("The unique ID of the log export to update"),
|
|
5245
|
+
workspace_id: z12.string().optional().describe("Workspace ID for the export"),
|
|
5246
|
+
time_of_generation_max: z12.string().optional().describe(
|
|
4751
5247
|
"Maximum time filter in date format (e.g., '2024-07-25' or ISO 8601)"
|
|
4752
5248
|
),
|
|
4753
|
-
requested_fields:
|
|
5249
|
+
requested_fields: z12.array(logExportFieldSchema).optional().describe(
|
|
4754
5250
|
"Fields to include in export: id, trace_id, created_at, request, response, is_success, ai_org, ai_model, req_units, res_units, total_units, request_url, cost, cost_currency, response_time, response_status_code, mode, config, prompt_slug, metadata"
|
|
4755
5251
|
)
|
|
4756
5252
|
}
|
|
4757
5253
|
};
|
|
4758
5254
|
function registerLoggingTools(server, service) {
|
|
5255
|
+
server.registerTool(
|
|
5256
|
+
"get_log",
|
|
5257
|
+
{
|
|
5258
|
+
description: "Get one gateway request log by ID, including its request, response, usage, cost, and metadata payload when available. For path_format v2, also provide the log's created_at timestamp.",
|
|
5259
|
+
inputSchema: getLogInputSchema,
|
|
5260
|
+
annotations: {
|
|
5261
|
+
title: "Get Gateway Log",
|
|
5262
|
+
readOnlyHint: true,
|
|
5263
|
+
destructiveHint: false,
|
|
5264
|
+
idempotentHint: true,
|
|
5265
|
+
openWorldHint: true
|
|
5266
|
+
}
|
|
5267
|
+
},
|
|
5268
|
+
async (params) => {
|
|
5269
|
+
const result = await service.logging.getLog(params.log_id, {
|
|
5270
|
+
path_format: params.path_format,
|
|
5271
|
+
created_at: params.created_at,
|
|
5272
|
+
type: params.type
|
|
5273
|
+
});
|
|
5274
|
+
return {
|
|
5275
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
5276
|
+
};
|
|
5277
|
+
}
|
|
5278
|
+
);
|
|
5279
|
+
server.tool(
|
|
5280
|
+
"get_log_export_field_restrictions",
|
|
5281
|
+
"Get the organisation-managed fields that a workspace is restricted from including in log exports. Use before create_log_export or update_log_export to avoid requesting disallowed fields. Requires an API key with logs.export scope; completion-log fields may additionally require completion scope.",
|
|
5282
|
+
LOGGING_TOOL_SCHEMAS.getLogExportFieldRestrictions,
|
|
5283
|
+
{
|
|
5284
|
+
title: "Get Log Export Field Restrictions",
|
|
5285
|
+
readOnlyHint: true,
|
|
5286
|
+
destructiveHint: false,
|
|
5287
|
+
idempotentHint: true,
|
|
5288
|
+
openWorldHint: true
|
|
5289
|
+
},
|
|
5290
|
+
async (params) => {
|
|
5291
|
+
const result = await service.logging.getLogExportFieldRestrictions({
|
|
5292
|
+
workspace_id: params.workspace_id
|
|
5293
|
+
});
|
|
5294
|
+
return {
|
|
5295
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
5296
|
+
};
|
|
5297
|
+
}
|
|
5298
|
+
);
|
|
4759
5299
|
server.tool(
|
|
4760
5300
|
"insert_log",
|
|
4761
5301
|
"Insert log records for requests that bypassed the gateway. This writes request, response, and trace metadata into Portkey immediately, and the call will fail if request_provider does not match a configured integration. Use the span fields to stitch trace hierarchies together.",
|
|
@@ -4991,73 +5531,88 @@ function registerLoggingTools(server, service) {
|
|
|
4991
5531
|
}
|
|
4992
5532
|
|
|
4993
5533
|
// src/tools/mcp-integrations.tools.ts
|
|
4994
|
-
import { z as
|
|
5534
|
+
import { z as z13 } from "zod";
|
|
5535
|
+
var mcpSecretMappingSchema = createSecretMappingSchema({
|
|
5536
|
+
allowKeyTarget: false,
|
|
5537
|
+
targetFieldDescription: "Configuration field resolved at runtime, such as configurations.oauth_metadata",
|
|
5538
|
+
secretReferenceDescription: "Secret Reference UUID or slug accessible to this integration",
|
|
5539
|
+
valueFormatDescription: "Use json when the target configuration field expects a structured object"
|
|
5540
|
+
});
|
|
5541
|
+
var mcpSecretMappingsSchema = uniqueSecretMappingsSchema(
|
|
5542
|
+
mcpSecretMappingSchema
|
|
5543
|
+
);
|
|
4995
5544
|
var MCP_INTEGRATIONS_TOOL_SCHEMAS = {
|
|
4996
5545
|
listMcpIntegrations: {
|
|
4997
|
-
current_page:
|
|
4998
|
-
page_size:
|
|
4999
|
-
workspace_id:
|
|
5546
|
+
current_page: z13.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
5547
|
+
page_size: z13.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)"),
|
|
5548
|
+
workspace_id: z13.string().optional().describe("Filter by workspace ID")
|
|
5000
5549
|
},
|
|
5001
5550
|
createMcpIntegration: {
|
|
5002
|
-
name:
|
|
5003
|
-
url:
|
|
5004
|
-
auth_type:
|
|
5551
|
+
name: z13.string().describe("Display name for the MCP integration"),
|
|
5552
|
+
url: z13.string().describe("URL endpoint of the MCP server to integrate"),
|
|
5553
|
+
auth_type: z13.enum(["oauth_auto", "headers", "none"]).describe(
|
|
5005
5554
|
"Authentication type: 'none', 'headers' (custom headers), or 'oauth_auto' (OAuth)"
|
|
5006
5555
|
),
|
|
5007
|
-
transport:
|
|
5556
|
+
transport: z13.enum(["http", "sse"]).describe(
|
|
5008
5557
|
"MCP transport protocol: 'http' (streamable HTTP) or 'sse' (server-sent events)"
|
|
5009
5558
|
),
|
|
5010
|
-
slug:
|
|
5011
|
-
description:
|
|
5012
|
-
custom_headers:
|
|
5559
|
+
slug: z13.string().optional().describe("Custom slug. Auto-generated if omitted"),
|
|
5560
|
+
description: z13.string().optional().describe("Description of the MCP integration"),
|
|
5561
|
+
custom_headers: z13.record(z13.string(), z13.string()).optional().describe(
|
|
5013
5562
|
'Custom headers for authentication (e.g. { "Authorization": "Bearer xxx" }). Sent via configurations.custom_headers'
|
|
5014
5563
|
),
|
|
5015
|
-
workspace_id:
|
|
5564
|
+
workspace_id: z13.string().optional().describe(
|
|
5016
5565
|
"Workspace ID \u2014 required when using organization admin API keys"
|
|
5566
|
+
),
|
|
5567
|
+
secret_mappings: mcpSecretMappingsSchema.optional().describe(
|
|
5568
|
+
"Runtime Secret Reference mappings; every configurations.<field> target must be unique"
|
|
5017
5569
|
)
|
|
5018
5570
|
},
|
|
5019
5571
|
getMcpIntegration: {
|
|
5020
|
-
id:
|
|
5572
|
+
id: z13.string().describe("The MCP integration ID or slug to retrieve")
|
|
5021
5573
|
},
|
|
5022
5574
|
updateMcpIntegration: {
|
|
5023
|
-
id:
|
|
5024
|
-
name:
|
|
5025
|
-
description:
|
|
5026
|
-
url:
|
|
5027
|
-
auth_type:
|
|
5028
|
-
transport:
|
|
5029
|
-
custom_headers:
|
|
5575
|
+
id: z13.string().describe("The MCP integration ID or slug to update"),
|
|
5576
|
+
name: z13.string().optional().describe("New display name"),
|
|
5577
|
+
description: z13.string().optional().describe("New description"),
|
|
5578
|
+
url: z13.string().optional().describe("New URL endpoint"),
|
|
5579
|
+
auth_type: z13.enum(["oauth_auto", "headers", "none"]).optional().describe("New authentication type"),
|
|
5580
|
+
transport: z13.enum(["http", "sse"]).optional().describe("New transport protocol"),
|
|
5581
|
+
custom_headers: z13.record(z13.string(), z13.string()).optional().describe(
|
|
5030
5582
|
"New custom headers for authentication. Sent via configurations.custom_headers"
|
|
5583
|
+
),
|
|
5584
|
+
secret_mappings: mcpSecretMappingsSchema.optional().describe(
|
|
5585
|
+
"Replacement runtime Secret Reference mappings; each target_field must be unique"
|
|
5031
5586
|
)
|
|
5032
5587
|
},
|
|
5033
5588
|
deleteMcpIntegration: {
|
|
5034
|
-
id:
|
|
5589
|
+
id: z13.string().describe("The MCP integration ID or slug to delete")
|
|
5035
5590
|
},
|
|
5036
5591
|
getMcpIntegrationMetadata: {
|
|
5037
|
-
id:
|
|
5592
|
+
id: z13.string().describe("The MCP integration ID or slug")
|
|
5038
5593
|
},
|
|
5039
5594
|
listMcpIntegrationCapabilities: {
|
|
5040
|
-
id:
|
|
5595
|
+
id: z13.string().describe("The MCP integration ID or slug")
|
|
5041
5596
|
},
|
|
5042
5597
|
updateMcpIntegrationCapabilities: {
|
|
5043
|
-
id:
|
|
5044
|
-
capabilities:
|
|
5045
|
-
|
|
5046
|
-
name:
|
|
5047
|
-
type:
|
|
5048
|
-
enabled:
|
|
5598
|
+
id: z13.string().describe("The MCP integration ID or slug"),
|
|
5599
|
+
capabilities: z13.array(
|
|
5600
|
+
z13.object({
|
|
5601
|
+
name: z13.string().describe("Capability name"),
|
|
5602
|
+
type: z13.enum(["tool", "prompt", "resource"]).describe("Capability type"),
|
|
5603
|
+
enabled: z13.boolean().describe("Whether to enable the capability")
|
|
5049
5604
|
})
|
|
5050
5605
|
).min(1).describe("Array of capability updates")
|
|
5051
5606
|
},
|
|
5052
5607
|
listMcpIntegrationWorkspaces: {
|
|
5053
|
-
id:
|
|
5608
|
+
id: z13.string().describe("The MCP integration ID or slug")
|
|
5054
5609
|
},
|
|
5055
5610
|
updateMcpIntegrationWorkspaces: {
|
|
5056
|
-
id:
|
|
5057
|
-
workspaces:
|
|
5058
|
-
|
|
5059
|
-
id:
|
|
5060
|
-
enabled:
|
|
5611
|
+
id: z13.string().describe("The MCP integration ID or slug"),
|
|
5612
|
+
workspaces: z13.array(
|
|
5613
|
+
z13.object({
|
|
5614
|
+
id: z13.string().describe("Workspace ID"),
|
|
5615
|
+
enabled: z13.boolean().describe("Whether workspace has access")
|
|
5061
5616
|
})
|
|
5062
5617
|
).min(1).describe("Array of workspace access updates")
|
|
5063
5618
|
}
|
|
@@ -5085,6 +5640,7 @@ function formatMcpIntegration(integration) {
|
|
|
5085
5640
|
global_workspace_access: integration.global_workspace_access,
|
|
5086
5641
|
configuration_keys: integration.configurations ? Object.keys(integration.configurations) : void 0,
|
|
5087
5642
|
custom_header_names: getCustomHeaderNames(integration.configurations),
|
|
5643
|
+
secret_mappings: integration.secret_mappings,
|
|
5088
5644
|
created_at: integration.created_at,
|
|
5089
5645
|
last_updated_at: integration.last_updated_at
|
|
5090
5646
|
};
|
|
@@ -5137,10 +5693,19 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5137
5693
|
);
|
|
5138
5694
|
server.tool(
|
|
5139
5695
|
"create_mcp_integration",
|
|
5140
|
-
"Create
|
|
5696
|
+
"Create a Portkey integration for an external MCP server URL. For headers auth, provide custom_headers or a Secret Reference mapping targeting configurations.custom_headers; secret_mappings resolve protected values at runtime without storing them in the tool call. Organisation admin keys normally need workspace_id. After creation, create_mcp_server and configure capabilities/access; returns the integration id and slug.",
|
|
5141
5697
|
MCP_INTEGRATIONS_TOOL_SCHEMAS.createMcpIntegration,
|
|
5698
|
+
{
|
|
5699
|
+
title: "Create MCP Integration",
|
|
5700
|
+
readOnlyHint: false,
|
|
5701
|
+
destructiveHint: false,
|
|
5702
|
+
idempotentHint: false,
|
|
5703
|
+
openWorldHint: true
|
|
5704
|
+
},
|
|
5142
5705
|
async (params) => {
|
|
5143
|
-
if (params.auth_type === "headers" && (!params.custom_headers || Object.keys(params.custom_headers).length === 0)
|
|
5706
|
+
if (params.auth_type === "headers" && (!params.custom_headers || Object.keys(params.custom_headers).length === 0) && !params.secret_mappings?.some(
|
|
5707
|
+
(mapping) => mapping.target_field === "configurations.custom_headers"
|
|
5708
|
+
)) {
|
|
5144
5709
|
return {
|
|
5145
5710
|
content: [
|
|
5146
5711
|
{
|
|
@@ -5190,8 +5755,15 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5190
5755
|
);
|
|
5191
5756
|
server.tool(
|
|
5192
5757
|
"update_mcp_integration",
|
|
5193
|
-
"Update an MCP integration's name, description, URL, auth, or
|
|
5758
|
+
"Update an MCP integration's name, description, URL, auth, transport, headers, or runtime Secret Reference mappings. Only supplied fields change; URL, auth, header, and secret changes apply immediately and can break active clients, so inspect get_mcp_integration first. Use update_mcp_server when changing only a Portkey server instance's display metadata.",
|
|
5194
5759
|
MCP_INTEGRATIONS_TOOL_SCHEMAS.updateMcpIntegration,
|
|
5760
|
+
{
|
|
5761
|
+
title: "Update MCP Integration",
|
|
5762
|
+
readOnlyHint: false,
|
|
5763
|
+
destructiveHint: true,
|
|
5764
|
+
idempotentHint: true,
|
|
5765
|
+
openWorldHint: true
|
|
5766
|
+
},
|
|
5195
5767
|
async (params) => {
|
|
5196
5768
|
const { id, custom_headers, ...rest } = params;
|
|
5197
5769
|
await service.mcpIntegrations.updateMcpIntegration(id, {
|
|
@@ -5349,7 +5921,7 @@ function registerMcpIntegrationsTools(server, service) {
|
|
|
5349
5921
|
}
|
|
5350
5922
|
|
|
5351
5923
|
// src/tools/mcp-servers.tools.ts
|
|
5352
|
-
import { z as
|
|
5924
|
+
import { z as z14 } from "zod";
|
|
5353
5925
|
|
|
5354
5926
|
// src/tools/utils.ts
|
|
5355
5927
|
function formatFullName(firstName, lastName) {
|
|
@@ -5359,58 +5931,78 @@ function formatFullName(firstName, lastName) {
|
|
|
5359
5931
|
// src/tools/mcp-servers.tools.ts
|
|
5360
5932
|
var MCP_SERVERS_TOOL_SCHEMAS = {
|
|
5361
5933
|
listMcpServers: {
|
|
5362
|
-
current_page:
|
|
5363
|
-
page_size:
|
|
5364
|
-
workspace_id:
|
|
5934
|
+
current_page: z14.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
5935
|
+
page_size: z14.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)"),
|
|
5936
|
+
workspace_id: z14.string().optional().describe("Filter by workspace ID")
|
|
5365
5937
|
},
|
|
5366
5938
|
createMcpServer: {
|
|
5367
|
-
name:
|
|
5368
|
-
mcp_integration_id:
|
|
5369
|
-
slug:
|
|
5370
|
-
description:
|
|
5939
|
+
name: z14.string().describe("Display name for the MCP server"),
|
|
5940
|
+
mcp_integration_id: z14.string().describe("ID or slug of the MCP integration this server belongs to"),
|
|
5941
|
+
slug: z14.string().optional().describe("Custom slug. Auto-generated if omitted"),
|
|
5942
|
+
description: z14.string().optional().describe("Description of the MCP server")
|
|
5371
5943
|
},
|
|
5372
5944
|
getMcpServer: {
|
|
5373
|
-
id:
|
|
5945
|
+
id: z14.string().describe("The MCP server ID or slug to retrieve")
|
|
5374
5946
|
},
|
|
5375
5947
|
updateMcpServer: {
|
|
5376
|
-
id:
|
|
5377
|
-
name:
|
|
5378
|
-
description:
|
|
5948
|
+
id: z14.string().describe("The MCP server ID or slug to update"),
|
|
5949
|
+
name: z14.string().optional().describe("New display name"),
|
|
5950
|
+
description: z14.string().optional().describe("New description")
|
|
5379
5951
|
},
|
|
5380
5952
|
deleteMcpServer: {
|
|
5381
|
-
id:
|
|
5953
|
+
id: z14.string().describe("The MCP server ID or slug to delete")
|
|
5382
5954
|
},
|
|
5383
5955
|
testMcpServer: {
|
|
5384
|
-
id:
|
|
5956
|
+
id: z14.string().describe("The MCP server ID or slug to test")
|
|
5385
5957
|
},
|
|
5386
5958
|
listMcpServerCapabilities: {
|
|
5387
|
-
id:
|
|
5388
|
-
current_page:
|
|
5389
|
-
page_size:
|
|
5959
|
+
id: z14.string().describe("The MCP server ID or slug"),
|
|
5960
|
+
current_page: z14.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
5961
|
+
page_size: z14.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
5390
5962
|
},
|
|
5391
5963
|
updateMcpServerCapabilities: {
|
|
5392
|
-
id:
|
|
5393
|
-
capabilities:
|
|
5394
|
-
|
|
5395
|
-
name:
|
|
5396
|
-
type:
|
|
5397
|
-
enabled:
|
|
5964
|
+
id: z14.string().describe("The MCP server ID or slug"),
|
|
5965
|
+
capabilities: z14.array(
|
|
5966
|
+
z14.object({
|
|
5967
|
+
name: z14.string().describe("Capability name"),
|
|
5968
|
+
type: z14.enum(["tool", "prompt", "resource"]).describe("Capability type"),
|
|
5969
|
+
enabled: z14.boolean().describe("Whether to enable the capability")
|
|
5398
5970
|
})
|
|
5399
5971
|
).min(1).describe("Array of capability updates")
|
|
5400
5972
|
},
|
|
5401
5973
|
listMcpServerUserAccess: {
|
|
5402
|
-
id:
|
|
5403
|
-
current_page:
|
|
5404
|
-
page_size:
|
|
5974
|
+
id: z14.string().describe("The MCP server ID or slug"),
|
|
5975
|
+
current_page: z14.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
5976
|
+
page_size: z14.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
5405
5977
|
},
|
|
5406
5978
|
updateMcpServerUserAccess: {
|
|
5407
|
-
id:
|
|
5408
|
-
users:
|
|
5409
|
-
|
|
5410
|
-
user_id:
|
|
5411
|
-
enabled:
|
|
5979
|
+
id: z14.string().describe("The MCP server ID or slug"),
|
|
5980
|
+
users: z14.array(
|
|
5981
|
+
z14.object({
|
|
5982
|
+
user_id: z14.string().describe("User ID"),
|
|
5983
|
+
enabled: z14.boolean().describe("Whether user has access")
|
|
5412
5984
|
})
|
|
5413
5985
|
).min(1).describe("Array of user access updates")
|
|
5986
|
+
},
|
|
5987
|
+
listMcpServerConnections: {
|
|
5988
|
+
id: z14.string().describe("MCP server ID or slug whose connections to list"),
|
|
5989
|
+
user_id: z14.string().uuid().optional().describe(
|
|
5990
|
+
"User UUID to filter; user-scoped keys default to their own user when omitted"
|
|
5991
|
+
),
|
|
5992
|
+
workspace_id: z14.string().optional().describe(
|
|
5993
|
+
"Workspace ID or slug; required with an organisation admin API key"
|
|
5994
|
+
),
|
|
5995
|
+
current_page: z14.coerce.number().int().min(0).optional().describe("Zero-based results page; defaults to 0"),
|
|
5996
|
+
page_size: z14.coerce.number().int().min(1).max(500).optional().describe("Connections per page, from 1 through 500; defaults to 100")
|
|
5997
|
+
},
|
|
5998
|
+
disconnectMcpServerConnection: {
|
|
5999
|
+
id: z14.string().describe("MCP server ID or slug containing the active connection"),
|
|
6000
|
+
user_id: z14.string().uuid().optional().describe(
|
|
6001
|
+
"User UUID to disconnect; required with service keys and derived from user keys when omitted"
|
|
6002
|
+
),
|
|
6003
|
+
workspace_id: z14.string().optional().describe(
|
|
6004
|
+
"Workspace ID or slug; required with an organisation admin API key"
|
|
6005
|
+
)
|
|
5414
6006
|
}
|
|
5415
6007
|
};
|
|
5416
6008
|
function formatMcpServer(server) {
|
|
@@ -5444,6 +6036,73 @@ function formatMcpServerUserAccess(user) {
|
|
|
5444
6036
|
};
|
|
5445
6037
|
}
|
|
5446
6038
|
function registerMcpServersTools(server, service) {
|
|
6039
|
+
server.tool(
|
|
6040
|
+
"list_mcp_server_connections",
|
|
6041
|
+
"List active connection records for one Portkey-managed MCP server, including user, connected state, and connection timestamps. Use it to audit sessions or identify the user/workspace before disconnect_mcp_server_connection; service keys can list all users, while user keys default to their own user. Organisation admin keys must provide workspace_id. This reads live connection state and does not test upstream server reachability (use test_mcp_server for that).",
|
|
6042
|
+
MCP_SERVERS_TOOL_SCHEMAS.listMcpServerConnections,
|
|
6043
|
+
{
|
|
6044
|
+
title: "List MCP Server Connections",
|
|
6045
|
+
readOnlyHint: true,
|
|
6046
|
+
destructiveHint: false,
|
|
6047
|
+
idempotentHint: true,
|
|
6048
|
+
openWorldHint: true
|
|
6049
|
+
},
|
|
6050
|
+
async (params) => {
|
|
6051
|
+
const result = await service.mcpServers.listMcpServerConnections(
|
|
6052
|
+
params.id,
|
|
6053
|
+
{
|
|
6054
|
+
user_id: params.user_id,
|
|
6055
|
+
workspace_id: params.workspace_id,
|
|
6056
|
+
current_page: params.current_page,
|
|
6057
|
+
page_size: params.page_size
|
|
6058
|
+
}
|
|
6059
|
+
);
|
|
6060
|
+
return {
|
|
6061
|
+
content: [
|
|
6062
|
+
{
|
|
6063
|
+
type: "text",
|
|
6064
|
+
text: JSON.stringify({
|
|
6065
|
+
total: result.total,
|
|
6066
|
+
has_more: result.has_more,
|
|
6067
|
+
connections: result.data
|
|
6068
|
+
})
|
|
6069
|
+
}
|
|
6070
|
+
]
|
|
6071
|
+
};
|
|
6072
|
+
}
|
|
6073
|
+
);
|
|
6074
|
+
server.tool(
|
|
6075
|
+
"disconnect_mcp_server_connection",
|
|
6076
|
+
"Disconnect one user's active session from a Portkey-managed MCP server. This immediately ends that connection but does not revoke future access; use update_mcp_server_user_access when access itself should be removed. Provide user_id with service keys (user keys derive it), and workspace_id with organisation admin keys. Inspect list_mcp_server_connections first when the target is uncertain.",
|
|
6077
|
+
MCP_SERVERS_TOOL_SCHEMAS.disconnectMcpServerConnection,
|
|
6078
|
+
{
|
|
6079
|
+
title: "Disconnect MCP Server Connection",
|
|
6080
|
+
readOnlyHint: false,
|
|
6081
|
+
destructiveHint: true,
|
|
6082
|
+
idempotentHint: true,
|
|
6083
|
+
openWorldHint: true
|
|
6084
|
+
},
|
|
6085
|
+
async (params) => {
|
|
6086
|
+
const result = await service.mcpServers.disconnectMcpServerConnection(
|
|
6087
|
+
params.id,
|
|
6088
|
+
{
|
|
6089
|
+
user_id: params.user_id,
|
|
6090
|
+
workspace_id: params.workspace_id
|
|
6091
|
+
}
|
|
6092
|
+
);
|
|
6093
|
+
return {
|
|
6094
|
+
content: [
|
|
6095
|
+
{
|
|
6096
|
+
type: "text",
|
|
6097
|
+
text: JSON.stringify({
|
|
6098
|
+
message: `Disconnected MCP server connection for "${params.id}"`,
|
|
6099
|
+
...result
|
|
6100
|
+
})
|
|
6101
|
+
}
|
|
6102
|
+
]
|
|
6103
|
+
};
|
|
6104
|
+
}
|
|
6105
|
+
);
|
|
5447
6106
|
server.tool(
|
|
5448
6107
|
"list_mcp_servers",
|
|
5449
6108
|
"List MCP servers in the organization. Returns paginated server records plus total for discovering server IDs; use get_mcp_server for one server's details and list_mcp_integrations for the parent integration.",
|
|
@@ -5652,40 +6311,40 @@ function registerMcpServersTools(server, service) {
|
|
|
5652
6311
|
}
|
|
5653
6312
|
|
|
5654
6313
|
// src/tools/partials.tools.ts
|
|
5655
|
-
import { z as
|
|
6314
|
+
import { z as z15 } from "zod";
|
|
5656
6315
|
var PARTIALS_TOOL_SCHEMAS = {
|
|
5657
6316
|
createPromptPartial: {
|
|
5658
|
-
name:
|
|
5659
|
-
string:
|
|
5660
|
-
workspace_id:
|
|
6317
|
+
name: z15.string().describe("Display name for the partial"),
|
|
6318
|
+
string: z15.string().describe("The partial content/template string"),
|
|
6319
|
+
workspace_id: z15.string().optional().describe(
|
|
5661
6320
|
"Workspace ID to create partial in (required for org-level API keys)"
|
|
5662
6321
|
),
|
|
5663
|
-
version_description:
|
|
6322
|
+
version_description: z15.string().optional().describe("Description for this version")
|
|
5664
6323
|
},
|
|
5665
6324
|
listPromptPartials: {
|
|
5666
|
-
collection_id:
|
|
6325
|
+
collection_id: z15.string().optional().describe(
|
|
5667
6326
|
"Filter by collection ID. Optional \u2014 omit to list all partials across collections"
|
|
5668
6327
|
)
|
|
5669
6328
|
},
|
|
5670
6329
|
getPromptPartial: {
|
|
5671
|
-
prompt_partial_id:
|
|
6330
|
+
prompt_partial_id: z15.string().describe("Prompt partial ID or slug to retrieve")
|
|
5672
6331
|
},
|
|
5673
6332
|
updatePromptPartial: {
|
|
5674
|
-
prompt_partial_id:
|
|
5675
|
-
name:
|
|
5676
|
-
string:
|
|
5677
|
-
description:
|
|
5678
|
-
status:
|
|
6333
|
+
prompt_partial_id: z15.string().describe("Prompt partial ID or slug to update"),
|
|
6334
|
+
name: z15.string().optional().describe("New display name for the partial"),
|
|
6335
|
+
string: z15.string().optional().describe("New content for the partial"),
|
|
6336
|
+
description: z15.string().optional().describe("Description for this version"),
|
|
6337
|
+
status: z15.enum(["active", "archived"]).optional().describe("New status for the partial")
|
|
5679
6338
|
},
|
|
5680
6339
|
deletePromptPartial: {
|
|
5681
|
-
prompt_partial_id:
|
|
6340
|
+
prompt_partial_id: z15.string().describe("Prompt partial ID or slug to delete")
|
|
5682
6341
|
},
|
|
5683
6342
|
listPartialVersions: {
|
|
5684
|
-
prompt_partial_id:
|
|
6343
|
+
prompt_partial_id: z15.string().describe("Prompt partial ID or slug to list versions for")
|
|
5685
6344
|
},
|
|
5686
6345
|
publishPartial: {
|
|
5687
|
-
prompt_partial_id:
|
|
5688
|
-
version:
|
|
6346
|
+
prompt_partial_id: z15.string().describe("Prompt partial ID or slug"),
|
|
6347
|
+
version: z15.coerce.number().positive().describe("Version number to publish as default")
|
|
5689
6348
|
}
|
|
5690
6349
|
};
|
|
5691
6350
|
function registerPartialsTools(server, service) {
|
|
@@ -5871,57 +6530,57 @@ function registerPartialsTools(server, service) {
|
|
|
5871
6530
|
}
|
|
5872
6531
|
|
|
5873
6532
|
// src/tools/prompts.tools.ts
|
|
5874
|
-
import { z as
|
|
6533
|
+
import { z as z17 } from "zod";
|
|
5875
6534
|
|
|
5876
6535
|
// src/lib/schemas.ts
|
|
5877
|
-
import { z as
|
|
5878
|
-
var PromptFunctionSchema =
|
|
5879
|
-
name:
|
|
5880
|
-
description:
|
|
5881
|
-
parameters:
|
|
6536
|
+
import { z as z16 } from "zod";
|
|
6537
|
+
var PromptFunctionSchema = z16.object({
|
|
6538
|
+
name: z16.string().describe("Function name"),
|
|
6539
|
+
description: z16.string().optional().describe("Function description"),
|
|
6540
|
+
parameters: z16.record(z16.string(), z16.unknown()).optional().describe("Function parameters schema")
|
|
5882
6541
|
});
|
|
5883
|
-
var PromptToolSchema =
|
|
5884
|
-
type:
|
|
6542
|
+
var PromptToolSchema = z16.object({
|
|
6543
|
+
type: z16.literal("function").describe("Tool type"),
|
|
5885
6544
|
function: PromptFunctionSchema.describe("Function definition")
|
|
5886
6545
|
});
|
|
5887
|
-
var HyperparametersSchema =
|
|
5888
|
-
max_tokens:
|
|
5889
|
-
temperature:
|
|
5890
|
-
top_p:
|
|
5891
|
-
top_k:
|
|
5892
|
-
presence_penalty:
|
|
5893
|
-
frequency_penalty:
|
|
5894
|
-
stop:
|
|
6546
|
+
var HyperparametersSchema = z16.object({
|
|
6547
|
+
max_tokens: z16.coerce.number().positive().optional().describe("Maximum tokens to generate"),
|
|
6548
|
+
temperature: z16.coerce.number().min(0).max(2).optional().describe("Sampling temperature (0-2)"),
|
|
6549
|
+
top_p: z16.coerce.number().min(0).max(1).optional().describe("Top-p sampling (0-1)"),
|
|
6550
|
+
top_k: z16.coerce.number().positive().optional().describe("Top-k sampling"),
|
|
6551
|
+
presence_penalty: z16.coerce.number().min(-2).max(2).optional().describe("Presence penalty (-2 to 2)"),
|
|
6552
|
+
frequency_penalty: z16.coerce.number().min(-2).max(2).optional().describe("Frequency penalty (-2 to 2)"),
|
|
6553
|
+
stop: z16.array(z16.string()).optional().describe("Stop sequences")
|
|
5895
6554
|
});
|
|
5896
|
-
var PromptAppIdentifierSchema =
|
|
6555
|
+
var PromptAppIdentifierSchema = z16.string().min(1).describe(
|
|
5897
6556
|
"App identifier (REQUIRED). Use your deployed app name, for example 'hourlink' or 'support-console'."
|
|
5898
6557
|
);
|
|
5899
|
-
var PromptEnvironmentIdentifierSchema =
|
|
6558
|
+
var PromptEnvironmentIdentifierSchema = z16.string().min(1).describe(
|
|
5900
6559
|
"Environment identifier (REQUIRED). Use your environment name, for example 'dev', 'staging', 'prod', or 'qa'."
|
|
5901
6560
|
);
|
|
5902
|
-
var BillingMetadataSchema =
|
|
5903
|
-
client_id:
|
|
6561
|
+
var BillingMetadataSchema = z16.object({
|
|
6562
|
+
client_id: z16.string().describe("Client ID for billing attribution (REQUIRED)"),
|
|
5904
6563
|
app: PromptAppIdentifierSchema,
|
|
5905
6564
|
env: PromptEnvironmentIdentifierSchema,
|
|
5906
|
-
project_id:
|
|
5907
|
-
feature:
|
|
6565
|
+
project_id: z16.string().optional().describe("Project ID for granular billing"),
|
|
6566
|
+
feature: z16.string().optional().describe("Feature name for tracking")
|
|
5908
6567
|
});
|
|
5909
|
-
var ToolChoiceSchema =
|
|
5910
|
-
mode:
|
|
6568
|
+
var ToolChoiceSchema = z16.object({
|
|
6569
|
+
mode: z16.enum(["auto", "none", "function"]).describe(
|
|
5911
6570
|
"Tool choice mode: auto lets the model decide, none disables tool use, function forces one function by name"
|
|
5912
6571
|
),
|
|
5913
|
-
function_name:
|
|
6572
|
+
function_name: z16.string().optional().describe("Required when mode is 'function'; ignored otherwise")
|
|
5914
6573
|
}).superRefine((value, ctx) => {
|
|
5915
6574
|
if (value.mode === "function" && !value.function_name) {
|
|
5916
6575
|
ctx.addIssue({
|
|
5917
|
-
code:
|
|
6576
|
+
code: z16.ZodIssueCode.custom,
|
|
5918
6577
|
path: ["function_name"],
|
|
5919
6578
|
message: "function_name is required when mode is 'function'"
|
|
5920
6579
|
});
|
|
5921
6580
|
}
|
|
5922
6581
|
if (value.mode !== "function" && value.function_name !== void 0) {
|
|
5923
6582
|
ctx.addIssue({
|
|
5924
|
-
code:
|
|
6583
|
+
code: z16.ZodIssueCode.custom,
|
|
5925
6584
|
path: ["function_name"],
|
|
5926
6585
|
message: "function_name is only allowed when mode is 'function'"
|
|
5927
6586
|
});
|
|
@@ -5943,98 +6602,98 @@ function toPromptToolChoice(toolChoice) {
|
|
|
5943
6602
|
}
|
|
5944
6603
|
|
|
5945
6604
|
// src/tools/prompts.tools.ts
|
|
5946
|
-
var PROMPT_VARIABLES_SCHEMA =
|
|
5947
|
-
var PROMPT_TEMPLATE_CONTENT_BLOCK_SCHEMA =
|
|
5948
|
-
type:
|
|
5949
|
-
text:
|
|
6605
|
+
var PROMPT_VARIABLES_SCHEMA = z17.record(z17.string(), z17.union([z17.string(), z17.coerce.number(), z17.boolean()])).describe("Variable values to substitute into the template");
|
|
6606
|
+
var PROMPT_TEMPLATE_CONTENT_BLOCK_SCHEMA = z17.object({
|
|
6607
|
+
type: z17.string().describe("Content block type"),
|
|
6608
|
+
text: z17.string().optional().describe("Text content for text-based blocks")
|
|
5950
6609
|
}).passthrough().describe("Content block within a structured chat message");
|
|
5951
|
-
var PROMPT_TEMPLATE_MESSAGE_SCHEMA =
|
|
5952
|
-
role:
|
|
5953
|
-
content:
|
|
6610
|
+
var PROMPT_TEMPLATE_MESSAGE_SCHEMA = z17.object({
|
|
6611
|
+
role: z17.enum(["system", "user", "assistant"]).describe("Message role in the chat template"),
|
|
6612
|
+
content: z17.array(PROMPT_TEMPLATE_CONTENT_BLOCK_SCHEMA).describe("Message content blocks")
|
|
5954
6613
|
}).passthrough().describe("Structured chat message in a prompt template");
|
|
5955
6614
|
var PROMPTS_TOOL_SCHEMAS = {
|
|
5956
6615
|
createPrompt: {
|
|
5957
|
-
name:
|
|
5958
|
-
collection_id:
|
|
6616
|
+
name: z17.string().describe("Display name for the prompt"),
|
|
6617
|
+
collection_id: z17.string().describe(
|
|
5959
6618
|
"Collection ID to organize the prompt in (use list_collections to find)"
|
|
5960
6619
|
),
|
|
5961
|
-
string:
|
|
6620
|
+
string: z17.string().optional().describe(
|
|
5962
6621
|
"Legacy prompt template string. Use plain text for single-message prompts, or a JSON-encoded messages array string for multi-message chat prompts."
|
|
5963
6622
|
),
|
|
5964
|
-
messages:
|
|
6623
|
+
messages: z17.array(PROMPT_TEMPLATE_MESSAGE_SCHEMA).optional().describe(
|
|
5965
6624
|
"Structured chat template alias. Serialized to the legacy string format before creation."
|
|
5966
6625
|
),
|
|
5967
|
-
parameters:
|
|
5968
|
-
virtual_key:
|
|
5969
|
-
model:
|
|
6626
|
+
parameters: z17.record(z17.string(), z17.unknown()).describe("Default values for template variables"),
|
|
6627
|
+
virtual_key: z17.string().describe("Virtual key slug for model access"),
|
|
6628
|
+
model: z17.string().optional().describe(
|
|
5970
6629
|
"Model identifier (e.g., 'gpt-4', 'claude-3-opus'). Required unless ai_model_id or finetune_id is provided"
|
|
5971
6630
|
),
|
|
5972
|
-
ai_model_id:
|
|
6631
|
+
ai_model_id: z17.string().optional().describe(
|
|
5973
6632
|
"AI model ID (alternative to model). Required unless model or finetune_id is provided"
|
|
5974
6633
|
),
|
|
5975
|
-
finetune_id:
|
|
6634
|
+
finetune_id: z17.string().optional().describe(
|
|
5976
6635
|
"Fine-tune ID (alternative to model). Required unless model or ai_model_id is provided"
|
|
5977
6636
|
),
|
|
5978
|
-
version_description:
|
|
5979
|
-
template_metadata:
|
|
5980
|
-
functions:
|
|
5981
|
-
tools:
|
|
6637
|
+
version_description: z17.string().optional().describe("Description for this prompt version"),
|
|
6638
|
+
template_metadata: z17.record(z17.string(), z17.unknown()).optional().describe("Custom metadata (app, env, source_file, etc.)"),
|
|
6639
|
+
functions: z17.array(PromptFunctionSchema).optional().describe("Function definitions for function calling"),
|
|
6640
|
+
tools: z17.array(PromptToolSchema).optional().describe("Tool definitions for tool use"),
|
|
5982
6641
|
tool_choice: ToolChoiceSchema.optional().describe("Tool choice strategy"),
|
|
5983
|
-
dry_run:
|
|
6642
|
+
dry_run: z17.boolean().optional().describe("When true, validate without creating")
|
|
5984
6643
|
},
|
|
5985
6644
|
listPrompts: {
|
|
5986
|
-
collection_id:
|
|
6645
|
+
collection_id: z17.string().optional().describe(
|
|
5987
6646
|
"Filter by collection ID (recommended for app-specific prompts)"
|
|
5988
6647
|
),
|
|
5989
|
-
workspace_id:
|
|
5990
|
-
search:
|
|
5991
|
-
current_page:
|
|
5992
|
-
page_size:
|
|
6648
|
+
workspace_id: z17.string().optional().describe("Filter by workspace ID"),
|
|
6649
|
+
search: z17.string().optional().describe("Search prompts by name"),
|
|
6650
|
+
current_page: z17.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
6651
|
+
page_size: z17.coerce.number().int().positive().max(100).optional().describe("Results per page (max 100)")
|
|
5993
6652
|
},
|
|
5994
6653
|
getPrompt: {
|
|
5995
|
-
prompt_id:
|
|
6654
|
+
prompt_id: z17.string().describe("Prompt ID or slug to retrieve")
|
|
5996
6655
|
},
|
|
5997
6656
|
updatePrompt: {
|
|
5998
|
-
prompt_id:
|
|
5999
|
-
name:
|
|
6000
|
-
collection_id:
|
|
6001
|
-
string:
|
|
6657
|
+
prompt_id: z17.string().describe("Prompt ID or slug to update"),
|
|
6658
|
+
name: z17.string().optional().describe("New display name for the prompt"),
|
|
6659
|
+
collection_id: z17.string().optional().describe("Move to a different collection"),
|
|
6660
|
+
string: z17.string().optional().describe(
|
|
6002
6661
|
"Legacy prompt template string. Use plain text for single-message prompts, or a JSON-encoded messages array string for multi-message chat prompts."
|
|
6003
6662
|
),
|
|
6004
|
-
messages:
|
|
6663
|
+
messages: z17.array(PROMPT_TEMPLATE_MESSAGE_SCHEMA).optional().describe(
|
|
6005
6664
|
"Structured chat template alias for updates. Serialized to the legacy string format before the prompt is updated."
|
|
6006
6665
|
),
|
|
6007
|
-
parameters:
|
|
6008
|
-
model:
|
|
6009
|
-
virtual_key:
|
|
6010
|
-
version_description:
|
|
6011
|
-
template_metadata:
|
|
6012
|
-
functions:
|
|
6013
|
-
tools:
|
|
6666
|
+
parameters: z17.record(z17.string(), z17.unknown()).optional().describe("New default values for template variables"),
|
|
6667
|
+
model: z17.string().optional().describe("New model identifier"),
|
|
6668
|
+
virtual_key: z17.string().optional().describe("New virtual key slug"),
|
|
6669
|
+
version_description: z17.string().optional().describe("Description for this version"),
|
|
6670
|
+
template_metadata: z17.record(z17.string(), z17.unknown()).optional().describe("New metadata"),
|
|
6671
|
+
functions: z17.array(PromptFunctionSchema).optional().describe("New function definitions"),
|
|
6672
|
+
tools: z17.array(PromptToolSchema).optional().describe("New tool definitions"),
|
|
6014
6673
|
tool_choice: ToolChoiceSchema.optional().describe(
|
|
6015
6674
|
"New tool choice strategy"
|
|
6016
6675
|
),
|
|
6017
|
-
dry_run:
|
|
6676
|
+
dry_run: z17.boolean().optional().describe("When true, validate without updating")
|
|
6018
6677
|
},
|
|
6019
6678
|
deletePrompt: {
|
|
6020
|
-
prompt_id:
|
|
6679
|
+
prompt_id: z17.string().describe("Prompt ID or slug to delete")
|
|
6021
6680
|
},
|
|
6022
6681
|
publishPrompt: {
|
|
6023
|
-
prompt_id:
|
|
6024
|
-
version:
|
|
6682
|
+
prompt_id: z17.string().describe("Prompt ID or slug to publish"),
|
|
6683
|
+
version: z17.coerce.number().positive().describe("Version number to publish as the default")
|
|
6025
6684
|
},
|
|
6026
6685
|
listPromptVersions: {
|
|
6027
|
-
prompt_id:
|
|
6686
|
+
prompt_id: z17.string().describe("Prompt ID or slug to list versions for")
|
|
6028
6687
|
},
|
|
6029
6688
|
renderPrompt: {
|
|
6030
|
-
prompt_id:
|
|
6689
|
+
prompt_id: z17.string().describe("Prompt ID or slug to render"),
|
|
6031
6690
|
variables: PROMPT_VARIABLES_SCHEMA,
|
|
6032
6691
|
hyperparameters: HyperparametersSchema.optional().describe(
|
|
6033
6692
|
"Override default hyperparameters"
|
|
6034
6693
|
)
|
|
6035
6694
|
},
|
|
6036
6695
|
runPromptCompletion: {
|
|
6037
|
-
prompt_id:
|
|
6696
|
+
prompt_id: z17.string().describe("Prompt ID or slug to execute"),
|
|
6038
6697
|
variables: PROMPT_VARIABLES_SCHEMA,
|
|
6039
6698
|
metadata: BillingMetadataSchema.describe(
|
|
6040
6699
|
"Billing metadata - client_id, app, env are REQUIRED for cost attribution"
|
|
@@ -6044,54 +6703,54 @@ var PROMPTS_TOOL_SCHEMAS = {
|
|
|
6044
6703
|
)
|
|
6045
6704
|
},
|
|
6046
6705
|
migratePrompt: {
|
|
6047
|
-
name:
|
|
6706
|
+
name: z17.string().describe("Prompt name to create or find for update"),
|
|
6048
6707
|
app: PromptAppIdentifierSchema,
|
|
6049
6708
|
env: PromptEnvironmentIdentifierSchema,
|
|
6050
|
-
collection_id:
|
|
6051
|
-
string:
|
|
6709
|
+
collection_id: z17.string().describe("Collection ID to search in and create under"),
|
|
6710
|
+
string: z17.string().optional().describe(
|
|
6052
6711
|
"Legacy prompt template string with {{variable}} mustache syntax."
|
|
6053
6712
|
),
|
|
6054
|
-
messages:
|
|
6713
|
+
messages: z17.array(PROMPT_TEMPLATE_MESSAGE_SCHEMA).optional().describe(
|
|
6055
6714
|
"Structured chat template alias for migrations. Serialized to the legacy string format before the prompt is created or updated."
|
|
6056
6715
|
),
|
|
6057
|
-
parameters:
|
|
6058
|
-
virtual_key:
|
|
6059
|
-
model:
|
|
6060
|
-
version_description:
|
|
6061
|
-
template_metadata:
|
|
6062
|
-
functions:
|
|
6063
|
-
tools:
|
|
6716
|
+
parameters: z17.record(z17.string(), z17.unknown()).describe("Default values for template variables"),
|
|
6717
|
+
virtual_key: z17.string().describe("Virtual key slug for model access"),
|
|
6718
|
+
model: z17.string().optional().describe("Model identifier"),
|
|
6719
|
+
version_description: z17.string().optional().describe("Description for this version"),
|
|
6720
|
+
template_metadata: z17.record(z17.string(), z17.unknown()).optional().describe("Additional custom metadata"),
|
|
6721
|
+
functions: z17.array(PromptFunctionSchema).optional().describe("Function definitions"),
|
|
6722
|
+
tools: z17.array(PromptToolSchema).optional().describe("Tool definitions"),
|
|
6064
6723
|
tool_choice: ToolChoiceSchema.optional().describe("Tool choice strategy"),
|
|
6065
|
-
dry_run:
|
|
6724
|
+
dry_run: z17.boolean().optional().describe(
|
|
6066
6725
|
"When true, only check what action would be taken without making changes"
|
|
6067
6726
|
)
|
|
6068
6727
|
},
|
|
6069
6728
|
promotePrompt: {
|
|
6070
|
-
source_prompt_id:
|
|
6071
|
-
target_collection_id:
|
|
6072
|
-
target_name:
|
|
6729
|
+
source_prompt_id: z17.string().describe("Source prompt ID or slug (e.g., staging prompt)"),
|
|
6730
|
+
target_collection_id: z17.string().describe("Target collection ID for the promoted prompt"),
|
|
6731
|
+
target_name: z17.string().optional().describe(
|
|
6073
6732
|
"Target prompt name (defaults to source name with env suffix replaced)"
|
|
6074
6733
|
),
|
|
6075
6734
|
target_env: PromptEnvironmentIdentifierSchema,
|
|
6076
|
-
virtual_key:
|
|
6735
|
+
virtual_key: z17.string().optional().describe(
|
|
6077
6736
|
"Virtual key ID to use (defaults to source prompt's virtual_key)"
|
|
6078
6737
|
)
|
|
6079
6738
|
},
|
|
6080
6739
|
validateCompletionMetadata: {
|
|
6081
|
-
client_id:
|
|
6740
|
+
client_id: z17.string().optional().describe("Client ID for billing attribution"),
|
|
6082
6741
|
app: PromptAppIdentifierSchema.optional(),
|
|
6083
6742
|
env: PromptEnvironmentIdentifierSchema.optional(),
|
|
6084
|
-
project_id:
|
|
6085
|
-
feature:
|
|
6743
|
+
project_id: z17.string().optional().describe("Project ID for granular billing"),
|
|
6744
|
+
feature: z17.string().optional().describe("Feature name for tracking")
|
|
6086
6745
|
},
|
|
6087
6746
|
getPromptVersion: {
|
|
6088
|
-
prompt_id:
|
|
6089
|
-
version_id:
|
|
6747
|
+
prompt_id: z17.string().describe("Prompt ID or slug"),
|
|
6748
|
+
version_id: z17.string().describe("Version UUID to retrieve")
|
|
6090
6749
|
},
|
|
6091
6750
|
updatePromptVersion: {
|
|
6092
|
-
prompt_id:
|
|
6093
|
-
version_id:
|
|
6094
|
-
label_id:
|
|
6751
|
+
prompt_id: z17.string().describe("Prompt ID or slug"),
|
|
6752
|
+
version_id: z17.string().describe("Version UUID to update"),
|
|
6753
|
+
label_id: z17.string().nullable().describe(
|
|
6095
6754
|
"Label ID to assign to this version, or null to remove the label"
|
|
6096
6755
|
)
|
|
6097
6756
|
}
|
|
@@ -6681,68 +7340,68 @@ function registerPromptsTools(server, service) {
|
|
|
6681
7340
|
}
|
|
6682
7341
|
|
|
6683
7342
|
// src/tools/providers.tools.ts
|
|
6684
|
-
import { z as
|
|
7343
|
+
import { z as z18 } from "zod";
|
|
6685
7344
|
var PROVIDERS_TOOL_SCHEMAS = {
|
|
6686
7345
|
listProviders: {
|
|
6687
|
-
current_page:
|
|
6688
|
-
page_size:
|
|
6689
|
-
workspace_id:
|
|
7346
|
+
current_page: z18.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
7347
|
+
page_size: z18.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100, default 50)"),
|
|
7348
|
+
workspace_id: z18.string().optional().describe(
|
|
6690
7349
|
"Workspace ID - required when using organization admin keys, optional with workspace API keys"
|
|
6691
7350
|
)
|
|
6692
7351
|
},
|
|
6693
7352
|
createProvider: {
|
|
6694
|
-
name:
|
|
6695
|
-
integration_id:
|
|
7353
|
+
name: z18.string().describe("Display name for the provider"),
|
|
7354
|
+
integration_id: z18.string().describe(
|
|
6696
7355
|
"Integration slug for the provider (e.g., 'openai', 'anthropic', 'azure-openai')"
|
|
6697
7356
|
),
|
|
6698
|
-
workspace_id:
|
|
7357
|
+
workspace_id: z18.string().optional().describe(
|
|
6699
7358
|
"Workspace ID - required when using organization admin API keys"
|
|
6700
7359
|
),
|
|
6701
|
-
slug:
|
|
7360
|
+
slug: z18.string().optional().describe(
|
|
6702
7361
|
"Custom slug for the provider. Auto-generated with random suffix if omitted"
|
|
6703
7362
|
),
|
|
6704
|
-
note:
|
|
6705
|
-
credit_limit:
|
|
6706
|
-
alert_threshold:
|
|
6707
|
-
usage_limit_type:
|
|
7363
|
+
note: z18.string().optional().describe("Optional note or description for the provider"),
|
|
7364
|
+
credit_limit: z18.coerce.number().positive().optional().describe("Credit limit for usage"),
|
|
7365
|
+
alert_threshold: z18.coerce.number().min(0).max(100).optional().describe("Alert threshold percentage (0-100)"),
|
|
7366
|
+
usage_limit_type: z18.enum(["cost", "tokens"]).optional().describe(
|
|
6708
7367
|
"Type of usage limit: 'cost' (monetary) or 'tokens' (token count). Defaults to 'cost'."
|
|
6709
7368
|
),
|
|
6710
|
-
periodic_reset:
|
|
7369
|
+
periodic_reset: z18.enum(["monthly", "weekly"]).optional().describe(
|
|
6711
7370
|
"Period for resetting usage limits: 'monthly' or 'weekly'. Defaults to 'monthly'."
|
|
6712
7371
|
),
|
|
6713
|
-
rate_limit_value:
|
|
6714
|
-
rate_limit_unit:
|
|
7372
|
+
rate_limit_value: z18.coerce.number().positive().optional().describe("Must be provided together with rate_limit_unit."),
|
|
7373
|
+
rate_limit_unit: z18.enum(["rpm", "rph", "rpd"]).optional().describe(
|
|
6715
7374
|
"Must be provided together with rate_limit_value. Values: 'rpm' (requests/min), 'rph' (requests/hour), or 'rpd' (requests/day)."
|
|
6716
7375
|
),
|
|
6717
|
-
expires_at:
|
|
7376
|
+
expires_at: z18.string().optional().describe("Expiration date in ISO 8601 format")
|
|
6718
7377
|
},
|
|
6719
7378
|
getProvider: {
|
|
6720
|
-
slug:
|
|
6721
|
-
workspace_id:
|
|
7379
|
+
slug: z18.string().describe("The unique slug identifier of the provider to retrieve"),
|
|
7380
|
+
workspace_id: z18.string().optional().describe("Workspace ID - required when using organization admin keys")
|
|
6722
7381
|
},
|
|
6723
7382
|
updateProvider: {
|
|
6724
|
-
slug:
|
|
6725
|
-
workspace_id:
|
|
6726
|
-
name:
|
|
6727
|
-
note:
|
|
6728
|
-
credit_limit:
|
|
6729
|
-
alert_threshold:
|
|
6730
|
-
usage_limit_type:
|
|
7383
|
+
slug: z18.string().describe("The slug of the provider to update"),
|
|
7384
|
+
workspace_id: z18.string().optional().describe("Workspace ID - required when using organization admin keys"),
|
|
7385
|
+
name: z18.string().optional().describe("New display name for the provider"),
|
|
7386
|
+
note: z18.string().optional().describe("New note or description for the provider"),
|
|
7387
|
+
credit_limit: z18.coerce.number().positive().optional().describe("New credit limit for usage"),
|
|
7388
|
+
alert_threshold: z18.coerce.number().min(0).max(100).optional().describe("New alert threshold percentage (0-100)"),
|
|
7389
|
+
usage_limit_type: z18.enum(["cost", "tokens"]).optional().describe(
|
|
6731
7390
|
"Type of usage limit: 'cost' (monetary) or 'tokens' (token count). Defaults to 'cost'."
|
|
6732
7391
|
),
|
|
6733
|
-
periodic_reset:
|
|
7392
|
+
periodic_reset: z18.enum(["monthly", "weekly"]).optional().describe(
|
|
6734
7393
|
"Period for resetting usage limits: 'monthly' or 'weekly'. Defaults to 'monthly'."
|
|
6735
7394
|
),
|
|
6736
|
-
rate_limit_value:
|
|
6737
|
-
rate_limit_unit:
|
|
7395
|
+
rate_limit_value: z18.coerce.number().positive().optional().describe("New rate limit value"),
|
|
7396
|
+
rate_limit_unit: z18.enum(["rpm", "rph", "rpd"]).optional().describe(
|
|
6738
7397
|
"Rate limit unit: 'rpm' (requests per minute), 'rph' (requests per hour), or 'rpd' (requests per day)"
|
|
6739
7398
|
),
|
|
6740
|
-
expires_at:
|
|
6741
|
-
reset_usage:
|
|
7399
|
+
expires_at: z18.string().optional().describe("New expiration date in ISO 8601 format"),
|
|
7400
|
+
reset_usage: z18.boolean().optional().describe("Set to true to reset accumulated usage metrics")
|
|
6742
7401
|
},
|
|
6743
7402
|
deleteProvider: {
|
|
6744
|
-
slug:
|
|
6745
|
-
workspace_id:
|
|
7403
|
+
slug: z18.string().describe("The slug of the provider to delete"),
|
|
7404
|
+
workspace_id: z18.string().optional().describe("Workspace ID - required when using organization admin keys")
|
|
6746
7405
|
}
|
|
6747
7406
|
};
|
|
6748
7407
|
function registerProvidersTools(server, service) {
|
|
@@ -6924,73 +7583,73 @@ function registerProvidersTools(server, service) {
|
|
|
6924
7583
|
}
|
|
6925
7584
|
|
|
6926
7585
|
// src/tools/secret-references.tools.ts
|
|
6927
|
-
import { z as
|
|
7586
|
+
import { z as z19 } from "zod";
|
|
6928
7587
|
var authFields = {
|
|
6929
|
-
aws_auth_type:
|
|
7588
|
+
aws_auth_type: z19.enum(["accessKey", "assumedRole", "serviceRole"]).describe(
|
|
6930
7589
|
"AWS authentication mode: accessKey uses a key pair, assumedRole uses an IAM role, and serviceRole uses the runtime workload identity"
|
|
6931
7590
|
),
|
|
6932
|
-
aws_access_key_id:
|
|
6933
|
-
aws_secret_access_key:
|
|
7591
|
+
aws_access_key_id: z19.string().min(1).describe("AWS access key ID; required when aws_auth_type is accessKey"),
|
|
7592
|
+
aws_secret_access_key: z19.string().min(1).describe(
|
|
6934
7593
|
"AWS secret access key; required when aws_auth_type is accessKey and exposed to the MCP transcript"
|
|
6935
7594
|
),
|
|
6936
|
-
aws_region:
|
|
6937
|
-
aws_role_arn:
|
|
7595
|
+
aws_region: z19.string().min(1).describe("AWS region containing the secret, for example us-east-1"),
|
|
7596
|
+
aws_role_arn: z19.string().min(1).describe(
|
|
6938
7597
|
"IAM role ARN to assume; required when aws_auth_type is assumedRole"
|
|
6939
7598
|
),
|
|
6940
|
-
aws_external_id:
|
|
6941
|
-
azure_auth_mode:
|
|
7599
|
+
aws_external_id: z19.string().nullable().describe("Optional external ID required by the target IAM role"),
|
|
7600
|
+
azure_auth_mode: z19.enum(["entra", "managed", "default"]).describe(
|
|
6942
7601
|
"Azure authentication mode: entra uses a client secret, managed uses managed identity, and default uses the runtime credential chain"
|
|
6943
7602
|
),
|
|
6944
|
-
azure_entra_tenant_id:
|
|
6945
|
-
azure_entra_client_id:
|
|
7603
|
+
azure_entra_tenant_id: z19.string().min(1).describe("Microsoft Entra tenant ID; required for entra authentication"),
|
|
7604
|
+
azure_entra_client_id: z19.string().min(1).describe(
|
|
6946
7605
|
"Microsoft Entra application client ID; required for entra authentication"
|
|
6947
7606
|
),
|
|
6948
|
-
azure_entra_client_secret:
|
|
7607
|
+
azure_entra_client_secret: z19.string().min(1).describe(
|
|
6949
7608
|
"Microsoft Entra client secret; required for entra authentication and exposed to the MCP transcript"
|
|
6950
7609
|
),
|
|
6951
|
-
azure_managed_client_id:
|
|
7610
|
+
azure_managed_client_id: z19.string().min(1).describe(
|
|
6952
7611
|
"Optional client ID of a user-assigned managed identity; omit for the system-assigned identity"
|
|
6953
7612
|
),
|
|
6954
|
-
azure_vault_url:
|
|
7613
|
+
azure_vault_url: z19.url().describe(
|
|
6955
7614
|
"Azure Key Vault URL, for example https://example.vault.azure.net"
|
|
6956
7615
|
),
|
|
6957
|
-
vault_auth_type:
|
|
7616
|
+
vault_auth_type: z19.enum(["token", "approle", "kubernetes"]).describe(
|
|
6958
7617
|
"HashiCorp Vault authentication mode: token, AppRole, or Kubernetes"
|
|
6959
7618
|
),
|
|
6960
|
-
vault_addr:
|
|
6961
|
-
vault_token:
|
|
7619
|
+
vault_addr: z19.url().describe("Base URL of the HashiCorp Vault server"),
|
|
7620
|
+
vault_token: z19.string().min(1).describe(
|
|
6962
7621
|
"HashiCorp Vault token; required for token authentication and exposed to the MCP transcript"
|
|
6963
7622
|
),
|
|
6964
|
-
vault_namespace:
|
|
6965
|
-
vault_role_id:
|
|
7623
|
+
vault_namespace: z19.string().min(1).describe("Optional HashiCorp Vault Enterprise namespace"),
|
|
7624
|
+
vault_role_id: z19.string().min(1).describe(
|
|
6966
7625
|
"HashiCorp Vault AppRole role ID; required for approle authentication"
|
|
6967
7626
|
),
|
|
6968
|
-
vault_secret_id:
|
|
7627
|
+
vault_secret_id: z19.string().min(1).describe(
|
|
6969
7628
|
"HashiCorp Vault AppRole secret ID; required for approle authentication and exposed to the MCP transcript"
|
|
6970
7629
|
),
|
|
6971
|
-
vault_role:
|
|
7630
|
+
vault_role: z19.string().min(1).describe("HashiCorp Vault Kubernetes auth role name")
|
|
6972
7631
|
};
|
|
6973
|
-
var authConfigSchema =
|
|
6974
|
-
|
|
6975
|
-
aws_auth_type:
|
|
7632
|
+
var authConfigSchema = z19.union([
|
|
7633
|
+
z19.object({
|
|
7634
|
+
aws_auth_type: z19.literal("accessKey").describe("Use an AWS access key ID and secret access key"),
|
|
6976
7635
|
aws_access_key_id: authFields.aws_access_key_id,
|
|
6977
7636
|
aws_secret_access_key: authFields.aws_secret_access_key,
|
|
6978
7637
|
aws_region: authFields.aws_region
|
|
6979
7638
|
}).strict(),
|
|
6980
|
-
|
|
6981
|
-
aws_auth_type:
|
|
7639
|
+
z19.object({
|
|
7640
|
+
aws_auth_type: z19.literal("assumedRole").describe("Assume the specified AWS IAM role"),
|
|
6982
7641
|
aws_role_arn: authFields.aws_role_arn,
|
|
6983
7642
|
aws_external_id: authFields.aws_external_id.optional(),
|
|
6984
7643
|
aws_region: authFields.aws_region
|
|
6985
7644
|
}).strict(),
|
|
6986
|
-
|
|
6987
|
-
aws_auth_type:
|
|
6988
|
-
aws_region:
|
|
7645
|
+
z19.object({
|
|
7646
|
+
aws_auth_type: z19.literal("serviceRole").describe("Use the AWS workload or service role available at runtime"),
|
|
7647
|
+
aws_region: z19.string().optional().describe(
|
|
6989
7648
|
"Optional AWS region containing the secret, for example us-east-1"
|
|
6990
7649
|
)
|
|
6991
7650
|
}).strict(),
|
|
6992
|
-
|
|
6993
|
-
azure_auth_mode:
|
|
7651
|
+
z19.object({
|
|
7652
|
+
azure_auth_mode: z19.literal("entra").describe(
|
|
6994
7653
|
"Authenticate with a Microsoft Entra application client secret"
|
|
6995
7654
|
),
|
|
6996
7655
|
azure_entra_tenant_id: authFields.azure_entra_tenant_id,
|
|
@@ -6998,30 +7657,30 @@ var authConfigSchema = z18.union([
|
|
|
6998
7657
|
azure_entra_client_secret: authFields.azure_entra_client_secret,
|
|
6999
7658
|
azure_vault_url: authFields.azure_vault_url
|
|
7000
7659
|
}).strict(),
|
|
7001
|
-
|
|
7002
|
-
azure_auth_mode:
|
|
7660
|
+
z19.object({
|
|
7661
|
+
azure_auth_mode: z19.literal("managed").describe("Authenticate with an Azure managed identity"),
|
|
7003
7662
|
azure_managed_client_id: authFields.azure_managed_client_id.optional(),
|
|
7004
7663
|
azure_vault_url: authFields.azure_vault_url
|
|
7005
7664
|
}).strict(),
|
|
7006
|
-
|
|
7007
|
-
azure_auth_mode:
|
|
7665
|
+
z19.object({
|
|
7666
|
+
azure_auth_mode: z19.literal("default").describe("Use Azure's default runtime credential chain"),
|
|
7008
7667
|
azure_vault_url: authFields.azure_vault_url
|
|
7009
7668
|
}).strict(),
|
|
7010
|
-
|
|
7011
|
-
vault_auth_type:
|
|
7669
|
+
z19.object({
|
|
7670
|
+
vault_auth_type: z19.literal("token").describe("Authenticate to HashiCorp Vault with a token"),
|
|
7012
7671
|
vault_addr: authFields.vault_addr,
|
|
7013
7672
|
vault_token: authFields.vault_token,
|
|
7014
7673
|
vault_namespace: authFields.vault_namespace.optional()
|
|
7015
7674
|
}).strict(),
|
|
7016
|
-
|
|
7017
|
-
vault_auth_type:
|
|
7675
|
+
z19.object({
|
|
7676
|
+
vault_auth_type: z19.literal("approle").describe("Authenticate to HashiCorp Vault with AppRole credentials"),
|
|
7018
7677
|
vault_addr: authFields.vault_addr,
|
|
7019
7678
|
vault_role_id: authFields.vault_role_id,
|
|
7020
7679
|
vault_secret_id: authFields.vault_secret_id,
|
|
7021
7680
|
vault_namespace: authFields.vault_namespace.optional()
|
|
7022
7681
|
}).strict(),
|
|
7023
|
-
|
|
7024
|
-
vault_auth_type:
|
|
7682
|
+
z19.object({
|
|
7683
|
+
vault_auth_type: z19.literal("kubernetes").describe(
|
|
7025
7684
|
"Authenticate to HashiCorp Vault with a Kubernetes service account"
|
|
7026
7685
|
),
|
|
7027
7686
|
vault_addr: authFields.vault_addr,
|
|
@@ -7029,61 +7688,61 @@ var authConfigSchema = z18.union([
|
|
|
7029
7688
|
vault_namespace: authFields.vault_namespace.optional()
|
|
7030
7689
|
}).strict()
|
|
7031
7690
|
]);
|
|
7032
|
-
var updateAuthConfigSchema =
|
|
7033
|
-
|
|
7691
|
+
var updateAuthConfigSchema = z19.union([
|
|
7692
|
+
z19.object({
|
|
7034
7693
|
aws_auth_type: authFields.aws_auth_type.optional(),
|
|
7035
7694
|
aws_access_key_id: authFields.aws_access_key_id.optional(),
|
|
7036
7695
|
aws_secret_access_key: authFields.aws_secret_access_key.optional(),
|
|
7037
|
-
aws_region:
|
|
7696
|
+
aws_region: z19.string().optional().describe("AWS region containing the secret, for example us-east-1"),
|
|
7038
7697
|
aws_role_arn: authFields.aws_role_arn.optional(),
|
|
7039
7698
|
aws_external_id: authFields.aws_external_id.optional()
|
|
7040
7699
|
}).strict(),
|
|
7041
|
-
|
|
7700
|
+
z19.object({
|
|
7042
7701
|
azure_auth_mode: authFields.azure_auth_mode.optional(),
|
|
7043
7702
|
azure_entra_tenant_id: authFields.azure_entra_tenant_id.optional(),
|
|
7044
7703
|
azure_entra_client_id: authFields.azure_entra_client_id.optional(),
|
|
7045
7704
|
azure_entra_client_secret: authFields.azure_entra_client_secret.optional(),
|
|
7046
|
-
azure_managed_client_id:
|
|
7705
|
+
azure_managed_client_id: z19.string().optional().describe(
|
|
7047
7706
|
"Optional client ID of a user-assigned managed identity; omit for the system-assigned identity"
|
|
7048
7707
|
),
|
|
7049
7708
|
azure_vault_url: authFields.azure_vault_url.optional()
|
|
7050
7709
|
}).strict(),
|
|
7051
|
-
|
|
7710
|
+
z19.object({
|
|
7052
7711
|
vault_auth_type: authFields.vault_auth_type.optional(),
|
|
7053
7712
|
vault_addr: authFields.vault_addr.optional(),
|
|
7054
7713
|
vault_token: authFields.vault_token.optional(),
|
|
7055
|
-
vault_namespace:
|
|
7714
|
+
vault_namespace: z19.string().optional().describe("Optional HashiCorp Vault Enterprise namespace"),
|
|
7056
7715
|
vault_role_id: authFields.vault_role_id.optional(),
|
|
7057
7716
|
vault_secret_id: authFields.vault_secret_id.optional(),
|
|
7058
7717
|
vault_role: authFields.vault_role.optional()
|
|
7059
7718
|
}).strict()
|
|
7060
7719
|
]);
|
|
7061
|
-
var managerTypeSchema =
|
|
7720
|
+
var managerTypeSchema = z19.enum(["aws_sm", "azure_kv", "hashicorp_vault"]).describe(
|
|
7062
7721
|
"External secret manager: aws_sm for AWS Secrets Manager, azure_kv for Azure Key Vault, or hashicorp_vault for HashiCorp Vault; must match the auth_config field family"
|
|
7063
7722
|
);
|
|
7064
|
-
var tagsSchema =
|
|
7723
|
+
var tagsSchema = z19.record(z19.string(), z19.string()).describe("Tag filters or metadata as string key-value pairs");
|
|
7065
7724
|
var SECRET_REFERENCE_TOOL_SCHEMAS = {
|
|
7066
7725
|
create: {
|
|
7067
|
-
name:
|
|
7726
|
+
name: z19.string().min(1).max(255).describe("Human-readable name"),
|
|
7068
7727
|
manager_type: managerTypeSchema,
|
|
7069
7728
|
auth_config: authConfigSchema.describe(
|
|
7070
7729
|
"Choose exactly one documented authentication shape matching manager_type. Credentials are sent to Portkey and visible in the MCP transcript; prefer workload identity or short-lived credentials when available."
|
|
7071
7730
|
),
|
|
7072
|
-
secret_path:
|
|
7073
|
-
organisation_id:
|
|
7731
|
+
secret_path: z19.string().max(1024).describe("Path of the secret in the external secret manager"),
|
|
7732
|
+
organisation_id: z19.string().uuid().optional().describe(
|
|
7074
7733
|
"Organisation UUID; required when the MCP server is not authenticated with a Portkey API key"
|
|
7075
7734
|
),
|
|
7076
|
-
slug:
|
|
7735
|
+
slug: z19.string().max(255).regex(/^[a-zA-Z0-9_-]+$/).optional().describe(
|
|
7077
7736
|
"Optional stable slug containing only letters, numbers, underscores, or hyphens; Portkey generates one when omitted"
|
|
7078
7737
|
),
|
|
7079
|
-
description:
|
|
7080
|
-
secret_key:
|
|
7738
|
+
description: z19.string().max(1024).nullable().optional().describe("Optional description; use null to leave it empty"),
|
|
7739
|
+
secret_key: z19.string().max(255).nullable().optional().describe(
|
|
7081
7740
|
"Optional key within a structured external secret; null uses the whole secret value"
|
|
7082
7741
|
),
|
|
7083
|
-
allow_all_workspaces:
|
|
7742
|
+
allow_all_workspaces: z19.boolean().optional().describe(
|
|
7084
7743
|
"Whether every workspace may use this reference; defaults to true and cannot be true with allowed_workspaces"
|
|
7085
7744
|
),
|
|
7086
|
-
allowed_workspaces:
|
|
7745
|
+
allowed_workspaces: z19.array(z19.string()).min(1).optional().describe(
|
|
7087
7746
|
"Workspace UUIDs or slugs allowed to use this reference; omit when allow_all_workspaces is true"
|
|
7088
7747
|
),
|
|
7089
7748
|
tags: tagsSchema.nullable().optional().describe(
|
|
@@ -7095,34 +7754,34 @@ var SECRET_REFERENCE_TOOL_SCHEMAS = {
|
|
|
7095
7754
|
"Filter by external secret manager: aws_sm, azure_kv, or hashicorp_vault"
|
|
7096
7755
|
),
|
|
7097
7756
|
tags: tagsSchema.optional().describe("Return references matching these tags"),
|
|
7098
|
-
search:
|
|
7099
|
-
current_page:
|
|
7100
|
-
page_size:
|
|
7757
|
+
search: z19.string().min(1).max(255).optional().describe("Search references by name"),
|
|
7758
|
+
current_page: z19.coerce.number().int().nonnegative().optional().describe("Zero-based page number; defaults to 0"),
|
|
7759
|
+
page_size: z19.coerce.number().int().min(1).max(100).optional().describe("References per page, from 1 to 100; defaults to 20")
|
|
7101
7760
|
},
|
|
7102
7761
|
get: {
|
|
7103
|
-
id:
|
|
7762
|
+
id: z19.string().min(1).describe("Secret Reference UUID or slug")
|
|
7104
7763
|
},
|
|
7105
7764
|
update: {
|
|
7106
|
-
id:
|
|
7107
|
-
name:
|
|
7108
|
-
description:
|
|
7765
|
+
id: z19.string().min(1).describe("Secret Reference UUID or slug"),
|
|
7766
|
+
name: z19.string().min(1).max(255).optional().describe("New human-readable name"),
|
|
7767
|
+
description: z19.string().max(1024).nullable().optional().describe("New description, or null to clear it"),
|
|
7109
7768
|
auth_config: updateAuthConfigSchema.optional().describe(
|
|
7110
7769
|
"Provide at least one changed authentication field to merge into the existing configuration; choose one AWS, Azure, or HashiCorp field family and do not mix families"
|
|
7111
7770
|
),
|
|
7112
|
-
secret_path:
|
|
7113
|
-
secret_key:
|
|
7771
|
+
secret_path: z19.string().max(1024).optional().describe("New path of the secret in the external secret manager"),
|
|
7772
|
+
secret_key: z19.string().max(255).nullable().optional().describe(
|
|
7114
7773
|
"New key within a structured secret, or null to use the whole value"
|
|
7115
7774
|
),
|
|
7116
|
-
allow_all_workspaces:
|
|
7775
|
+
allow_all_workspaces: z19.boolean().optional().describe(
|
|
7117
7776
|
"Whether every workspace may use this reference; cannot be true with allowed_workspaces"
|
|
7118
7777
|
),
|
|
7119
|
-
allowed_workspaces:
|
|
7778
|
+
allowed_workspaces: z19.array(z19.string()).min(1).optional().describe(
|
|
7120
7779
|
"Replacement list of workspace UUIDs or slugs allowed to use this reference; supplying it sets allow_all_workspaces=false"
|
|
7121
7780
|
),
|
|
7122
7781
|
tags: tagsSchema.nullable().optional().describe("Replacement string key-value tags, or null to clear them")
|
|
7123
7782
|
},
|
|
7124
7783
|
delete: {
|
|
7125
|
-
id:
|
|
7784
|
+
id: z19.string().min(1).describe("Secret Reference UUID or slug")
|
|
7126
7785
|
}
|
|
7127
7786
|
};
|
|
7128
7787
|
function validateWorkspaceAccess(value) {
|
|
@@ -7321,29 +7980,29 @@ function registerSecretReferencesTools(server, service) {
|
|
|
7321
7980
|
}
|
|
7322
7981
|
|
|
7323
7982
|
// src/tools/tracing.tools.ts
|
|
7324
|
-
import { z as
|
|
7983
|
+
import { z as z20 } from "zod";
|
|
7325
7984
|
var TRACING_TOOL_SCHEMAS = {
|
|
7326
7985
|
createFeedback: {
|
|
7327
|
-
trace_id:
|
|
7986
|
+
trace_id: z20.string().describe(
|
|
7328
7987
|
"The trace ID to associate the feedback with. This links feedback to a specific request/generation."
|
|
7329
7988
|
),
|
|
7330
|
-
value:
|
|
7989
|
+
value: z20.coerce.number().describe(
|
|
7331
7990
|
"Feedback value/rating. Common patterns: 1 for positive (thumbs up), 0 for negative (thumbs down), or use a scale like 1-5."
|
|
7332
7991
|
),
|
|
7333
|
-
weight:
|
|
7992
|
+
weight: z20.coerce.number().positive().optional().describe(
|
|
7334
7993
|
"Optional weighting factor for the feedback. Use to give more importance to certain feedback."
|
|
7335
7994
|
),
|
|
7336
|
-
metadata:
|
|
7995
|
+
metadata: z20.record(z20.string(), z20.unknown()).optional().describe(
|
|
7337
7996
|
"Optional custom metadata for categorization and analysis (e.g., feedback_source, category, user_segment)."
|
|
7338
7997
|
)
|
|
7339
7998
|
},
|
|
7340
7999
|
updateFeedback: {
|
|
7341
|
-
id:
|
|
7342
|
-
value:
|
|
8000
|
+
id: z20.string().describe("The unique identifier of the feedback to update"),
|
|
8001
|
+
value: z20.coerce.number().optional().describe(
|
|
7343
8002
|
"New feedback value/rating. Common patterns: 1 for positive, 0 for negative."
|
|
7344
8003
|
),
|
|
7345
|
-
weight:
|
|
7346
|
-
metadata:
|
|
8004
|
+
weight: z20.coerce.number().positive().optional().describe("New weighting factor for the feedback"),
|
|
8005
|
+
metadata: z20.record(z20.string(), z20.unknown()).optional().describe("New or updated custom metadata for the feedback")
|
|
7347
8006
|
}
|
|
7348
8007
|
};
|
|
7349
8008
|
function registerTracingTools(server, service) {
|
|
@@ -7399,77 +8058,77 @@ function registerTracingTools(server, service) {
|
|
|
7399
8058
|
}
|
|
7400
8059
|
|
|
7401
8060
|
// src/tools/users.tools.ts
|
|
7402
|
-
import { z as
|
|
8061
|
+
import { z as z21 } from "zod";
|
|
7403
8062
|
var USERS_TOOL_SCHEMAS = {
|
|
7404
8063
|
listAllUsers: {
|
|
7405
|
-
current_page:
|
|
7406
|
-
page_size:
|
|
8064
|
+
current_page: z21.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
8065
|
+
page_size: z21.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
7407
8066
|
},
|
|
7408
8067
|
inviteUser: {
|
|
7409
|
-
email:
|
|
7410
|
-
role:
|
|
8068
|
+
email: z21.string().email().describe("Email address of the user to invite"),
|
|
8069
|
+
role: z21.enum(["admin", "member"]).describe(
|
|
7411
8070
|
"Organization-level role: 'admin' for full access, 'member' for limited access"
|
|
7412
8071
|
),
|
|
7413
|
-
first_name:
|
|
7414
|
-
last_name:
|
|
7415
|
-
workspaces:
|
|
7416
|
-
|
|
7417
|
-
id:
|
|
8072
|
+
first_name: z21.string().optional().describe("User's first name"),
|
|
8073
|
+
last_name: z21.string().optional().describe("User's last name"),
|
|
8074
|
+
workspaces: z21.array(
|
|
8075
|
+
z21.object({
|
|
8076
|
+
id: z21.string().describe(
|
|
7418
8077
|
"Workspace ID/slug where the user will be granted access"
|
|
7419
8078
|
),
|
|
7420
|
-
role:
|
|
8079
|
+
role: z21.enum(["admin", "member", "manager"]).describe(
|
|
7421
8080
|
"Workspace-level role: 'admin' for full access, 'manager' for workspace management, 'member' for basic access"
|
|
7422
8081
|
)
|
|
7423
8082
|
})
|
|
7424
8083
|
).describe(
|
|
7425
8084
|
"List of workspaces and corresponding roles to grant to the user"
|
|
7426
8085
|
),
|
|
7427
|
-
workspace_api_key_details:
|
|
7428
|
-
name:
|
|
7429
|
-
expiry:
|
|
7430
|
-
metadata:
|
|
7431
|
-
scopes:
|
|
8086
|
+
workspace_api_key_details: z21.object({
|
|
8087
|
+
name: z21.string().optional().describe("Name of the API key to be created"),
|
|
8088
|
+
expiry: z21.string().optional().describe("Expiration date for the API key (ISO8601 format)"),
|
|
8089
|
+
metadata: z21.record(z21.string(), z21.string()).optional().describe("Additional metadata key-value pairs for the API key"),
|
|
8090
|
+
scopes: z21.array(z21.string()).describe("List of permission scopes for the API key")
|
|
7432
8091
|
}).optional().describe("Optional API key to be created for the user")
|
|
7433
8092
|
},
|
|
7434
8093
|
getUserStats: {
|
|
7435
|
-
time_of_generation_min:
|
|
8094
|
+
time_of_generation_min: z21.string().describe(
|
|
7436
8095
|
"Start time for the analytics period (ISO8601 format, e.g., '2024-01-01T00:00:00Z')"
|
|
7437
8096
|
),
|
|
7438
|
-
time_of_generation_max:
|
|
8097
|
+
time_of_generation_max: z21.string().describe(
|
|
7439
8098
|
"End time for the analytics period (ISO8601 format, e.g., '2024-02-01T00:00:00Z')"
|
|
7440
8099
|
),
|
|
7441
|
-
total_units_min:
|
|
7442
|
-
total_units_max:
|
|
7443
|
-
cost_min:
|
|
7444
|
-
cost_max:
|
|
7445
|
-
status_code:
|
|
7446
|
-
virtual_keys:
|
|
7447
|
-
page_size:
|
|
8100
|
+
total_units_min: z21.coerce.number().positive().optional().describe("Minimum number of total tokens to filter by"),
|
|
8101
|
+
total_units_max: z21.coerce.number().positive().optional().describe("Maximum number of total tokens to filter by"),
|
|
8102
|
+
cost_min: z21.coerce.number().positive().optional().describe("Minimum cost in cents to filter by"),
|
|
8103
|
+
cost_max: z21.coerce.number().positive().optional().describe("Maximum cost in cents to filter by"),
|
|
8104
|
+
status_code: z21.string().optional().describe("Filter by specific HTTP status codes (comma-separated)"),
|
|
8105
|
+
virtual_keys: z21.string().optional().describe("Filter by specific virtual key slugs (comma-separated)"),
|
|
8106
|
+
page_size: z21.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
7448
8107
|
},
|
|
7449
8108
|
getUser: {
|
|
7450
|
-
user_id:
|
|
8109
|
+
user_id: z21.string().describe("The user ID to retrieve")
|
|
7451
8110
|
},
|
|
7452
8111
|
updateUser: {
|
|
7453
|
-
user_id:
|
|
7454
|
-
first_name:
|
|
7455
|
-
last_name:
|
|
7456
|
-
role:
|
|
8112
|
+
user_id: z21.string().describe("The user ID to update"),
|
|
8113
|
+
first_name: z21.string().optional().describe("New first name"),
|
|
8114
|
+
last_name: z21.string().optional().describe("New last name"),
|
|
8115
|
+
role: z21.enum(["admin", "member"]).optional().describe("New organization-level role")
|
|
7457
8116
|
},
|
|
7458
8117
|
deleteUser: {
|
|
7459
|
-
user_id:
|
|
8118
|
+
user_id: z21.string().describe("The user ID to delete")
|
|
7460
8119
|
},
|
|
7461
8120
|
listUserInvites: {
|
|
7462
|
-
current_page:
|
|
7463
|
-
page_size:
|
|
8121
|
+
current_page: z21.coerce.number().int().positive().optional().describe("Page number for pagination"),
|
|
8122
|
+
page_size: z21.coerce.number().int().positive().max(100).optional().describe("Number of results per page (max 100)")
|
|
7464
8123
|
},
|
|
7465
8124
|
getUserInvite: {
|
|
7466
|
-
invite_id:
|
|
8125
|
+
invite_id: z21.string().describe("The invite ID to retrieve")
|
|
7467
8126
|
},
|
|
7468
8127
|
deleteUserInvite: {
|
|
7469
|
-
invite_id:
|
|
8128
|
+
invite_id: z21.string().describe("The invite ID to delete")
|
|
7470
8129
|
},
|
|
7471
8130
|
resendUserInvite: {
|
|
7472
|
-
invite_id:
|
|
8131
|
+
invite_id: z21.string().describe("The invite ID to resend")
|
|
7473
8132
|
}
|
|
7474
8133
|
};
|
|
7475
8134
|
function formatUser(user) {
|
|
@@ -7695,59 +8354,97 @@ function registerUsersTools(server, service) {
|
|
|
7695
8354
|
}
|
|
7696
8355
|
|
|
7697
8356
|
// src/tools/workspaces.tools.ts
|
|
7698
|
-
import { z as
|
|
8357
|
+
import { z as z22 } from "zod";
|
|
8358
|
+
var scimWorkspaceMappingBaseShape = {
|
|
8359
|
+
workspace_id: z22.string().describe("Portkey workspace ID that the SCIM group should access"),
|
|
8360
|
+
role: z22.enum(["admin", "member", "manager"]).describe("Workspace role automatically granted to group members")
|
|
8361
|
+
};
|
|
8362
|
+
var createScimWorkspaceMappingInputSchema = z22.object({
|
|
8363
|
+
...scimWorkspaceMappingBaseShape,
|
|
8364
|
+
scim_group_id: z22.string().min(1).optional().describe(
|
|
8365
|
+
"Existing identity-provider SCIM group ID; provide this or scim_group_name, but not both"
|
|
8366
|
+
),
|
|
8367
|
+
scim_group_name: z22.string().min(1).optional().describe(
|
|
8368
|
+
"Existing SCIM group display name; provide this or scim_group_id, but not both"
|
|
8369
|
+
)
|
|
8370
|
+
}).superRefine((input, context) => {
|
|
8371
|
+
if (Boolean(input.scim_group_id) === Boolean(input.scim_group_name)) {
|
|
8372
|
+
context.addIssue({
|
|
8373
|
+
code: "custom",
|
|
8374
|
+
path: ["scim_group_id"],
|
|
8375
|
+
message: "Provide exactly one of scim_group_id or scim_group_name"
|
|
8376
|
+
});
|
|
8377
|
+
}
|
|
8378
|
+
});
|
|
7699
8379
|
var WORKSPACES_TOOL_SCHEMAS = {
|
|
7700
8380
|
listWorkspaces: {
|
|
7701
|
-
page_size:
|
|
7702
|
-
current_page:
|
|
8381
|
+
page_size: z22.coerce.number().int().positive().max(100).optional().describe("Number of workspaces to return per page (max 100)"),
|
|
8382
|
+
current_page: z22.coerce.number().int().positive().optional().describe("Page number to retrieve when results are paginated")
|
|
7703
8383
|
},
|
|
7704
8384
|
getWorkspace: {
|
|
7705
|
-
workspace_id:
|
|
8385
|
+
workspace_id: z22.string().describe(
|
|
7706
8386
|
"The unique identifier of the workspace to retrieve. This can be found in the workspace's URL or from the list_workspaces tool response"
|
|
7707
8387
|
)
|
|
7708
8388
|
},
|
|
7709
8389
|
createWorkspace: {
|
|
7710
|
-
name:
|
|
7711
|
-
slug:
|
|
7712
|
-
description:
|
|
7713
|
-
is_default:
|
|
7714
|
-
metadata:
|
|
8390
|
+
name: z22.string().describe("Name of the workspace"),
|
|
8391
|
+
slug: z22.string().optional().describe("URL-friendly slug (auto-generated if not provided)"),
|
|
8392
|
+
description: z22.string().optional().describe("Description of the workspace"),
|
|
8393
|
+
is_default: z22.coerce.number().optional().describe("Set as default workspace (1 = yes, 0 = no)"),
|
|
8394
|
+
metadata: z22.record(z22.string(), z22.string()).optional().describe("Custom metadata key-value pairs")
|
|
7715
8395
|
},
|
|
7716
8396
|
updateWorkspace: {
|
|
7717
|
-
workspace_id:
|
|
7718
|
-
name:
|
|
7719
|
-
slug:
|
|
7720
|
-
description:
|
|
7721
|
-
is_default:
|
|
7722
|
-
metadata:
|
|
8397
|
+
workspace_id: z22.string().describe("The workspace ID to update"),
|
|
8398
|
+
name: z22.string().optional().describe("New name for the workspace"),
|
|
8399
|
+
slug: z22.string().optional().describe("New slug for the workspace"),
|
|
8400
|
+
description: z22.string().optional().describe("New description"),
|
|
8401
|
+
is_default: z22.coerce.number().optional().describe("Set as default workspace (1 = yes, 0 = no)"),
|
|
8402
|
+
metadata: z22.record(z22.string(), z22.string()).optional().describe("New metadata key-value pairs")
|
|
7723
8403
|
},
|
|
7724
8404
|
deleteWorkspace: {
|
|
7725
|
-
workspace_id:
|
|
8405
|
+
workspace_id: z22.string().describe("The workspace ID to delete")
|
|
7726
8406
|
},
|
|
7727
8407
|
addWorkspaceMember: {
|
|
7728
|
-
workspace_id:
|
|
7729
|
-
user_id:
|
|
8408
|
+
workspace_id: z22.string().describe("The workspace ID to add the member to"),
|
|
8409
|
+
user_id: z22.string().uuid(
|
|
7730
8410
|
"user_id must be a valid UUID (use list_all_users to find user IDs)"
|
|
7731
8411
|
).describe(
|
|
7732
8412
|
"The user ID to add (must be a valid UUID from list_all_users, not an email address)"
|
|
7733
8413
|
),
|
|
7734
|
-
role:
|
|
8414
|
+
role: z22.enum(["admin", "member", "manager"]).describe("Role in the workspace")
|
|
7735
8415
|
},
|
|
7736
8416
|
listWorkspaceMembers: {
|
|
7737
|
-
workspace_id:
|
|
8417
|
+
workspace_id: z22.string().describe("The workspace ID to list members for")
|
|
7738
8418
|
},
|
|
7739
8419
|
getWorkspaceMember: {
|
|
7740
|
-
workspace_id:
|
|
7741
|
-
user_id:
|
|
8420
|
+
workspace_id: z22.string().describe("The workspace ID"),
|
|
8421
|
+
user_id: z22.string().describe("The user ID to retrieve")
|
|
7742
8422
|
},
|
|
7743
8423
|
updateWorkspaceMember: {
|
|
7744
|
-
workspace_id:
|
|
7745
|
-
user_id:
|
|
7746
|
-
role:
|
|
8424
|
+
workspace_id: z22.string().describe("The workspace ID"),
|
|
8425
|
+
user_id: z22.string().describe("The user ID to update"),
|
|
8426
|
+
role: z22.enum(["admin", "member", "manager"]).describe("New role in the workspace")
|
|
7747
8427
|
},
|
|
7748
8428
|
removeWorkspaceMember: {
|
|
7749
|
-
workspace_id:
|
|
7750
|
-
user_id:
|
|
8429
|
+
workspace_id: z22.string().describe("The workspace ID"),
|
|
8430
|
+
user_id: z22.string().describe("The user ID to remove")
|
|
8431
|
+
},
|
|
8432
|
+
listScimWorkspaceMappings: {
|
|
8433
|
+
workspace_id: z22.string().optional().describe("Return only mappings for this Portkey workspace ID"),
|
|
8434
|
+
scim_group_id: z22.string().optional().describe(
|
|
8435
|
+
"Return only mappings for this identity-provider SCIM group ID"
|
|
8436
|
+
),
|
|
8437
|
+
role: z22.enum(["admin", "member", "manager"]).optional().describe("Return only mappings that grant this workspace role"),
|
|
8438
|
+
page: z22.coerce.number().int().nonnegative().optional().describe("Zero-based results page to retrieve; the first page is 0"),
|
|
8439
|
+
page_size: z22.coerce.number().int().positive().max(100).optional().describe("Mappings per page, from 1 through 100")
|
|
8440
|
+
},
|
|
8441
|
+
deleteScimWorkspaceMapping: {
|
|
8442
|
+
mapping_id: z22.string().describe("SCIM workspace mapping ID from list_scim_workspace_mappings")
|
|
8443
|
+
},
|
|
8444
|
+
listScimGroups: {
|
|
8445
|
+
search: z22.string().optional().describe("Case-insensitive text to match against SCIM group names"),
|
|
8446
|
+
page: z22.coerce.number().int().nonnegative().optional().describe("Zero-based results page to retrieve; the first page is 0"),
|
|
8447
|
+
page_size: z22.coerce.number().int().positive().max(100).optional().describe("SCIM groups per page, from 1 through 100")
|
|
7751
8448
|
}
|
|
7752
8449
|
};
|
|
7753
8450
|
function formatWorkspaceDefaults(defaults) {
|
|
@@ -7794,6 +8491,114 @@ function formatWorkspaceDetail(workspace) {
|
|
|
7794
8491
|
};
|
|
7795
8492
|
}
|
|
7796
8493
|
function registerWorkspacesTools(server, service) {
|
|
8494
|
+
server.tool(
|
|
8495
|
+
"list_scim_workspace_mappings",
|
|
8496
|
+
"List identity-provider SCIM group mappings that automatically grant Portkey workspace roles. Use it to audit provisioned access or obtain mapping_id before delete_scim_workspace_mapping; filter by workspace, group, or role and page through large directories. This reads mappings only and does not query individual workspace members.",
|
|
8497
|
+
WORKSPACES_TOOL_SCHEMAS.listScimWorkspaceMappings,
|
|
8498
|
+
{
|
|
8499
|
+
title: "List SCIM Workspace Mappings",
|
|
8500
|
+
readOnlyHint: true,
|
|
8501
|
+
destructiveHint: false,
|
|
8502
|
+
idempotentHint: true,
|
|
8503
|
+
openWorldHint: true
|
|
8504
|
+
},
|
|
8505
|
+
async (params) => ({
|
|
8506
|
+
content: [
|
|
8507
|
+
{
|
|
8508
|
+
type: "text",
|
|
8509
|
+
text: JSON.stringify(
|
|
8510
|
+
await service.workspaces.listScimWorkspaceMappings(params)
|
|
8511
|
+
)
|
|
8512
|
+
}
|
|
8513
|
+
]
|
|
8514
|
+
})
|
|
8515
|
+
);
|
|
8516
|
+
server.registerTool(
|
|
8517
|
+
"create_scim_workspace_mapping",
|
|
8518
|
+
{
|
|
8519
|
+
description: "Map one identity-provider SCIM group to a Portkey workspace role so current and future group members receive access automatically. Provide exactly one of scim_group_id or scim_group_name; a name can pre-create the Portkey SCIM group before the IdP provisions it. Use list_scim_groups to discover existing groups and list_workspaces for the workspace ID. This changes access provisioning and is distinct from add_workspace_member, which grants one user directly.",
|
|
8520
|
+
inputSchema: createScimWorkspaceMappingInputSchema,
|
|
8521
|
+
annotations: {
|
|
8522
|
+
title: "Create SCIM Workspace Mapping",
|
|
8523
|
+
readOnlyHint: false,
|
|
8524
|
+
destructiveHint: false,
|
|
8525
|
+
idempotentHint: false,
|
|
8526
|
+
openWorldHint: true
|
|
8527
|
+
}
|
|
8528
|
+
},
|
|
8529
|
+
async (params) => {
|
|
8530
|
+
let request;
|
|
8531
|
+
if (params.scim_group_id !== void 0) {
|
|
8532
|
+
request = {
|
|
8533
|
+
workspace_id: params.workspace_id,
|
|
8534
|
+
role: params.role,
|
|
8535
|
+
scim_group_id: params.scim_group_id
|
|
8536
|
+
};
|
|
8537
|
+
} else if (params.scim_group_name !== void 0) {
|
|
8538
|
+
request = {
|
|
8539
|
+
workspace_id: params.workspace_id,
|
|
8540
|
+
role: params.role,
|
|
8541
|
+
scim_group_name: params.scim_group_name
|
|
8542
|
+
};
|
|
8543
|
+
} else {
|
|
8544
|
+
throw new Error(
|
|
8545
|
+
"Provide exactly one of scim_group_id or scim_group_name"
|
|
8546
|
+
);
|
|
8547
|
+
}
|
|
8548
|
+
const result = await service.workspaces.createScimWorkspaceMapping(request);
|
|
8549
|
+
return {
|
|
8550
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
8551
|
+
};
|
|
8552
|
+
}
|
|
8553
|
+
);
|
|
8554
|
+
server.tool(
|
|
8555
|
+
"delete_scim_workspace_mapping",
|
|
8556
|
+
"Delete a SCIM group-to-workspace mapping by mapping_id and stop future group updates from affecting that workspace. Existing provisioned members remain in the workspace and must be managed separately. Inspect list_scim_workspace_mappings first; this does not delete the identity-provider group or the Portkey workspace.",
|
|
8557
|
+
WORKSPACES_TOOL_SCHEMAS.deleteScimWorkspaceMapping,
|
|
8558
|
+
{
|
|
8559
|
+
title: "Delete SCIM Workspace Mapping",
|
|
8560
|
+
readOnlyHint: false,
|
|
8561
|
+
destructiveHint: true,
|
|
8562
|
+
idempotentHint: true,
|
|
8563
|
+
openWorldHint: true
|
|
8564
|
+
},
|
|
8565
|
+
async (params) => {
|
|
8566
|
+
const result = await service.workspaces.deleteScimWorkspaceMapping(
|
|
8567
|
+
params.mapping_id
|
|
8568
|
+
);
|
|
8569
|
+
return {
|
|
8570
|
+
content: [
|
|
8571
|
+
{
|
|
8572
|
+
type: "text",
|
|
8573
|
+
text: JSON.stringify({
|
|
8574
|
+
message: `Deleted SCIM workspace mapping "${params.mapping_id}"`,
|
|
8575
|
+
...result
|
|
8576
|
+
})
|
|
8577
|
+
}
|
|
8578
|
+
]
|
|
8579
|
+
};
|
|
8580
|
+
}
|
|
8581
|
+
);
|
|
8582
|
+
server.tool(
|
|
8583
|
+
"list_scim_groups",
|
|
8584
|
+
"Search and page through identity-provider groups synchronized to Portkey over SCIM. Use this to resolve a group ID or exact display name before create_scim_workspace_mapping; it reads directory groups only and does not show their workspace mappings or individual members.",
|
|
8585
|
+
WORKSPACES_TOOL_SCHEMAS.listScimGroups,
|
|
8586
|
+
{
|
|
8587
|
+
title: "List SCIM Groups",
|
|
8588
|
+
readOnlyHint: true,
|
|
8589
|
+
destructiveHint: false,
|
|
8590
|
+
idempotentHint: true,
|
|
8591
|
+
openWorldHint: true
|
|
8592
|
+
},
|
|
8593
|
+
async (params) => ({
|
|
8594
|
+
content: [
|
|
8595
|
+
{
|
|
8596
|
+
type: "text",
|
|
8597
|
+
text: JSON.stringify(await service.workspaces.listScimGroups(params))
|
|
8598
|
+
}
|
|
8599
|
+
]
|
|
8600
|
+
})
|
|
8601
|
+
);
|
|
7797
8602
|
server.tool(
|
|
7798
8603
|
"list_workspaces",
|
|
7799
8604
|
"List workspaces with id, name, slug, default settings, and timestamps. Use this to find a workspace_id before get_workspace, update_workspace, add_workspace_member, or remove_workspace_member.",
|
|
@@ -8100,7 +8905,25 @@ var ENTERPRISE_GATED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
8100
8905
|
"list_all_users",
|
|
8101
8906
|
"get_user",
|
|
8102
8907
|
"list_user_invites",
|
|
8103
|
-
"get_user_stats"
|
|
8908
|
+
"get_user_stats",
|
|
8909
|
+
"get_organisation_defaults",
|
|
8910
|
+
"update_organisation_defaults",
|
|
8911
|
+
"list_input_guardrail_workspace_exclusions",
|
|
8912
|
+
"update_input_guardrail_workspace_exclusions",
|
|
8913
|
+
"list_output_guardrail_workspace_exclusions",
|
|
8914
|
+
"update_output_guardrail_workspace_exclusions",
|
|
8915
|
+
"create_log_export",
|
|
8916
|
+
"list_log_exports",
|
|
8917
|
+
"get_log_export",
|
|
8918
|
+
"start_log_export",
|
|
8919
|
+
"cancel_log_export",
|
|
8920
|
+
"download_log_export",
|
|
8921
|
+
"update_log_export",
|
|
8922
|
+
"get_log_export_field_restrictions",
|
|
8923
|
+
"list_scim_workspace_mappings",
|
|
8924
|
+
"create_scim_workspace_mapping",
|
|
8925
|
+
"delete_scim_workspace_mapping",
|
|
8926
|
+
"list_scim_groups"
|
|
8104
8927
|
]);
|
|
8105
8928
|
var ENTERPRISE_GATED_DESCRIPTION_NOTE = "Enterprise-gated. Returns 403 on non-Enterprise Portkey plans.";
|
|
8106
8929
|
function isToolAnnotationsLike(value) {
|
|
@@ -8157,71 +8980,71 @@ function getToolErrorMessage(error) {
|
|
|
8157
8980
|
return String(error);
|
|
8158
8981
|
}
|
|
8159
8982
|
var STANDARD_TOOL_OUTPUT_SCHEMA = {
|
|
8160
|
-
ok:
|
|
8161
|
-
data:
|
|
8162
|
-
error:
|
|
8163
|
-
message:
|
|
8164
|
-
details:
|
|
8983
|
+
ok: z23.boolean().describe("Whether the tool call succeeded and returned structured data"),
|
|
8984
|
+
data: z23.unknown().optional().describe("Structured success payload when ok is true"),
|
|
8985
|
+
error: z23.object({
|
|
8986
|
+
message: z23.string().describe("Human-readable error message"),
|
|
8987
|
+
details: z23.unknown().optional().describe("Optional structured error details")
|
|
8165
8988
|
}).optional().describe("Structured error payload when ok is false")
|
|
8166
8989
|
};
|
|
8167
8990
|
var TOOL_SUCCESS_DATA_SCHEMAS = {
|
|
8168
|
-
rotate_api_key:
|
|
8169
|
-
message:
|
|
8170
|
-
warning:
|
|
8171
|
-
id:
|
|
8172
|
-
key:
|
|
8173
|
-
key_transition_expires_at:
|
|
8991
|
+
rotate_api_key: z23.object({
|
|
8992
|
+
message: z23.string().describe("Rotation confirmation"),
|
|
8993
|
+
warning: z23.string().describe("Required handling guidance for the one-time secret"),
|
|
8994
|
+
id: z23.string().uuid().describe("Rotated API key UUID"),
|
|
8995
|
+
key: z23.string().describe("New API key secret, returned only once"),
|
|
8996
|
+
key_transition_expires_at: z23.iso.datetime().describe("Time when the previous key stops working")
|
|
8174
8997
|
}),
|
|
8175
|
-
create_secret_reference:
|
|
8176
|
-
message:
|
|
8177
|
-
id:
|
|
8178
|
-
slug:
|
|
8998
|
+
create_secret_reference: z23.object({
|
|
8999
|
+
message: z23.string().describe("Creation confirmation"),
|
|
9000
|
+
id: z23.string().uuid().describe("New Secret Reference UUID"),
|
|
9001
|
+
slug: z23.string().describe("New Secret Reference slug")
|
|
8179
9002
|
}),
|
|
8180
|
-
list_secret_references:
|
|
8181
|
-
total:
|
|
8182
|
-
secret_references:
|
|
8183
|
-
|
|
8184
|
-
id:
|
|
8185
|
-
name:
|
|
8186
|
-
slug:
|
|
9003
|
+
list_secret_references: z23.object({
|
|
9004
|
+
total: z23.number().int().nonnegative().describe("Total matching references"),
|
|
9005
|
+
secret_references: z23.array(
|
|
9006
|
+
z23.object({
|
|
9007
|
+
id: z23.string().uuid().describe("Secret Reference UUID"),
|
|
9008
|
+
name: z23.string().describe("Human-readable name"),
|
|
9009
|
+
slug: z23.string().describe("Stable Secret Reference slug"),
|
|
8187
9010
|
manager_type: SecretManagerTypeSchema.describe(
|
|
8188
9011
|
"External secret manager type"
|
|
8189
9012
|
),
|
|
8190
|
-
status:
|
|
8191
|
-
created_at:
|
|
8192
|
-
last_updated_at:
|
|
9013
|
+
status: z23.literal("ACTIVE").describe("Current reference status"),
|
|
9014
|
+
created_at: z23.iso.datetime().describe("ISO 8601 creation timestamp"),
|
|
9015
|
+
last_updated_at: z23.iso.datetime().describe("ISO 8601 last-update timestamp")
|
|
8193
9016
|
})
|
|
8194
9017
|
).describe(
|
|
8195
9018
|
"Current page of Secret References without authentication values"
|
|
8196
9019
|
)
|
|
8197
9020
|
}),
|
|
8198
|
-
get_secret_reference:
|
|
8199
|
-
id:
|
|
8200
|
-
organisation_id:
|
|
8201
|
-
name:
|
|
8202
|
-
slug:
|
|
8203
|
-
description:
|
|
9021
|
+
get_secret_reference: z23.object({
|
|
9022
|
+
id: z23.string().uuid().describe("Secret Reference UUID"),
|
|
9023
|
+
organisation_id: z23.string().uuid().describe("Owning organisation UUID"),
|
|
9024
|
+
name: z23.string().describe("Human-readable name"),
|
|
9025
|
+
slug: z23.string().describe("Stable Secret Reference slug"),
|
|
9026
|
+
description: z23.string().nullable().describe("Reference description"),
|
|
8204
9027
|
manager_type: SecretManagerTypeSchema.describe(
|
|
8205
9028
|
"External secret manager type"
|
|
8206
9029
|
),
|
|
8207
|
-
secret_path:
|
|
8208
|
-
secret_key:
|
|
8209
|
-
allow_all_workspaces:
|
|
8210
|
-
tags:
|
|
8211
|
-
status:
|
|
8212
|
-
created_by:
|
|
8213
|
-
created_at:
|
|
8214
|
-
last_updated_at:
|
|
8215
|
-
auth_config:
|
|
8216
|
-
object:
|
|
9030
|
+
secret_path: z23.string().describe("Path in the external secret manager"),
|
|
9031
|
+
secret_key: z23.string().nullable().describe("Selected key within a structured secret"),
|
|
9032
|
+
allow_all_workspaces: z23.boolean().describe("Whether all workspaces may use the reference"),
|
|
9033
|
+
tags: z23.record(z23.string(), z23.string()).nullable().describe("String metadata tags"),
|
|
9034
|
+
status: z23.literal("ACTIVE").describe("Current reference status"),
|
|
9035
|
+
created_by: z23.string().describe("Creator identifier"),
|
|
9036
|
+
created_at: z23.iso.datetime().describe("ISO 8601 creation timestamp"),
|
|
9037
|
+
last_updated_at: z23.iso.datetime().describe("ISO 8601 last-update timestamp"),
|
|
9038
|
+
auth_config: z23.record(z23.string(), z23.unknown()).describe("Authentication configuration with sensitive values redacted"),
|
|
9039
|
+
object: z23.literal("secret-reference").describe("Portkey object type")
|
|
8217
9040
|
}),
|
|
8218
|
-
update_secret_reference:
|
|
8219
|
-
message:
|
|
8220
|
-
success:
|
|
9041
|
+
update_secret_reference: z23.object({
|
|
9042
|
+
message: z23.string().describe("Update confirmation"),
|
|
9043
|
+
success: z23.literal(true).describe("Whether the update succeeded")
|
|
8221
9044
|
}),
|
|
8222
|
-
delete_secret_reference:
|
|
8223
|
-
message:
|
|
8224
|
-
success:
|
|
9045
|
+
delete_secret_reference: z23.object({
|
|
9046
|
+
message: z23.string().describe("Deletion confirmation"),
|
|
9047
|
+
success: z23.literal(true).describe("Whether the deletion succeeded")
|
|
8225
9048
|
})
|
|
8226
9049
|
};
|
|
8227
9050
|
function getToolOutputSchema(toolName) {
|
|
@@ -8366,6 +9189,36 @@ function createSafeToolServer(server) {
|
|
|
8366
9189
|
args
|
|
8367
9190
|
);
|
|
8368
9191
|
};
|
|
9192
|
+
safeServer.registerTool = ((name, config, callback) => {
|
|
9193
|
+
const description = augmentToolDescription(
|
|
9194
|
+
name,
|
|
9195
|
+
typeof config.description === "string" ? config.description : void 0
|
|
9196
|
+
);
|
|
9197
|
+
const annotations = {
|
|
9198
|
+
...inferToolAnnotations(name),
|
|
9199
|
+
...isToolAnnotationsLike(config.annotations) ? config.annotations : {}
|
|
9200
|
+
};
|
|
9201
|
+
const wrappedCallback = wrapToolCallback(name, callback);
|
|
9202
|
+
if (originalRegisterTool) {
|
|
9203
|
+
return callOriginalRegisterTool(
|
|
9204
|
+
name,
|
|
9205
|
+
{
|
|
9206
|
+
...config,
|
|
9207
|
+
...description === void 0 ? {} : { description },
|
|
9208
|
+
outputSchema: config.outputSchema ?? getToolOutputSchema(name),
|
|
9209
|
+
annotations
|
|
9210
|
+
},
|
|
9211
|
+
wrappedCallback
|
|
9212
|
+
);
|
|
9213
|
+
}
|
|
9214
|
+
const legacyArguments = [
|
|
9215
|
+
...description === void 0 ? [] : [description],
|
|
9216
|
+
...config.inputSchema === void 0 ? [] : [config.inputSchema],
|
|
9217
|
+
annotations,
|
|
9218
|
+
wrappedCallback
|
|
9219
|
+
];
|
|
9220
|
+
return callOriginalTool(name, ...legacyArguments);
|
|
9221
|
+
});
|
|
8369
9222
|
safeServer.tool = ((name, ...rest) => {
|
|
8370
9223
|
const maybeCallback = rest.at(-1);
|
|
8371
9224
|
if (typeof maybeCallback !== "function") {
|
|
@@ -8485,8 +9338,8 @@ function registerServerPromptsAndResources(server) {
|
|
|
8485
9338
|
title: "Plan Portkey Admin Workflow",
|
|
8486
9339
|
description: "Create a concise, safe plan for a Portkey Admin API task using this MCP server.",
|
|
8487
9340
|
argsSchema: {
|
|
8488
|
-
task:
|
|
8489
|
-
area:
|
|
9341
|
+
task: z24.string().min(1).max(500).describe("Portkey admin task to plan, such as promoting a prompt"),
|
|
9342
|
+
area: z24.string().max(80).optional().describe(
|
|
8490
9343
|
"Optional Portkey area, such as prompts, analytics, configs, or users"
|
|
8491
9344
|
)
|
|
8492
9345
|
}
|