portkey-admin-mcp 0.1.0-beta.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Scott Benson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,645 @@
1
+ <div align="center">
2
+
3
+ # Portkey Admin MCP Server
4
+
5
+ <picture>
6
+ <source media="(prefers-color-scheme: dark)" srcset="https://readme-typing-svg.demolab.com?font=Fira+Code&pause=1000&color=FFFFFF&center=true&vCenter=true&width=500&lines=116+tools+for+Portkey+Admin+API;Prompts%2C+Configs%2C+Analytics;Full+MCP+Protocol+1.0+Server">
7
+ <source media="(prefers-color-scheme: light)" srcset="https://readme-typing-svg.demolab.com?font=Fira+Code&pause=1000&color=000000&center=true&vCenter=true&width=500&lines=116+tools+for+Portkey+Admin+API;Prompts%2C+Configs%2C+Analytics;Full+MCP+Protocol+1.0+Server">
8
+ <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&pause=1000&color=000000&center=true&vCenter=true&width=500&lines=116+tools+for+Portkey+Admin+API;Prompts%2C+Configs%2C+Analytics;Full+MCP+Protocol+1.0+Server" alt="Typing SVG">
9
+ </picture>
10
+
11
+ MCP server for [Portkey](https://portkey.ai/) Admin API. **116 tools** for prompts, configs, analytics & more.
12
+
13
+ </div>
14
+
15
+ <p align="center">
16
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg" alt="Node.js"></a>
17
+ <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.9-blue.svg" alt="TypeScript"></a>
18
+ </p>
19
+
20
+ <p align="center">
21
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
22
+ <a href="./ENDPOINTS.md"><img src="https://img.shields.io/badge/docs-ENDPOINTS.md-blue" alt="Docs"></a>
23
+ </p>
24
+
25
+ ---
26
+
27
+ ## ๐Ÿ“‘ Contents
28
+
29
+ - [๐Ÿš€ Quick Start](#-quick-start)
30
+ - [โœจ Features](#-features)
31
+ - [๐Ÿ”ง Tools](#-tools-116)
32
+ - [๐Ÿ—๏ธ Architecture](#-architecture)
33
+ - [๐Ÿšข Deployment](#-deployment)
34
+ - [โ–ฒ Vercel Guide](./docs/VERCEL_DEPLOYMENT.md)
35
+ - [๐Ÿ” Security Policy](./SECURITY.md)
36
+ - [โš ๏ธ Limitations](#-limitations)
37
+
38
+ ---
39
+
40
+ ## ๐Ÿš€ Quick Start
41
+
42
+ ### Installation Methods
43
+
44
+ | Method | Type | Setup |
45
+ |--------|------|-------|
46
+ | `npx portkey-admin-mcp` | Zero-install | Runs directly via npx |
47
+ | [![Docker](https://img.shields.io/badge/Docker-Container-2496ED?logo=docker&logoColor=white)](https://github.com/s-b-e-n-s-o-n/portkey-admin-mcp) | Self-hosted | `docker pull` or build from source |
48
+
49
+ ### npx (Recommended)
50
+
51
+ ```bash
52
+ PORTKEY_API_KEY=your_key npx -y portkey-admin-mcp
53
+ ```
54
+
55
+ <details>
56
+ <summary><strong>Claude Code</strong></summary>
57
+
58
+ ```bash
59
+ claude mcp add -e PORTKEY_API_KEY=your_key portkey -- npx -y portkey-admin-mcp
60
+ ```
61
+
62
+ </details>
63
+
64
+ <details>
65
+ <summary><strong>Cursor / Windsurf / VS Code</strong></summary>
66
+
67
+ Add to your MCP config (`.cursor/mcp.json`, `.windsurf/mcp.json`, or `.vscode/mcp.json`):
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "portkey": {
73
+ "command": "npx",
74
+ "args": ["-y", "portkey-admin-mcp"],
75
+ "env": {
76
+ "PORTKEY_API_KEY": "your_api_key"
77
+ }
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ </details>
84
+
85
+ ---
86
+
87
+ <details>
88
+ <summary><strong>๐Ÿ”จ Build from source</strong></summary>
89
+
90
+ ```bash
91
+ git clone https://github.com/s-b-e-n-s-o-n/portkey-admin-mcp.git
92
+ cd portkey-admin-mcp
93
+ npm install
94
+ npm run build
95
+ ```
96
+
97
+ Then use this config:
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "portkey": {
102
+ "command": "node",
103
+ "args": ["/path/to/portkey-admin-mcp/build/index.js"],
104
+ "env": {
105
+ "PORTKEY_API_KEY": "your_api_key"
106
+ }
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ </details>
113
+
114
+ ---
115
+
116
+ ## โœจ Features
117
+
118
+ <table>
119
+ <tr>
120
+ <td align="center" width="33%">
121
+ <h3>๐Ÿ“ Prompt Management</h3>
122
+ Create, version, render & execute prompts
123
+ </td>
124
+ <td align="center" width="33%">
125
+ <h3>โšก Gateway Configs</h3>
126
+ Loadbalancing, fallbacks, caching
127
+ </td>
128
+ <td align="center" width="33%">
129
+ <h3>๐Ÿ“Š Analytics</h3>
130
+ Cost, latency, errors, feedback
131
+ </td>
132
+ </tr>
133
+ <tr>
134
+ <td align="center">
135
+ <h3>๐Ÿ›ก๏ธ Governance</h3>
136
+ Rate limits, usage limits, guardrails
137
+ </td>
138
+ <td align="center">
139
+ <h3>๐Ÿ” Observability</h3>
140
+ Logs, traces, audit trails
141
+ </td>
142
+ <td align="center">
143
+ <h3>๐Ÿ” Access Control</h3>
144
+ Users, workspaces, API keys
145
+ </td>
146
+ </tr>
147
+ </table>
148
+
149
+ ---
150
+
151
+ ## ๐Ÿ”ง Tools (116)
152
+
153
+ <details>
154
+ <summary><strong>๐Ÿ‘ฅ User & Access</strong> (10 tools)</summary>
155
+
156
+ | Tool | Description |
157
+ |------|-------------|
158
+ | `list_all_users` | List all users in organization |
159
+ | `get_user` | Get user details |
160
+ | `update_user` | Update user |
161
+ | `delete_user` | Remove user |
162
+ | `invite_user` | Invite a new user |
163
+ | `list_user_invites` | List pending invites |
164
+ | `get_user_invite` | Get invite details |
165
+ | `delete_user_invite` | Cancel invite |
166
+ | `resend_user_invite` | Resend invite email |
167
+ | `get_user_stats` | Get user statistics |
168
+
169
+ </details>
170
+
171
+ <details>
172
+ <summary><strong>๐Ÿข Workspaces</strong> (10 tools)</summary>
173
+
174
+ | Tool | Description |
175
+ |------|-------------|
176
+ | `list_workspaces` | List all workspaces |
177
+ | `get_workspace` | Get workspace details |
178
+ | `create_workspace` | Create workspace |
179
+ | `update_workspace` | Update workspace |
180
+ | `delete_workspace` | Delete workspace |
181
+ | `add_workspace_member` | Add member to workspace |
182
+ | `list_workspace_members` | List workspace members |
183
+ | `get_workspace_member` | Get member details |
184
+ | `update_workspace_member` | Update member role |
185
+ | `remove_workspace_member` | Remove member |
186
+
187
+ </details>
188
+
189
+ <details>
190
+ <summary><strong>โš™๏ธ Configs</strong> (6 tools)</summary>
191
+
192
+ | Tool | Description |
193
+ |------|-------------|
194
+ | `list_configs` | List gateway configs |
195
+ | `get_config` | Get config details |
196
+ | `create_config` | Create config |
197
+ | `update_config` | Update config |
198
+ | `delete_config` | Delete config |
199
+ | `list_config_versions` | List config version history |
200
+
201
+ </details>
202
+
203
+ <details>
204
+ <summary><strong>๐Ÿ”‘ API & Virtual Keys</strong> (10 tools)</summary>
205
+
206
+ | Tool | Description |
207
+ |------|-------------|
208
+ | `list_api_keys` | List API keys |
209
+ | `create_api_key` | Create API key |
210
+ | `get_api_key` | Get API key details |
211
+ | `update_api_key` | Update API key |
212
+ | `delete_api_key` | Delete API key |
213
+ | `list_virtual_keys` | List virtual keys |
214
+ | `create_virtual_key` | Create virtual key |
215
+ | `get_virtual_key` | Get virtual key details |
216
+ | `update_virtual_key` | Update virtual key |
217
+ | `delete_virtual_key` | Delete virtual key |
218
+
219
+ </details>
220
+
221
+ <details>
222
+ <summary><strong>๐Ÿ“ Collections</strong> (5 tools)</summary>
223
+
224
+ | Tool | Description |
225
+ |------|-------------|
226
+ | `list_collections` | List prompt collections |
227
+ | `create_collection` | Create a collection |
228
+ | `get_collection` | Get collection details |
229
+ | `update_collection` | Update collection |
230
+ | `delete_collection` | Delete collection |
231
+
232
+ </details>
233
+
234
+ <details>
235
+ <summary><strong>๐Ÿ“ Prompts</strong> (12 tools)</summary>
236
+
237
+ | Tool | Description |
238
+ |------|-------------|
239
+ | `list_prompts` | List prompts |
240
+ | `create_prompt` | Create a prompt template |
241
+ | `get_prompt` | Get prompt details |
242
+ | `update_prompt` | Update a prompt |
243
+ | `delete_prompt` | Delete prompt |
244
+ | `publish_prompt` | Publish prompt version |
245
+ | `list_prompt_versions` | List version history |
246
+ | `render_prompt` | Render prompt with variables |
247
+ | `run_prompt_completion` | Execute prompt completion |
248
+ | `migrate_prompt` | Create-or-update prompt |
249
+ | `promote_prompt` | Promote prompt between environments |
250
+ | `validate_completion_metadata` | Validate billing metadata |
251
+
252
+ </details>
253
+
254
+ <details>
255
+ <summary><strong>๐Ÿงฉ Prompt Partials</strong> (7 tools)</summary>
256
+
257
+ | Tool | Description |
258
+ |------|-------------|
259
+ | `create_prompt_partial` | Create reusable partial |
260
+ | `list_prompt_partials` | List partials |
261
+ | `get_prompt_partial` | Get partial details |
262
+ | `update_prompt_partial` | Update partial |
263
+ | `delete_prompt_partial` | Delete partial |
264
+ | `list_partial_versions` | List partial versions |
265
+ | `publish_partial` | Publish partial version |
266
+
267
+ </details>
268
+
269
+ <details>
270
+ <summary><strong>๐Ÿท๏ธ Prompt Labels</strong> (5 tools)</summary>
271
+
272
+ | Tool | Description |
273
+ |------|-------------|
274
+ | `create_prompt_label` | Create label |
275
+ | `list_prompt_labels` | List labels |
276
+ | `get_prompt_label` | Get label details |
277
+ | `update_prompt_label` | Update label |
278
+ | `delete_prompt_label` | Delete label |
279
+
280
+ </details>
281
+
282
+ <details>
283
+ <summary><strong>๐Ÿ›ก๏ธ Guardrails</strong> (5 tools)</summary>
284
+
285
+ | Tool | Description |
286
+ |------|-------------|
287
+ | `list_guardrails` | List guardrails |
288
+ | `create_guardrail` | Create guardrail |
289
+ | `get_guardrail` | Get guardrail details |
290
+ | `update_guardrail` | Update guardrail |
291
+ | `delete_guardrail` | Delete guardrail |
292
+
293
+ </details>
294
+
295
+ <details>
296
+ <summary><strong>๐Ÿ“ Usage Limits</strong> (5 tools)</summary>
297
+
298
+ | Tool | Description |
299
+ |------|-------------|
300
+ | `list_usage_limits` | List usage limits |
301
+ | `create_usage_limit` | Create usage limit |
302
+ | `get_usage_limit` | Get limit details |
303
+ | `update_usage_limit` | Update limit |
304
+ | `delete_usage_limit` | Delete limit |
305
+
306
+ </details>
307
+
308
+ <details>
309
+ <summary><strong>โฑ๏ธ Rate Limits</strong> (5 tools)</summary>
310
+
311
+ | Tool | Description |
312
+ |------|-------------|
313
+ | `list_rate_limits` | List rate limits |
314
+ | `create_rate_limit` | Create rate limit |
315
+ | `get_rate_limit` | Get rate limit details |
316
+ | `update_rate_limit` | Update rate limit |
317
+ | `delete_rate_limit` | Delete rate limit |
318
+
319
+ </details>
320
+
321
+ <details>
322
+ <summary><strong>๐Ÿ“œ Audit</strong> (1 tool)</summary>
323
+
324
+ | Tool | Description |
325
+ |------|-------------|
326
+ | `list_audit_logs` | List audit log entries |
327
+
328
+ </details>
329
+
330
+ <details>
331
+ <summary><strong>๐Ÿ“Š Analytics</strong> (9 tools)</summary>
332
+
333
+ | Tool | Description |
334
+ |------|-------------|
335
+ | `get_cost_analytics` | Get cost analytics data |
336
+ | `get_request_analytics` | Request analytics |
337
+ | `get_token_analytics` | Token usage analytics |
338
+ | `get_latency_analytics` | Latency analytics |
339
+ | `get_error_analytics` | Error analytics |
340
+ | `get_error_rate_analytics` | Error rate analytics |
341
+ | `get_users_analytics` | Per-user analytics |
342
+ | `get_cache_hit_latency` | Cache hit latency |
343
+ | `get_cache_hit_rate` | Cache hit rate |
344
+
345
+ </details>
346
+
347
+ <details>
348
+ <summary><strong>๐Ÿ“‹ Logging</strong> (8 tools)</summary>
349
+
350
+ | Tool | Description |
351
+ |------|-------------|
352
+ | `insert_log` | Insert log entry |
353
+ | `create_log_export` | Create log export |
354
+ | `list_log_exports` | List exports |
355
+ | `get_log_export` | Get export details |
356
+ | `update_log_export` | Update export |
357
+ | `start_log_export` | Start export job |
358
+ | `cancel_log_export` | Cancel export |
359
+ | `download_log_export` | Download export |
360
+
361
+ </details>
362
+
363
+ <details>
364
+ <summary><strong>๐Ÿ” Tracing</strong> (3 tools)</summary>
365
+
366
+ | Tool | Description |
367
+ |------|-------------|
368
+ | `create_feedback` | Create feedback |
369
+ | `update_feedback` | Update feedback |
370
+ | `get_trace` | Get trace details |
371
+
372
+ </details>
373
+
374
+ <details>
375
+ <summary><strong>๐Ÿ”Œ Providers</strong> (5 tools)</summary>
376
+
377
+ | Tool | Description |
378
+ |------|-------------|
379
+ | `list_providers` | List providers |
380
+ | `create_provider` | Create provider |
381
+ | `get_provider` | Get provider details |
382
+ | `update_provider` | Update provider |
383
+ | `delete_provider` | Delete provider |
384
+
385
+ </details>
386
+
387
+ <details>
388
+ <summary><strong>๐Ÿ”— Integrations</strong> (10 tools)</summary>
389
+
390
+ | Tool | Description |
391
+ |------|-------------|
392
+ | `list_integrations` | List integrations |
393
+ | `create_integration` | Create integration |
394
+ | `get_integration` | Get integration details |
395
+ | `update_integration` | Update integration |
396
+ | `delete_integration` | Delete integration |
397
+ | `list_integration_models` | List custom models |
398
+ | `update_integration_models` | Update custom models |
399
+ | `delete_integration_model` | Delete custom model |
400
+ | `list_integration_workspaces` | List workspace access |
401
+ | `update_integration_workspaces` | Update workspace access |
402
+
403
+ </details>
404
+
405
+ ---
406
+
407
+ ## ๐Ÿ—๏ธ Architecture
408
+
409
+ ```mermaid
410
+ sequenceDiagram
411
+ participant Client as Client (Claude)
412
+ participant Transport as MCP Transport<br/>(Stdio or HTTP)
413
+ participant Server as MCP Server
414
+ participant Facade as PortkeyService
415
+ participant Domain as Domain Service<br/>(e.g., UsersService)
416
+ participant API as Portkey API
417
+
418
+ Client->>Transport: Tool invocation request
419
+ Transport->>Server: Forward request
420
+ Server->>Server: Parse tool name & params
421
+ Server->>Facade: Call delegated method
422
+ Facade->>Domain: Delegate to domain service
423
+ Domain->>API: HTTP GET /users
424
+ API-->>Domain: JSON response
425
+ Domain-->>Facade: Return typed data
426
+ Facade-->>Server: Return data
427
+ Server-->>Transport: Tool result
428
+ Transport-->>Client: Display result
429
+ ```
430
+
431
+ ---
432
+
433
+ ## ๐Ÿšข Deployment
434
+
435
+ ### Transports
436
+
437
+ | Transport | Entrypoint | Use Case |
438
+ |-----------|------------|----------|
439
+ | `stdio` | `node build/index.js` | Local CLI tools (Claude Code, Cursor) |
440
+ | `Streamable HTTP` | `node build/server.js` | Remote clients, web, production |
441
+
442
+ `MCP_TRANSPORT` is retained for compatibility, but transport selection is done by choosing the correct entrypoint.
443
+
444
+ ### Session Modes (HTTP)
445
+
446
+ | Mode | Env | Best For | Tradeoff |
447
+ |------|-----|----------|----------|
448
+ | Stateful | `MCP_SESSION_MODE=stateful` (default) | Single-instance always-on services | Session transport state is in memory |
449
+ | Stateless | `MCP_SESSION_MODE=stateless` | Autoscaling/serverless (Render scale-out, Vercel, Cloud Run) | `DELETE /mcp` not used; no server-side session tracking |
450
+
451
+ ### Recommended Hosted Defaults (Team Setup)
452
+
453
+ For shared/team hosting, use:
454
+
455
+ - `MCP_SESSION_MODE=stateless`
456
+ - `MCP_EVENT_STORE=redis`
457
+ - `MCP_REDIS_URL=...` (or `REDIS_URL=...`)
458
+ - `MCP_AUTH_MODE=clerk` (or `bearer` for internal-only setups)
459
+ - `ALLOWED_ORIGINS=https://your-app-domain`
460
+ - `MCP_READY_CHECK_MODE=portkey`
461
+
462
+ This keeps MCP request handling stateless while preserving stream resumability across instances.
463
+
464
+ ### Event Store Modes
465
+
466
+ | Mode | Env | Default | Purpose |
467
+ |------|-----|---------|---------|
468
+ | Off | `MCP_EVENT_STORE=off` | `stateful` mode | No resumability store |
469
+ | Memory | `MCP_EVENT_STORE=memory` | `stateless` mode | In-process resumability |
470
+ | Redis | `MCP_EVENT_STORE=redis` + `MCP_REDIS_URL` or `REDIS_URL` | none | Shared resumability across instances |
471
+
472
+ `MCP_EVENT_TTL_SECONDS` controls retention (default `3600`).
473
+ When `MCP_EVENT_STORE=redis`, the server resolves Redis URL in this order:
474
+ `MCP_REDIS_URL` first, then `REDIS_URL`.
475
+
476
+ ### HTTP Mode
477
+
478
+ ```bash
479
+ PORTKEY_API_KEY=your_key \
480
+ MCP_HOST=0.0.0.0 \
481
+ MCP_PORT=3000 \
482
+ MCP_SESSION_MODE=stateful \
483
+ MCP_EVENT_STORE=off \
484
+ MCP_AUTH_MODE=bearer \
485
+ MCP_AUTH_TOKEN=replace_with_long_random_secret \
486
+ node build/server.js
487
+ ```
488
+
489
+ Exposes a single `/mcp` endpoint with session management via `Mcp-Session-Id` header.
490
+
491
+ ### HTTPS Mode (Native TLS)
492
+
493
+ ```bash
494
+ PORTKEY_API_KEY=your_key \
495
+ MCP_HOST=0.0.0.0 \
496
+ MCP_PORT=3443 \
497
+ MCP_TLS_KEY_PATH=/etc/ssl/private/server.key \
498
+ MCP_TLS_CERT_PATH=/etc/ssl/certs/server.crt \
499
+ MCP_AUTH_MODE=clerk \
500
+ CLERK_ISSUER=https://your-clerk-domain \
501
+ node build/server.js
502
+ ```
503
+
504
+ If you host behind a platform/load balancer (Vercel, Cloud Run, Fly, Nginx, Cloudflare), leave `MCP_TLS_*` unset and let the platform terminate HTTPS.
505
+
506
+ ### Clerk Auth (HTTP)
507
+
508
+ ```bash
509
+ PORTKEY_API_KEY=your_key \
510
+ MCP_HOST=0.0.0.0 \
511
+ MCP_PORT=3000 \
512
+ MCP_SESSION_MODE=stateless \
513
+ MCP_EVENT_STORE=redis \
514
+ MCP_REDIS_URL=redis://localhost:6379 \
515
+ MCP_AUTH_MODE=clerk \
516
+ CLERK_ISSUER=https://your-clerk-domain \
517
+ CLERK_AUDIENCE=your-audience \
518
+ node build/server.js
519
+ ```
520
+
521
+ ### Vercel
522
+
523
+ This repo includes Vercel routing files:
524
+
525
+ - `api/index.ts` - Vercel function entrypoint
526
+ - `vercel.json` - rewrites `/`, `/mcp`, `/health`, `/ready`, `/auth/info` to that function
527
+
528
+ Full setup guide (including public-repo security checklist):
529
+ - [`docs/VERCEL_DEPLOYMENT.md`](./docs/VERCEL_DEPLOYMENT.md)
530
+
531
+ Recommended Vercel environment variables:
532
+
533
+ - `PORTKEY_API_KEY=...`
534
+ - `MCP_SESSION_MODE=stateless`
535
+ - `MCP_EVENT_STORE=redis`
536
+ - `MCP_REDIS_URL=redis://...`
537
+ - `MCP_AUTH_MODE=clerk` (or `bearer`)
538
+ - `CLERK_ISSUER=https://your-clerk-domain` (required when `MCP_AUTH_MODE=clerk`)
539
+ - `CLERK_AUDIENCE=your-audience` (required when `MCP_AUTH_MODE=clerk`)
540
+ - `ALLOWED_ORIGINS=https://your-app-domain`
541
+ - `MCP_TRUST_PROXY=true`
542
+ - `MCP_READY_CHECK_MODE=portkey`
543
+
544
+ Notes:
545
+
546
+ - Leave `MCP_TLS_*` unset on Vercel (Vercel terminates HTTPS).
547
+ - Keep MCP on Streamable HTTP/SSE (Vercel does not support WebSockets).
548
+ - `vercel.json` sets function `maxDuration` to `300`; adjust based on your plan limits.
549
+ - For public repos, never commit keys; keep all credentials in Vercel Environment Variables only.
550
+
551
+ ### Quick MCP HTTP Test
552
+
553
+ After starting the HTTP server, run:
554
+
555
+ ```bash
556
+ npm run test:http
557
+ ```
558
+
559
+ Optional overrides:
560
+
561
+ - `MCP_TEST_BASE_URL=https://your-host`
562
+ - `MCP_TEST_MCP_URL=https://your-host/mcp`
563
+ - `MCP_TEST_BEARER_TOKEN=...` (or `MCP_TEST_AUTH_HEADER='Authorization: Bearer ...'`)
564
+
565
+ The script verifies `/health`, `/ready`, runs `initialize`, then runs `tools/list`.
566
+
567
+ ### Docker
568
+
569
+ ```bash
570
+ docker build -t portkey-admin-mcp .
571
+ docker run \
572
+ -e PORTKEY_API_KEY=your_key \
573
+ -e MCP_HOST=0.0.0.0 \
574
+ -e MCP_PORT=3000 \
575
+ -e MCP_AUTH_MODE=bearer \
576
+ -e MCP_AUTH_TOKEN=replace_with_long_random_secret \
577
+ -p 3000:3000 \
578
+ portkey-admin-mcp
579
+ ```
580
+
581
+ ### Health Endpoints
582
+
583
+ - `GET /` - Web status/auth helper page
584
+ - `GET /auth/info` - Auth metadata (auth mode, session mode, event store mode, Clerk config flags, MCP endpoint URL)
585
+ - `GET /health` - Server status
586
+ - `GET /ready` - Readiness state (includes session mode/event store mode, and optional Portkey connectivity when `MCP_READY_CHECK_MODE=portkey`)
587
+
588
+ ---
589
+
590
+ ## โš ๏ธ Limitations
591
+
592
+ ### Enterprise Features
593
+
594
+ The following require a Portkey Enterprise plan with Admin API keys:
595
+
596
+ - Analytics (cost, request, token, latency, error, cache, feedback)
597
+ - Log exports
598
+ - Audit logs
599
+ - User management (list users, invites)
600
+ - Provider creation
601
+
602
+ ### Scope-Gated Endpoints (Verified 2026-02-25)
603
+
604
+ Most `403` responses include Portkey error code `AB03` ("not enough permissions").
605
+ This indicates missing API key scopes, not broken endpoint paths.
606
+
607
+ | Endpoint Group | Typical Failing Tools | Required Scope(s) |
608
+ |------|------|------|
609
+ | Users | `list_all_users`, `get_user` | `users.list`, `users.view` |
610
+ | User Invites | `list_user_invites`, `get_user_invite` | `users.invites.list`, `users.invites.view` |
611
+ | API Keys | `list_api_keys`, `get_api_key` | `apiKeys.list`, `apiKeys.view` (+ API key management feature) |
612
+ | Audit Logs | `list_audit_logs` | `auditLogs.list` |
613
+ | Analytics Graphs | `get_cost_analytics`, `get_request_analytics`, etc. | `analytics.view` |
614
+ | Analytics Groups | `get_user_grouped_data` | `analytics.groups.view` |
615
+ | Integration Access | `list_integration_models`, `list_integration_workspaces` | `integrations.models.list`, `integrations.workspaces.list` |
616
+
617
+ ---
618
+
619
+ ## ๐Ÿ› ๏ธ Development
620
+
621
+ ```bash
622
+ npm run dev # stdio with hot reload
623
+ npm run dev:http # HTTP with hot reload
624
+ npm run test:e2e # MCP protocol tests
625
+ npm run test:contract # API contract tests
626
+ npm run ci # full CI pipeline (lint + typecheck + test + build + verify)
627
+ ```
628
+
629
+ ---
630
+
631
+ <div align="center">
632
+
633
+ ### Built With
634
+
635
+ [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=fff)](#)
636
+ [![Node.js](https://img.shields.io/badge/Node.js-339933?logo=nodedotjs&logoColor=fff)](#)
637
+ [![Zod](https://img.shields.io/badge/Zod-3E67B1?logo=zod&logoColor=fff)](#)
638
+
639
+ ---
640
+
641
+ **MIT License** ยท Inspired by [r-huijts/portkey-admin-mcp-server](https://github.com/r-huijts/portkey-admin-mcp-server)
642
+
643
+ <a href="#portkey-admin-mcp-server">โ†‘ Back to top</a>
644
+
645
+ </div>