portkey-admin-mcp 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/server.js CHANGED
@@ -1453,9 +1453,6 @@ var TracingService = class extends BaseService {
1453
1453
  data
1454
1454
  );
1455
1455
  }
1456
- async getTrace(id) {
1457
- return this.get(`/logs/${this.encodePathSegment(id)}`);
1458
- }
1459
1456
  };
1460
1457
 
1461
1458
  // src/services/users.service.ts
@@ -1689,23 +1686,99 @@ var baseAnalyticsSchema = {
1689
1686
  prompt_token_max: z.coerce.number().positive().optional().describe("Maximum number of prompt tokens"),
1690
1687
  completion_token_min: z.coerce.number().positive().optional().describe("Minimum number of completion tokens"),
1691
1688
  completion_token_max: z.coerce.number().positive().optional().describe("Maximum number of completion tokens"),
1692
- status_code: z.string().optional().describe("Filter by specific HTTP status codes (comma-separated)"),
1689
+ status_code: z.string().optional().describe(
1690
+ "Legacy Portkey query param for HTTP status codes. Comma-separated string; prefer status_codes for structured inputs."
1691
+ ),
1693
1692
  weighted_feedback_min: z.coerce.number().min(-10).max(10).optional().describe("Minimum weighted feedback score (-10 to 10)"),
1694
1693
  weighted_feedback_max: z.coerce.number().min(-10).max(10).optional().describe("Maximum weighted feedback score (-10 to 10)"),
1695
- virtual_keys: z.string().optional().describe("Filter by specific virtual key slugs (comma-separated)"),
1696
- configs: z.string().optional().describe("Filter by specific config slugs (comma-separated)"),
1694
+ virtual_keys: z.string().optional().describe(
1695
+ "Legacy Portkey query param for virtual key slugs. Comma-separated string; prefer virtual_key_slugs for structured inputs."
1696
+ ),
1697
+ configs: z.string().optional().describe(
1698
+ "Legacy Portkey query param for config slugs. Comma-separated string; prefer config_slugs for structured inputs."
1699
+ ),
1700
+ status_codes: z.array(z.string()).optional().describe(
1701
+ "Structured alias for status_code. Use an array of HTTP status codes; normalized to the legacy comma-separated Portkey query param."
1702
+ ),
1703
+ virtual_key_slugs: z.array(z.string()).optional().describe(
1704
+ "Structured alias for virtual_keys. Use an array of virtual key slugs; normalized to the legacy comma-separated Portkey query param."
1705
+ ),
1706
+ config_slugs: z.array(z.string()).optional().describe(
1707
+ "Structured alias for configs. Use an array of config slugs; normalized to the legacy comma-separated Portkey query param."
1708
+ ),
1697
1709
  workspace_slug: z.string().optional().describe("Filter by specific workspace"),
1698
- api_key_ids: z.string().optional().describe("Filter by specific API key UUIDs (comma-separated)"),
1710
+ api_key_ids: z.preprocess((value) => {
1711
+ if (value == null) {
1712
+ return value;
1713
+ }
1714
+ if (Array.isArray(value)) {
1715
+ return value.map((item) => String(item)).join(",");
1716
+ }
1717
+ return value;
1718
+ }, z.string().optional()).describe(
1719
+ "Legacy Portkey query param for API key UUIDs. Comma-separated string; request_analytics also accepts an array and normalizes it to this form."
1720
+ ),
1699
1721
  metadata: z.string().optional().describe(
1700
- `Stringified JSON object for metadata filtering, e.g. '{"env":"prod","app":"myapp"}'.`
1722
+ `Legacy Portkey query param for metadata filtering. Stringified JSON object, e.g. '{"env":"prod","app":"myapp"}'; prefer metadata_filter for structured inputs.`
1701
1723
  ),
1702
1724
  ai_org_model: z.string().optional().describe(
1703
- "Filter by provider and model, format: 'provider__model' with double underscore, e.g. 'openai__gpt-4' or 'anthropic__claude-3-opus'. Comma-separated for multiple."
1725
+ "Legacy Portkey query param for provider/model pairs. Format: 'provider__model' with double underscore, e.g. 'openai__gpt-4' or 'anthropic__claude-3-opus'. Comma-separated string; prefer provider_models for structured inputs."
1726
+ ),
1727
+ provider_models: z.array(z.string()).optional().describe(
1728
+ "Structured alias for ai_org_model. Use provider__model strings in an array; normalized to the legacy comma-separated Portkey query param."
1729
+ ),
1730
+ trace_id: z.string().optional().describe(
1731
+ "Legacy Portkey query param for trace IDs. Comma-separated string; prefer trace_ids for structured inputs."
1732
+ ),
1733
+ trace_ids: z.array(z.string()).optional().describe(
1734
+ "Structured alias for trace_id. Use an array of trace IDs; normalized to the legacy comma-separated Portkey query param."
1735
+ ),
1736
+ span_id: z.string().optional().describe(
1737
+ "Legacy Portkey query param for span IDs. Comma-separated string; prefer span_ids for structured inputs."
1738
+ ),
1739
+ span_ids: z.array(z.string()).optional().describe(
1740
+ "Structured alias for span_id. Use an array of span IDs; normalized to the legacy comma-separated Portkey query param."
1741
+ ),
1742
+ metadata_filter: z.record(z.string(), z.unknown()).optional().describe(
1743
+ "Structured alias for metadata. Use an object such as { env: 'prod' }; normalized to a JSON string before the request is sent."
1704
1744
  ),
1705
- trace_id: z.string().optional().describe("Filter by trace IDs (comma-separated)"),
1706
- span_id: z.string().optional().describe("Filter by span IDs (comma-separated)"),
1707
1745
  prompt_slug: z.string().optional().describe("Filter by prompt slug")
1708
1746
  };
1747
+ var requestAnalyticsSchema = {
1748
+ ...baseAnalyticsSchema,
1749
+ status_codes: z.array(z.string()).optional().describe(
1750
+ "Structured alias for status_code. Use an array of HTTP status codes; normalized to the legacy comma-separated Portkey query param."
1751
+ ),
1752
+ virtual_key_slugs: z.array(z.string()).optional().describe(
1753
+ "Structured alias for virtual_keys. Use an array of virtual key slugs; normalized to the legacy comma-separated Portkey query param."
1754
+ ),
1755
+ config_slugs: z.array(z.string()).optional().describe(
1756
+ "Structured alias for configs. Use an array of config slugs; normalized to the legacy comma-separated Portkey query param."
1757
+ ),
1758
+ api_key_ids: z.preprocess((value) => {
1759
+ if (value == null) {
1760
+ return value;
1761
+ }
1762
+ if (Array.isArray(value)) {
1763
+ return value.map((item) => String(item)).join(",");
1764
+ }
1765
+ return value;
1766
+ }, z.string().optional()).describe(
1767
+ "API key UUIDs. Accepts the legacy comma-separated string or a structured array; normalized to the legacy Portkey query param before the request is sent."
1768
+ ),
1769
+ trace_ids: z.array(z.string()).optional().describe(
1770
+ "Structured alias for trace_id. Use an array of trace IDs; normalized to the legacy comma-separated Portkey query param."
1771
+ ),
1772
+ span_ids: z.array(z.string()).optional().describe(
1773
+ "Structured alias for span_id. Use an array of span IDs; normalized to the legacy comma-separated Portkey query param."
1774
+ ),
1775
+ provider_models: z.array(z.string()).optional().describe(
1776
+ "Structured alias for ai_org_model. Use provider__model strings in an array; normalized to the legacy comma-separated Portkey query param."
1777
+ ),
1778
+ metadata_filter: z.record(z.string(), z.unknown()).optional().describe(
1779
+ "Structured alias for metadata. Use an object such as { env: 'prod' }; normalized to a JSON string before the request is sent."
1780
+ )
1781
+ };
1709
1782
  var paginatedAnalyticsSchema = {
1710
1783
  ...baseAnalyticsSchema,
1711
1784
  current_page: z.coerce.number().positive().optional().describe("Page number for pagination"),
@@ -1732,13 +1805,88 @@ function formatGroupedAnalytics(analytics, groupLabel) {
1732
1805
  [groupLabel]: analytics.data
1733
1806
  };
1734
1807
  }
