@neon/tools 2.15.0 → 2.17.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 (78) hide show
  1. package/README.md +120 -5
  2. package/dist/descriptions.gen.js +2 -2
  3. package/dist/generated/output.gen.d.ts +1 -0
  4. package/dist/generated/output.gen.d.ts.map +1 -1
  5. package/dist/generated/output.gen.js +2 -1
  6. package/dist/generated/zod.gen.d.ts +11 -3
  7. package/dist/generated/zod.gen.d.ts.map +1 -1
  8. package/dist/generated/zod.gen.js +6 -3
  9. package/dist/index.d.ts +17 -5
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +30 -9
  12. package/dist/lib/caller-error.d.ts +16 -0
  13. package/dist/lib/caller-error.d.ts.map +1 -0
  14. package/dist/lib/caller-error.js +18 -0
  15. package/dist/lib/custom/auth-config.d.ts +0 -1
  16. package/dist/lib/custom/auth-config.d.ts.map +1 -1
  17. package/dist/lib/custom/auth-config.js +13 -6
  18. package/dist/lib/custom/docs.d.ts.map +1 -1
  19. package/dist/lib/custom/docs.js +8 -6
  20. package/dist/lib/custom/feedback.d.ts.map +1 -1
  21. package/dist/lib/custom/feedback.js +1 -0
  22. package/dist/lib/custom/fetch.d.ts +1 -1
  23. package/dist/lib/custom/fetch.d.ts.map +1 -1
  24. package/dist/lib/custom/fetch.js +4 -3
  25. package/dist/lib/custom/organizations.d.ts.map +1 -1
  26. package/dist/lib/custom/organizations.js +1 -0
  27. package/dist/lib/custom/resources.d.ts.map +1 -1
  28. package/dist/lib/custom/resources.js +1 -0
  29. package/dist/lib/custom/sql/connection.d.ts +7 -8
  30. package/dist/lib/custom/sql/connection.d.ts.map +1 -1
  31. package/dist/lib/custom/sql/connection.js +12 -14
  32. package/dist/lib/custom/sql/describe-branch.js +2 -2
  33. package/dist/lib/custom/sql/inspect/inspect.d.ts.map +1 -1
  34. package/dist/lib/custom/sql/inspect/inspect.js +5 -5
  35. package/dist/lib/custom/sql/inspect/targets.js +3 -3
  36. package/dist/lib/custom/sql/migrations.d.ts.map +1 -1
  37. package/dist/lib/custom/sql/migrations.js +3 -5
  38. package/dist/lib/custom/sql/plan.d.ts +2 -0
  39. package/dist/lib/custom/sql/plan.d.ts.map +1 -1
  40. package/dist/lib/custom/sql/plan.js +19 -6
  41. package/dist/lib/custom/sql/query-tuning.d.ts.map +1 -1
  42. package/dist/lib/custom/sql/query-tuning.js +9 -7
  43. package/dist/lib/custom/sql/run.d.ts.map +1 -1
  44. package/dist/lib/custom/sql/run.js +4 -5
  45. package/dist/lib/custom/sql/schema.d.ts.map +1 -1
  46. package/dist/lib/custom/sql/schema.js +6 -6
  47. package/dist/lib/custom/sql/slow-queries.d.ts.map +1 -1
  48. package/dist/lib/custom/sql/slow-queries.js +8 -3
  49. package/dist/lib/customize.d.ts +1 -1
  50. package/dist/lib/customize.d.ts.map +1 -1
  51. package/dist/lib/customize.js +8 -4
  52. package/dist/lib/effect/tools.d.ts.map +1 -1
  53. package/dist/lib/effect/tools.js +2 -1
  54. package/dist/lib/ergonomic/bind.d.ts +10 -6
  55. package/dist/lib/ergonomic/bind.d.ts.map +1 -1
  56. package/dist/lib/ergonomic/bind.js +11 -2
  57. package/dist/lib/ergonomic/catalog.d.ts +8 -12
  58. package/dist/lib/ergonomic/catalog.d.ts.map +1 -1
  59. package/dist/lib/ergonomic/catalog.js +102 -23
  60. package/dist/lib/ergonomic/composed.d.ts.map +1 -1
  61. package/dist/lib/ergonomic/composed.js +29 -0
  62. package/dist/lib/mcp-json-schema.d.ts.map +1 -1
  63. package/dist/lib/mcp-json-schema.js +15 -1
  64. package/dist/lib/operation.d.ts +50 -4
  65. package/dist/lib/operation.d.ts.map +1 -1
  66. package/dist/lib/operation.js +6 -1
  67. package/dist/lib/policy.d.ts +24 -0
  68. package/dist/lib/policy.d.ts.map +1 -0
  69. package/dist/lib/policy.js +49 -0
  70. package/dist/lib/redact.d.ts +8 -0
  71. package/dist/lib/redact.d.ts.map +1 -0
  72. package/dist/lib/redact.js +40 -0
  73. package/dist/mastra.d.ts +2 -1
  74. package/dist/mastra.d.ts.map +1 -1
  75. package/dist/operations.gen.d.ts +391 -388
  76. package/dist/operations.gen.d.ts.map +1 -1
  77. package/dist/operations.gen.js +6 -4
  78. package/package.json +4 -4
