@promptlayer/mcp-server 1.13.0 → 1.15.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/README.md +56 -3
- package/build/client.d.ts +39 -22
- package/build/client.d.ts.map +1 -1
- package/build/client.js +46 -24
- package/build/client.js.map +1 -1
- package/build/handlers.d.ts.map +1 -1
- package/build/handlers.js +62 -24
- package/build/handlers.js.map +1 -1
- package/build/index.js +10 -5
- package/build/index.js.map +1 -1
- package/build/types.d.ts +1984 -837
- package/build/types.d.ts.map +1 -1
- package/build/types.js +561 -269
- package/build/types.js.map +1 -1
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +10 -1
- package/build/utils.js.map +1 -1
- package/gcp/src/index.ts +95 -38
- package/package.json +1 -1
- package/src/client.ts +46 -25
- package/src/handlers.ts +136 -52
- package/src/index.ts +10 -5
- package/src/types.ts +615 -318
- package/src/utils.ts +8 -1
package/src/handlers.ts
CHANGED
|
@@ -4,6 +4,11 @@ import { createToolHandler } from "./utils.js";
|
|
|
4
4
|
|
|
5
5
|
type Args = Record<string, unknown> & { api_key?: string };
|
|
6
6
|
function body(args: Args) { const { api_key: _, ...rest } = args; return rest; }
|
|
7
|
+
function omit(args: Args, ...keys: string[]) {
|
|
8
|
+
const rest = body(args);
|
|
9
|
+
for (const key of keys) delete rest[key];
|
|
10
|
+
return rest;
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
14
|
export function registerAllTools(server: any) {
|
|
@@ -69,58 +74,125 @@ export function registerAllTools(server: any) {
|
|
|
69
74
|
reg(t["create-spans-bulk"], (c, a) => c.createSpansBulk(body(a)),
|
|
70
75
|
(r) => `Created ${(r as { spans?: unknown[] }).spans?.length ?? 0} span(s)`);
|
|
71
76
|
|
|
72
|
-
//
|
|
73
|
-
reg(t["list-
|
|
74
|
-
(r) => {
|
|
75
|
-
reg(t["create-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
reg(t["
|
|
84
|
-
(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
reg(t["
|
|
96
|
-
(c, a) =>
|
|
97
|
-
() => "
|
|
98
|
-
reg(t["
|
|
99
|
-
(c, a) => c.
|
|
100
|
-
() => "
|
|
101
|
-
reg(t["get-
|
|
102
|
-
(c, a) => c.
|
|
103
|
-
(r) =>
|
|
104
|
-
reg(t["
|
|
105
|
-
(c, a) =>
|
|
106
|
-
() =>
|
|
107
|
-
reg(t["
|
|
108
|
-
(c, a) => c.
|
|
109
|
-
() => "
|
|
110
|
-
reg(t["
|
|
111
|
-
(c, a) => c.
|
|
112
|
-
() =>
|
|
113
|
-
reg(t["
|
|
114
|
-
(c, a) =>
|
|
115
|
-
() =>
|
|
116
|
-
reg(t["
|
|
117
|
-
(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
() => "
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
() => "
|
|
77
|
+
// Smart Tables
|
|
78
|
+
reg(t["list-smart-tables"], (c, a) => c.listSmartTables(body(a)),
|
|
79
|
+
(r) => `${(r as { data?: unknown[] }).data?.length ?? 0} table(s)`);
|
|
80
|
+
reg(t["create-smart-table"], (c, a) => c.createSmartTable(body(a)),
|
|
81
|
+
(r) => {
|
|
82
|
+
const table = (r as { table?: { id?: string; title?: string } }).table;
|
|
83
|
+
return table?.id ? `Table "${table.title ?? ""}" created (${table.id})` : "Table created";
|
|
84
|
+
});
|
|
85
|
+
reg(t["get-smart-table"],
|
|
86
|
+
(c, a) => c.getSmartTable(a.table_id as string),
|
|
87
|
+
(r) => `Table "${(r as { table?: { title?: string } }).table?.title ?? ""}" retrieved`);
|
|
88
|
+
reg(t["update-smart-table"],
|
|
89
|
+
(c, a) => c.updateSmartTable(a.table_id as string, omit(a, "table_id")),
|
|
90
|
+
() => "Table updated");
|
|
91
|
+
reg(t["list-smart-table-sheets"],
|
|
92
|
+
(c, a) => c.listSmartTableSheets(a.table_id as string, omit(a, "table_id")),
|
|
93
|
+
(r) => `${(r as { data?: unknown[] }).data?.length ?? 0} sheet(s)`);
|
|
94
|
+
reg(t["create-smart-table-sheet"],
|
|
95
|
+
(c, a) => c.createSmartTableSheet(a.table_id as string, omit(a, "table_id")),
|
|
96
|
+
(r) => {
|
|
97
|
+
const op = (r as { operation_id?: string }).operation_id;
|
|
98
|
+
return op ? `Sheet import started (${op})` : "Sheet created";
|
|
99
|
+
});
|
|
100
|
+
reg(t["get-smart-table-sheet"],
|
|
101
|
+
(c, a) => c.getSmartTableSheet(a.table_id as string, a.sheet_id as string),
|
|
102
|
+
() => "Sheet retrieved");
|
|
103
|
+
reg(t["update-smart-table-sheet"],
|
|
104
|
+
(c, a) => c.updateSmartTableSheet(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
105
|
+
() => "Sheet updated");
|
|
106
|
+
reg(t["get-smart-table-sheet-import-operation"],
|
|
107
|
+
(c, a) => c.getSmartTableSheetImportOperation(a.table_id as string, a.operation_id as string),
|
|
108
|
+
(r) => `Import operation ${(r as { operation?: { status?: string } }).operation?.status ?? "retrieved"}`);
|
|
109
|
+
reg(t["import-smart-table-sheet-file"],
|
|
110
|
+
(c, a) => c.importSmartTableSheetFile(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
111
|
+
(r) => `File import started (${(r as { operation_id?: string }).operation_id ?? "operation queued"})`);
|
|
112
|
+
reg(t["import-smart-table-sheet-request-logs"],
|
|
113
|
+
(c, a) => c.importSmartTableSheetRequestLogs(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
114
|
+
(r) => `Request-log import started (${(r as { operation_id?: string }).operation_id ?? "operation queued"})`);
|
|
115
|
+
reg(t["list-smart-table-columns"],
|
|
116
|
+
(c, a) => c.listSmartTableColumns(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
117
|
+
(r) => `${(r as { data?: unknown[] }).data?.length ?? 0} column(s)`);
|
|
118
|
+
reg(t["create-smart-table-column"],
|
|
119
|
+
(c, a) => c.createSmartTableColumn(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
120
|
+
(r) => `Column created${(r as { column?: { id?: string } }).column?.id ? ` (${(r as { column?: { id?: string } }).column?.id})` : ""}`);
|
|
121
|
+
reg(t["update-smart-table-column"],
|
|
122
|
+
(c, a) => c.updateSmartTableColumn(a.table_id as string, a.sheet_id as string, a.column_id as string, omit(a, "table_id", "sheet_id", "column_id")),
|
|
123
|
+
(r) => (r as { requires_recalculation?: boolean }).requires_recalculation ? "Column updated; recalculation required" : "Column updated");
|
|
124
|
+
reg(t["list-smart-table-rows"],
|
|
125
|
+
(c, a) => c.listSmartTableRows(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
126
|
+
(r) => `${(r as { data?: unknown[] }).data?.length ?? 0} row(s)`);
|
|
127
|
+
reg(t["add-smart-table-rows"],
|
|
128
|
+
(c, a) => c.addSmartTableRows(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
129
|
+
(r) => `${(r as { rows?: unknown[]; data?: unknown[] }).rows?.length ?? (r as { data?: unknown[] }).data?.length ?? 0} row(s) added`);
|
|
130
|
+
reg(t["get-smart-table-cell"],
|
|
131
|
+
(c, a) => c.getSmartTableCell(a.table_id as string, a.sheet_id as string, a.cell_id as string),
|
|
132
|
+
() => "Cell retrieved");
|
|
133
|
+
reg(t["update-smart-table-cell"],
|
|
134
|
+
(c, a) => c.updateSmartTableCell(a.table_id as string, a.sheet_id as string, a.cell_id as string, omit(a, "table_id", "sheet_id", "cell_id")),
|
|
135
|
+
() => "Cell updated");
|
|
136
|
+
reg(t["recalculate-smart-table-cell"],
|
|
137
|
+
(c, a) => c.recalculateSmartTableCell(a.table_id as string, a.sheet_id as string, a.cell_id as string),
|
|
138
|
+
(r) => `${(r as { cell_count?: number }).cell_count ?? 0} cell(s) queued`);
|
|
139
|
+
reg(t["recalculate-smart-table-cells"],
|
|
140
|
+
(c, a) => c.recalculateSmartTableCells(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
141
|
+
(r) => `${(r as { cell_count?: number }).cell_count ?? 0} cell(s) queued`);
|
|
142
|
+
reg(t["list-smart-table-operations"],
|
|
143
|
+
(c, a) => c.listSmartTableOperations(a.table_id as string, a.sheet_id as string),
|
|
144
|
+
(r) => `${(r as { active_operations?: unknown[] }).active_operations?.length ?? 0} active operation(s)`);
|
|
145
|
+
reg(t["create-smart-table-operation"],
|
|
146
|
+
(c, a) => c.createSmartTableOperation(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
147
|
+
(r) => {
|
|
148
|
+
const op = (r as { operation_id?: string; cell_count?: number }).operation_id;
|
|
149
|
+
return op ? `Operation started (${op})` : `${(r as { cell_count?: number }).cell_count ?? 0} cell(s) affected`;
|
|
150
|
+
});
|
|
151
|
+
reg(t["get-smart-table-operation"],
|
|
152
|
+
(c, a) => c.getSmartTableOperation(a.table_id as string, a.sheet_id as string, a.operation_id as string),
|
|
153
|
+
(r) => `Operation ${(r as { operation?: { status?: string } }).operation?.status ?? "retrieved"}`);
|
|
154
|
+
reg(t["cancel-smart-table-operation"],
|
|
155
|
+
(c, a) => c.cancelSmartTableOperation(a.table_id as string, a.sheet_id as string, a.operation_id as string),
|
|
156
|
+
(r) => `${(r as { cancelled_cell_count?: number }).cancelled_cell_count ?? 0} cell(s) cancelled`);
|
|
157
|
+
reg(t["get-smart-table-score"],
|
|
158
|
+
(c, a) => c.getSmartTableScore(a.table_id as string, a.sheet_id as string),
|
|
159
|
+
(r) => `Score ${(r as { status?: string | null }).status ?? "retrieved"}`);
|
|
160
|
+
reg(t["configure-smart-table-score"],
|
|
161
|
+
(c, a) => c.configureSmartTableScore(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
162
|
+
() => "Score configured; recalculation required");
|
|
163
|
+
reg(t["recalculate-smart-table-score"],
|
|
164
|
+
(c, a) => c.recalculateSmartTableScore(a.table_id as string, a.sheet_id as string),
|
|
165
|
+
(r) => `Score recalculation ${(r as { status?: string }).status ?? "queued"}`);
|
|
166
|
+
reg(t["list-smart-table-versions"],
|
|
167
|
+
(c, a) => c.listSmartTableVersions(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
168
|
+
(r) => `${(r as { data?: unknown[] }).data?.length ?? 0} version(s)`);
|
|
169
|
+
reg(t["get-smart-table-version"],
|
|
170
|
+
(c, a) => c.getSmartTableVersion(a.table_id as string, a.sheet_id as string, a.version_id as string),
|
|
171
|
+
() => "Version retrieved");
|
|
172
|
+
reg(t["create-smart-table-version"],
|
|
173
|
+
(c, a) => c.createSmartTableVersion(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
174
|
+
(r) => `Version ${(r as { version?: { version_number?: number } }).version?.version_number ?? "created"}`);
|
|
175
|
+
reg(t["get-smart-table-score-history"],
|
|
176
|
+
(c, a) => c.getSmartTableScoreHistory(a.table_id as string, a.sheet_id as string, omit(a, "table_id", "sheet_id")),
|
|
177
|
+
(r) => `${(r as { score_history?: { returned_points?: number } }).score_history?.returned_points ?? 0} score point(s)`);
|
|
178
|
+
reg(t["list-legacy-smart-table-migrations"],
|
|
179
|
+
(c, a) => c.listLegacySmartTableMigrations(body(a)),
|
|
180
|
+
(r) => `${(r as { legacy_migrations?: unknown[] }).legacy_migrations?.length ?? 0} migration mapping(s)`);
|
|
181
|
+
reg(t["preview-legacy-smart-table-migration"],
|
|
182
|
+
(c, a) => c.previewLegacySmartTableMigration(body(a)),
|
|
183
|
+
(r) => {
|
|
184
|
+
const counts = (r as { estimated_counts?: { sheets?: number; columns?: number; cells?: number } }).estimated_counts;
|
|
185
|
+
return counts ? `Preview: ${counts.sheets ?? 0} sheet(s), ${counts.columns ?? 0} column(s), ${counts.cells ?? 0} cell(s)` : "Migration preview retrieved";
|
|
186
|
+
});
|
|
187
|
+
reg(t["migrate-legacy-to-smart-table"],
|
|
188
|
+
(c, a) => c.migrateLegacyToSmartTable(body(a)),
|
|
189
|
+
(r) => {
|
|
190
|
+
const job = (r as { job_id?: string; dry_run?: boolean }).job_id;
|
|
191
|
+
return (r as { dry_run?: boolean }).dry_run ? "Migration dry run complete" : `Migration queued${job ? ` (${job})` : ""}`;
|
|
192
|
+
});
|
|
193
|
+
reg(t["get-legacy-smart-table-migration-job"],
|
|
194
|
+
(c, a) => c.getLegacySmartTableMigrationJob(a.job_id as string),
|
|
195
|
+
(r) => `Migration job ${(r as { status?: string }).status ?? "retrieved"}`);
|
|
124
196
|
|
|
125
197
|
// Agents
|
|
126
198
|
reg(t["list-workflows"], (c, a) => c.listWorkflows(body(a)), () => "Agents listed");
|
|
@@ -167,6 +239,18 @@ export function registerAllTools(server: any) {
|
|
|
167
239
|
return `Tool executed (${res.duration_ms ?? 0} ms)`;
|
|
168
240
|
});
|
|
169
241
|
|
|
242
|
+
// Env Vars
|
|
243
|
+
reg(t["list-workspace-env-vars"], (c) => c.listWorkspaceEnvVars(),
|
|
244
|
+
(r) => { const v = (r as { workspace_env_vars?: unknown[] }).workspace_env_vars; return `${v?.length ?? 0} workspace env var(s)`; });
|
|
245
|
+
reg(t["create-workspace-env-var"], (c, a) => c.createWorkspaceEnvVar({ ...body(a), value: "" }),
|
|
246
|
+
(r) => { const v = (r as { workspace_env_var?: { key?: string; id?: number } }).workspace_env_var; return v ? `Workspace env var "${v.key}" scaffolded (ID: ${v.id}) — set the value in Settings` : "Workspace env var scaffolded"; });
|
|
247
|
+
reg(t["list-tool-env-vars"],
|
|
248
|
+
(c, a) => c.listToolEnvVars((a as { identifier: string }).identifier),
|
|
249
|
+
(r) => { const v = (r as { tool_env_vars?: unknown[] }).tool_env_vars; return `${v?.length ?? 0} tool env var(s)`; });
|
|
250
|
+
reg(t["create-tool-env-var"],
|
|
251
|
+
(c, a) => { const { api_key: _, identifier, ...b } = a as { identifier: string; api_key?: string } & Args; return c.createToolEnvVar(identifier, { ...b, value: "" }); },
|
|
252
|
+
(r) => { const v = (r as { tool_env_var?: { key?: string; id?: number } }).tool_env_var; return v ? `Tool env var "${v.key}" scaffolded (ID: ${v.id}) — set the value in Settings` : "Tool env var scaffolded"; });
|
|
253
|
+
|
|
170
254
|
// Folders
|
|
171
255
|
reg(t["create-folder"], (c, a) => c.createFolder(body(a)), () => "Folder created");
|
|
172
256
|
reg(t["edit-folder"],
|
package/src/index.ts
CHANGED
|
@@ -13,9 +13,10 @@ PromptLayer is a prompt management and observability platform. This MCP server l
|
|
|
13
13
|
- **Snippet**: A reusable prompt fragment referenced inside prompt templates with @@@snippet_name@@@ markers. Snippets are themselves prompt templates (with type "completion"). When a prompt is fetched, snippets are expanded inline by default.
|
|
14
14
|
- **Release label**: A pointer (e.g. "prod", "staging") attached to a specific prompt version. Move labels between versions for deployment.
|
|
15
15
|
- **Agent** (backend name: workflow): A multi-step pipeline of nodes. Each node has a type, configuration, and dependencies. Agents are versioned like prompts.
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
16
|
+
- **Smart Table**: The primary workspace for test data, evaluation columns, request-log imports, execution, scoring, and version history.
|
|
17
|
+
- **Smart Table sheet**: A tab inside a Smart Table. Sheets contain rows, columns, cells, operations, score configuration, and saved versions.
|
|
18
|
+
- **Legacy dataset/evaluation**: Older dataset and report resources. Tools for these remain available for compatibility, but prefer Smart Tables for new work.
|
|
19
|
+
- **Folder**: Organizes prompts, agents, Smart Tables, and other entities into a hierarchy.
|
|
19
20
|
|
|
20
21
|
## Working with prompts and snippets
|
|
21
22
|
|
|
@@ -25,9 +26,13 @@ When publishing back, keep @@@snippet_name@@@ markers intact in the prompt_templ
|
|
|
25
26
|
|
|
26
27
|
Use get-prompt-template (the POST variant) only when you need a fully rendered prompt ready to send to an LLM, with input_variables filled in and provider-specific formatting applied.
|
|
27
28
|
|
|
28
|
-
## Working with
|
|
29
|
+
## Working with Smart Tables
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
For new dataset or evaluation-style workflows, use Smart Tables instead of legacy datasets and reports. A typical flow is: create-smart-table, add or import sheets, create columns, add rows or import request logs, run recalculation operations, configure sheet scoring, and save versions.
|
|
32
|
+
|
|
33
|
+
Use uppercase Smart Table column type values such as TEXT, PROMPT_TEMPLATE, LLM_ASSERTION, CODE_EXECUTION, and COMPOSITION. Direct cell edits are for text cells; computed cells should be recalculated with cell or sheet operation tools.
|
|
34
|
+
|
|
35
|
+
Use the legacy migration tools to preview or convert existing dataset groups, datasets, and reports into Smart Tables.
|
|
31
36
|
|
|
32
37
|
## Additional documentation
|
|
33
38
|
|