1808
+ function normalizeCommaSeparatedParam(value) {
1809
+ if (value == null) {
1810
+ return void 0;
1811
+ }
1812
+ if (Array.isArray(value)) {
1813
+ return value.map((item) => String(item)).join(",");
1814
+ }
1815
+ if (typeof value === "string") {
1816
+ return value;
1817
+ }
1818
+ return void 0;
1819
+ }
1820
+ function normalizeMetadataFilter(value) {
1821
+ if (value == null) {
1822
+ return void 0;
1823
+ }
1824
+ if (typeof value === "string") {
1825
+ return value;
1826
+ }
1827
+ if (typeof value === "object") {
1828
+ return JSON.stringify(value);
1829
+ }
1830
+ return void 0;
1831
+ }
1832
+ function normalizeAnalyticsParams(params) {
1833
+ const {
1834
+ status_codes,
1835
+ virtual_key_slugs,
1836
+ config_slugs,
1837
+ api_key_ids,
1838
+ trace_ids,
1839
+ span_ids,
1840
+ provider_models,
1841
+ metadata_filter,
1842
+ ...legacyParams
1843
+ } = params;
1844
+ const normalizedParams = {
1845
+ ...legacyParams
1846
+ };
1847
+ const statusCode = normalizeCommaSeparatedParam(status_codes) ?? normalizeCommaSeparatedParam(legacyParams.status_code);
1848
+ if (statusCode !== void 0) {
1849
+ normalizedParams.status_code = statusCode;
1850
+ }
1851
+ const virtualKeys = normalizeCommaSeparatedParam(virtual_key_slugs) ?? normalizeCommaSeparatedParam(legacyParams.virtual_keys);
1852
+ if (virtualKeys !== void 0) {
1853
+ normalizedParams.virtual_keys = virtualKeys;
1854
+ }
1855
+ const configs = normalizeCommaSeparatedParam(config_slugs) ?? normalizeCommaSeparatedParam(legacyParams.configs);
1856
+ if (configs !== void 0) {
1857
+ normalizedParams.configs = configs;
1858
+ }
1859
+ const apiKeyIds = normalizeCommaSeparatedParam(api_key_ids) ?? normalizeCommaSeparatedParam(legacyParams.api_key_ids);
1860
+ if (apiKeyIds !== void 0) {
1861
+ normalizedParams.api_key_ids = apiKeyIds;
1862
+ }
1863
+ const metadata = normalizeMetadataFilter(metadata_filter) ?? normalizeMetadataFilter(legacyParams.metadata);
1864
+ if (metadata !== void 0) {
1865
+ normalizedParams.metadata = metadata;
1866
+ }
1867
+ const providerModels = normalizeCommaSeparatedParam(provider_models) ?? normalizeCommaSeparatedParam(legacyParams.ai_org_model);
1868
+ if (providerModels !== void 0) {
1869
+ normalizedParams.ai_org_model = providerModels;
1870
+ }
1871
+ const traceId = normalizeCommaSeparatedParam(trace_ids) ?? normalizeCommaSeparatedParam(legacyParams.trace_id);
1872
+ if (traceId !== void 0) {
1873
+ normalizedParams.trace_id = traceId;
1874
+ }
1875
+ const spanId = normalizeCommaSeparatedParam(span_ids) ?? normalizeCommaSeparatedParam(legacyParams.span_id);
1876
+ if (spanId !== void 0) {
1877
+ normalizedParams.span_id = spanId;
1878
+ }
1879
+ return normalizedParams;
1880
+ }
1735
1881
  function registerAnalyticsTools(server, service) {
1736
1882
  server.tool(
1737
1883
  "get_cost_analytics",
1738
- "Retrieve detailed cost analytics data over time, including total costs and averages per request",
1884
+ "Returns time-series of total and average cost per request over the specified period. Use to track spending trends and identify cost spikes. Differs from get_token_analytics which measures token consumption, not monetary cost. Requires time_of_generation_min and time_of_generation_max.",
1739
1885
  baseAnalyticsSchema,
1740
1886
  async (params) => {
1741
- const analytics = await service.analytics.getCostAnalytics(params);
1887
+ const analytics = await service.analytics.getCostAnalytics(
1888
+ normalizeAnalyticsParams(params)
1889
+ );
1742
1890
  const dataPoints = analytics.data_points.map((point) => ({
1743
1891
  timestamp: point.timestamp,
1744
1892
  total_cost: point.total,
@@ -1766,10 +1914,12 @@ function registerAnalyticsTools(server, service) {
1766
1914
  );
1767
1915
  server.tool(
1768
1916
  "get_request_analytics",
1769
- "Retrieve request analytics as time-series data, showing total, successful, and failed requests over time",
1770
- baseAnalyticsSchema,
1917
+ "Returns time-series of total, successful, and failed request counts over the specified period. Use to monitor traffic volume and success/failure trends. Differs from get_error_analytics which only shows error counts. Requires time_of_generation_min and time_of_generation_max.",
1918
+ requestAnalyticsSchema,
1771
1919
  async (params) => {
1772
- const analytics = await service.analytics.getRequestAnalytics(params);
1920
+ const analytics = await service.analytics.getRequestAnalytics(
1921
+ normalizeAnalyticsParams(params)
1922
+ );
1773
1923
  const dataPoints = analytics.data_points.map((point) => ({
1774
1924
  timestamp: point.timestamp,
1775
1925
  total: point.total,
@@ -1799,10 +1949,12 @@ function registerAnalyticsTools(server, service) {
1799
1949
  );
1800
1950
  server.tool(
1801
1951
  "get_token_analytics",
1802
- "Retrieve token usage analytics as time-series data, showing total, prompt, and completion tokens over time",
1952
+ "Returns time-series of total, prompt, and completion token counts over the specified period. Use to track token consumption and identify usage patterns. Differs from get_cost_analytics which shows monetary cost, not token volume. Requires time_of_generation_min and time_of_generation_max.",
1803
1953
  baseAnalyticsSchema,
1804
1954
  async (params) => {
1805
- const analytics = await service.analytics.getTokenAnalytics(params);
1955
+ const analytics = await service.analytics.getTokenAnalytics(
1956
+ normalizeAnalyticsParams(params)
1957
+ );
1806
1958
  const dataPoints = analytics.data_points.map((point) => ({
1807
1959
  timestamp: point.timestamp,
1808
1960
  total: point.total,
@@ -1832,10 +1984,12 @@ function registerAnalyticsTools(server, service) {
1832
1984
  );
1833
1985
  server.tool(
1834
1986
  "get_latency_analytics",
1835
- "Retrieve latency analytics as time-series data, showing average, p50, p90, and p99 latency percentiles over time",
1987
+ "Returns time-series of avg, p50, p90, and p99 latency percentiles in ms over the specified period. Use to monitor response times and detect latency regressions. Differs from get_cache_hit_latency which only measures latency for cached responses. Requires time_of_generation_min and time_of_generation_max.",
1836
1988
  baseAnalyticsSchema,
1837
1989
  async (params) => {
1838
- const analytics = await service.analytics.getLatencyAnalytics(params);
1990
+ const analytics = await service.analytics.getLatencyAnalytics(
1991
+ normalizeAnalyticsParams(params)
1992
+ );
1839
1993
  const dataPoints = analytics.data_points.map((point) => ({
1840
1994
  timestamp: point.timestamp,
1841
1995
  avg: point.avg,
@@ -1867,10 +2021,12 @@ function registerAnalyticsTools(server, service) {
1867
2021
  );
1868
2022
  server.tool(
1869
2023
  "get_error_analytics",
1870
- "Retrieve error count analytics as time-series data, showing total error counts over time",
2024
+ "Returns time-series of total error counts over the specified period. Use for high-level error trend monitoring. For error breakdown by status code, use get_error_status_codes_analytics or get_error_stacks_analytics; for error rate as a percentage, use get_error_rate_analytics. Requires time_of_generation_min and time_of_generation_max.",
1871
2025
  baseAnalyticsSchema,
1872
2026
  async (params) => {
1873
- const analytics = await service.analytics.getErrorAnalytics(params);
2027
+ const analytics = await service.analytics.getErrorAnalytics(
2028
+ normalizeAnalyticsParams(params)
2029
+ );
1874
2030
  const dataPoints = analytics.data_points.map((point) => ({
1875
2031
  timestamp: point.timestamp,
1876
2032
  total_errors: point.total
@@ -1896,10 +2052,12 @@ function registerAnalyticsTools(server, service) {
1896
2052
  );
1897
2053
  server.tool(
1898
2054
  "get_error_rate_analytics",
1899
- "Retrieve error rate analytics as time-series data, showing the percentage of failed requests over time",
2055
+ "Returns time-series of error rate as a percentage of total requests over the specified period. Use to track reliability trends and SLA compliance. Differs from get_error_analytics which shows absolute error counts, not percentages. Requires time_of_generation_min and time_of_generation_max.",
1900
2056
  baseAnalyticsSchema,
1901
2057
  async (params) => {
1902
- const analytics = await service.analytics.getErrorRateAnalytics(params);
2058
+ const analytics = await service.analytics.getErrorRateAnalytics(
2059
+ normalizeAnalyticsParams(params)
2060
+ );
1903
2061
  const dataPoints = analytics.data_points.map((point) => ({
1904
2062
  timestamp: point.timestamp,
1905
2063
  error_rate_percent: point.rate
@@ -1925,10 +2083,12 @@ function registerAnalyticsTools(server, service) {
1925
2083
  );
1926
2084
  server.tool(
1927
2085
  "get_cache_hit_latency",
1928
- "Retrieve cache hit latency analytics as time-series data, showing total and average latency for cache hits over time",
2086
+ "Returns time-series of latency specifically for cache hits over the specified period. Use to evaluate cache performance and response speed for cached requests. Differs from get_latency_analytics which measures latency across all requests. Requires time_of_generation_min and time_of_generation_max.",
1929
2087
  baseAnalyticsSchema,
1930
2088
  async (params) => {
1931
- const analytics = await service.analytics.getCacheHitLatency(params);
2089
+ const analytics = await service.analytics.getCacheHitLatency(
2090
+ normalizeAnalyticsParams(params)
2091
+ );
1932
2092
  const dataPoints = analytics.data_points.map((point) => ({
1933
2093
  timestamp: point.timestamp,
1934
2094
  total: point.total,
@@ -1956,10 +2116,12 @@ function registerAnalyticsTools(server, service) {
1956
2116
  );
1957
2117
  server.tool(
1958
2118
  "get_cache_hit_rate",
1959
- "Retrieve cache hit rate analytics as time-series data, showing hit rate percentage, total hits, and misses over time",
2119
+ "Returns time-series of cache hit rate percentage, total hits, and misses over the specified period. Use to evaluate cache effectiveness and tune caching strategy. Unrelated to get_cache_hit_latency which measures speed of cached responses, not hit/miss ratio. Requires time_of_generation_min and time_of_generation_max.",
1960
2120
  baseAnalyticsSchema,
1961
2121
  async (params) => {
1962
- const analytics = await service.analytics.getCacheHitRate(params);
2122
+ const analytics = await service.analytics.getCacheHitRate(
2123
+ normalizeAnalyticsParams(params)
2124
+ );
1963
2125
  const dataPoints = analytics.data_points.map((point) => ({
1964
2126
  timestamp: point.timestamp,
1965
2127
  rate: point.rate,
@@ -1989,10 +2151,12 @@ function registerAnalyticsTools(server, service) {
1989
2151
  );
1990
2152
  server.tool(
1991
2153
  "get_users_analytics",
1992
- "Retrieve user activity analytics over time, showing active and new user counts",
2154
+ "Returns time-series of active and new user counts over the specified period. Use for user growth tracking and adoption metrics. Differs from get_user_requests_analytics which shows per-user request breakdown, and get_analytics_group_users which shows per-user cost/token data. Requires time_of_generation_min and time_of_generation_max.",
1993
2155
  baseAnalyticsSchema,
1994
2156
  async (params) => {
1995
- const analytics = await service.analytics.getUsersAnalytics(params);
2157
+ const analytics = await service.analytics.getUsersAnalytics(
2158
+ normalizeAnalyticsParams(params)
2159
+ );
1996
2160
  const dataPoints = analytics.data_points.map((point) => ({
1997
2161
  timestamp: point.timestamp,
1998
2162
  active_users: point.active_users,
@@ -2020,10 +2184,12 @@ function registerAnalyticsTools(server, service) {
2020
2184
  );
2021
2185
  server.tool(
2022
2186
  "get_error_stacks_analytics",
2023
- "Retrieve error analytics broken down by status code stacks over time",
2187
+ "Returns errors broken down by status code stacks (e.g., 429, 500, 502) over the specified period. Use to identify which error types are most common and how they trend. Differs from get_error_status_codes_analytics which shows unique code distribution rather than stacked/cumulative breakdown. Requires time_of_generation_min and time_of_generation_max.",
2024
2188
  baseAnalyticsSchema,
2025
2189
  async (params) => {
2026
- const analytics = await service.analytics.getErrorStacksAnalytics(params);
2190
+ const analytics = await service.analytics.getErrorStacksAnalytics(
2191
+ normalizeAnalyticsParams(params)
2192
+ );
2027
2193
  return {
2028
2194
  content: [
2029
2195
  {
@@ -2040,10 +2206,12 @@ function registerAnalyticsTools(server, service) {
2040
2206
  );
2041
2207
  server.tool(
2042
2208
  "get_error_status_codes_analytics",
2043
- "Retrieve unique error status code distribution analytics over time",
2209
+ "Returns distribution of unique HTTP error status codes over the specified period. Use to see which status codes are occurring and their frequency. Differs from get_error_stacks_analytics which shows stacked/cumulative error breakdown rather than individual code distribution. Requires time_of_generation_min and time_of_generation_max.",
2044
2210
  baseAnalyticsSchema,
2045
2211
  async (params) => {
2046
- const analytics = await service.analytics.getErrorStatusCodesAnalytics(params);
2212
+ const analytics = await service.analytics.getErrorStatusCodesAnalytics(
2213
+ normalizeAnalyticsParams(params)
2214
+ );
2047
2215
  return {
2048
2216
  content: [
2049
2217
  {
@@ -2060,10 +2228,12 @@ function registerAnalyticsTools(server, service) {
2060
2228
  );
2061
2229
  server.tool(
2062
2230
  "get_user_requests_analytics",
2063
- "Retrieve per-user request count analytics over time",
2231
+ "Returns per-user request count breakdown over the specified period. Use to identify heavy users and per-user traffic patterns. Differs from get_users_analytics which shows aggregate active/new user counts, not individual user breakdowns. Requires time_of_generation_min and time_of_generation_max.",
2064
2232
  baseAnalyticsSchema,
2065
2233
  async (params) => {
2066
- const analytics = await service.analytics.getUserRequestsAnalytics(params);
2234
+ const analytics = await service.analytics.getUserRequestsAnalytics(
2235
+ normalizeAnalyticsParams(params)
2236
+ );
2067
2237
  return {
2068
2238
  content: [
2069
2239
  {
@@ -2080,10 +2250,12 @@ function registerAnalyticsTools(server, service) {
2080
2250
  );
2081
2251
  server.tool(
2082
2252
  "get_rescued_requests_analytics",
2083
- "Retrieve analytics for requests rescued by retry or fallback strategies over time",
2253
+ "Returns time-series of requests saved by retry or fallback strategies over the specified period. Use to evaluate the effectiveness of your Portkey configs' resilience features. Only relevant if configs include retry or fallback targets. Requires time_of_generation_min and time_of_generation_max.",
2084
2254
  baseAnalyticsSchema,
2085
2255
  async (params) => {
2086
- const analytics = await service.analytics.getRescuedRequestsAnalytics(params);
2256
+ const analytics = await service.analytics.getRescuedRequestsAnalytics(
2257
+ normalizeAnalyticsParams(params)
2258
+ );
2087
2259
  return {
2088
2260
  content: [
2089
2261
  {
@@ -2100,10 +2272,12 @@ function registerAnalyticsTools(server, service) {
2100
2272
  );
2101
2273
  server.tool(
2102
2274
  "get_feedback_analytics",
2103
- "Retrieve feedback submission analytics over time",
2275
+ "Returns time-series of feedback submission counts over the specified period. Use to track feedback volume trends. For breakdown by model, use get_feedback_models_analytics; for score distribution, use get_feedback_scores_analytics; for weighted scores, use get_feedback_weighted_analytics. Requires time_of_generation_min and time_of_generation_max.",
2104
2276
  baseAnalyticsSchema,
2105
2277
  async (params) => {
2106
- const analytics = await service.analytics.getFeedbackAnalytics(params);
2278
+ const analytics = await service.analytics.getFeedbackAnalytics(
2279
+ normalizeAnalyticsParams(params)
2280
+ );
2107
2281
  return {
2108
2282
  content: [
2109
2283
  {
@@ -2120,10 +2294,12 @@ function registerAnalyticsTools(server, service) {
2120
2294
  );
2121
2295
  server.tool(
2122
2296
  "get_feedback_models_analytics",
2123
- "Retrieve feedback analytics grouped by AI model over time",
2297
+ "Returns feedback counts grouped by AI model over the specified period. Use to compare user satisfaction and feedback volume across different models. Differs from get_feedback_analytics which shows total volume without model breakdown. Requires time_of_generation_min and time_of_generation_max.",
2124
2298
  baseAnalyticsSchema,
2125
2299
  async (params) => {
2126
- const analytics = await service.analytics.getFeedbackModelsAnalytics(params);
2300
+ const analytics = await service.analytics.getFeedbackModelsAnalytics(
2301
+ normalizeAnalyticsParams(params)
2302
+ );
2127
2303
  return {
2128
2304
  content: [
2129
2305
  {
@@ -2140,10 +2316,12 @@ function registerAnalyticsTools(server, service) {
2140
2316
  );
2141
2317
  server.tool(
2142
2318
  "get_feedback_scores_analytics",
2143
- "Retrieve feedback score distribution analytics over time",
2319
+ "Returns distribution of raw feedback score values over the specified period. Use to understand score patterns (e.g., mostly positive vs mixed). Differs from get_feedback_weighted_analytics which applies weight factors for calibrated metrics. Requires time_of_generation_min and time_of_generation_max.",
2144
2320
  baseAnalyticsSchema,
2145
2321
  async (params) => {
2146
- const analytics = await service.analytics.getFeedbackScoresAnalytics(params);
2322
+ const analytics = await service.analytics.getFeedbackScoresAnalytics(
2323
+ normalizeAnalyticsParams(params)
2324
+ );
2147
2325
  return {
2148
2326
  content: [
2149
2327
  {
@@ -2160,10 +2338,12 @@ function registerAnalyticsTools(server, service) {
2160
2338
  );
2161
2339
  server.tool(
2162
2340
  "get_feedback_weighted_analytics",
2163
- "Retrieve weighted feedback analytics over time",
2341
+ "Returns weighted feedback scores over the specified period, applying the weight factor set during feedback creation. Use for calibrated quality metrics where different feedback types have different importance. Differs from get_feedback_scores_analytics which shows raw unweighted scores. Requires time_of_generation_min and time_of_generation_max.",
2164
2342
  baseAnalyticsSchema,
2165
2343
  async (params) => {
2166
- const analytics = await service.analytics.getFeedbackWeightedAnalytics(params);
2344
+ const analytics = await service.analytics.getFeedbackWeightedAnalytics(
2345
+ normalizeAnalyticsParams(params)
2346
+ );
2167
2347
  return {
2168
2348
  content: [
2169
2349
  {
@@ -2180,10 +2360,12 @@ function registerAnalyticsTools(server, service) {
2180
2360
  );
2181
2361
  server.tool(
2182
2362
  "get_analytics_group_users",
2183
- "Retrieve analytics data grouped by user with pagination",
2363
+ "Returns analytics data aggregated per user with pagination, showing each user's request count, cost, and token usage. Use for per-user billing, audit, or identifying top consumers. Differs from get_users_analytics which shows aggregate active/new user counts over time. Requires time_of_generation_min and time_of_generation_max.",
2184
2364
  paginatedAnalyticsSchema,
2185
2365
  async (params) => {
2186
- const analytics = await service.analytics.getAnalyticsGroupUsers(params);
2366
+ const analytics = await service.analytics.getAnalyticsGroupUsers(
2367
+ normalizeAnalyticsParams(params)
2368
+ );
2187
2369
  return {
2188
2370
  content: [
2189
2371
  {
@@ -2200,10 +2382,12 @@ function registerAnalyticsTools(server, service) {
2200
2382
  );
2201
2383
  server.tool(
2202
2384
  "get_analytics_group_models",
2203
- "Retrieve analytics data grouped by AI model with pagination",
2385
+ "Returns analytics data aggregated per AI model with pagination, showing each model's request count, cost, and token usage. Use to compare model costs, popularity, and efficiency. Requires time_of_generation_min and time_of_generation_max.",
2204
2386
  paginatedAnalyticsSchema,
2205
2387
  async (params) => {
2206
- const analytics = await service.analytics.getAnalyticsGroupModels(params);
2388
+ const analytics = await service.analytics.getAnalyticsGroupModels(
2389
+ normalizeAnalyticsParams(params)
2390
+ );
2207
2391
  return {
2208
2392
  content: [
2209
2393
  {
@@ -2220,13 +2404,13 @@ function registerAnalyticsTools(server, service) {
2220
2404
  );
2221
2405
  server.tool(
2222
2406
  "get_analytics_group_metadata",
2223
- "Retrieve analytics data grouped by a specific metadata key with pagination",
2407
+ "Returns analytics data grouped by a custom metadata key (e.g., 'env', 'app', 'client_id') with pagination. Use for custom breakdowns like per-environment or per-feature cost analysis. Requires the metadata_key parameter in addition to time_of_generation_min and time_of_generation_max.",
2224
2408
  analyticsGroupMetadataSchema,
2225
2409
  async (params) => {
2226
2410
  const { metadata_key, ...analyticsParams } = params;
2227
2411
  const analytics = await service.analytics.getAnalyticsGroupMetadata(
2228
2412
  metadata_key,
2229
- analyticsParams
2413
+ normalizeAnalyticsParams(analyticsParams)
2230
2414
  );
2231
2415
  return {
2232
2416
  content: [
@@ -2270,7 +2454,7 @@ var AUDIT_TOOL_SCHEMAS = {
2270
2454
  function registerAuditTools(server, service) {
2271
2455
  server.tool(
2272
2456
  "list_audit_logs",
2273
- "Retrieve audit logs for your Portkey organization. Audit logs track all administrative actions including user management, configuration changes, and access events. Supports filtering by time range, actor, action type, and resource.",
2457
+ "Retrieve audit logs for your Portkey organization. Use this for compliance and security reviews. Audit logs track all administrative actions including user management, configuration changes, and access events. Unlike analytics tools which show aggregated metrics, audit logs show individual action events with actor details. Supports filtering by time range, actor, action type, and resource.",
2274
2458
  AUDIT_TOOL_SCHEMAS.listAuditLogs,
2275
2459
  async (params) => {
2276
2460
  const result = await service.audit.listAuditLogs({
@@ -2350,7 +2534,7 @@ var COLLECTIONS_TOOL_SCHEMAS = {
2350
2534
  function registerCollectionsTools(server, service) {
2351
2535
  server.tool(
2352
2536
  "list_collections",
2353
- "List all prompt collections in your Portkey organization. Collections group prompts by app (e.g., hourlink, apizone, research-pilot).",
2537
+ "List all prompt collections in your Portkey organization. Collections organize prompts by application (e.g., hourlink, apizone, research-pilot). Use to discover collection_id values before creating or listing prompts. Returns id, name, and slug per collection.",
2354
2538
  COLLECTIONS_TOOL_SCHEMAS.listCollections,
2355
2539
  async (params) => {
2356
2540
  const collections = await service.collections.listCollections(params);
@@ -2380,7 +2564,7 @@ function registerCollectionsTools(server, service) {
2380
2564
  );
2381
2565
  server.tool(
2382
2566
  "create_collection",
2383
- "Create a new prompt collection for organizing prompts by app. Use one collection per app (hourlink, apizone, research-pilot).",
2567
+ "Create a new prompt collection for organizing prompts by app. Use one collection per app (hourlink, apizone, research-pilot). Returns the new collection_id and slug needed for create_prompt.",
2384
2568
  COLLECTIONS_TOOL_SCHEMAS.createCollection,
2385
2569
  async (params) => {
2386
2570
  const result = await service.collections.createCollection(params);
@@ -2404,7 +2588,7 @@ function registerCollectionsTools(server, service) {
2404
2588
  );
2405
2589
  server.tool(
2406
2590
  "get_collection",
2407
- "Retrieve detailed information about a specific collection",
2591
+ "Retrieve full details of a specific collection by ID or slug, including name, slug, and workspace_id. Use get_collection when you have a specific ID; use list_collections to browse all collections.",
2408
2592
  COLLECTIONS_TOOL_SCHEMAS.getCollection,
2409
2593
  async (params) => {
2410
2594
  const collection = await service.collections.getCollection(
@@ -2433,7 +2617,7 @@ function registerCollectionsTools(server, service) {
2433
2617
  );
2434
2618
  server.tool(
2435
2619
  "update_collection",
2436
- "Update a collection's name or description",
2620
+ "Update a collection's display name or description. Does not affect prompts within the collection.",
2437
2621
  COLLECTIONS_TOOL_SCHEMAS.updateCollection,
2438
2622
  async (params) => {
2439
2623
  await service.collections.updateCollection(params.collection_id, {
@@ -2459,7 +2643,7 @@ function registerCollectionsTools(server, service) {
2459
2643
  );
2460
2644
  server.tool(
2461
2645
  "delete_collection",
2462
- "Delete a collection by ID. This action cannot be undone. Prompts in this collection will become orphaned.",
2646
+ "Delete a prompt collection by ID. This action cannot be undone. Prompts inside the collection are not deleted but lose their grouping and move to the top level. Reassign prompts to another collection first if organization must be preserved.",
2463
2647
  COLLECTIONS_TOOL_SCHEMAS.deleteCollection,
2464
2648
  async (params) => {
2465
2649
  const result = await service.collections.deleteCollection(
@@ -2557,7 +2741,7 @@ function hasConfigSettings(config) {
2557
2741
  function registerConfigsTools(server, service) {
2558
2742
  server.tool(
2559
2743
  "list_configs",
2560
- "Retrieve all configurations in your Portkey organization, including their status and workspace associations",
2744
+ "Retrieve all configurations in your Portkey organization, including their status and workspace associations. Configs define request routing behavior (cache, retry, fallback, load balancing). Use to discover config slugs before inspecting or modifying them.",
2561
2745
  CONFIGS_TOOL_SCHEMAS.listConfigs,
2562
2746
  async () => {
2563
2747
  const configs = await service.configs.listConfigs();
@@ -2591,7 +2775,7 @@ function registerConfigsTools(server, service) {
2591
2775
  );
2592
2776
  server.tool(
2593
2777
  "get_config",
2594
- "Retrieve detailed information about a specific configuration, including cache settings, retry policies, and routing strategy",
2778
+ "Retrieve detailed information about a specific configuration, including cache settings, retry policies, routing strategy, and targets. Use when you need to inspect a config's full settings or clone an existing config's structure.",
2595
2779
  CONFIGS_TOOL_SCHEMAS.getConfig,
2596
2780
  async (params) => {
2597
2781
  const response = await service.configs.getConfig(params.slug);
@@ -2635,7 +2819,7 @@ function registerConfigsTools(server, service) {
2635
2819
  );
2636
2820
  server.tool(
2637
2821
  "create_config",
2638
- "Create a new configuration with cache, retry, and routing settings. At least one setting is required: cache (cache_mode/cache_max_age), retry (retry_attempts/retry_on_status_codes), strategy_mode, or targets.",
2822
+ "Create a new configuration that defines how AI requests are routed, cached, retried, and load-balanced across providers. At least one setting is required: cache (cache_mode/cache_max_age), retry (retry_attempts/retry_on_status_codes), strategy_mode, or targets.",
2639
2823
  CONFIGS_TOOL_SCHEMAS.createConfig,
2640
2824
  async (params) => {
2641
2825
  const config = buildConfigPayload(params);
@@ -2675,7 +2859,7 @@ function registerConfigsTools(server, service) {
2675
2859
  );
2676
2860
  server.tool(
2677
2861
  "update_config",
2678
- "Update an existing configuration's cache, retry, or routing settings",
2862
+ "Update an existing configuration's cache, retry, or routing settings. Creates a new version; only provided fields are updated, unspecified fields remain unchanged.",
2679
2863
  CONFIGS_TOOL_SCHEMAS.updateConfig,
2680
2864
  async (params) => {
2681
2865
  const config = buildConfigPayload(params);
@@ -2710,7 +2894,7 @@ function registerConfigsTools(server, service) {
2710
2894
  );
2711
2895
  server.tool(
2712
2896
  "delete_config",
2713
- "Delete a configuration by slug. This action cannot be undone.",
2897
+ "Delete a configuration by slug. This action cannot be undone and removes all versions. Requests and API keys referencing this config slug will fail immediately. Use list_config_versions first to review history; audit dependent API keys before deleting.",
2714
2898
  CONFIGS_TOOL_SCHEMAS.deleteConfig,
2715
2899
  async (params) => {
2716
2900
  const result = await service.configs.deleteConfig(params.slug);
@@ -2733,7 +2917,7 @@ function registerConfigsTools(server, service) {
2733
2917
  );
2734
2918
  server.tool(
2735
2919
  "list_config_versions",
2736
- "List all versions of a configuration to view its change history",
2920
+ "List all versions of a configuration to view its change history. Use to audit past changes, compare versions, or find a specific version ID for rollback.",
2737
2921
  CONFIGS_TOOL_SCHEMAS.listConfigVersions,
2738
2922
  async (params) => {
2739
2923
  const result = await service.configs.listConfigVersions(params.slug);
@@ -2815,7 +2999,7 @@ var GUARDRAILS_TOOL_SCHEMAS = {
2815
2999
  function registerGuardrailsTools(server, service) {
2816
3000
  server.tool(
2817
3001
  "list_guardrails",
2818
- "List all guardrails in your Portkey organization with optional filtering by workspace or organization",
3002
+ "List all guardrails in your Portkey organization with optional filtering by workspace or organization. Guardrails are content moderation and security policies applied to AI requests. Use to discover guardrail IDs and slugs before inspecting or modifying them.",
2819
3003
  GUARDRAILS_TOOL_SCHEMAS.listGuardrails,
2820
3004
  async (params) => {
2821
3005
  const result = await service.guardrails.listGuardrails(params);
@@ -2849,7 +3033,7 @@ function registerGuardrailsTools(server, service) {
2849
3033
  );
2850
3034
  server.tool(
2851
3035
  "get_guardrail",
2852
- "Retrieve detailed information about a specific guardrail, including its checks and actions configuration",
3036
+ "Retrieve detailed information about a specific guardrail, including its full checks and actions configuration. Use when you need to inspect or modify a guardrail's rules, or to understand what checks are applied before updating.",
2853
3037
  GUARDRAILS_TOOL_SCHEMAS.getGuardrail,
2854
3038
  async (params) => {
2855
3039
  const guardrail = await service.guardrails.getGuardrail(
@@ -2884,7 +3068,7 @@ function registerGuardrailsTools(server, service) {
2884
3068
  );
2885
3069
  server.tool(
2886
3070
  "create_guardrail",
2887
- "Create a new guardrail with specified checks and actions for content moderation and security. checks is an array of check objects with id (e.g. 'default.jwt', 'default.pii'), optional name, is_enabled boolean, and parameters object.",
3071
+ "Create a new guardrail with specified checks and actions for content moderation and security. Guardrails are applied to requests via configs -- create the guardrail first, then reference it in a config. checks is an array of check objects with id (e.g. 'default.jwt', 'default.pii'), optional name, is_enabled boolean, and parameters object.",
2888
3072
  GUARDRAILS_TOOL_SCHEMAS.createGuardrail,
2889
3073
  async (params) => {
2890
3074
  const result = await service.guardrails.createGuardrail({
@@ -2915,7 +3099,7 @@ function registerGuardrailsTools(server, service) {
2915
3099
  );
2916
3100
  server.tool(
2917
3101
  "update_guardrail",
2918
- "Update an existing guardrail's name, checks, or actions configuration",
3102
+ "Update an existing guardrail's name, checks, or actions configuration. Creates a new version of the guardrail; existing references in configs continue working with the latest version.",
2919
3103
  GUARDRAILS_TOOL_SCHEMAS.updateGuardrail,
2920
3104
  async (params) => {
2921
3105
  const updateData = {};
@@ -2953,7 +3137,7 @@ function registerGuardrailsTools(server, service) {
2953
3137
  );
2954
3138
  server.tool(
2955
3139
  "delete_guardrail",
2956
- "Delete a guardrail by its ID or slug. This action cannot be undone.",
3140
+ "Delete a guardrail by its ID or slug. This action cannot be undone. Configs referencing this guardrail as a before/after request hook will stop enforcing it, silently dropping the safety check. Review dependent configs before deleting.",
2957
3141
  GUARDRAILS_TOOL_SCHEMAS.deleteGuardrail,
2958
3142
  async (params) => {
2959
3143
  const result = await service.guardrails.deleteGuardrail(
@@ -3116,7 +3300,7 @@ var INTEGRATIONS_TOOL_SCHEMAS = {
3116
3300
  function registerIntegrationsTools(server, service) {
3117
3301
  server.tool(
3118
3302
  "list_integrations",
3119
- "List all integrations in your Portkey organization with optional filtering by workspace or type",
3303
+ "List org-level connections to AI providers (OpenAI, Anthropic, Azure, etc.) with optional filtering by workspace or type. Use to discover integration slugs for other integration tools. Returns paginated results with id, slug, provider, and status. Differs from list_providers, which shows workspace-scoped provider instances.",
3120
3304
  INTEGRATIONS_TOOL_SCHEMAS.listIntegrations,
3121
3305
  async (params) => {
3122
3306
  const integrations = await service.integrations.listIntegrations({
@@ -3202,7 +3386,7 @@ function registerIntegrationsTools(server, service) {
3202
3386
  );
3203
3387
  server.tool(
3204
3388
  "get_integration",
3205
- "Retrieve detailed information about a specific integration by its slug",
3389
+ "Retrieve detailed information about a specific integration by its slug. Returns full config including masked API key, workspace access settings, and allowed models. Use when you need provider-specific details or to audit an integration's configuration.",
3206
3390
  INTEGRATIONS_TOOL_SCHEMAS.getIntegration,
3207
3391
  async (params) => {
3208
3392
  const integration = await service.integrations.getIntegration(
@@ -3239,7 +3423,7 @@ function registerIntegrationsTools(server, service) {
3239
3423
  );
3240
3424
  server.tool(
3241
3425
  "update_integration",
3242
- "Update an existing integration's name, API key, description, or provider-specific configurations",
3426
+ "Update an existing integration's name, API key, description, or provider-specific configurations. API key changes take effect immediately. Changing provider-specific configs (Azure resource_name, Vertex region, etc.) may break active requests using this integration.",
3243
3427
  INTEGRATIONS_TOOL_SCHEMAS.updateIntegration,
3244
3428
  async (params) => {
3245
3429
  const configurations = {};
@@ -3286,7 +3470,7 @@ function registerIntegrationsTools(server, service) {
3286
3470
  );
3287
3471
  server.tool(
3288
3472
  "delete_integration",
3289
- "Delete an integration by slug. This action cannot be undone.",
3473
+ "Delete an integration by slug. This action cannot be undone. Removes the org-level provider connection; all dependent virtual keys and providers will stop working.",
3290
3474
  INTEGRATIONS_TOOL_SCHEMAS.deleteIntegration,
3291
3475
  async (params) => {
3292
3476
  const result = await service.integrations.deleteIntegration(params.slug);
@@ -3309,7 +3493,7 @@ function registerIntegrationsTools(server, service) {
3309
3493
  );
3310
3494
  server.tool(
3311
3495
  "list_integration_models",
3312
- "List all models available for a specific integration with their enabled status",
3496
+ "List which AI models are enabled for a specific integration, with their enabled/disabled status and custom flag. Use to check model availability before creating prompts or configs. Returns paginated results with model id, name, and enabled state.",
3313
3497
  INTEGRATIONS_TOOL_SCHEMAS.listIntegrationModels,
3314
3498
  async (params) => {
3315
3499
  const models = await service.integrations.listIntegrationModels(
@@ -3347,7 +3531,7 @@ function registerIntegrationsTools(server, service) {
3347
3531
  );
3348
3532
  server.tool(
3349
3533
  "update_integration_models",
3350
- "Update model access settings for an integration - enable/disable models or add custom models",
3534
+ "Enable/disable specific models or register custom model names for an integration. Changes affect all workspaces using this integration. Pass an array of model configurations with slug, enabled state, and optional is_custom flag.",
3351
3535
  INTEGRATIONS_TOOL_SCHEMAS.updateIntegrationModels,
3352
3536
  async (params) => {
3353
3537
  const result = await service.integrations.updateIntegrationModels(
@@ -3376,7 +3560,7 @@ function registerIntegrationsTools(server, service) {
3376
3560
  );
3377
3561
  server.tool(
3378
3562
  "delete_integration_model",
3379
- "Delete a specific custom model from an integration",
3563
+ "Delete a specific custom model from an integration. Only custom models can be deleted; built-in models should be disabled via update_integration_models instead. Returns success status.",
3380
3564
  INTEGRATIONS_TOOL_SCHEMAS.deleteIntegrationModel,
3381
3565
  async (params) => {
3382
3566
  const result = await service.integrations.deleteIntegrationModel(
@@ -3402,7 +3586,7 @@ function registerIntegrationsTools(server, service) {
3402
3586
  );
3403
3587
  server.tool(
3404
3588
  "list_integration_workspaces",
3405
- "List all workspaces that have access to a specific integration",
3589
+ "List which workspaces can access a specific integration, including their usage limits and rate limits. Use to audit workspace access and review per-workspace spending/rate configurations. Returns paginated results.",
3406
3590
  INTEGRATIONS_TOOL_SCHEMAS.listIntegrationWorkspaces,
3407
3591
  async (params) => {
3408
3592
  const workspaces = await service.integrations.listIntegrationWorkspaces(
@@ -3441,7 +3625,7 @@ function registerIntegrationsTools(server, service) {
3441
3625
  );
3442
3626
  server.tool(
3443
3627
  "update_integration_workspaces",
3444
- "Update workspace access settings for an integration - enable/disable workspace access and configure limits",
3628
+ "Control which workspaces can use an integration and set per-workspace usage/rate limits. Pass an array of workspace configurations with id, enabled state, and optional credit_limit, alert_threshold, and rate_limit_rpm.",
3445
3629
  INTEGRATIONS_TOOL_SCHEMAS.updateIntegrationWorkspaces,
3446
3630
  async (params) => {
3447
3631
  const result = await service.integrations.updateIntegrationWorkspaces(
@@ -3569,7 +3753,7 @@ var KEYS_TOOL_SCHEMAS = {
3569
3753
  function registerKeysTools(server, service) {
3570
3754
  server.tool(
3571
3755
  "list_virtual_keys",
3572
- "Retrieve all virtual keys in your Portkey organization, including their usage limits, rate limits, and status",
3756
+ "List virtual keys that securely store provider API keys (OpenAI, Anthropic, etc.) in your Portkey organization. Use to discover virtual key slugs referenced in prompts and configs. Returns all keys with their usage limits, rate limits, and status.",
3573
3757
  KEYS_TOOL_SCHEMAS.listVirtualKeys,
3574
3758
  async () => {
3575
3759
  const virtualKeys = await service.keys.listVirtualKeys();
@@ -3610,7 +3794,7 @@ function registerKeysTools(server, service) {
3610
3794
  );
3611
3795
  server.tool(
3612
3796
  "create_virtual_key",
3613
- "Create a new virtual key for a provider (e.g., openai, anthropic). Virtual keys securely store provider API keys.",
3797
+ "Securely store a provider API key as a virtual key. The original key is encrypted and never returned after creation. Use the returned slug to reference this key in prompts and configs. Supports optional usage/rate limits.",
3614
3798
  KEYS_TOOL_SCHEMAS.createVirtualKey,
3615
3799
  async (params) => {
3616
3800
  const result = await service.keys.createVirtualKey({
@@ -3649,7 +3833,7 @@ function registerKeysTools(server, service) {
3649
3833
  );
3650
3834
  server.tool(
3651
3835
  "get_virtual_key",
3652
- "Retrieve detailed information about a specific virtual key by its slug",
3836
+ "Retrieve detailed information about a specific virtual key by its slug. Returns key metadata with a masked version of the stored API key. Use to check usage limits, rate limits, and status.",
3653
3837
  KEYS_TOOL_SCHEMAS.getVirtualKey,
3654
3838
  async (params) => {
3655
3839
  const virtualKey = await service.keys.getVirtualKey(params.slug);
@@ -3687,7 +3871,7 @@ function registerKeysTools(server, service) {
3687
3871
  );
3688
3872
  server.tool(
3689
3873
  "update_virtual_key",
3690
- "Update an existing virtual key's name, API key, note, or limits",
3874
+ "Update an existing virtual key's name, API key, note, or limits. Can rotate the underlying provider API key by passing a new key value. Changes to limits take effect immediately.",
3691
3875
  KEYS_TOOL_SCHEMAS.updateVirtualKey,
3692
3876
  async (params) => {
3693
3877
  const result = await service.keys.updateVirtualKey(params.slug, {
@@ -3721,7 +3905,7 @@ function registerKeysTools(server, service) {
3721
3905
  );
3722
3906
  server.tool(
3723
3907
  "delete_virtual_key",
3724
- "Delete a virtual key by slug. This action cannot be undone.",
3908
+ "Delete a virtual key by slug. This action cannot be undone. Prompts and configs referencing this key will fail; ensure no active resources depend on it before deleting.",
3725
3909
  KEYS_TOOL_SCHEMAS.deleteVirtualKey,
3726
3910
  async (params) => {
3727
3911
  const result = await service.keys.deleteVirtualKey(params.slug);
@@ -3744,7 +3928,7 @@ function registerKeysTools(server, service) {
3744
3928
  );
3745
3929
  server.tool(
3746
3930
  "create_api_key",
3747
- "Create a new Portkey API key for authentication. Organisation-level keys provide full access, workspace keys are scoped. Scopes control read/write permissions to specific resources (logs, analytics, prompts, etc.).",
3931
+ "Create a new Portkey API key for authentication. Organisation-level keys provide full access, workspace keys are scoped. Scopes control read/write permissions to specific resources (logs, analytics, prompts, etc.). Returns the key value only once at creation time \u2014 save it immediately.",
3748
3932
  KEYS_TOOL_SCHEMAS.createApiKey,
3749
3933
  async (params) => {
3750
3934
  if (params.type === "workspace" && !params.workspace_id) {
@@ -3815,7 +3999,7 @@ function registerKeysTools(server, service) {
3815
3999
  );
3816
4000
  server.tool(
3817
4001
  "list_api_keys",
3818
- "List all API keys in your Portkey organization with optional pagination and workspace filtering",
4002
+ "List Portkey API keys (not provider keys \u2014 use list_virtual_keys for those) with optional pagination and workspace filtering. Use to audit access and review key scopes, limits, and expiration across your organization.",
3819
4003
  KEYS_TOOL_SCHEMAS.listApiKeys,
3820
4004
  async (params) => {
3821
4005
  const apiKeys = await service.keys.listApiKeys({
@@ -3868,7 +4052,7 @@ function registerKeysTools(server, service) {
3868
4052
  );
3869
4053
  server.tool(
3870
4054
  "get_api_key",
3871
- "Retrieve detailed information about a specific API key by its UUID",
4055
+ "Retrieve detailed information about a specific API key by its UUID. Returns key metadata without the secret key value. Use to check scopes, usage/rate limits, defaults, and expiration.",
3872
4056
  KEYS_TOOL_SCHEMAS.getApiKey,
3873
4057
  async (params) => {
3874
4058
  const apiKey = await service.keys.getApiKey(params.id);
@@ -3915,7 +4099,7 @@ function registerKeysTools(server, service) {
3915
4099
  );
3916
4100
  server.tool(
3917
4101
  "update_api_key",
3918
- "Update an existing API key's name, description, scopes, or limits",
4102
+ "Update an existing API key's name, description, scopes, or limits. Can modify scopes, usage/rate limits, defaults, and expiration. Cannot change key type or sub_type after creation.",
3919
4103
  KEYS_TOOL_SCHEMAS.updateApiKey,
3920
4104
  async (params) => {
3921
4105
  const result = await service.keys.updateApiKey(params.id, {
@@ -3953,7 +4137,7 @@ function registerKeysTools(server, service) {
3953
4137
  );
3954
4138
  server.tool(
3955
4139
  "delete_api_key",
3956
- "Delete an API key by UUID. This action cannot be undone.",
4140
+ "Delete an API key by UUID. This action cannot be undone. Immediately revokes authentication; active sessions using this key will fail.",
3957
4141
  KEYS_TOOL_SCHEMAS.deleteApiKey,
3958
4142
  async (params) => {
3959
4143
  const result = await service.keys.deleteApiKey(params.id);
@@ -4013,7 +4197,7 @@ var LABELS_TOOL_SCHEMAS = {
4013
4197
  function registerLabelsTools(server, service) {
4014
4198
  server.tool(
4015
4199
  "create_prompt_label",
4016
- "Create a new prompt label to categorize and organize prompts. Labels can be color-coded and scoped to workspaces or organizations.",
4200
+ "Create a new prompt label to categorize prompt versions (e.g., 'production', 'staging', 'experiment'). Requires either organisation_id or workspace_id to set the label's scope. Returns the new label's id. Use update_prompt_version to assign labels to specific prompt versions.",
4017
4201
  LABELS_TOOL_SCHEMAS.createPromptLabel,
4018
4202
  async (params) => {
4019
4203
  if (!params.organisation_id && !params.workspace_id) {
@@ -4053,7 +4237,7 @@ function registerLabelsTools(server, service) {
4053
4237
  );
4054
4238
  server.tool(
4055
4239
  "list_prompt_labels",
4056
- "List all prompt labels in your Portkey organization with optional filtering by workspace, organisation, or search query",
4240
+ "List all prompt labels with optional filtering by workspace, organisation, or search query. Returns id, name, color_code, and status for each label. Use to discover label IDs before assigning them to prompt versions via update_prompt_version.",
4057
4241
  LABELS_TOOL_SCHEMAS.listPromptLabels,
4058
4242
  async (params) => {
4059
4243
  const result = await service.labels.listLabels(params);
@@ -4085,7 +4269,7 @@ function registerLabelsTools(server, service) {
4085
4269
  );
4086
4270
  server.tool(
4087
4271
  "get_prompt_label",
4088
- "Retrieve detailed information about a specific prompt label",
4272
+ "Retrieve full details of a specific prompt label including its scope (organisation_id vs workspace_id), color, and status. Use when you need to inspect a label's properties before updating it.",
4089
4273
  LABELS_TOOL_SCHEMAS.getPromptLabel,
4090
4274
  async (params) => {
4091
4275
  const label = await service.labels.getLabel(params.label_id, {
@@ -4119,7 +4303,7 @@ function registerLabelsTools(server, service) {
4119
4303
  );
4120
4304
  server.tool(
4121
4305
  "update_prompt_label",
4122
- "Update an existing prompt label's name, description, or color",
4306
+ "Update a prompt label's name, description, or color_code. Changes apply to the label definition only; existing prompt version assignments using this label are not affected.",
4123
4307
  LABELS_TOOL_SCHEMAS.updatePromptLabel,
4124
4308
  async (params) => {
4125
4309
  const { label_id, ...updateData } = params;
@@ -4143,7 +4327,7 @@ function registerLabelsTools(server, service) {
4143
4327
  );
4144
4328
  server.tool(
4145
4329
  "delete_prompt_label",
4146
- "Delete a prompt label by ID. This action cannot be undone.",
4330
+ "Delete a prompt label by ID. This action cannot be undone. Prompt versions carrying this label lose it, and any workflow resolving prompts by this label (e.g., 'production', 'staging') will fail until reassigned. Audit label usage via list_prompts before deleting.",
4147
4331
  LABELS_TOOL_SCHEMAS.deletePromptLabel,
4148
4332
  async (params) => {
4149
4333
  await service.labels.deleteLabel(params.label_id);
@@ -4295,7 +4479,7 @@ function formatUsageLimitEntity(entity) {
4295
4479
  function registerLimitsTools(server, service) {
4296
4480
  server.tool(
4297
4481
  "list_rate_limits",
4298
- "Retrieve all rate limits in your Portkey organization. Rate limits control how many requests or tokens can be consumed per time unit (rpm/rph/rpd).",
4482
+ "Retrieve all rate limits in your Portkey organization. Use to discover existing rate limit policies before creating new ones. Returns an array of rate limits each containing id, type, unit, value, and status. Rate limits control how many requests or tokens can be consumed per time unit (rpm/rph/rpd).",
4299
4483
  LIMITS_TOOL_SCHEMAS.listRateLimits,
4300
4484
  async (params) => {
4301
4485
  const result = await service.limits.listRateLimits(params.workspace_id);
@@ -4318,7 +4502,7 @@ function registerLimitsTools(server, service) {
4318
4502
  );
4319
4503
  server.tool(
4320
4504
  "get_rate_limit",
4321
- "Retrieve detailed information about a specific rate limit by its ID",
4505
+ "Retrieve detailed information about a specific rate limit by its ID. Returns full detail including conditions and group_by fields. Use when you have a specific rate limit ID from list_rate_limits and need to inspect its complete configuration.",
4322
4506
  LIMITS_TOOL_SCHEMAS.getRateLimit,
4323
4507
  async (params) => {
4324
4508
  const result = await service.limits.getRateLimit(params.id);
@@ -4334,7 +4518,7 @@ function registerLimitsTools(server, service) {
4334
4518
  );
4335
4519
  server.tool(
4336
4520
  "create_rate_limit",
4337
- "Create a new rate limit policy to control request/token consumption per time unit. Requires conditions to match against and group_by to specify how limits are applied.",
4521
+ "Create a new rate limit policy to throttle requests in real-time by controlling request/token consumption per time unit. Differs from usage limits, which cap cumulative consumption over time. Requires conditions to match against and group_by to specify how limits are applied.",
4338
4522
  LIMITS_TOOL_SCHEMAS.createRateLimit,
4339
4523
  async (params) => {
4340
4524
  const result = await service.limits.createRateLimit({
@@ -4366,7 +4550,7 @@ function registerLimitsTools(server, service) {
4366
4550
  );
4367
4551
  server.tool(
4368
4552
  "update_rate_limit",
4369
- "Update an existing rate limit's name, unit, or value",
4553
+ "Update an existing rate limit's name, unit, or value. Only name, unit, and value can be changed after creation; conditions and group_by are immutable. Returns the updated rate limit object.",
4370
4554
  LIMITS_TOOL_SCHEMAS.updateRateLimit,
4371
4555
  async (params) => {
4372
4556
  const result = await service.limits.updateRateLimit(params.id, {
@@ -4393,7 +4577,7 @@ function registerLimitsTools(server, service) {
4393
4577
  );
4394
4578
  server.tool(
4395
4579
  "delete_rate_limit",
4396
- "Delete a rate limit by ID. This action cannot be undone.",
4580
+ "Delete a rate limit policy by ID. This action cannot be undone. Requests previously throttled by this policy will no longer be limited; review dependent configs and virtual keys first to avoid unexpected traffic spikes.",
4397
4581
  LIMITS_TOOL_SCHEMAS.deleteRateLimit,
4398
4582
  async (params) => {
4399
4583
  await service.limits.deleteRateLimit(params.id);
@@ -4416,7 +4600,7 @@ function registerLimitsTools(server, service) {
4416
4600
  );
4417
4601
  server.tool(
4418
4602
  "list_usage_limits",
4419
- "Retrieve all usage limits in your Portkey organization. Usage limits control how much cost or tokens can be consumed, with optional periodic resets.",
4603
+ "Retrieve all usage limits in your Portkey organization. Differs from rate limits: usage limits cap total cumulative cost or tokens over time, optionally resetting on a weekly or monthly schedule. Returns an array of usage limits with id, type, credit_limit, status, and reset schedule.",
4420
4604
  LIMITS_TOOL_SCHEMAS.listUsageLimits,
4421
4605
  async (params) => {
4422
4606
  const result = await service.limits.listUsageLimits(params.workspace_id);
@@ -4439,7 +4623,7 @@ function registerLimitsTools(server, service) {
4439
4623
  );
4440
4624
  server.tool(
4441
4625
  "get_usage_limit",
4442
- "Retrieve detailed information about a specific usage limit by its ID",
4626
+ "Retrieve detailed information about a specific usage limit by its ID. Returns full detail including conditions, group_by, credit_limit, alert_threshold, and periodic reset schedule.",
4443
4627
  LIMITS_TOOL_SCHEMAS.getUsageLimit,
4444
4628
  async (params) => {
4445
4629
  const result = await service.limits.getUsageLimit(params.id);
@@ -4455,7 +4639,7 @@ function registerLimitsTools(server, service) {
4455
4639
  );
4456
4640
  server.tool(
4457
4641
  "create_usage_limit",
4458
- "Create a new usage limit policy to control cost or token consumption. Requires conditions to match against and group_by to specify how limits are applied.",
4642
+ "Create a new usage limit policy to enforce spending or token budgets over time. Differs from rate limits, which control real-time request velocity. Requires conditions to match against and group_by to specify how limits are applied. Supports optional periodic resets and alert thresholds.",
4459
4643
  LIMITS_TOOL_SCHEMAS.createUsageLimit,
4460
4644
  async (params) => {
4461
4645
  const result = await service.limits.createUsageLimit({
@@ -4488,7 +4672,7 @@ function registerLimitsTools(server, service) {
4488
4672
  );
4489
4673
  server.tool(
4490
4674
  "update_usage_limit",
4491
- "Update an existing usage limit's configuration",
4675
+ "Update an existing usage limit's configuration. Modifiable fields: name, credit_limit, alert_threshold, periodic_reset, and reset_usage_for_value. Conditions and group_by are immutable after creation.",
4492
4676
  LIMITS_TOOL_SCHEMAS.updateUsageLimit,
4493
4677
  async (params) => {
4494
4678
  const result = await service.limits.updateUsageLimit(params.id, {
@@ -4517,7 +4701,7 @@ function registerLimitsTools(server, service) {
4517
4701
  );
4518
4702
  server.tool(
4519
4703
  "delete_usage_limit",
4520
- "Delete a usage limit by ID. This action cannot be undone.",
4704
+ "Delete a usage limit policy by ID. This action cannot be undone. Budgets and quotas enforced by this policy are removed immediately and tracked entities lose accumulated usage state. Use list_usage_limit_entities first to review impact before deleting.",
4521
4705
  LIMITS_TOOL_SCHEMAS.deleteUsageLimit,
4522
4706
  async (params) => {
4523
4707
  await service.limits.deleteUsageLimit(params.id);
@@ -4540,7 +4724,7 @@ function registerLimitsTools(server, service) {
4540
4724
  );
4541
4725
  server.tool(
4542
4726
  "list_usage_limit_entities",
4543
- "List all entities tracked against a usage limit policy, showing current usage per entity",
4727
+ "List all entities (individual keys, users, or groups) tracked against a usage limit policy. Shows current consumption per entity, useful for monitoring who is approaching or has exceeded their budget.",
4544
4728
  LIMITS_TOOL_SCHEMAS.listUsageLimitEntities,
4545
4729
  async (params) => {
4546
4730
  const result = await service.limits.listUsageLimitEntities(
@@ -4565,7 +4749,7 @@ function registerLimitsTools(server, service) {
4565
4749
  );
4566
4750
  server.tool(
4567
4751
  "reset_usage_limit_entity",
4568
- "Reset accumulated usage for a specific entity on a usage limit policy",
4752
+ "Reset the accumulated usage counter to zero for a specific entity on a usage limit policy. Does not delete the entity or the policy itself. Use when an entity needs its budget restored before the next scheduled periodic reset.",
4569
4753
  LIMITS_TOOL_SCHEMAS.resetUsageLimitEntity,
4570
4754
  async (params) => {
4571
4755
  await service.limits.resetUsageLimitEntity(
@@ -4682,7 +4866,7 @@ var LOGGING_TOOL_SCHEMAS = {
4682
4866
  function registerLoggingTools(server, service) {
4683
4867
  server.tool(
4684
4868
  "insert_log",
4685
- "Insert a log entry (or multiple entries) into Portkey for tracking AI requests and responses. request_provider must match a configured integration (e.g. 'openai', 'anthropic'). Use metadata_span_id and metadata_parent_span_id to create trace hierarchies.",
4869
+ "Insert a log entry (or multiple entries) into Portkey for tracking AI requests and responses. Use this for external or custom logs not routed through the Portkey gateway. request_provider must match a configured integration (e.g. 'openai', 'anthropic'). Use metadata_span_id and metadata_parent_span_id to create trace hierarchies.",
4686
4870
  LOGGING_TOOL_SCHEMAS.insertLog,
4687
4871
  async (params) => {
4688
4872
  const entry = {
@@ -4730,7 +4914,7 @@ function registerLoggingTools(server, service) {
4730
4914
  );
4731
4915
  server.tool(
4732
4916
  "create_log_export",
4733
- "Create a new log export job to export logs matching specified filters. time_min/time_max accept ISO 8601 format ('2024-01-01T00:00:00Z'). requested_fields selects which columns to include.",
4917
+ "Create a new log export job definition with filters and field selection. This only creates the job \u2014 you must call start_log_export to begin processing, then poll get_log_export to check status. time_min/time_max accept ISO 8601 format ('2024-01-01T00:00:00Z'). Returns the export ID and matching log count.",
4734
4918
  LOGGING_TOOL_SCHEMAS.createLogExport,
4735
4919
  async (params) => {
4736
4920
  const result = await service.logging.createLogExport({
@@ -4768,7 +4952,7 @@ function registerLoggingTools(server, service) {
4768
4952
  );
4769
4953
  server.tool(
4770
4954
  "list_log_exports",
4771
- "List all log export jobs for a workspace",
4955
+ "List all log export jobs for a workspace. Returns each export with its current status (pending/running/completed/failed), filters, and timestamps. Use this to find export_ids for subsequent get, start, cancel, or download operations.",
4772
4956
  LOGGING_TOOL_SCHEMAS.listLogExports,
4773
4957
  async (params) => {
4774
4958
  const result = await service.logging.listLogExports({
@@ -4803,7 +4987,7 @@ function registerLoggingTools(server, service) {
4803
4987
  );
4804
4988
  server.tool(
4805
4989
  "get_log_export",
4806
- "Get details of a specific log export by its ID",
4990
+ "Get details of a specific log export by its ID. Use this to check the current status of an export (pending/running/completed/failed) and view its full configuration. Unlike list_log_exports which returns summaries of all exports, this returns complete detail for a single export including filters and requested fields.",
4807
4991
  LOGGING_TOOL_SCHEMAS.getLogExport,
4808
4992
  async (params) => {
4809
4993
  const result = await service.logging.getLogExport(params.export_id);
@@ -4834,7 +5018,7 @@ function registerLoggingTools(server, service) {
4834
5018
  );
4835
5019
  server.tool(
4836
5020
  "start_log_export",
4837
- "Start a log export job that was previously created",
5021
+ "Trigger processing of a previously created log export job. You must call create_log_export first to define the export before starting it. After starting, poll get_log_export to monitor progress until status is 'completed', then use download_log_export to retrieve results.",
4838
5022
  LOGGING_TOOL_SCHEMAS.startLogExport,
4839
5023
  async (params) => {
4840
5024
  const result = await service.logging.startLogExport(params.export_id);
@@ -4858,7 +5042,7 @@ function registerLoggingTools(server, service) {
4858
5042
  );
4859
5043
  server.tool(
4860
5044
  "cancel_log_export",
4861
- "Cancel a running log export job",
5045
+ "Cancel a running or pending log export job. This permanently stops the export \u2014 it cannot be resumed after cancellation. To export the same data, create a new export job with create_log_export.",
4862
5046
  LOGGING_TOOL_SCHEMAS.cancelLogExport,
4863
5047
  async (params) => {
4864
5048
  const result = await service.logging.cancelLogExport(params.export_id);
@@ -5073,7 +5257,7 @@ function formatMcpIntegrationWorkspace(workspace) {
5073
5257
  function registerMcpIntegrationsTools(server, service) {
5074
5258
  server.tool(
5075
5259
  "list_mcp_integrations",
5076
- "List all MCP integrations in your Portkey organization with optional pagination and workspace filtering",
5260
+ "List all MCP integrations in your Portkey organization with optional pagination and workspace filtering. MCP integrations connect external MCP servers to your Portkey org. Use to discover integration IDs needed by other tools. Differs from list_mcp_servers which shows server instances under an integration. Returns paginated array of integrations with total count and has_more flag.",
5077
5261
  MCP_INTEGRATIONS_TOOL_SCHEMAS.listMcpIntegrations,
5078
5262
  async (params) => {
5079
5263
  const result = await service.mcpIntegrations.listMcpIntegrations(params);
@@ -5097,7 +5281,7 @@ function registerMcpIntegrationsTools(server, service) {
5097
5281
  );
5098
5282
  server.tool(
5099
5283
  "create_mcp_integration",
5100
- "Create a new MCP integration in Portkey for connecting external MCP servers to your organization",
5284
+ "Create a new MCP integration by registering an external MCP server URL with auth configuration. After creation, use create_mcp_server to add server instances and update_mcp_integration_capabilities to control which tools are exposed. Returns the new integration's id and slug.",
5101
5285
  MCP_INTEGRATIONS_TOOL_SCHEMAS.createMcpIntegration,
5102
5286
  async (params) => {
5103
5287
  if (params.auth_type === "headers" && (!params.custom_headers || Object.keys(params.custom_headers).length === 0)) {
@@ -5136,7 +5320,7 @@ function registerMcpIntegrationsTools(server, service) {
5136
5320
  );
5137
5321
  server.tool(
5138
5322
  "get_mcp_integration",
5139
- "Retrieve detailed information about a specific MCP integration by ID or slug",
5323
+ "Retrieve detailed information about a specific MCP integration by ID or slug. Returns full integration config including auth type, transport, and configuration keys (header values are masked). Use to inspect Portkey-side connection details. Differs from get_mcp_integration_metadata which returns the external server's self-reported info.",
5140
5324
  MCP_INTEGRATIONS_TOOL_SCHEMAS.getMcpIntegration,
5141
5325
  async (params) => {
5142
5326
  const integration = await service.mcpIntegrations.getMcpIntegration(
@@ -5154,7 +5338,7 @@ function registerMcpIntegrationsTools(server, service) {
5154
5338
  );
5155
5339
  server.tool(
5156
5340
  "update_mcp_integration",
5157
- "Update an existing MCP integration's name, description, URL, auth, or transport",
5341
+ "Update an existing MCP integration's name, description, URL, auth, or transport. Changing url or auth_type may break active connections. Changes take effect immediately for all connected users.",
5158
5342
  MCP_INTEGRATIONS_TOOL_SCHEMAS.updateMcpIntegration,
5159
5343
  async (params) => {
5160
5344
  const { id, custom_headers, ...rest } = params;
@@ -5181,7 +5365,7 @@ function registerMcpIntegrationsTools(server, service) {
5181
5365
  );
5182
5366
  server.tool(
5183
5367
  "delete_mcp_integration",
5184
- "Delete an MCP integration. This action cannot be undone.",
5368
+ "Delete an MCP integration permanently. Also removes all MCP servers under this integration. Connected users will lose access immediately. This action cannot be undone.",
5185
5369
  MCP_INTEGRATIONS_TOOL_SCHEMAS.deleteMcpIntegration,
5186
5370
  async (params) => {
5187
5371
  await service.mcpIntegrations.deleteMcpIntegration(params.id);
@@ -5204,7 +5388,7 @@ function registerMcpIntegrationsTools(server, service) {
5204
5388
  );
5205
5389
  server.tool(
5206
5390
  "get_mcp_integration_metadata",
5207
- "Retrieve metadata for a specific MCP integration",
5391
+ "Retrieve server-reported metadata for an MCP integration including name, version, protocol, and sync status. Use to verify the external server is responding and check its capabilities. Differs from get_mcp_integration which shows Portkey-side config.",
5208
5392
  MCP_INTEGRATIONS_TOOL_SCHEMAS.getMcpIntegrationMetadata,
5209
5393
  async (params) => {
5210
5394
  const metadata = await service.mcpIntegrations.getMcpIntegrationMetadata(
@@ -5226,7 +5410,7 @@ function registerMcpIntegrationsTools(server, service) {
5226
5410
  );
5227
5411
  server.tool(
5228
5412
  "list_mcp_integration_capabilities",
5229
- "List all capabilities (tools, resources, prompts) available on an MCP integration",
5413
+ "List all capabilities (tools, resources, prompts) the external MCP server exposes on an integration. Use before update_mcp_integration_capabilities to see what can be enabled or disabled. Returns total count and array of capabilities with their enabled status.",
5230
5414
  MCP_INTEGRATIONS_TOOL_SCHEMAS.listMcpIntegrationCapabilities,
5231
5415
  async (params) => {
5232
5416
  const result = await service.mcpIntegrations.listMcpIntegrationCapabilities(params.id);
@@ -5246,7 +5430,7 @@ function registerMcpIntegrationsTools(server, service) {
5246
5430
  );
5247
5431
  server.tool(
5248
5432
  "update_mcp_integration_capabilities",
5249
- "Bulk enable or disable capabilities on an MCP integration",
5433
+ "Bulk enable or disable capabilities on an MCP integration to control which MCP tools, resources, and prompts are available to users. Disabled capabilities are hidden from connected clients. Changes take effect immediately.",
5250
5434
  MCP_INTEGRATIONS_TOOL_SCHEMAS.updateMcpIntegrationCapabilities,
5251
5435
  async (params) => {
5252
5436
  await service.mcpIntegrations.updateMcpIntegrationCapabilities(
@@ -5274,7 +5458,7 @@ function registerMcpIntegrationsTools(server, service) {
5274
5458
  );
5275
5459
  server.tool(
5276
5460
  "list_mcp_integration_workspaces",
5277
- "List workspace access settings for an MCP integration",
5461
+ "List which workspaces have access to an MCP integration. Returns global access setting and per-workspace enabled status. Use to audit access before modifying permissions with update_mcp_integration_workspaces.",
5278
5462
  MCP_INTEGRATIONS_TOOL_SCHEMAS.listMcpIntegrationWorkspaces,
5279
5463
  async (params) => {
5280
5464
  const result = await service.mcpIntegrations.listMcpIntegrationWorkspaces(
@@ -5302,7 +5486,7 @@ function registerMcpIntegrationsTools(server, service) {
5302
5486
  );
5303
5487
  server.tool(
5304
5488
  "update_mcp_integration_workspaces",
5305
- "Bulk update workspace access for an MCP integration",
5489
+ "Grant or revoke workspace access to an MCP integration in bulk. Changes affect all users in the workspace immediately. Use list_mcp_integration_workspaces first to see current access state.",
5306
5490
  MCP_INTEGRATIONS_TOOL_SCHEMAS.updateMcpIntegrationWorkspaces,
5307
5491
  async (params) => {
5308
5492
  await service.mcpIntegrations.updateMcpIntegrationWorkspaces(params.id, {
@@ -5417,7 +5601,7 @@ function formatMcpServerUserAccess(user) {
5417
5601
  function registerMcpServersTools(server, service) {
5418
5602
  server.tool(
5419
5603
  "list_mcp_servers",
5420
- "List all MCP servers in your Portkey organization with optional pagination and workspace filtering",
5604
+ "List all MCP servers in your Portkey organization with optional pagination and workspace filtering. MCP servers are instances under MCP integrations. Use to discover server IDs needed by other tools. Differs from list_mcp_integrations which shows the parent integration connections. Returns paginated array of servers with total count.",
5421
5605
  MCP_SERVERS_TOOL_SCHEMAS.listMcpServers,
5422
5606
  async (params) => {
5423
5607
  const result = await service.mcpServers.listMcpServers(params);
@@ -5440,7 +5624,7 @@ function registerMcpServersTools(server, service) {
5440
5624
  );
5441
5625
  server.tool(
5442
5626
  "create_mcp_server",
5443
- "Register a new MCP server under an existing MCP integration",
5627
+ "Register a new MCP server instance under an existing MCP integration. Use list_mcp_integrations to find the mcp_integration_id first. Returns the new server's id and slug.",
5444
5628
  MCP_SERVERS_TOOL_SCHEMAS.createMcpServer,
5445
5629
  async (params) => {
5446
5630
  const result = await service.mcpServers.createMcpServer(params);
@@ -5464,7 +5648,7 @@ function registerMcpServersTools(server, service) {
5464
5648
  );
5465
5649
  server.tool(
5466
5650
  "get_mcp_server",
5467
- "Retrieve detailed information about a specific MCP server by ID or slug",
5651
+ "Retrieve detailed information about a specific MCP server by ID or slug. Returns server details including linked integration ID and status. Use to check server configuration and health.",
5468
5652
  MCP_SERVERS_TOOL_SCHEMAS.getMcpServer,
5469
5653
  async (params) => {
5470
5654
  const mcpServer = await service.mcpServers.getMcpServer(params.id);
@@ -5480,7 +5664,7 @@ function registerMcpServersTools(server, service) {
5480
5664
  );
5481
5665
  server.tool(
5482
5666
  "update_mcp_server",
5483
- "Update an existing MCP server's name or description",
5667
+ "Update an existing MCP server's name or description. Only name and description can be changed on a server. To change the URL or auth configuration, update the parent MCP integration instead.",
5484
5668
  MCP_SERVERS_TOOL_SCHEMAS.updateMcpServer,
5485
5669
  async (params) => {
5486
5670
  const { id, ...data } = params;
@@ -5504,7 +5688,7 @@ function registerMcpServersTools(server, service) {
5504
5688
  );
5505
5689
  server.tool(
5506
5690
  "delete_mcp_server",
5507
- "Delete an MCP server. This action cannot be undone.",
5691
+ "Delete an MCP server instance by ID. This action cannot be undone. Connected users and workspaces lose access immediately, and workspace access grants to this server are removed. Verify no active integrations depend on it before deleting.",
5508
5692
  MCP_SERVERS_TOOL_SCHEMAS.deleteMcpServer,
5509
5693
  async (params) => {
5510
5694
  await service.mcpServers.deleteMcpServer(params.id);
@@ -5527,7 +5711,7 @@ function registerMcpServersTools(server, service) {
5527
5711
  );
5528
5712
  server.tool(
5529
5713
  "test_mcp_server",
5530
- "Test connectivity to an MCP server to verify it is reachable and responding",
5714
+ "Send a connectivity check to an MCP server to verify it is reachable and responding. Returns success/failure, response time in ms, and any error message. Use to diagnose connection issues before investigating configuration.",
5531
5715
  MCP_SERVERS_TOOL_SCHEMAS.testMcpServer,
5532
5716
  async (params) => {
5533
5717
  const result = await service.mcpServers.testMcpServer(params.id);
@@ -5543,7 +5727,7 @@ function registerMcpServersTools(server, service) {
5543
5727
  );
5544
5728
  server.tool(
5545
5729
  "list_mcp_server_capabilities",
5546
- "List all capabilities (tools, resources, prompts) exposed by an MCP server",
5730
+ "List all capabilities (tools, resources, prompts) exposed by an MCP server instance. Differs from list_mcp_integration_capabilities which shows integration-level capability settings. Returns total count and array of capabilities.",
5547
5731
  MCP_SERVERS_TOOL_SCHEMAS.listMcpServerCapabilities,
5548
5732
  async (params) => {
5549
5733
  const result = await service.mcpServers.listMcpServerCapabilities(
@@ -5565,7 +5749,7 @@ function registerMcpServersTools(server, service) {
5565
5749
  );
5566
5750
  server.tool(
5567
5751
  "update_mcp_server_capabilities",
5568
- "Bulk enable or disable capabilities on an MCP server",
5752
+ "Enable or disable specific capabilities on an MCP server instance. Overrides integration-level capability settings for this server. Changes take effect immediately for connected users.",
5569
5753
  MCP_SERVERS_TOOL_SCHEMAS.updateMcpServerCapabilities,
5570
5754
  async (params) => {
5571
5755
  await service.mcpServers.updateMcpServerCapabilities(params.id, {
@@ -5590,7 +5774,7 @@ function registerMcpServersTools(server, service) {
5590
5774
  );
5591
5775
  server.tool(
5592
5776
  "list_mcp_server_user_access",
5593
- "List user access settings for an MCP server",
5777
+ "List per-user access settings for an MCP server including override flags and connection status. Returns default_user_access setting and array of users. Use to audit who can access this server before modifying permissions.",
5594
5778
  MCP_SERVERS_TOOL_SCHEMAS.listMcpServerUserAccess,
5595
5779
  async (params) => {
5596
5780
  const result = await service.mcpServers.listMcpServerUserAccess(
@@ -5616,7 +5800,7 @@ function registerMcpServersTools(server, service) {
5616
5800
  );
5617
5801
  server.tool(
5618
5802
  "update_mcp_server_user_access",
5619
- "Bulk update user access for an MCP server",
5803
+ "Grant or revoke individual user access to an MCP server. Overrides the default_user_access setting for specified users. Changes take effect immediately.",
5620
5804
  MCP_SERVERS_TOOL_SCHEMAS.updateMcpServerUserAccess,
5621
5805
  async (params) => {
5622
5806
  await service.mcpServers.updateMcpServerUserAccess(params.id, {
@@ -5681,7 +5865,7 @@ var PARTIALS_TOOL_SCHEMAS = {
5681
5865
  function registerPartialsTools(server, service) {
5682
5866
  server.tool(
5683
5867
  "create_prompt_partial",
5684
- "Create a new prompt partial (reusable text snippet) that can be included in prompts using mustache syntax like {{> partial_name}}",
5868
+ "Create a new prompt partial (reusable text snippet) that can be included in prompts using mustache syntax like {{> partial_name}}. After creation, use publish_partial to make it the default version. Returns id, slug, and version_id.",
5685
5869
  PARTIALS_TOOL_SCHEMAS.createPromptPartial,
5686
5870
  async (params) => {
5687
5871
  const result = await service.partials.createPromptPartial({
@@ -5711,7 +5895,7 @@ function registerPartialsTools(server, service) {
5711
5895
  );
5712
5896
  server.tool(
5713
5897
  "list_prompt_partials",
5714
- "List all prompt partials in your Portkey organization with optional filtering by collection",
5898
+ "List all prompt partials in your Portkey organization with optional filtering by collection. Returns all partials with id, slug, name, and status. Use to discover partial IDs or check if a partial already exists before creating.",
5715
5899
  PARTIALS_TOOL_SCHEMAS.listPromptPartials,
5716
5900
  async (params) => {
5717
5901
  const partials = await service.partials.listPromptPartials(params);
@@ -5742,7 +5926,7 @@ function registerPartialsTools(server, service) {
5742
5926
  );
5743
5927
  server.tool(
5744
5928
  "get_prompt_partial",
5745
- "Retrieve detailed information about a specific prompt partial including its content and version info",
5929
+ "Retrieve detailed information about a specific prompt partial. Returns the partial's content string and current version info. Use to inspect content before including it in a prompt via {{> partial_name}}.",
5746
5930
  PARTIALS_TOOL_SCHEMAS.getPromptPartial,
5747
5931
  async (params) => {
5748
5932
  const partial = await service.partials.getPromptPartial(
@@ -5803,7 +5987,7 @@ function registerPartialsTools(server, service) {
5803
5987
  );
5804
5988
  server.tool(
5805
5989
  "delete_prompt_partial",
5806
- "Delete a prompt partial by ID. This action cannot be undone.",
5990
+ "Delete a prompt partial by ID. This action cannot be undone. Prompts referencing this partial via {{> name}} will fail to render. Ensure no active prompts depend on it.",
5807
5991
  PARTIALS_TOOL_SCHEMAS.deletePromptPartial,
5808
5992
  async (params) => {
5809
5993
  await service.partials.deletePromptPartial(params.prompt_partial_id);
@@ -5826,7 +6010,7 @@ function registerPartialsTools(server, service) {
5826
6010
  );
5827
6011
  server.tool(
5828
6012
  "list_partial_versions",
5829
- "List all versions of a prompt partial to view its change history",
6013
+ "List all versions of a prompt partial to view its change history. Returns all versions with content preview. Use to find a version number before calling publish_partial to roll back or promote a version.",
5830
6014
  PARTIALS_TOOL_SCHEMAS.listPartialVersions,
5831
6015
  async (params) => {
5832
6016
  const versions = await service.partials.listPartialVersions(
@@ -5861,7 +6045,7 @@ function registerPartialsTools(server, service) {
5861
6045
  );
5862
6046
  server.tool(
5863
6047
  "publish_partial",
5864
- "Publish a specific version of a prompt partial, making it the default version",
6048
+ "Publish a specific version of a prompt partial, making it the default version. After publishing, all prompts using {{> partial_name}} will resolve to this version's content.",
5865
6049
  PARTIALS_TOOL_SCHEMAS.publishPartial,
5866
6050
  async (params) => {
5867
6051
  await service.partials.publishPartial(params.prompt_partial_id, {
@@ -5962,14 +6146,25 @@ function toPromptToolChoice(toolChoice) {
5962
6146
 
5963
6147
  // src/tools/prompts.tools.ts
5964
6148
  var PROMPT_VARIABLES_SCHEMA = z15.record(z15.string(), z15.union([z15.string(), z15.coerce.number(), z15.boolean()])).describe("Variable values to substitute into the template");
6149
+ var PROMPT_TEMPLATE_CONTENT_BLOCK_SCHEMA = z15.object({
6150
+ type: z15.string().describe("Content block type"),
6151
+ text: z15.string().optional().describe("Text content for text-based blocks")
6152
+ }).passthrough().describe("Content block within a structured chat message");
6153
+ var PROMPT_TEMPLATE_MESSAGE_SCHEMA = z15.object({
6154
+ role: z15.enum(["system", "user", "assistant"]).describe("Message role in the chat template"),
6155
+ content: z15.array(PROMPT_TEMPLATE_CONTENT_BLOCK_SCHEMA).describe("Message content blocks")
6156
+ }).passthrough().describe("Structured chat message in a prompt template");
5965
6157
  var PROMPTS_TOOL_SCHEMAS = {
5966
6158
  createPrompt: {
5967
6159
  name: z15.string().describe("Display name for the prompt"),
5968
6160
  collection_id: z15.string().describe(
5969
6161
  "Collection ID to organize the prompt in (use list_collections to find)"
5970
6162
  ),
5971
- string: z15.string().describe(
5972
- `The prompt template. Plain text OR a JSON-encoded messages array string for multi-message chat prompts: '[{"role":"system","content":[{"type":"text","text":"..."}]},{"role":"user","content":[{"type":"text","text":"{{input}}"}]}]'. Use get_prompt on an existing prompt to see the exact format.`
6163
+ string: z15.string().optional().describe(
6164
+ "Legacy prompt template string. Use plain text for single-message prompts, or a JSON-encoded messages array string for multi-message chat prompts."
6165
+ ),
6166
+ messages: z15.array(PROMPT_TEMPLATE_MESSAGE_SCHEMA).optional().describe(
6167
+ "Structured chat template alias. Serialized to the legacy string format before creation."
5973
6168
  ),
5974
6169
  parameters: z15.record(z15.string(), z15.unknown()).describe("Default values for template variables"),
5975
6170
  virtual_key: z15.string().describe("Virtual key slug for model access"),
@@ -6006,7 +6201,10 @@ var PROMPTS_TOOL_SCHEMAS = {
6006
6201
  name: z15.string().optional().describe("New display name for the prompt"),
6007
6202
  collection_id: z15.string().optional().describe("Move to a different collection"),
6008
6203
  string: z15.string().optional().describe(
6009
- "Updated prompt template. Plain text OR a JSON-encoded messages array string for multi-message chat prompts. Use get_prompt to see the current format before updating."
6204
+ "Legacy prompt template string. Use plain text for single-message prompts, or a JSON-encoded messages array string for multi-message chat prompts."
6205
+ ),
6206
+ messages: z15.array(PROMPT_TEMPLATE_MESSAGE_SCHEMA).optional().describe(
6207
+ "Structured chat template alias for updates. Serialized to the legacy string format before the prompt is updated."
6010
6208
  ),
6011
6209
  parameters: z15.record(z15.string(), z15.unknown()).optional().describe("New default values for template variables"),
6012
6210
  model: z15.string().optional().describe("New model identifier"),
@@ -6052,7 +6250,12 @@ var PROMPTS_TOOL_SCHEMAS = {
6052
6250
  app: PromptAppIdentifierSchema,
6053
6251
  env: PromptEnvironmentIdentifierSchema,
6054
6252
  collection_id: z15.string().describe("Collection ID to search in and create under"),
6055
- string: z15.string().describe("Prompt template string with {{variable}} mustache syntax"),
6253
+ string: z15.string().optional().describe(
6254
+ "Legacy prompt template string with {{variable}} mustache syntax."
6255
+ ),
6256
+ messages: z15.array(PROMPT_TEMPLATE_MESSAGE_SCHEMA).optional().describe(
6257
+ "Structured chat template alias for migrations. Serialized to the legacy string format before the prompt is created or updated."
6258
+ ),
6056
6259
  parameters: z15.record(z15.string(), z15.unknown()).describe("Default values for template variables"),
6057
6260
  virtual_key: z15.string().describe("Virtual key slug for model access"),
6058
6261
  model: z15.string().optional().describe("Model identifier"),
@@ -6095,6 +6298,15 @@ var PROMPTS_TOOL_SCHEMAS = {
6095
6298
  )
6096
6299
  }
6097
6300
  };
6301
+ function normalizePromptTemplateString(params) {
6302
+ if (params.string !== void 0) {
6303
+ return params.string;
6304
+ }
6305
+ if (params.messages !== void 0) {
6306
+ return JSON.stringify(params.messages);
6307
+ }
6308
+ return void 0;
6309
+ }
6098
6310
  function extractPromptTemplateString(template) {
6099
6311
  const inner = typeof template === "object" && template !== null && "string" in template ? template.string : template;
6100
6312
  if (inner === void 0) {
@@ -6158,14 +6370,14 @@ function formatPromptListResponse(prompts, params) {
6158
6370
  function registerPromptsTools(server, service) {
6159
6371
  server.tool(
6160
6372
  "create_prompt",
6161
- `Create a new prompt template in Portkey. Supports both single-message and multi-message (chat) templates.
6373
+ `Create a new prompt template in Portkey. Supports both the legacy string template and a structured messages alias for chat prompts.
6162
6374
 
6163
- IMPORTANT: The "string" parameter accepts TWO formats:
6375
+ IMPORTANT: The "string" parameter accepts TWO legacy formats:
6164
6376
  1. Plain text: "Hello {{name}}, how can I help?"
6165
6377
  2. Multi-message JSON array (MUST be a JSON-encoded string):
6166
6378
  '[{"role":"system","content":[{"type":"text","text":"You are a helpful assistant."}]},{"role":"user","content":[{"type":"text","text":"{{user_input}}"}]}]'
6167
6379
 
6168
- Most production prompts use format #2 (multi-message). Use get_prompt to see examples of the format.`,
6380
+ For structured prompts, prefer the "messages" alias and let the server serialize it to the legacy string format.`,
6169
6381
  PROMPTS_TOOL_SCHEMAS.createPrompt,
6170
6382
  async (params) => {
6171
6383
  if (!params.model && !params.ai_model_id && !params.finetune_id) {
@@ -6179,6 +6391,18 @@ Most production prompts use format #2 (multi-message). Use get_prompt to see exa
6179
6391
  isError: true
6180
6392
  };
6181
6393
  }
6394
+ const templateString = normalizePromptTemplateString(params);
6395
+ if (templateString === void 0) {
6396
+ return {
6397
+ content: [
6398
+ {
6399
+ type: "text",
6400
+ text: "Error creating prompt: Provide either string or messages"
6401
+ }
6402
+ ],
6403
+ isError: true
6404
+ };
6405
+ }
6182
6406
  if (params.dry_run) {
6183
6407
  return {
6184
6408
  content: [
@@ -6193,7 +6417,7 @@ Most production prompts use format #2 (multi-message). Use get_prompt to see exa
6193
6417
  name: params.name,
6194
6418
  collection_id: params.collection_id,
6195
6419
  model: params.model,
6196
- template_length: params.string.length,
6420
+ template_length: templateString.length,
6197
6421
  parameter_count: Object.keys(params.parameters ?? {}).length
6198
6422
  }
6199
6423
  },
@@ -6207,17 +6431,17 @@ Most production prompts use format #2 (multi-message). Use get_prompt to see exa
6207
6431
  const result = await service.prompts.createPrompt({
6208
6432
  name: params.name,
6209
6433
  collection_id: params.collection_id,
6210
- string: params.string,
6434
+ string: templateString,
6211
6435
  parameters: params.parameters,
6212
6436
  virtual_key: params.virtual_key,
6213
- model: params.model,
6214
- ai_model_id: params.ai_model_id,
6215
- finetune_id: params.finetune_id,
6216
- version_description: params.version_description,
6217
- template_metadata: params.template_metadata,
6218
- functions: params.functions,
6219
- tools: params.tools,
6220
- tool_choice: toPromptToolChoice(params.tool_choice)
6437
+ ...params.model !== void 0 ? { model: params.model } : {},
6438
+ ...params.ai_model_id !== void 0 ? { ai_model_id: params.ai_model_id } : {},
6439
+ ...params.finetune_id !== void 0 ? { finetune_id: params.finetune_id } : {},
6440
+ ...params.version_description !== void 0 ? { version_description: params.version_description } : {},
6441
+ ...params.template_metadata !== void 0 ? { template_metadata: params.template_metadata } : {},
6442
+ ...params.functions !== void 0 ? { functions: params.functions } : {},
6443
+ ...params.tools !== void 0 ? { tools: params.tools } : {},
6444
+ ...params.tool_choice !== void 0 ? { tool_choice: toPromptToolChoice(params.tool_choice) } : {}
6221
6445
  });
6222
6446
  return {
6223
6447
  content: [
@@ -6240,7 +6464,7 @@ Most production prompts use format #2 (multi-message). Use get_prompt to see exa
6240
6464
  );
6241
6465
  server.tool(
6242
6466
  "list_prompts",
6243
- "List all prompts in your Portkey organization with optional filtering by collection, workspace, or search query",
6467
+ "List all prompts in your Portkey organization with optional filtering by collection, workspace, or search query. Returns paginated results with id, name, slug, model, and status. Use collection_id to filter by app. Use to discover prompt_id values before calling get_prompt.",
6244
6468
  PROMPTS_TOOL_SCHEMAS.listPrompts,
6245
6469
  async (params) => {
6246
6470
  const prompts = await service.prompts.listPrompts(params);
@@ -6329,15 +6553,19 @@ When updating a prompt, pass the same format back in the "string" field of updat
6329
6553
  "update_prompt",
6330
6554
  `Update an existing prompt template. Creates a new version. Uses patch mode \u2014 only provided fields are updated, others are kept from the current version.
6331
6555
 
6332
- IMPORTANT: The "string" parameter accepts the same two formats as create_prompt:
6556
+ IMPORTANT: The legacy "string" parameter accepts the same two formats as create_prompt:
6333
6557
  1. Plain text: "Hello {{name}}"
6334
6558
  2. Multi-message JSON array (MUST be a JSON-encoded string):
6335
6559
  '[{"role":"system","content":[{"type":"text","text":"..."}]},{"role":"user","content":[{"type":"text","text":"{{input}}"}]}]'
6336
6560
 
6337
- Use get_prompt first to see the current format, then pass the same format back. New versions are created in "archived" status \u2014 use publish_prompt to make active.`,
6561
+ For structured chat prompts, prefer the "messages" alias and let the server serialize it for you. New versions are created in "archived" status \u2014 use publish_prompt to make active.`,
6338
6562
  PROMPTS_TOOL_SCHEMAS.updatePrompt,
6339
6563
  async (params) => {
6340
- const { prompt_id, dry_run, ...updateData } = params;
6564
+ const { prompt_id, dry_run, messages, ...updateData } = params;
6565
+ const templateString = normalizePromptTemplateString({
6566
+ string: updateData.string,
6567
+ messages
6568
+ });
6341
6569
  if (dry_run) {
6342
6570
  const current = await service.prompts.getPrompt(prompt_id);
6343
6571
  return {
@@ -6362,8 +6590,17 @@ Use get_prompt first to see the current format, then pass the same format back.
6362
6590
  };
6363
6591
  }
6364
6592
  const result = await service.prompts.updatePrompt(prompt_id, {
6365
- ...updateData,
6366
- tool_choice: toPromptToolChoice(updateData.tool_choice)
6593
+ ...updateData.name !== void 0 ? { name: updateData.name } : {},
6594
+ ...updateData.collection_id !== void 0 ? { collection_id: updateData.collection_id } : {},
6595
+ ...templateString !== void 0 ? { string: templateString } : {},
6596
+ ...updateData.parameters !== void 0 ? { parameters: updateData.parameters } : {},
6597
+ ...updateData.model !== void 0 ? { model: updateData.model } : {},
6598
+ ...updateData.virtual_key !== void 0 ? { virtual_key: updateData.virtual_key } : {},
6599
+ ...updateData.version_description !== void 0 ? { version_description: updateData.version_description } : {},
6600
+ ...updateData.template_metadata !== void 0 ? { template_metadata: updateData.template_metadata } : {},
6601
+ ...updateData.functions !== void 0 ? { functions: updateData.functions } : {},
6602
+ ...updateData.tools !== void 0 ? { tools: updateData.tools } : {},
6603
+ ...updateData.tool_choice !== void 0 ? { tool_choice: toPromptToolChoice(updateData.tool_choice) } : {}
6367
6604
  });
6368
6605
  return {
6369
6606
  content: [
@@ -6386,7 +6623,7 @@ Use get_prompt first to see the current format, then pass the same format back.
6386
6623
  );
6387
6624
  server.tool(
6388
6625
  "delete_prompt",
6389
- "Delete a prompt by its ID. This action cannot be undone and will remove the prompt and all its versions.",
6626
+ "Delete a prompt and all its versions by ID. This action cannot be undone. Applications calling this prompt slug will fail immediately. Use list_prompt_versions first to review history; consider archiving via update_prompt status instead if an audit trail is needed.",
6390
6627
  PROMPTS_TOOL_SCHEMAS.deletePrompt,
6391
6628
  async (params) => {
6392
6629
  await service.prompts.deletePrompt(params.prompt_id);
@@ -6474,7 +6711,7 @@ Use get_prompt first to see the current format, then pass the same format back.
6474
6711
  );
6475
6712
  server.tool(
6476
6713
  "render_prompt",
6477
- "Render a prompt template by substituting variables, returning the final messages without executing",
6714
+ "Render a prompt template by substituting variables, returning the final messages without executing. Previews the final messages after variable substitution without sending to the AI model. Use to verify template output before running a completion. Differs from run_prompt_completion which actually calls the model.",
6478
6715
  PROMPTS_TOOL_SCHEMAS.renderPrompt,
6479
6716
  async (params) => {
6480
6717
  const result = await service.prompts.renderPrompt(params.prompt_id, {
@@ -6506,7 +6743,7 @@ Use get_prompt first to see the current format, then pass the same format back.
6506
6743
  );
6507
6744
  server.tool(
6508
6745
  "run_prompt_completion",
6509
- "Execute a prompt template with variables and get the model completion response. REQUIRES billing metadata (client_id, app, env). Use validate_completion_metadata first if uncertain.",
6746
+ "Execute a prompt template against the configured AI model and return the model's response. Costs money \u2014 use render_prompt to preview first. REQUIRES billing metadata (client_id, app, env). Use validate_completion_metadata first if uncertain.",
6510
6747
  PROMPTS_TOOL_SCHEMAS.runPromptCompletion,
6511
6748
  async (params) => {
6512
6749
  const result = await service.prompts.runPromptCompletion(
@@ -6545,24 +6782,36 @@ Use get_prompt first to see the current format, then pass the same format back.
6545
6782
  );
6546
6783
  server.tool(
6547
6784
  "migrate_prompt",
6548
- "Create or update a prompt based on whether it exists. Useful for CI/CD and prompt-as-code workflows. Finds existing prompts by name within the collection. The app and env values are added to template_metadata automatically.",
6785
+ "Create or update a prompt based on whether it exists. Useful for CI/CD and prompt-as-code workflows. Finds existing prompts by name within the collection. The app and env values are added to template_metadata automatically. For structured chat prompts, prefer the messages alias instead of hand-encoding JSON into string.",
6549
6786
  PROMPTS_TOOL_SCHEMAS.migratePrompt,
6550
6787
  async (params) => {
6788
+ const templateString = normalizePromptTemplateString(params);
6789
+ if (templateString === void 0) {
6790
+ return {
6791
+ content: [
6792
+ {
6793
+ type: "text",
6794
+ text: "Error migrating prompt: Provide either string or messages"
6795
+ }
6796
+ ],
6797
+ isError: true
6798
+ };
6799
+ }
6551
6800
  const result = await service.prompts.migratePrompt({
6552
6801
  name: params.name,
6553
6802
  app: params.app,
6554
6803
  env: params.env,
6555
6804
  collection_id: params.collection_id,
6556
- string: params.string,
6805
+ string: templateString,
6557
6806
  parameters: params.parameters,
6558
6807
  virtual_key: params.virtual_key,
6559
- model: params.model,
6560
- version_description: params.version_description,
6561
- template_metadata: params.template_metadata,
6562
- functions: params.functions,
6563
- tools: params.tools,
6564
- tool_choice: toPromptToolChoice(params.tool_choice),
6565
- dry_run: params.dry_run
6808
+ ...params.model !== void 0 ? { model: params.model } : {},
6809
+ ...params.version_description !== void 0 ? { version_description: params.version_description } : {},
6810
+ ...params.template_metadata !== void 0 ? { template_metadata: params.template_metadata } : {},
6811
+ ...params.functions !== void 0 ? { functions: params.functions } : {},
6812
+ ...params.tools !== void 0 ? { tools: params.tools } : {},
6813
+ ...params.tool_choice !== void 0 ? { tool_choice: toPromptToolChoice(params.tool_choice) } : {},
6814
+ ...params.dry_run !== void 0 ? { dry_run: params.dry_run } : {}
6566
6815
  });
6567
6816
  return {
6568
6817
  content: [
@@ -6625,7 +6874,7 @@ Use get_prompt first to see the current format, then pass the same format back.
6625
6874
  );
6626
6875
  server.tool(
6627
6876
  "validate_completion_metadata",
6628
- "Validate billing metadata before running a completion. Checks for required fields (client_id, app, env) and valid values.",
6877
+ "Validate billing metadata before running a completion. Checks for required fields (client_id, app, env) and valid values. Call this before run_prompt_completion to catch missing or invalid billing fields. Does not make any changes.",
6629
6878
  PROMPTS_TOOL_SCHEMAS.validateCompletionMetadata,
6630
6879
  async (params) => {
6631
6880
  const result = service.prompts.validateBillingMetadata(params);
@@ -6650,7 +6899,7 @@ Use get_prompt first to see the current format, then pass the same format back.
6650
6899
  );
6651
6900
  server.tool(
6652
6901
  "get_prompt_version",
6653
- "Retrieve a specific version of a prompt by its version ID",
6902
+ "Retrieve a specific version of a prompt by its version UUID. Use list_prompt_versions to find version IDs. Returns full template, parameters, and model config for that version.",
6654
6903
  PROMPTS_TOOL_SCHEMAS.getPromptVersion,
6655
6904
  async (params) => {
6656
6905
  const version = await service.prompts.getPromptVersion(
@@ -6669,7 +6918,7 @@ Use get_prompt first to see the current format, then pass the same format back.
6669
6918
  );
6670
6919
  server.tool(
6671
6920
  "update_prompt_version",
6672
- "Update a specific prompt version, e.g. to assign or remove a label",
6921
+ "Update a specific prompt version. Currently only supports assigning or removing a label. Use list_prompt_labels to find label IDs. Pass null to remove the current label.",
6673
6922
  PROMPTS_TOOL_SCHEMAS.updatePromptVersion,
6674
6923
  async (params) => {
6675
6924
  if (params.label_id === void 0) {
@@ -6777,7 +7026,7 @@ var PROVIDERS_TOOL_SCHEMAS = {
6777
7026
  function registerProvidersTools(server, service) {
6778
7027
  server.tool(
6779
7028
  "list_providers",
6780
- "List all providers in your Portkey organization with optional pagination and workspace filtering",
7029
+ "List workspace-scoped providers, which are instances of org-level integrations with their own usage and rate limits. Differs from list_integrations which shows org-level provider connections. Use to discover provider slugs for a workspace. Returns name, slug, limits, and status per provider.",
6781
7030
  PROVIDERS_TOOL_SCHEMAS.listProviders,
6782
7031
  async (params) => {
6783
7032
  const providers = await service.providers.listProviders({
@@ -6823,7 +7072,7 @@ function registerProvidersTools(server, service) {
6823
7072
  );
6824
7073
  server.tool(
6825
7074
  "create_provider",
6826
- "Create a new provider configuration in Portkey. Providers define integrations with AI model providers like OpenAI, Anthropic, etc.",
7075
+ "Create a workspace-scoped provider linked to an org-level integration. Use list_integrations to find the integration_id first. Providers inherit the integration's API key but can have independent usage limits, rate limits, and expiration. Returns the new provider's id and slug.",
6827
7076
  PROVIDERS_TOOL_SCHEMAS.createProvider,
6828
7077
  async (params) => {
6829
7078
  const result = await service.providers.createProvider({
@@ -6864,7 +7113,7 @@ function registerProvidersTools(server, service) {
6864
7113
  );
6865
7114
  server.tool(
6866
7115
  "get_provider",
6867
- "Retrieve detailed information about a specific provider by its slug",
7116
+ "Retrieve full provider details by slug, including usage limits, rate limits, and expiration. Use to check current consumption against limits or inspect provider configuration before updating.",
6868
7117
  PROVIDERS_TOOL_SCHEMAS.getProvider,
6869
7118
  async (params) => {
6870
7119
  const provider = await service.providers.getProvider(
@@ -6906,7 +7155,7 @@ function registerProvidersTools(server, service) {
6906
7155
  );
6907
7156
  server.tool(
6908
7157
  "update_provider",
6909
- "Update an existing provider's name, note, limits, or expiration",
7158
+ "Update a provider's name, note, usage limits, rate limits, or expiration. Set reset_usage to true to clear accumulated usage counters without changing the limit. Returns the updated provider's id and slug.",
6910
7159
  PROVIDERS_TOOL_SCHEMAS.updateProvider,
6911
7160
  async (params) => {
6912
7161
  const result = await service.providers.updateProvider(
@@ -6949,7 +7198,7 @@ function registerProvidersTools(server, service) {
6949
7198
  );
6950
7199
  server.tool(
6951
7200
  "delete_provider",
6952
- "Delete a provider by slug. This action cannot be undone.",
7201
+ "Delete a workspace-level provider by slug. This action cannot be undone. Virtual keys, configs, and prompts referencing this provider will stop working. Audit dependent resources first; use delete_integration for org-level provider connections instead.",
6953
7202
  PROVIDERS_TOOL_SCHEMAS.deleteProvider,
6954
7203
  async (params) => {
6955
7204
  await service.providers.deleteProvider(params.slug, params.workspace_id);
@@ -6996,15 +7245,12 @@ var TRACING_TOOL_SCHEMAS = {
6996
7245
  ),
6997
7246
  weight: z17.coerce.number().positive().optional().describe("New weighting factor for the feedback"),
6998
7247
  metadata: z17.record(z17.string(), z17.unknown()).optional().describe("New or updated custom metadata for the feedback")
6999
- },
7000
- getTrace: {
7001
- id: z17.string().describe("The unique identifier of the trace to retrieve")
7002
7248
  }
7003
7249
  };
7004
7250
  function registerTracingTools(server, service) {
7005
7251
  server.tool(
7006
7252
  "create_feedback",
7007
- "Create feedback for a specific trace/request. Use this to capture user feedback (thumbs up/down, ratings) on AI generations. Feedback is linked via trace_id and can include custom metadata for analysis.",
7253
+ "Create feedback for a specific trace/request. Use this to capture user feedback (thumbs up/down, ratings) on AI generations. Feedback is linked via trace_id and can include custom metadata for analysis. Trace IDs are surfaced in request logs and via log exports (create_log_export).",
7008
7254
  TRACING_TOOL_SCHEMAS.createFeedback,
7009
7255
  async (params) => {
7010
7256
  const result = await service.tracing.createFeedback({
@@ -7033,7 +7279,7 @@ function registerTracingTools(server, service) {
7033
7279
  );
7034
7280
  server.tool(
7035
7281
  "update_feedback",
7036
- "Update existing feedback by ID. Allows modifying the feedback value, weight, or metadata after initial creation.",
7282
+ "Update existing feedback by ID. Use this instead of create_feedback when feedback already exists and needs correction or refinement. Only value, weight, and metadata can be changed; the trace_id association is immutable. Returns the updated feedback status and IDs.",
7037
7283
  TRACING_TOOL_SCHEMAS.updateFeedback,
7038
7284
  async (params) => {
7039
7285
  const result = await service.tracing.updateFeedback(params.id, {
@@ -7059,51 +7305,6 @@ function registerTracingTools(server, service) {
7059
7305
  };
7060
7306
  }
7061
7307
  );
7062
- server.tool(
7063
- "get_trace",
7064
- "Retrieve detailed information about a specific trace by ID. Returns full request/response data, all spans, metadata, cost, token usage, and any associated feedback.",
7065
- TRACING_TOOL_SCHEMAS.getTrace,
7066
- async (params) => {
7067
- const result = await service.tracing.getTrace(params.id);
7068
- const trace = result.data;
7069
- return {
7070
- content: [
7071
- {
7072
- type: "text",
7073
- text: JSON.stringify(
7074
- {
7075
- success: result.success,
7076
- trace: {
7077
- id: trace.id,
7078
- trace_id: trace.trace_id,
7079
- request: trace.request,
7080
- response: trace.response,
7081
- metadata: trace.metadata,
7082
- workspace_id: trace.workspace_id,
7083
- organisation_id: trace.organisation_id,
7084
- cost: trace.cost,
7085
- tokens: trace.tokens,
7086
- spans: trace.spans?.map((span) => ({
7087
- span_id: span.span_id,
7088
- span_name: span.span_name,
7089
- parent_span_id: span.parent_span_id,
7090
- start_time: span.start_time,
7091
- end_time: span.end_time,
7092
- status: span.status,
7093
- attributes: span.attributes
7094
- })),
7095
- feedback: trace.feedback,
7096
- created_at: trace.created_at
7097
- }
7098
- },
7099
- null,
7100
- 2
7101
- )
7102
- }
7103
- ]
7104
- };
7105
- }
7106
- );
7107
7308
  }
7108
7309
 
7109
7310
  // src/tools/users.tools.ts
@@ -7207,7 +7408,7 @@ function formatUserAnalyticsGroup(group) {
7207
7408
  function registerUsersTools(server, service) {
7208
7409
  server.tool(
7209
7410
  "list_all_users",
7210
- "List all users in your Portkey organization, including their roles and account details",
7411
+ "List all users in your Portkey organization. Returns each user's ID, name, email, role, and timestamps. Use this for browsing or auditing the full member list; use get_user to fetch a single user by ID.",
7211
7412
  USERS_TOOL_SCHEMAS.listAllUsers,
7212
7413
  async () => {
7213
7414
  const users = await service.users.listUsers();
@@ -7254,7 +7455,7 @@ function registerUsersTools(server, service) {
7254
7455
  );
7255
7456
  server.tool(
7256
7457
  "get_user_stats",
7257
- "Retrieve detailed analytics data about user activity within a specified time range, including request counts and costs",
7458
+ "Retrieve per-user request count and cost analytics for a required time range (time_of_generation_min/max). Unlike get_users_analytics which tracks active/new user counts over time, this returns usage-based stats grouped by user. Supports filtering by cost, tokens, status codes, and virtual keys.",
7258
7459
  USERS_TOOL_SCHEMAS.getUserStats,
7259
7460
  async (params) => {
7260
7461
  const stats = await service.users.getUserGroupedData(params);
@@ -7277,7 +7478,7 @@ function registerUsersTools(server, service) {
7277
7478
  );
7278
7479
  server.tool(
7279
7480
  "get_user",
7280
- "Retrieve detailed information about a specific user by their ID",
7481
+ "Retrieve a single user's profile by their ID. Returns ID, name, email, role, and timestamps. Use this when you already have a user ID; use list_all_users to browse or search all organization members.",
7281
7482
  USERS_TOOL_SCHEMAS.getUser,
7282
7483
  async (params) => {
7283
7484
  const user = await service.users.getUser(params.user_id);
@@ -7293,7 +7494,7 @@ function registerUsersTools(server, service) {
7293
7494
  );
7294
7495
  server.tool(
7295
7496
  "update_user",
7296
- "Update a user's profile information including name and organization role",
7497
+ "Update a user's first name, last name, or organization role (admin/member). Cannot change the user's email address or workspace-level roles; use update_workspace_member for workspace roles.",
7297
7498
  USERS_TOOL_SCHEMAS.updateUser,
7298
7499
  async (params) => {
7299
7500
  const { user_id, ...updateData } = params;
@@ -7317,7 +7518,7 @@ function registerUsersTools(server, service) {
7317
7518
  );
7318
7519
  server.tool(
7319
7520
  "delete_user",
7320
- "Remove a user from your Portkey organization. Permanently removes the user and all their org/workspace memberships. Cannot be undone.",
7521
+ "Remove a user from your Portkey organization by ID. This action cannot be undone. Permanently removes org and workspace memberships and revokes the user's API keys; active sessions will fail immediately. Use delete_user_invite for pending invitations instead.",
7321
7522
  USERS_TOOL_SCHEMAS.deleteUser,
7322
7523
  async (params) => {
7323
7524
  await service.users.deleteUser(params.user_id);
@@ -7340,7 +7541,7 @@ function registerUsersTools(server, service) {
7340
7541
  );
7341
7542
  server.tool(
7342
7543
  "list_user_invites",
7343
- "List all pending and sent user invitations in your Portkey organization",
7544
+ "List all pending and sent user invitations in your Portkey organization. Returns each invite's ID, email, role, status, and expiry. Use this to check invitation status; use list_all_users for users who have already accepted.",
7344
7545
  USERS_TOOL_SCHEMAS.listUserInvites,
7345
7546
  async () => {
7346
7547
  const invites = await service.users.listUserInvites();
@@ -7363,7 +7564,7 @@ function registerUsersTools(server, service) {
7363
7564
  );
7364
7565
  server.tool(
7365
7566
  "get_user_invite",
7366
- "Retrieve details about a specific user invitation",
7567
+ "Retrieve a specific invitation by its invite ID. Returns the invite's email, role, status, creation date, and expiry. This looks up a pending invitation, not an existing user; use get_user for accepted members.",
7367
7568
  USERS_TOOL_SCHEMAS.getUserInvite,
7368
7569
  async (params) => {
7369
7570
  const invite = await service.users.getUserInvite(params.invite_id);
@@ -7379,7 +7580,7 @@ function registerUsersTools(server, service) {
7379
7580
  );
7380
7581
  server.tool(
7381
7582
  "delete_user_invite",
7382
- "Cancel and delete a pending user invitation",
7583
+ "Cancel and permanently delete a pending user invitation. This revokes the invite link so it can no longer be accepted. Does not remove existing users; use delete_user for that.",
7383
7584
  USERS_TOOL_SCHEMAS.deleteUserInvite,
7384
7585
  async (params) => {
7385
7586
  await service.users.deleteUserInvite(params.invite_id);
@@ -7402,7 +7603,7 @@ function registerUsersTools(server, service) {
7402
7603
  );
7403
7604
  server.tool(
7404
7605
  "resend_user_invite",
7405
- "Resend an invitation email to a pending user",
7606
+ "Resend the invitation email for a pending invite that has not yet been accepted. Use when the original email was lost or expired. The invite must still exist; check with get_user_invite first if unsure.",
7406
7607
  USERS_TOOL_SCHEMAS.resendUserInvite,
7407
7608
  async (params) => {
7408
7609
  await service.users.resendUserInvite(params.invite_id);
@@ -7532,7 +7733,7 @@ function formatWorkspaceDetail(workspace) {
7532
7733
  function registerWorkspacesTools(server, service) {
7533
7734
  server.tool(
7534
7735
  "list_workspaces",
7535
- "Retrieve all workspaces in your Portkey organization, including their configurations and metadata",
7736
+ "Retrieve a paginated list of all workspaces in your Portkey organization. Returns id, name, slug, and configuration for each workspace. Use this tool first to discover workspace_id values needed by other workspace-scoped operations.",
7536
7737
  WORKSPACES_TOOL_SCHEMAS.listWorkspaces,
7537
7738
  async (params) => {
7538
7739
  const workspaces = await service.workspaces.listWorkspaces(params);
@@ -7555,7 +7756,7 @@ function registerWorkspacesTools(server, service) {
7555
7756
  );
7556
7757
  server.tool(
7557
7758
  "get_workspace",
7558
- "Retrieve detailed information about a specific workspace, including its configuration, metadata, and user access details",
7759
+ "Retrieve full details for a single workspace by ID, including its configuration, metadata, and complete member list with roles. Unlike list_workspaces, this includes the full user roster \u2014 use it when you need member details or workspace membership counts.",
7559
7760
  WORKSPACES_TOOL_SCHEMAS.getWorkspace,
7560
7761
  async (params) => {
7561
7762
  const workspace = await service.workspaces.getWorkspace(
@@ -7573,7 +7774,7 @@ function registerWorkspacesTools(server, service) {
7573
7774
  );
7574
7775
  server.tool(
7575
7776
  "create_workspace",
7576
- "Create a new workspace in your Portkey organization",
7777
+ "Create a new workspace to isolate resources, API keys, and team members within your Portkey organization. A URL-friendly slug is auto-generated from the name if not provided. Returns the created workspace's id, name, and slug.",
7577
7778
  WORKSPACES_TOOL_SCHEMAS.createWorkspace,
7578
7779
  async (params) => {
7579
7780
  const workspace = await service.workspaces.createWorkspace({
@@ -7604,7 +7805,7 @@ function registerWorkspacesTools(server, service) {
7604
7805
  );
7605
7806
  server.tool(
7606
7807
  "update_workspace",
7607
- "Update an existing workspace's settings and metadata",
7808
+ "Update a workspace's name, slug, description, default status, or metadata. Only provided fields are changed; omitted fields remain unchanged. Warning: changing a workspace's slug may break existing references and URLs that depend on it.",
7608
7809
  WORKSPACES_TOOL_SCHEMAS.updateWorkspace,
7609
7810
  async (params) => {
7610
7811
  const { workspace_id, is_default, metadata, ...rest } = params;
@@ -7657,7 +7858,7 @@ function registerWorkspacesTools(server, service) {
7657
7858
  );
7658
7859
  server.tool(
7659
7860
  "add_workspace_member",
7660
- "Add a user to a workspace with a specific role",
7861
+ "Add an existing organization user to a workspace with a specified role (admin, manager, or member). Requires user_id as a UUID \u2014 use list_all_users to find it. For users not yet in the organization, use invite_user first.",
7661
7862
  WORKSPACES_TOOL_SCHEMAS.addWorkspaceMember,
7662
7863
  async (params) => {
7663
7864
  const member = await service.workspaces.addWorkspaceMember(
@@ -7686,7 +7887,7 @@ function registerWorkspacesTools(server, service) {
7686
7887
  );
7687
7888
  server.tool(
7688
7889
  "list_workspace_members",
7689
- "List all members of a workspace with their roles",
7890
+ "List all members of a workspace, returning each member's user_id, name, organization role, workspace role, and status. Use this to discover user_id values needed for get_workspace_member, update_workspace_member, or remove_workspace_member.",
7690
7891
  WORKSPACES_TOOL_SCHEMAS.listWorkspaceMembers,
7691
7892
  async (params) => {
7692
7893
  const members = await service.workspaces.listWorkspaceMembers(
@@ -7711,7 +7912,7 @@ function registerWorkspacesTools(server, service) {
7711
7912
  );
7712
7913
  server.tool(
7713
7914
  "get_workspace_member",
7714
- "Get details about a specific member of a workspace",
7915
+ "Get details about a single workspace member by workspace_id and user_id. Returns the member's name, organization role, workspace role, and status. Unlike list_workspace_members, this fetches a single member directly when you already know both IDs.",
7715
7916
  WORKSPACES_TOOL_SCHEMAS.getWorkspaceMember,
7716
7917
  async (params) => {
7717
7918
  const member = await service.workspaces.getWorkspaceMember(
@@ -7730,7 +7931,7 @@ function registerWorkspacesTools(server, service) {
7730
7931
  );
7731
7932
  server.tool(
7732
7933
  "update_workspace_member",
7733
- "Update a member's role in a workspace",
7934
+ "Update a workspace member's role. Only the role can be changed \u2014 valid values are admin, manager, or member. Use list_workspace_members or get_workspace_member to check the current role first.",
7734
7935
  WORKSPACES_TOOL_SCHEMAS.updateWorkspaceMember,
7735
7936
  async (params) => {
7736
7937
  const member = await service.workspaces.updateWorkspaceMember(
@@ -7759,7 +7960,7 @@ function registerWorkspacesTools(server, service) {
7759
7960
  );
7760
7961
  server.tool(
7761
7962
  "remove_workspace_member",
7762
- "Remove a user from a workspace",
7963
+ "Remove a user from a workspace, revoking their workspace-level access. This does not delete the user from the organization \u2014 use delete_user for full org removal. The user can be re-added later with add_workspace_member.",
7763
7964
  WORKSPACES_TOOL_SCHEMAS.removeWorkspaceMember,
7764
7965
  async (params) => {
7765
7966
  await service.workspaces.removeWorkspaceMember(
@@ -7840,6 +8041,37 @@ var DESTRUCTIVE_TOOL_PREFIXES = [
7840
8041
  "cancel_",
7841
8042
  "reset_"
7842
8043
  ];
8044
+ var ENTERPRISE_GATED_TOOL_NAMES = /* @__PURE__ */ new Set([
8045
+ "get_cost_analytics",
8046
+ "get_request_analytics",
8047
+ "get_token_analytics",
8048
+ "get_latency_analytics",
8049
+ "get_error_analytics",
8050
+ "get_error_rate_analytics",
8051
+ "get_cache_hit_latency",
8052
+ "get_cache_hit_rate",
8053
+ "get_users_analytics",
8054
+ "get_error_stacks_analytics",
8055
+ "get_error_status_codes_analytics",
8056
+ "get_user_requests_analytics",
8057
+ "get_rescued_requests_analytics",
8058
+ "get_feedback_analytics",
8059
+ "get_feedback_models_analytics",
8060
+ "get_feedback_scores_analytics",
8061
+ "get_feedback_weighted_analytics",
8062
+ "get_analytics_group_users",
8063
+ "get_analytics_group_models",
8064
+ "get_analytics_group_metadata",
8065
+ "list_audit_logs",
8066
+ "get_integration",
8067
+ "list_integration_models",
8068
+ "list_integration_workspaces",
8069
+ "list_all_users",
8070
+ "get_user",
8071
+ "list_user_invites",
8072
+ "get_user_stats"
8073
+ ]);
8074
+ var ENTERPRISE_GATED_DESCRIPTION_NOTE = "Enterprise-gated. Returns 403 on non-Enterprise Portkey plans.";
7843
8075
  function isToolAnnotationsLike(value) {
7844
8076
  if (!isRecord2(value)) {
7845
8077
  return false;
@@ -7888,6 +8120,15 @@ function inferToolAnnotations(toolName) {
7888
8120
  openWorldHint: true
7889
8121
  };
7890
8122
  }
8123
+ function augmentToolDescription(toolName, description) {
8124
+ if (!description || !ENTERPRISE_GATED_TOOL_NAMES.has(toolName)) {
8125
+ return description;
8126
+ }
8127
+ if (description.includes(ENTERPRISE_GATED_DESCRIPTION_NOTE)) {
8128
+ return description;
8129
+ }
8130
+ return `${description} ${ENTERPRISE_GATED_DESCRIPTION_NOTE}`;
8131
+ }
7891
8132
  function getToolErrorMessage(error) {
7892
8133
  if (error instanceof Error && error.message) {
7893
8134
  return error.message;
@@ -7992,6 +8233,7 @@ function buildToolRegistration(name, rest) {
7992
8233
  if (typeof args[0] === "string") {
7993
8234
  description = args.shift();
7994
8235
  }
8236
+ description = augmentToolDescription(name, description);
7995
8237
  let inputSchema;
7996
8238
  let annotations = inferredAnnotations;
7997
8239
  if (args.length === 1) {
@@ -8637,7 +8879,27 @@ function readPackageVersion() {
8637
8879
  return "0.0.0";
8638
8880
  }
8639
8881
  var PACKAGE_VERSION = readPackageVersion();
8640
- var SERVER_INSTRUCTIONS = "Portkey Admin API server. Use list_* tools for discovery and get_* tools for details. Analytics tools require time_of_generation_min/max. Prompt workflows: create_prompt -> publish_prompt. Always validate_completion_metadata before run_prompt_completion.";
8882
+ var SERVER_INSTRUCTIONS = "Portkey Admin API server. Use list_* tools for discovery and get_* tools for details. Analytics tools require time_of_generation_min/max. Prompt workflows: create_prompt -> publish_prompt. Always validate_completion_metadata before run_prompt_completion. If the server is configured with only some domains, stay within that subset instead of assuming every Portkey admin tool is available.";
8883
+ function parseConfiguredToolDomains(rawValue = process.env.PORTKEY_TOOL_DOMAINS?.trim() || process.env.MCP_TOOL_DOMAINS?.trim()) {
8884
+ if (!rawValue) {
8885
+ return void 0;
8886
+ }
8887
+ const requestedDomains = rawValue.split(",").map((value) => value.trim().toLowerCase()).filter((value) => value.length > 0);
8888
+ if (requestedDomains.length === 0) {
8889
+ throw new Error(
8890
+ `Invalid PORTKEY_TOOL_DOMAINS value. Expected one or more domains from: ${TOOL_DOMAIN_NAMES.join(", ")}`
8891
+ );
8892
+ }
8893
+ const invalidDomains = requestedDomains.filter(
8894
+ (value) => !isToolDomain(value)
8895
+ );
8896
+ if (invalidDomains.length > 0) {
8897
+ throw new Error(
8898
+ `Unknown tool domains in PORTKEY_TOOL_DOMAINS: ${invalidDomains.join(", ")}. Valid domains: ${TOOL_DOMAIN_NAMES.join(", ")}`
8899
+ );
8900
+ }
8901
+ return normalizeToolDomains(requestedDomains);
8902
+ }
8641
8903
  function createMcpServer(options = {}) {
8642
8904
  const service = getSharedPortkeyService();
8643
8905
  const server = new McpServer(
@@ -8652,7 +8914,9 @@ function createMcpServer(options = {}) {
8652
8914
  instructions: SERVER_INSTRUCTIONS
8653
8915
  }
8654
8916
  );
8655
- registerAllTools(server, service, { domains: options.toolDomains });
8917
+ registerAllTools(server, service, {
8918
+ domains: options.toolDomains ?? parseConfiguredToolDomains()
8919
+ });
8656
8920
  return {
8657
8921
  server,
8658
8922
  service