@@ -1,5 +1,6 @@
1
1
  import { decodeBase64 } from "../binary.js";
2
2
  import { toToolResult } from "../result.js";
3
+ import { toolMetadata } from "../operation.js";
3
4
  import { bindTool, collectObjectList, collectPages, fromGenerated, publishedId } from "./bind.js";
4
5
  import { describeTableTool, listTablesTool } from "../custom/sql/schema.js";
5
6
  import { inspectDatabaseTool } from "../custom/sql/inspect/inspect.js";
@@ -25,18 +26,6 @@ const logReadAnnotations = {
25
26
  idempotentHint: true,
26
27
  openWorldHint: false
27
28
  };
28
- const withoutSmtpPassword = (config) => config.type === "standard" ? {
29
- ...config,
30
- password: ""
31
- } : config;
32
- const withoutPluginSecrets = (plugins) => ({
33
- ...plugins,
34
- ...plugins.email_provider && { email_provider: withoutSmtpPassword(plugins.email_provider) },
35
- ...plugins.oauth_providers && { oauth_providers: plugins.oauth_providers.map((provider) => provider.client_secret === void 0 ? provider : {
36
- ...provider,
37
- client_secret: ""
38
- }) }
39
- });
40
29
  const listIncidentsInputSchema = z.strictObject({});
