portkey-admin-mcp 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +89 -34
  2. package/build/index.js +1243 -638
  3. package/build/server.js +2275 -845
  4. package/package.json +18 -14
package/README.md CHANGED
@@ -2,28 +2,44 @@
2
2
 
3
3
  <img src="./assets/portkey-balloon-spin-light.webp" alt="Portkey Admin MCP icon" width="180" height="180">
4
4
 
5
- # Portkey Admin MCP Server
5
+ <h1>Portkey Admin MCP Server</h1>
6
6
 
7
- MCP server for the [Portkey](https://portkey.ai/) Admin API. Manage prompts, configs, analytics, API keys, and more from any MCP client.
7
+ **The full [Portkey](https://portkey.ai/) Admin API as an MCP server — 156 tools across prompts, configs, keys, analytics, and more.**
8
8
 
9
- <a href="https://www.npmjs.com/package/portkey-admin-mcp"><img src="https://img.shields.io/npm/v/portkey-admin-mcp.svg" alt="npm version"></a>
10
- <a href="https://www.npmjs.com/package/portkey-admin-mcp"><img src="https://img.shields.io/npm/dm/portkey-admin-mcp.svg" alt="npm downloads"></a>
11
- <a href="https://github.com/CodesWhat/portkey-admin-mcp/actions/workflows/ci.yml"><img src="https://github.com/CodesWhat/portkey-admin-mcp/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
12
- <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D24-brightgreen.svg" alt="Node.js"></a>
13
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
14
- <a href="https://github.com/punkpeye/awesome-mcp-servers"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome MCP Servers"></a>
15
- [![MCP Badge](https://lobehub.com/badge/mcp-full/codeswhat-portkey-admin-mcp?theme=light)](https://lobehub.com/mcp/codeswhat-portkey-admin-mcp)
9
+ </div>
16
10
 
17
- <a href="https://glama.ai/mcp/servers/CodesWhat/portkey-admin-mcp"><img src="https://glama.ai/mcp/servers/CodesWhat/portkey-admin-mcp/badges/card.svg" alt="portkey-admin-mcp MCP server"></a>
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/portkey-admin-mcp"><img src="https://img.shields.io/npm/v/portkey-admin-mcp.svg" alt="npm version"></a>
13
+ <a href="https://www.npmjs.com/package/portkey-admin-mcp"><img src="https://img.shields.io/npm/dm/portkey-admin-mcp.svg" alt="npm downloads"></a>
14
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D24-brightgreen.svg" alt="Node.js"></a>
15
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
16
+ <br>
17
+ <a href="https://github.com/CodesWhat/portkey-admin-mcp/actions/workflows/ci.yml"><img src="https://github.com/CodesWhat/portkey-admin-mcp/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
18
+ <a href="https://github.com/punkpeye/awesome-mcp-servers"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome MCP Servers"></a>
19
+ <a href="https://lobehub.com/mcp/codeswhat-portkey-admin-mcp"><img src="https://lobehub.com/badge/mcp/codeswhat-portkey-admin-mcp" alt="LobeHub MCP"></a>
20
+ </p>
18
21
 
19
- </div>
22
+ <p align="center">
23
+ <a href="https://glama.ai/mcp/servers/CodesWhat/portkey-admin-mcp"><img src="https://glama.ai/mcp/servers/CodesWhat/portkey-admin-mcp/badges/card.svg" alt="portkey-admin-mcp MCP server"></a>
24
+ </p>
20
25
 
21
- ---
26
+ <hr>
22
27
 
23
28
  > [!IMPORTANT]
24
- > **Maintenance mode.** Portkey was acquired by **Palo Alto Networks** (completed 2026‑05‑29) and is being folded into the Prisma AIRS platform. The Portkey Admin API this server targets is **live and unchanged as of June 2026**, and this project still works end‑to‑end — but it is now in **maintenance mode**: security and dependency patches only, no new features, pending Palo Alto's post‑acquisition API roadmap. If the hosted Admin API is ever deprecated, point `PORTKEY_BASE_URL` at a self‑hosted [Portkey gateway](https://github.com/Portkey-AI/gateway). See [docs/audit-2026-06.md](./docs/audit-2026-06.md) for the full assessment.
29
+ > **Maintenance mode.** Portkey was acquired by **Palo Alto Networks** (completed 2026‑05‑29) and is being folded into the Prisma AIRS platform. The Portkey Admin API this server targets is **live and unchanged as of June 2026**, and this project still works end‑to‑end — but it is now in **maintenance mode**: security and dependency patches only, no new features, pending Palo Alto's post‑acquisition API roadmap. If the hosted Admin API is ever deprecated, point `PORTKEY_BASE_URL` at a self‑hosted [Portkey gateway](https://github.com/Portkey-AI/gateway). See [docs/audit-2026-06.md](./docs/audit-2026-06.md) for the full assessment and [security_best_practices_report.md](./security_best_practices_report.md) for the 0.6.0 security-hardening review.
30
+
31
+ <h2 align="center">📑 Contents</h2>
25
32
 
26
- ## Quick Start
33
+ - [🚀 Quick Start](#quick-start)
34
+ - [🧰 What You Can Do](#what-you-can-do)
35
+ - [🔑 API Key Scopes](#api-key-scopes)
36
+ - [🌐 HTTP Server (Experimental)](#http-server)
37
+ - [🛠️ Development](#development)
38
+ - [🧾 Full tool list — ENDPOINTS.md](./ENDPOINTS.md)
39
+
40
+ <hr>
41
+
42
+ <h2 align="center" id="quick-start">🚀 Quick Start</h2>
27
43
 
28
44
  You need a **Portkey API key** with appropriate scopes. Get one from your [Portkey dashboard](https://app.portkey.ai/) under API Keys.
29
45
 
@@ -91,9 +107,9 @@ Then use this config:
91
107
 
92
108
  </details>
93
109
 
94
- ---
110
+ <hr>
95
111
 
96
- ## What You Can Do
112
+ <h2 align="center" id="what-you-can-do">🧰 What You Can Do</h2>
97
113
 
98
114
  | Category | Tools | Examples |
99
115
  |----------|-------|---------|
@@ -101,7 +117,8 @@ Then use this config:
101
117
  | **Prompt Partials** | 7 | Reusable prompt fragments with versioning |
102
118
  | **Prompt Labels** | 5 | Organize prompt versions (production, staging, dev) |
103
119
  | **Configs** | 6 | Gateway routing, caching, retry, loadbalancing |
104
- | **API Keys** | 5 | Create and manage scoped API keys |
120
+ | **API Keys** | 6 | Create, rotate, and manage scoped API keys |
121
+ | **Secret References** | 5 | Manage AWS, Azure, and HashiCorp external-secret references |
105
122
  | **Virtual Keys** | 5 | Manage provider access keys |
106
123
  | **Collections** | 5 | Group prompts by app or project |
107
124
  | **Providers** | 5 | Manage AI provider configurations |
@@ -117,11 +134,11 @@ Then use this config:
117
134
  | **Users & Workspaces** | 20 | User management, invites, workspace members |
118
135
  | **Audit** | 1 | Audit log access |
119
136
 
120
- **150 tools total.** See [ENDPOINTS.md](./ENDPOINTS.md) for the full list with descriptions.
137
+ **156 tools total.** See [ENDPOINTS.md](./ENDPOINTS.md) for the full list with descriptions.
121
138
 
122
- ---
139
+ <hr>
123
140
 
124
- ## API Key Scopes
141
+ <h2 align="center" id="api-key-scopes">🔑 API Key Scopes</h2>
125
142
 
126
143
  Most tools work with a **workspace-scoped service key** that has Select All permissions enabled. That covers prompts, configs, virtual/API keys, providers, guardrails, workspace integrations, MCP servers, rate/usage limits, logs, prompt completions, and workspace user management.
127
144
 
@@ -145,9 +162,9 @@ The following tools require an **organisation-level scope that is only available
145
162
 
146
163
  If a tool returns a `403` with Portkey error `AB03`, it means missing scopes — not a broken endpoint.
147
164
 
148
- ---
165
+ <hr>
149
166
 
150
- ## HTTP Server (Experimental)
167
+ <h2 align="center" id="http-server">🌐 HTTP Server (Experimental)</h2>
151
168
 
152
169
  > **Status**: The HTTP transport works locally and is covered by the integration test suite, but it is a proof of concept — there is **no hosted version** of this server, and hosted deployment is not currently a goal. Use stdio (npx) as the supported transport.
153
170
 
@@ -176,24 +193,39 @@ For local-only HTTP use, leave `MCP_HOST` at its default `127.0.0.1`. Set `MCP_H
176
193
  | Variable | Default | Description |
177
194
  |----------|---------|-------------|
178
195
  | `PORTKEY_API_KEY` | (required) | Your Portkey API key |
179
- | `PORTKEY_BASE_URL` | `https://api.portkey.ai/v1` | Portkey Admin API base URL. Point at a self-hosted Portkey gateway if needed. Loopback/private-network hosts are rejected unless `PORTKEY_ALLOW_PRIVATE_BASE_URL=true` |
180
- | `PORTKEY_ALLOW_PRIVATE_BASE_URL` | — | Set to `true` to allow a `PORTKEY_BASE_URL` on loopback or a private network (e.g. a self-hosted gateway at `http://localhost:8787`) |
181
- | `PORTKEY_TOOL_DOMAINS` | — | Optional comma-separated stdio/HTTP default tool subset, e.g. `prompts,analytics` |
196
+ | `PORTKEY_BASE_URL` | `https://api.portkey.ai/v1` | Portkey Admin API base URL. Credentialed requests never auto-follow redirects |
197
+ | `PORTKEY_ALLOW_PRIVATE_BASE_URL` | — | Set to `true` to allow a literal loopback/private `PORTKEY_BASE_URL` |
198
+ | `PORTKEY_ALLOW_INSECURE_HTTP` | — | Separately set to `true` only when a trusted self-hosted gateway cannot use HTTPS |
199
+ | `PORTKEY_TOOL_DOMAINS` | — | Server-side tool-domain allowlist. HTTP `?tools=` may narrow this set but cannot expand it |
182
200
  | `MCP_HOST` | `127.0.0.1` | Bind address |
183
201
  | `MCP_PORT` | `3000` | Port |
184
202
  | `MCP_PUBLIC_BASE_URL` | — | Public absolute base URL to advertise from `/auth/info` and the status page; recommended for hosted deployments |
185
203
  | `MCP_AUTH_MODE` | `none` | `none`, `bearer`, or `clerk` (`none` is blocked for HTTP unless explicitly overridden) |
186
204
  | `MCP_AUTH_TOKEN` | — | Secret for bearer auth |
205
+ | `CLERK_ISSUER` / `CLERK_AUDIENCE` | — | Required issuer and audience when `MCP_AUTH_MODE=clerk` |
206
+ | `CLERK_ALLOWED_SUBJECTS` | — | Optional CSV subject allowlist for Clerk; at least one Clerk authorization policy is required |
207
+ | `CLERK_ALLOWED_ORGANIZATION_IDS` / `CLERK_ALLOWED_ROLES` | — | Optional CSV organization and role constraints; every configured constraint must match |
208
+ | `CLERK_REQUIRED_PERMISSIONS` | — | Optional CSV permissions that must all be present in the verified Clerk JWT |
187
209
  | `MCP_ALLOW_UNAUTHENTICATED_HTTP` | — | Set to `true` only for intentional local unauthenticated HTTP debugging |
188
210
  | `MCP_SESSION_MODE` | `stateful` | `stateful` or `stateless` |
189
- | `MCP_MAX_SESSIONS` | `100` | Maximum concurrent stateful MCP sessions before new initialize requests are rejected |
190
- | `MCP_EVENT_STORE` | `off` | `off`, `memory`, or `redis` |
191
- | `MCP_REDIS_URL` | — | Redis URL for shared event store |
211
+ | `MCP_MAX_SESSIONS` | `100` | Maximum concurrent stateful sessions or active stateless request handlers |
212
+ | `MCP_EVENT_STORE` | `off` | `off`, `memory`, or `redis`; stateless `GET /mcp` replay requires `memory` or `redis` |
213
+ | `MCP_EVENT_TTL_SECONDS` | `300` | Replay retention in seconds |
214
+ | `MCP_REDIS_URL` | — | Redis URL for shared event store; production requires `rediss://` and ACL-scoped credentials |
215
+ | `MCP_EVENT_ENCRYPTION_KEY` | — | Required 32-byte base64 AES key for Redis replay payloads; generate with `openssl rand -base64 32` |
216
+ | `MCP_REDIS_KEY_PREFIX` | `mcp:event-store` | Dedicated Redis namespace for replay data |
192
217
  | `MCP_TLS_KEY_PATH` | — | TLS key for native HTTPS |
193
218
  | `MCP_TLS_CERT_PATH` | — | TLS cert for native HTTPS |
194
219
  | `ALLOWED_ORIGINS` | — | CORS allow-list; also used to validate the `Host` header (DNS-rebinding protection) when `MCP_AUTH_MODE=none` |
195
220
  | `MCP_TRUST_PROXY` | `false` | Trust proxy headers (for reverse proxies) |
196
- | `RATE_LIMIT_MAX_BUCKETS` | `10000` | Maximum distinct in-memory rate-limit buckets before new clients share an overflow bucket |
221
+ | `RATE_LIMIT_STORE` | `memory` | `redis` for multi-instance/serverless deployments; production memory mode requires `RATE_LIMIT_SINGLE_PROCESS=true` |
222
+ | `RATE_LIMIT_REDIS_URL` | — | Shared limiter Redis URL, falling back to `MCP_REDIS_URL`/`REDIS_URL`; production requires `rediss://` |
223
+ | `RATE_LIMIT_REDIS_KEY_PREFIX` | `mcp:rate-limit` | Redis namespace for atomic pre-authentication IP and principal-plus-IP token buckets |
224
+ | `RATE_LIMIT_MAX_BUCKETS` | `10000` | Maximum local buckets in explicit memory mode before new clients share overflow capacity |
225
+
226
+ Production containers must choose their rate-limit topology explicitly: set
227
+ `RATE_LIMIT_STORE=redis` for multi-instance deployments, or set
228
+ `RATE_LIMIT_SINGLE_PROCESS=true` only for a single long-lived process.
197
229
 
198
230
  <details>
199
231
  <summary><strong>Vercel deployment</strong></summary>
@@ -201,7 +233,7 @@ For local-only HTTP use, leave `MCP_HOST` at its default `127.0.0.1`. Set `MCP_H
201
233
  Vercel support is kept as a reference proof of concept — we do not run a hosted deployment. See [docs/VERCEL_DEPLOYMENT.md](./docs/VERCEL_DEPLOYMENT.md) if you want to self-deploy.
202
234
 
203
235
  Key points:
204
- - Uses stateless mode with Redis event store
236
+ - Uses stateless request handling with encrypted, principal-bound Redis replay and a shared atomic Redis rate limiter
205
237
  - Requires Clerk or bearer auth
206
238
  - Leave `MCP_TLS_*` unset (Vercel terminates HTTPS)
207
239
  - Set `MCP_PUBLIC_BASE_URL` to your deployment URL so advertised MCP endpoints never depend on request headers
@@ -235,9 +267,9 @@ docker run \
235
267
  | `GET /ready` | Readiness (includes optional Portkey connectivity check) |
236
268
  | `GET /auth/info` | Auth configuration metadata |
237
269
 
238
- ---
270
+ <hr>
239
271
 
240
- ## Development
272
+ <h2 align="center" id="development">🛠️ Development</h2>
241
273
 
242
274
  ```bash
243
275
  npm run dev # stdio with hot reload
@@ -254,8 +286,31 @@ npm run ci # full pipeline (lint + typecheck + test + build + e2e + v
254
286
 
255
287
  <div align="center">
256
288
 
257
- **MIT License** · Inspired by [r-huijts/portkey-admin-mcp-server](https://github.com/r-huijts/portkey-admin-mcp-server)
289
+ ### Built With
290
+
291
+ [![TypeScript](https://img.shields.io/badge/TypeScript_7.0-3178C6?logo=typescript&logoColor=fff)](https://www.typescriptlang.org/)
292
+ [![MCP SDK](https://img.shields.io/badge/MCP_SDK_1.29-000?logo=modelcontextprotocol&logoColor=fff)](https://github.com/modelcontextprotocol/typescript-sdk)
293
+ [![Zod 4](https://img.shields.io/badge/Zod_4-3E67B1?logo=zod&logoColor=fff)](https://zod.dev/)
294
+ [![Biome](https://img.shields.io/badge/Biome_2.5-60a5fa?logo=biome&logoColor=fff)](https://biomejs.dev/)
295
+ [![Node 24](https://img.shields.io/badge/Node_24-339933?logo=nodedotjs&logoColor=fff)](https://nodejs.org/)
296
+ [![Anthropic](https://img.shields.io/badge/Anthropic-CC785C?style=flat&logo=anthropic&logoColor=white)](https://claude.ai/)
297
+
298
+ [![SemVer](https://img.shields.io/badge/semver-2.0.0-blue)](https://semver.org/)
299
+ [![Conventional Commits](https://img.shields.io/badge/commits-conventional-fe5196?logo=conventionalcommits&logoColor=fff)](https://www.conventionalcommits.org/)
300
+ [![Keep a Changelog](https://img.shields.io/badge/changelog-Keep%20a%20Changelog-E05735)](https://keepachangelog.com/)
301
+
302
+ **[MIT License](LICENSE)** · Inspired by [r-huijts/portkey-admin-mcp-server](https://github.com/r-huijts/portkey-admin-mcp-server)
303
+
304
+ <a href="https://github.com/CodesWhat">
305
+ <picture>
306
+ <source media="(prefers-color-scheme: dark)" srcset="assets/codeswhat-logo-dark.svg" />
307
+ <source media="(prefers-color-scheme: light)" srcset="assets/codeswhat-logo-original.svg" />
308
+ <img src="assets/codeswhat-logo-original.svg" alt="CodesWhat" height="28">
309
+ </picture>
310
+ </a>
311
+
312
+ [![Sponsor](https://img.shields.io/badge/Sponsor-ea4aaa?logo=githubsponsors&logoColor=white)](https://github.com/sponsors/CodesWhat)
258
313
 
259
- <a href="#portkey-admin-mcp-server">↑ Back to top</a>
314
+ <a href="#portkey-admin-mcp-server">Back to top</a>
260
315
 
261
316
  </div>