41
30
  const listIncidentsOutputSchema = z.looseObject({
42
31
  status: z.string().describe("Overall status: operational, degraded, or outage."),
@@ -85,13 +74,14 @@ const listIncidentsTool = (options) => ({
85
74
  openWorldHint: true
86
75
  },
87
76
  requiresApproval: false,
88
- metadata: {
77
+ metadata: toolMetadata({
89
78
  method: "GET",
79
+ readOnlySafe: true,
90
80
  path: NEON_STATUS_API_URL,
91
81
  stability: "stable",
92
82
  deprecated: false,
93
83
  tags: ["Status"]
94
- },
84
+ }),
95
85
  async execute(input, context) {
96
86
  await listIncidentsInputSchema.parseAsync(input);
97
87
  return toToolResult(await listNeonIncidents({
@@ -403,6 +393,10 @@ const toolFactories = {
403
393
  id: "postgres.roles.list",
404
394
  generated: "listProjectBranchRoles",
405
395
  output: RolesResponse.shape.roles,
396
+ secretOutputFields: [{
397
+ path: "$[*].password",
398
+ kind: "setup"
399
+ }],
406
400
  run: (neon, input, signal) => neon.postgres.roles.list({
407
401
  projectId: input.project_id,
408
402
  branchId: input.branch_id
@@ -412,6 +406,10 @@ const toolFactories = {
412
406
  id: "postgres.roles.get",
413
407
  generated: "getProjectBranchRole",
414
408
  output: Role,
409
+ secretOutputFields: [{
410
+ path: "$.password",
411
+ kind: "setup"
412
+ }],
415
413
  run: (neon, input, signal) => neon.postgres.roles.get({
416
414
  projectId: input.project_id,
417
415
  branchId: input.branch_id,
@@ -433,6 +431,11 @@ const toolFactories = {
433
431
  id: "postgres.roles.resetPassword",
434
432
  generated: "resetProjectBranchRolePassword",
435
433
  output: Role,
434
+ secretOutputFields: [{
435
+ path: "$.password",
436
+ kind: "setup"
437
+ }],
438
+ returnsOnlySecrets: true,
436
439
  run: (neon, input, signal) => neon.postgres.roles.resetPassword({
437
440
  projectId: input.project_id,
438
441
  branchId: input.branch_id,
@@ -639,6 +642,11 @@ const toolFactories = {
639
642
  id: "storage.objects.presign",
640
643
  generated: "presignProjectBranchBucketObject",
641
644
  output: PresignResponse,
645
+ secretOutputFields: [{
646
+ path: "$.url",
647
+ kind: "setup"
648
+ }],
649
+ returnsOnlySecrets: true,
642
650
  run: (neon, input, signal) => neon.storage.objects.presign({
643
651
  projectId: input.project_id,
644
652
  branchId: input.branch_id,
@@ -802,12 +810,20 @@ const toolFactories = {
802
810
  id: "credentials.create",
803
811
  generated: "createCredential",
804
812
  output: CreateCredentialResponse,
813
+ secretOutputFields: [{
814
+ path: "$.api_token",
815
+ kind: "setup"
816
+ }, {
817
+ path: "$.s3_secret_access_key",
818
+ kind: "setup"
819
+ }],
805
820
  run: (neon, input, signal) => neon.credentials.create({
806
821
  projectId: input.project_id,
807
822
  branchId: input.branch_id,
808
823
  name: input.name,
809
824
  scopes: input.scopes,
810
- principal_type: input.principal_type
825
+ principal_type: input.principal_type,
826
+ expires_at: input.expires_at
811
827
  }, { signal })
812
828
  }),
813
829
  "credentials.revoke": (options) => fromGenerated(options, {
@@ -824,6 +840,14 @@ const toolFactories = {
824
840
  id: "credentials.rotate",
825
841
  generated: "rotateCredential",
826
842
  output: RotateCredentialResponse,
843
+ secretOutputFields: [{
844
+ path: "$.api_token",
845
+ kind: "setup"
846
+ }, {
847
+ path: "$.s3_secret_access_key",
848
+ kind: "setup"
849
+ }],
850
+ returnsOnlySecrets: true,
827
851
  annotations: {
828
852
  readOnlyHint: false,
829
853
  destructiveHint: true,
@@ -877,6 +901,11 @@ const toolFactories = {
877
901
  id: "realtime.secret",
878
902
  generated: "getProjectBranchRealtimeSecret",
879
903
  output: RealtimeSecret,
904
+ secretOutputFields: [{
905
+ path: "$.secret",
906
+ kind: "setup"
907
+ }],
908
+ returnsOnlySecrets: true,
880
909
  requiresApproval: true,
881
910
  run: (neon, input, signal) => neon.realtime.secret({
882
911
  projectId: input.project_id,
@@ -906,6 +935,7 @@ const toolFactories = {
906
935
  list: true,
907
936
  annotations: logReadAnnotations,
908
937
  requiresApproval: false,
938
+ readOnlySafe: true,
909
939
  run: (neon, input, signal) => collectPages(neon.logs.query({
910
940
  projectId: input.project_id,
911
941
  branchId: input.branch_id,
@@ -1029,6 +1059,10 @@ const toolFactories = {
1029
1059
  id: "auth.create",
1030
1060
  generated: "createNeonAuth",
1031
1061
  output: NeonAuthCreateIntegrationResponse,
1062
+ secretOutputFields: [{
1063
+ path: "$.secret_server_key",
1064
+ kind: "setup"
1065
+ }],
1032
1066
  run: (neon, input, signal) => neon.auth.create({
1033
1067
  projectId: input.project_id,
1034
1068
  branchId: input.branch_id,
@@ -1060,6 +1094,10 @@ const toolFactories = {
1060
1094
  id: "auth.oauthProviders.list",
1061
1095
  generated: "listBranchNeonAuthOauthProviders",
1062
1096
  output: ListNeonAuthOauthProvidersResponse.shape.providers,
1097
+ secretOutputFields: [{
1098
+ path: "$[*].client_secret",
1099
+ kind: "stored"
1100
+ }],
1063
1101
  run: (neon, input, signal) => neon.auth.oauthProviders.list({
1064
1102
  projectId: input.project_id,
1065
1103
  branchId: input.branch_id
@@ -1069,6 +1107,10 @@ const toolFactories = {
1069
1107
  id: "auth.oauthProviders.add",
1070
1108
  generated: "addBranchNeonAuthOauthProvider",
1071
1109
  output: NeonAuthOauthProvider,
1110
+ secretOutputFields: [{
1111
+ path: "$.client_secret",
1112
+ kind: "stored"
1113
+ }],
1072
1114
  run: (neon, input, signal) => neon.auth.oauthProviders.add({
1073
1115
  projectId: input.project_id,
1074
1116
  branchId: input.branch_id,
@@ -1084,6 +1126,10 @@ const toolFactories = {
1084
1126
  id: "auth.oauthProviders.update",
1085
1127
  generated: "updateBranchNeonAuthOauthProvider",
1086
1128
  output: NeonAuthOauthProvider,
1129
+ secretOutputFields: [{
1130
+ path: "$.client_secret",
1131
+ kind: "stored"
1132
+ }],
1087
1133
  run: (neon, input, signal) => neon.auth.oauthProviders.update({
1088
1134
  projectId: input.project_id,
1089
1135
  branchId: input.branch_id,
@@ -1151,6 +1197,10 @@ const toolFactories = {
1151
1197
  id: "auth.oauthClients.create",
1152
1198
  generated: "createNeonAuthOAuthClient",
1153
1199
  output: NeonAuthOAuthClientCreated,
1200
+ secretOutputFields: [{
1201
+ path: "$.client_secret",
1202
+ kind: "setup"
1203
+ }],
1154
1204
  run: (neon, input, signal) => neon.auth.oauthClients.create({
1155
1205
  projectId: input.project_id,
1156
1206
  branchId: input.branch_id,
@@ -1190,6 +1240,11 @@ const toolFactories = {
1190
1240
  id: "auth.oauthClients.rotateSecret",
1191
1241
  generated: "rotateNeonAuthOAuthClientSecret",
1192
1242
  output: NeonAuthOAuthClientSecret,
1243
+ secretOutputFields: [{
1244
+ path: "$.client_secret",
1245
+ kind: "setup"
1246
+ }],
1247
+ returnsOnlySecrets: true,
1193
1248
  run: (neon, input, signal) => neon.auth.oauthClients.rotateSecret({
1194
1249
  projectId: input.project_id,
1195
1250
  branchId: input.branch_id,
@@ -1308,21 +1363,29 @@ const toolFactories = {
1308
1363
  id: "auth.emailProvider.get",
1309
1364
  generated: "getNeonAuthEmailProvider",
1310
1365
  output: NeonAuthEmailServerConfigResponse,
1311
- requiresApproval: false,
1312
- run: async (neon, input, signal) => withoutSmtpPassword(await neon.auth.emailProvider.get({
1366
+ secretOutputFields: [{
1367
+ path: "$.password",
1368
+ kind: "stored"
1369
+ }],
1370
+ readOnlySafe: true,
1371
+ run: (neon, input, signal) => neon.auth.emailProvider.get({
1313
1372
  projectId: input.project_id,
1314
1373
  branchId: input.branch_id
1315
- }, { signal }))
1374
+ }, { signal })
1316
1375
  }),
1317
1376
  "auth.emailProvider.update": (options) => fromGenerated(options, {
1318
1377
  id: "auth.emailProvider.update",
1319
1378
  generated: "updateNeonAuthEmailProvider",
1320
1379
  output: NeonAuthEmailServerConfigResponse,
1321
- run: async (neon, input, signal) => withoutSmtpPassword(await neon.auth.emailProvider.update({
1380
+ secretOutputFields: [{
1381
+ path: "$.password",
1382
+ kind: "stored"
1383
+ }],
1384
+ run: (neon, input, signal) => neon.auth.emailProvider.update({
1322
1385
  projectId: input.project_id,
1323
1386
  branchId: input.branch_id,
1324
1387
  ...input.body
1325
- }, { signal }))
1388
+ }, { signal })
1326
1389
  }),
1327
1390
  "auth.emailProvider.sendTest": (options) => fromGenerated(options, {
1328
1391
  id: "auth.emailProvider.sendTest",
@@ -1338,11 +1401,18 @@ const toolFactories = {
1338
1401
  id: "auth.plugins.get",
1339
1402
  generated: "getNeonAuthPluginConfigs",
1340
1403
  output: NeonAuthPluginConfigs,
1341
- requiresApproval: false,
1342
- run: async (neon, input, signal) => withoutPluginSecrets(await neon.auth.plugins.get({
1404
+ secretOutputFields: [{
1405
+ path: "$.email_provider.password",
1406
+ kind: "stored"
1407
+ }, {
1408
+ path: "$.oauth_providers[*].client_secret",
1409
+ kind: "stored"
1410
+ }],
1411
+ readOnlySafe: true,
1412
+ run: (neon, input, signal) => neon.auth.plugins.get({
1343
1413
  projectId: input.project_id,
1344
1414
  branchId: input.branch_id
1345
- }, { signal }))
1415
+ }, { signal })
1346
1416
  }),
1347
1417
  "auth.plugins.magicLink.update": (options) => fromGenerated(options, {
1348
1418
  id: "auth.plugins.magicLink.update",
@@ -1482,6 +1552,10 @@ const toolFactories = {
1482
1552
  id: "apiKeys.create",
1483
1553
  generated: "createApiKey",
1484
1554
  output: ApiKeyCreateResponse,
1555
+ secretOutputFields: [{
1556
+ path: "$.key",
1557
+ kind: "setup"
1558
+ }],
1485
1559
  run: (neon, input, signal) => neon.apiKeys.create({ keyName: input.key_name }, { signal })
1486
1560
  }),
1487
1561
  "apiKeys.revoke": (options) => fromGenerated(options, {
@@ -1583,6 +1657,10 @@ const toolFactories = {
1583
1657
  id: "organizations.apiKeys.create",
1584
1658
  generated: "createOrgApiKey",
1585
1659
  output: OrgApiKeyCreateResponse,
1660
+ secretOutputFields: [{
1661
+ path: "$.key",
1662
+ kind: "setup"
1663
+ }],
1586
1664
  run: (neon, input, signal) => neon.organizations.apiKeys.create({
1587
1665
  orgId: input.org_id,
1588
1666
  keyName: input.key_name,
@@ -1612,6 +1690,7 @@ const toolFactories = {
1612
1690
  requiresApproval: false,
1613
1691
  metadata: {
1614
1692
  method: "GET",
1693
+ readOnlySafe: true,
1615
1694
  path: "/regions",
1616
1695
  stability: "stable",
1617
1696
  deprecated: false,
@@ -1 +1 @@
1
- {"version":3,"file":"composed.d.ts","sourceRoot":"","sources":["../../../src/lib/ergonomic/composed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAUzB,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAwD1E,eAAO,MAAM,uBAAuB;;;;;;;;;;kBAuBjC,CAAC;AAEJ,eAAO,MAAM,iCAAiC;;;;;;;;;;kBAQ5C,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,MAAM,mBAAmB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC5D,CAAC;AAEH,eAAO,MAAM,eAAe,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;CA8BxD,CAAC"}
@@ -108,6 +108,7 @@ const lokiQueryRangeTool = (options) => bindTool(options, {
108
108
  requiresApproval: false,
109
109
  metadata: {
110
110
  method: "GET",
111
+ readOnlySafe: true,
111
112
  path: "/telemetry/v1/projects/{project_id}/branches/{branch_id}/loki/api/v1/query_range",
112
113
  stability: "beta",
113
114
  deprecated: false,
@@ -183,6 +184,7 @@ const createBranchTool = (options) => bindTool(options, {
183
184
  requiresApproval: true,
184
185
  metadata: {
185
186
  method: "POST",
187
+ readOnlySafe: false,
186
188
  path: "/projects/{project_id}/branches",
187
189
  stability: "stable",
188
190
  deprecated: false,
@@ -218,6 +220,11 @@ const createBranchAndConnectTool = (options) => bindTool(options, {
218
220
  requiresApproval: true,
219
221
  metadata: {
220
222
  method: "POST",
223
+ readOnlySafe: false,
224
+ secretOutputFields: [{
225
+ path: "$.connectionString",
226
+ kind: "setup"
227
+ }],
221
228
  path: "/projects/{project_id}/branches",
222
229
  stability: "stable",
223
230
  deprecated: false,
@@ -241,6 +248,7 @@ const createProjectTool = (options) => bindTool(options, {
241
248
  requiresApproval: true,
242
249
  metadata: {
243
250
  method: "POST",
251
+ readOnlySafe: false,
244
252
  path: "/projects",
245
253
  stability: "stable",
246
254
  deprecated: false,
@@ -262,6 +270,11 @@ const createProjectAndConnectTool = (options) => bindTool(options, {
262
270
  requiresApproval: true,
263
271
  metadata: {
264
272
  method: "POST",
273
+ readOnlySafe: false,
274
+ secretOutputFields: [{
275
+ path: "$.connectionString",
276
+ kind: "setup"
277
+ }],
265
278
  path: "/projects",
266
279
  stability: "stable",
267
280
  deprecated: false,
@@ -279,6 +292,7 @@ const getDefaultTool = (options) => bindTool(options, {
279
292
  requiresApproval: false,
280
293
  metadata: {
281
294
  method: "GET",
295
+ readOnlySafe: true,
282
296
  path: "/projects/{project_id}/branches",
283
297
  stability: "stable",
284
298
  deprecated: false,
@@ -296,6 +310,7 @@ const resetFromParentTool = (options) => bindTool(options, {
296
310
  requiresApproval: true,
297
311
  metadata: {
298
312
  method: "POST",
313
+ readOnlySafe: false,
299
314
  path: "/projects/{project_id}/branches/{branch_id}/restore",
300
315
  stability: "stable",
301
316
  deprecated: false,
@@ -317,6 +332,7 @@ const compareSchemaTool = (options) => bindTool(options, {
317
332
  requiresApproval: false,
318
333
  metadata: {
319
334
  method: "GET",
335
+ readOnlySafe: true,
320
336
  path: "/projects/{project_id}/branches/{branch_id}/compare_schema",
321
337
  stability: "stable",
322
338
  deprecated: false,
@@ -344,6 +360,12 @@ const connectionStringTool = (options) => bindTool(options, {
344
360
  requiresApproval: true,
345
361
  metadata: {
346
362
  method: "GET",
363
+ readOnlySafe: false,
364
+ secretOutputFields: [{
365
+ path: "$",
366
+ kind: "setup"
367
+ }],
368
+ returnsOnlySecrets: true,
347
369
  path: "/projects/{project_id}/connection_uri",
348
370
  stability: "stable",
349
371
  deprecated: false,
@@ -367,6 +389,11 @@ const createRoleTool = (options) => bindTool(options, {
367
389
  requiresApproval: true,
368
390
  metadata: {
369
391
  method: "POST",
392
+ readOnlySafe: false,
393
+ secretOutputFields: [{
394
+ path: "$.password",
395
+ kind: "setup"
396
+ }],
370
397
  path: "/projects/{project_id}/branches/{branch_id}/roles",
371
398
  stability: "stable",
372
399
  deprecated: false,
@@ -398,6 +425,7 @@ const restoreSnapshotTool = (options) => bindTool(options, {
398
425
  requiresApproval: true,
399
426
  metadata: {
400
427
  method: "POST",
428
+ readOnlySafe: false,
401
429
  path: "/projects/{project_id}/snapshots/{snapshot_id}/restore",
402
430
  stability: "stable",
403
431
  deprecated: false,
@@ -421,6 +449,7 @@ const setScheduleTool = (options) => bindTool(options, {
421
449
  requiresApproval: true,
422
450
  metadata: {
423
451
  method: "PUT",
452
+ readOnlySafe: false,
424
453
  path: "/projects/{project_id}/branches/{branch_id}/backup_schedule",
425
454
  stability: "stable",
426
455
  deprecated: false,
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-json-schema.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,eAAO,MAAM,iBAAiB,GAAI,MAAM,OAAO,KAAG,OAOjD,CAAC;AAMF,MAAM,WAAW,iBAAiB;IACjC,WAAW,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE;YACX,KAAK,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACrC,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACtC,CAAC;QACF,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;KACtC,CAAC;CACF;AAqHD,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GACjC,cAAc,CAAC,CAAC,OAAO,EACvB,UAAS,sBAA2B,KAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAUvB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC7B,cAAc,CAAC,CAAC,OAAO,EACvB,UAAS,sBAA2B,KAClC,iBAoBF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,iBAiCpD,CAAC"}
1
+ {"version":3,"file":"mcp-json-schema.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,eAAO,MAAM,iBAAiB,GAAI,MAAM,OAAO,KAAG,OAOjD,CAAC;AAMF,MAAM,WAAW,iBAAiB;IACjC,WAAW,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE;YACX,KAAK,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACrC,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACtC,CAAC;QACF,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;KACtC,CAAC;CACF;AAqHD,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GACjC,cAAc,CAAC,CAAC,OAAO,EACvB,UAAS,sBAA2B,KAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAUvB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC7B,cAAc,CAAC,CAAC,OAAO,EACvB,UAAS,sBAA2B,KAClC,iBAoBF,CAAC;AAiCF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,iBAmCpD,CAAC"}
@@ -96,8 +96,22 @@ const toMcpOutputSchema = (outputSchema, options = {}) => {
96
96
  }
97
97
  } };
98
98
  };
99
+ const ZOD_ISO_DATETIME_PATTERN = z.toJSONSchema(z.iso.datetime()).pattern;
100
+ /**
101
+ * `z.iso.datetime()` publishes a 256-character pattern next to
102
+ * `format: "date-time"`. Its main constraint beyond `format` is a `Z` offset,
103
+ * so `tools/list` carries `Z$` instead. `validate` still runs the full schema.
104
+ * Other patterns are published unchanged.
105
+ */
106
+ const compactDateTimePatterns = (node) => {
107
+ if (Array.isArray(node)) return node.map(compactDateTimePatterns);
108
+ if (!isPlainObject(node)) return node;
109
+ const out = Object.fromEntries(Object.entries(node).map(([key, value]) => [key, compactDateTimePatterns(value)]));
110
+ if (typeof ZOD_ISO_DATETIME_PATTERN === "string" && out.format === "date-time" && out.pattern === ZOD_ISO_DATETIME_PATTERN) out.pattern = "Z$";
111
+ return out;
112
+ };
99
113
  const toMcpInputSchema = (schema) => {
100
- const json = compactJsonSchema(z.toJSONSchema(schema, { io: "input" }));
114
+ const json = compactDateTimePatterns(compactJsonSchema(z.toJSONSchema(schema, { io: "input" })));
101
115
  if (!isPlainObject(json)) throw new TypeError("MCP tool input schemas must be JSON Schema objects");
102
116
  const standard = "~standard" in schema && isPlainObject(schema["~standard"]) ? schema["~standard"] : void 0;
103
117
  const validate = standard === void 0 ? void 0 : standard.validate;
@@ -15,20 +15,62 @@ export interface NeonToolCaller {
15
15
  export interface NeonToolExecutionContext {
16
16
  signal?: AbortSignal;
17
17
  apiKey?: NeonBearerCredential;
18
- /** SQL tools run caller SQL in a `READ ONLY` transaction or refuse to run. */
18
+ /**
19
+ * Refuses every tool whose `metadata.readOnlySafe` is false. SQL tools run
20
+ * caller SQL in a `READ ONLY` transaction or refuse to run.
21
+ */
19
22
  readOnly?: boolean;
23
+ /**
24
+ * Which secrets results keep. A hidden secret reads `"***redacted***"`, and
25
+ * a tool whose `metadata.returnsOnlySecrets` result would be hidden refuses.
26
+ */
27
+ secrets?: NeonSecretsMode;
20
28
  /** Every SQL connection logs in as this Postgres role. */
21
29
  postgresRole?: string;
22
30
  /** Attribution sent with `docs.search` requests. */
23
31
  caller?: NeonToolCaller;
24
32
  }
25
- export interface NeonToolMetadata {
33
+ /**
34
+ * `setup`: a credential Neon issues for an app, CI job, or agent to use, such as
35
+ * a connection string, role password, or credential token.
36
+ * `stored`: a secret you gave Neon to call another service, such as an SMTP
37
+ * password or an OAuth provider's client secret.
38
+ */
39
+ export type NeonSecretKind = "setup" | "stored";
40
+ /** `all` keeps every secret, `setup` keeps only `setup` secrets, `none` keeps none. */
41
+ export type NeonSecretsMode = "all" | "setup" | "none";
42
+ export interface NeonSecretField {
43
+ /**
44
+ * `$` for the whole value, `.key` for a field, `[*]` for every array item,
45
+ * as in `$.oauth_providers[*].client_secret`.
46
+ */
47
+ path: string;
48
+ kind: NeonSecretKind;
49
+ }
50
+ export interface NeonOperationMetadata {
26
51
  method: string;
27
52
  path: string;
28
53
  stability: string;
29
54
  deprecated: boolean;
30
55
  tags: readonly string[];
31
56
  }
57
+ export interface NeonToolMetadata extends NeonOperationMetadata {
58
+ /**
59
+ * Changes no Neon resource and returns no connection string or role
60
+ * password. A tool that is not refuses to run when `readOnly` is true.
61
+ */
62
+ readOnlySafe: boolean;
63
+ /** Where the result carries a secret, and what kind it is. */
64
+ secretOutputFields: readonly NeonSecretField[];
65
+ /**
66
+ * The result is the secret itself: a read of an existing secret, or a
67
+ * rotation that returns the replacement. Refused when `secrets` hides it.
68
+ */
69
+ returnsOnlySecrets: boolean;
70
+ }
71
+ /** Literal tool metadata; the secret fields default to none. */
72
+ export type NeonToolMetadataInput = Omit<NeonToolMetadata, "secretOutputFields" | "returnsOnlySecrets"> & Partial<Pick<NeonToolMetadata, "secretOutputFields" | "returnsOnlySecrets">>;
73
+ export declare const toolMetadata: (metadata: NeonToolMetadataInput) => NeonToolMetadata;
32
74
  export interface JsonSafeBlob {
33
75
  base64: string;
34
76
  contentType: string;
@@ -64,9 +106,13 @@ export interface NeonOperation<InputSchema extends z.ZodType, Id extends string
64
106
  inputSchema: InputSchema;
65
107
  annotations: NeonToolAnnotations;
66
108
  requiresApproval: boolean;
67
- metadata: NeonToolMetadata;
109
+ metadata: NeonOperationMetadata;
68
110
  invoke(client: Client, input: z.output<InputSchema>, signal?: AbortSignal): Promise<Output>;
69
111
  }
70
112
  export declare const defineOperation: <const InputSchema extends z.ZodType, const Id extends string, Output>(operation: NeonOperation<InputSchema, Id, Output>) => NeonOperation<InputSchema, Id, Output>;
71
- export declare const bindOperation: <const InputSchema extends z.ZodType, const Id extends string, Output>(operation: NeonOperation<InputSchema, Id, Output>, client: Client) => NeonTool<InputSchema, Id, JsonSafe<Awaited<Output>>>;
113
+ /** A generated operation bound to a client. `fromGenerated` adds the tool policy. */
114
+ export type NeonOperationTool<InputSchema extends z.ZodType = z.ZodType, Id extends string = string, Output = unknown> = Omit<NeonTool<InputSchema, Id, Output>, "metadata"> & {
115
+ metadata: NeonOperationMetadata;
116
+ };
117
+ export declare const bindOperation: <const InputSchema extends z.ZodType, const Id extends string, Output>(operation: NeonOperation<InputSchema, Id, Output>, client: Client) => NeonOperationTool<InputSchema, Id, JsonSafe<Awaited<Output>>>;
72
118
  //# sourceMappingURL=operation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/lib/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,WAAW,CAAC;AAG/E,MAAM,WAAW,mBAAmB;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,MA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AAM,EACd,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAC5B,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,CAAC,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,GAC3B,KAAK,CAAC,WAAW,SAAS,CAAC,CAAC,OAAO,EACnC,KAAK,CAAC,EAAE,SAAS,MAAM,EACvB,MAAM,EAEN,WAAW,aAAa,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,2CACpC,CAAC;AAEf,qFAAqF;AACrF,MAAM,MAAM,iBAAiB,CAC5B,WAAW,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EACzC,EAAE,SAAS,MAAM,GAAG,MAAM,EAC1B,MAAM,GAAG,OAAO,IACb,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IACzD,QAAQ,EAAE,qBAAqB,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,aAAa,GACzB,KAAK,CAAC,WAAW,SAAS,CAAC,CAAC,OAAO,EACnC,KAAK,CAAC,EAAE,SAAS,MAAM,EACvB,MAAM,EAEN,WAAW,aAAa,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,EACjD,QAAQ,MAAM,KACZ,iBAAiB,CAAC,WAAW,EAAE,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAsB7D,CAAC"}
@@ -2,6 +2,11 @@ import { requireBearerCredential } from "./auth.js";
2
2
  import { toToolResult } from "./result.js";
3
3
  import { createClient } from "@neon/sdk/raw";
4
4
  // src/lib/operation.ts
5
+ const toolMetadata = (metadata) => ({
6
+ ...metadata,
7
+ secretOutputFields: metadata.secretOutputFields ?? [],
8
+ returnsOnlySecrets: metadata.returnsOnlySecrets ?? false
9
+ });
5
10
  const defineOperation = (operation) => operation;
6
11
  const bindOperation = (operation, client) => ({
7
12
  operationId: operation.operationId,
@@ -26,4 +31,4 @@ const clientWithCredential = (client, apiKey) => {
26
31
  auth: requireBearerCredential(apiKey)
27
32
  });
28
33
  };
29
- export { bindOperation, defineOperation };
34
+ export { bindOperation, defineOperation, toolMetadata };
@@ -0,0 +1,24 @@
1
+ import type { NeonSecretField, NeonSecretsMode, NeonTool, NeonToolExecutionContext, NeonToolMetadata } from "./operation.js";
2
+ export interface NeonToolPolicyOptions {
3
+ /** The default for `readOnly` in every execution context. */
4
+ readOnly?: boolean;
5
+ /** The default for `secrets` in every execution context; `"all"` when unset. */
6
+ secrets?: NeonSecretsMode;
7
+ }
8
+ /** What a `tools` predicate sees: a tool without its `execute`. */
9
+ export type NeonToolDescriptor = Pick<NeonTool, "operationId" | "id" | "title" | "description" | "annotations" | "requiresApproval" | "metadata">;
10
+ export type NeonToolPredicate = (tool: NeonToolDescriptor) => boolean;
11
+ export declare const toolDescriptor: (tool: NeonTool) => NeonToolDescriptor;
12
+ export type NeonToolCallGuard = (context?: NeonToolExecutionContext) => void;
13
+ /** The secret fields `mode` replaces with `REDACTED_SECRET`. */
14
+ export declare const hiddenSecretFields: (metadata: Pick<NeonToolMetadata, "secretOutputFields">, mode: NeonSecretsMode) => NeonSecretField[];
15
+ /** The tool refuses under `mode` because its whole result would be hidden. */
16
+ export declare const withheldUnderSecrets: (metadata: Pick<NeonToolMetadata, "secretOutputFields" | "returnsOnlySecrets">, mode: NeonSecretsMode) => boolean;
17
+ /** Throws for a call the effective policy forbids. */
18
+ export declare const toolCallGuard: (tool: NeonTool, options: NeonToolPolicyOptions, publishedId: string) => NeonToolCallGuard;
19
+ /**
20
+ * SQL tools read the effective `readOnly` to open a `READ ONLY` transaction.
21
+ * Redaction runs inside `onExecute`, so a tracking hook sees the redacted result.
22
+ */
23
+ export declare const applyToolPolicy: <Tool extends NeonTool>(tool: Tool, options: NeonToolPolicyOptions, guard: NeonToolCallGuard) => Tool;
24
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
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BF,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { NeonToolCallerError } from "./caller-error.js";
2
+ import { redactSecretFields } from "./redact.js";
3
+ // src/lib/policy.ts
4
+ const toolDescriptor = (tool) => ({
5
+ operationId: tool.operationId,
6
+ id: tool.id,
7
+ title: tool.title,
8
+ description: tool.description,
9
+ annotations: tool.annotations,
10
+ requiresApproval: tool.requiresApproval,
11
+ metadata: tool.metadata
12
+ });
13
+ const secretsMode = (options, context) => context?.secrets ?? options.secrets ?? "all";
14
+ const hides = (mode, field) => mode === "none" || mode === "setup" && field.kind !== "setup";
15
+ /** The secret fields `mode` replaces with `REDACTED_SECRET`. */
16
+ const hiddenSecretFields = (metadata, mode) => metadata.secretOutputFields.filter((field) => hides(mode, field));
17
+ /** The tool refuses under `mode` because its whole result would be hidden. */
18
+ const withheldUnderSecrets = (metadata, mode) => metadata.returnsOnlySecrets && hiddenSecretFields(metadata, mode).length > 0;
19
+ /** Throws for a call the effective policy forbids. */
20
+ const toolCallGuard = (tool, options, publishedId) => (context) => {
21
+ if ((context?.readOnly ?? options.readOnly) === true && !tool.metadata.readOnlySafe) throw new NeonToolCallerError(`${publishedId} is unavailable in read-only mode because it can change Neon resources or returns a connection string or role password.`);
22
+ const secrets = secretsMode(options, context);
23
+ if (withheldUnderSecrets(tool.metadata, secrets)) throw new NeonToolCallerError(`${publishedId} is unavailable with secrets: "${secrets}" because its result is a secret.`);
24
+ };
25
+ /**
26
+ * SQL tools read the effective `readOnly` to open a `READ ONLY` transaction.
27
+ * Redaction runs inside `onExecute`, so a tracking hook sees the redacted result.
28
+ */
29
+ const applyToolPolicy = (tool, options, guard) => {
30
+ const execute = tool.execute.bind(tool);
31
+ return {
32
+ ...tool,
33
+ execute: async (input, context) => {
34
+ guard(context);
35
+ const readOnly = context?.readOnly ?? options.readOnly;
36
+ const result = await execute(input, readOnly === void 0 ? context : {
37
+ ...context,
38
+ readOnly
39
+ });
40
+ const hidden = hiddenSecretFields(tool.metadata, secretsMode(options, context));
41
+ if (hidden.length === 0) return result;
42
+ return {
43
+ ...result,
44
+ data: redactSecretFields(result.data, hidden.map((field) => field.path))
45
+ };
46
+ }
47
+ };
48
+ };
49
+ export { applyToolPolicy, hiddenSecretFields, toolCallGuard, toolDescriptor, withheldUnderSecrets };
@@ -0,0 +1,8 @@
1
+ export declare const REDACTED_SECRET = "***redacted***";
2
+ /**
3
+ * Replaces every non-empty string at `paths` with `REDACTED_SECRET`. An absent,
4
+ * null, or empty value is left as is, so "no secret" stays distinguishable
5
+ * from "redacted". A path that meets a different shape throws.
6
+ */
7
+ export declare const redactSecretFields: (data: unknown, paths: readonly string[]) => unknown;
8
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/lib/redact.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAwDhD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC9B,MAAM,OAAO,EACb,OAAO,SAAS,MAAM,EAAE,KACtB,OAID,CAAC"}