@vectros-ai/mcp-server 0.10.0 → 0.12.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/dist/cli.js CHANGED
@@ -61,6 +61,7 @@ __export(api_exports, {
61
61
  FileUploadRequest: () => FileUploadRequest,
62
62
  ForbiddenError: () => ForbiddenError,
63
63
  IdentityLookupRequest: () => IdentityLookupRequest,
64
+ IndexFailure: () => IndexFailure,
64
65
  InternalServerError: () => InternalServerError,
65
66
  ListEntitiesRequestOrder: () => ListEntitiesRequestOrder,
66
67
  ListUsersRequestOrder: () => ListUsersRequestOrder,
@@ -582,6 +583,17 @@ var IdentityLookupRequest;
582
583
  Desc: "desc"
583
584
  };
584
585
  })(IdentityLookupRequest || (IdentityLookupRequest = {}));
586
+ var IndexFailure;
587
+ ((IndexFailure2) => {
588
+ IndexFailure2.Code = {
589
+ SourceUnavailable: "SOURCE_UNAVAILABLE",
590
+ TextIndexFailed: "TEXT_INDEX_FAILED",
591
+ EmbeddingFailed: "EMBEDDING_FAILED",
592
+ IndexingFailed: "INDEXING_FAILED",
593
+ VectorLimitExceeded: "VECTOR_LIMIT_EXCEEDED",
594
+ Internal: "INTERNAL"
595
+ };
596
+ })(IndexFailure || (IndexFailure = {}));
585
597
  var ModelDataVersionResponse;
586
598
  ((ModelDataVersionResponse2) => {
587
599
  ModelDataVersionResponse2.ChangeType = {
@@ -4098,7 +4110,7 @@ var AuthClient = class {
4098
4110
  );
4099
4111
  }
4100
4112
  /**
4101
- * Creates a short-lived JWT bearer token restricted to specific actions and, optionally, to a particular user, organization, or client. Use this to hand a narrowly-scoped credential to a browser or downstream service so it never sees your root API key. Only callable with a root API key (`sk_*`).
4113
+ * Creates a short-lived JWT bearer token restricted to specific actions and, optionally, to a particular user or identity entity (in any namespace). Use this to hand a narrowly-scoped credential to a browser or downstream service so it never sees your root API key. Only callable with a root API key (`sk_*`).
4102
4114
  *
4103
4115
  * @param {Vectros.TokenRequest} request
4104
4116
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4315,7 +4327,7 @@ var ComplianceClient = class {
4315
4327
  this._options = normalizeClientOptionsWithAuth(options);
4316
4328
  }
4317
4329
  /**
4318
- * Submits a right-to-erasure request for a single end-subject (a user, client, or organization). Erasure removes exactly the data the subject solely owns across the declared contexts, plus the subject's identity and lookup rows. It never touches another account's data and never cascades into another subject's data. The request is asynchronous: it returns 202 with a `requestId`; poll `GET /v1/erasure-requests/{id}` until the job completes to obtain the completion certificate. Requires a root API key — a scoped credential is rejected with 403.
4330
+ * Submits a right-to-erasure request for a single end-subject (a user, or an identity entity in any namespace). Erasure removes exactly the data the subject solely owns across the declared contexts, plus the subject's identity and lookup rows. It never touches another account's data and never cascades into another subject's data. The request is asynchronous: it returns 202 with a `requestId`; poll `GET /v1/erasure-requests/{id}` until the job completes to obtain the completion certificate. Requires a root API key — a scoped credential is rejected with 403.
4319
4331
  *
4320
4332
  * @param {Vectros.ErasureRequest} request
4321
4333
  * @param {ComplianceClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4624,7 +4636,7 @@ var DocumentsClient = class {
4624
4636
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents");
4625
4637
  }
4626
4638
  /**
4627
- * Creates a document from a raw text string and queues it for asynchronous indexing so it becomes searchable. Optionally supply an `externalId` to make the create idempotent — if a document with the same `externalId` already exists in your context, that existing document is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing document was returned) tells the two apart. To overwrite an existing document's content instead of returning it unchanged, set `?upsert=true` (this also requires the `documents:u` scope). Requires the `documents:c` scope.
4639
+ * Creates a document from a raw text string and queues it for asynchronous indexing so it becomes searchable. Optionally supply an `externalId` to make the create idempotent — if a document with the same `externalId` already exists in your context, that existing document is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing document was returned) tells the two apart. To overwrite an existing document's content instead of returning it unchanged, set `?upsert=true` (this also requires the `documents:u` scope). Requires the `documents:c` scope to create. Being returned the existing document on a collision is a read of that document's data and additionally requires the `documents:r` scope — a credential holding `documents:c` alone receives a `400` ("already exists") on collision instead of the document.
4628
4640
  *
4629
4641
  * @param {Vectros.IngestDocumentRequest} request
4630
4642
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4950,25 +4962,29 @@ var DocumentsClient = class {
4950
4962
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v1/documents/{id}");
4951
4963
  }
4952
4964
  /**
4953
- * Finds documents of a given type by field value. Supported fields: `externalId` (the document's first-class external identifier — no schema declaration required) and any field declared as a lookup field on the bound schema. A lookup on a sensitive field is rejected here because the value would appear in the URL query string; use POST /v1/documents/lookup (the request-body variant) for a sensitive field instead. Results are paginated: set `limit` for the page size and feed the returned `nextCursor` back as `startFrom` to fetch the next page. The response is a `{data, nextCursor}` envelope. Requires the `documents:r` scope.
4965
+ * Finds documents of a given type by field value. Supported fields: `externalId` (the document's first-class external identifier — no schema declaration required) and any field declared as a lookup field on the bound schema. A lookup on a sensitive field is rejected here because the value would appear in the URL query string; use POST /v1/documents/lookup (the request-body variant) for a sensitive field instead. `type`'s schema resolves with basedOn-aware shadowing: your own `userId`- or `scope`-owned variant if you have one, otherwise the shared base — for a scoped credential the owner is always your own token identity; `userId`/`scope` here only apply as an explicit owner selector for a root API key. Results are paginated: set `limit` for the page size and feed the returned `nextCursor` back as `startFrom` to fetch the next page. The response is a `{data, nextCursor}` envelope. Requires the `documents:r` scope.
4954
4966
  *
4955
4967
  * @param {Vectros.LookupDocumentsRequest} request
4956
4968
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
4957
4969
  *
4970
+ * @throws {@link Vectros.BadRequestError}
4971
+ *
4958
4972
  * @example
4959
4973
  * await client.documents.lookupDocuments({
4960
4974
  * type: "invoice",
4961
4975
  * field: "po_number",
4962
4976
  * value: "PO-1001",
4963
4977
  * prefix: "PO-2024",
4964
- * startFrom: "550e8400-e29b-41d4-a716-446655440000"
4978
+ * startFrom: "550e8400-e29b-41d4-a716-446655440000",
4979
+ * userId: "550e8400-e29b-41d4-a716-446655440000",
4980
+ * scope: "org:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
4965
4981
  * })
4966
4982
  */
4967
4983
  lookupDocuments(request, requestOptions) {
4968
4984
  return HttpResponsePromise.fromPromise(this.__lookupDocuments(request, requestOptions));
4969
4985
  }
4970
4986
  async __lookupDocuments(request, requestOptions) {
4971
- const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order } = request;
4987
+ const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order, userId, scope } = request;
4972
4988
  const _queryParams = {
4973
4989
  type: type_,
4974
4990
  field,
@@ -4978,7 +4994,9 @@ var DocumentsClient = class {
4978
4994
  prefix,
4979
4995
  startFrom,
4980
4996
  limit,
4981
- order: order != null ? order : void 0
4997
+ order: order != null ? order : void 0,
4998
+ userId,
4999
+ scope
4982
5000
  };
4983
5001
  const _authRequest = await this._options.authProvider.getAuthRequest();
4984
5002
  const _headers = mergeHeaders(
@@ -5004,11 +5022,16 @@ var DocumentsClient = class {
5004
5022
  return { data: _response.body, rawResponse: _response.rawResponse };
5005
5023
  }
5006
5024
  if (_response.error.reason === "status-code") {
5007
- throw new VectrosError({
5008
- statusCode: _response.error.statusCode,
5009
- body: _response.error.body,
5010
- rawResponse: _response.rawResponse
5011
- });
5025
+ switch (_response.error.statusCode) {
5026
+ case 400:
5027
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
5028
+ default:
5029
+ throw new VectrosError({
5030
+ statusCode: _response.error.statusCode,
5031
+ body: _response.error.body,
5032
+ rawResponse: _response.rawResponse
5033
+ });
5034
+ }
5012
5035
  }
5013
5036
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents/lookup");
5014
5037
  }
@@ -5376,7 +5399,7 @@ var FoldersClient = class {
5376
5399
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/folders");
5377
5400
  }
5378
5401
  /**
5379
- * Creates a folder to organize your documents and records. If `parentFolderId` is omitted, the folder is created under your context's default root folder. Folder creation is idempotent by (slug + parent): if a folder with the same slug already exists under the same parent, that existing folder is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing folder was returned) tells the two apart. To overwrite an existing folder's mutable fields instead of returning it unchanged, set `?upsert=true` (this also requires the `folders:u` scope). Requires the `folders:c` scope.
5402
+ * Creates a folder to organize your documents and records. If `parentFolderId` is omitted, the folder is created under your context's default root folder. Folder creation is idempotent by (slug + parent): if a folder with the same slug already exists under the same parent, that existing folder is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing folder was returned) tells the two apart. To overwrite an existing folder's mutable fields instead of returning it unchanged, set `?upsert=true` (this also requires the `folders:u` scope). Requires the `folders:c` scope to create. Being returned the existing folder on a collision is a read of that folder's data and additionally requires the `folders:r` scope — a credential holding `folders:c` alone receives a `400` ("already exists") on collision instead of the folder.
5380
5403
  *
5381
5404
  * @param {Vectros.CreateFolderRequest} request
5382
5405
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -5834,7 +5857,7 @@ var IdentityClient = class {
5834
5857
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}");
5835
5858
  }
5836
5859
  /**
5837
- * Creates a new entity in the given namespace. This call is idempotent on `externalId` within the namespace: if an entity with the same `externalId` already exists, the existing record is returned instead of creating a duplicate (`created: false`, HTTP 200). To overwrite an existing entity's content instead of returning it unchanged, set `?upsert=true` (also requires the `entities:u:<namespace>` scope). The namespace must be entity-backed (`org`/`client`, or registered via `POST /v1/namespaces`). Requires the `entities:c:<namespace>` scope.
5860
+ * Creates a new entity in the given namespace. This call is idempotent on `externalId` within the namespace: if an entity with the same `externalId` already exists, the existing record is returned instead of creating a duplicate (`created: false`, HTTP 200). To overwrite an existing entity's content instead of returning it unchanged, set `?upsert=true` (also requires the `entities:u:<namespace>` scope). The namespace must be entity-backed (`org`/`client`, or registered via `POST /v1/namespaces`). Requires the `entities:c:<namespace>` scope to create. Being returned the existing entity on a collision is a read of that entity's data and additionally requires the `entities:r:<namespace>` scope — a credential holding `entities:c:<namespace>` alone receives a `400` ("already in use") on collision instead of the entity.
5838
5861
  *
5839
5862
  * @param {Vectros.CreateEntityRequest} request
5840
5863
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6278,7 +6301,7 @@ var IdentityClient = class {
6278
6301
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces/{namespace}");
6279
6302
  }
6280
6303
  /**
6281
- * Updates the mutable fields (`entityBacked`, `defaultSchemaId`) of a registered namespace. The namespace name itself is immutable. Requires a root API key. The reserved built-ins cannot be updated.
6304
+ * Updates the mutable fields (`entityBacked`, `defaultSchemaId`, `specificityRank`) of a registered namespace. The namespace name itself is immutable. Requires a root API key. The reserved built-ins cannot be updated.
6282
6305
  *
6283
6306
  * @param {Vectros.UpdateNamespaceRequest} request
6284
6307
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6291,7 +6314,8 @@ var IdentityClient = class {
6291
6314
  * await client.identity.updateNamespace({
6292
6315
  * namespace: "team",
6293
6316
  * body: {
6294
- * namespace: "team"
6317
+ * namespace: "team",
6318
+ * specificityRank: 1500
6295
6319
  * }
6296
6320
  * })
6297
6321
  */
@@ -6456,7 +6480,7 @@ var IdentityClient = class {
6456
6480
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces");
6457
6481
  }
6458
6482
  /**
6459
- * Registers a new scope namespace and declares whether its values resolve to identity entities (`entityBacked`). Requires a root API key. The reserved names `org` and `client` are built in and cannot be registered.
6483
+ * Registers a new scope namespace and declares whether its values resolve to identity entities (`entityBacked`). Also requires `specificityRank`, an explicit, account-unique position in the specificity order used to break recordType schema-resolution ties. Requires a root API key. The reserved names `org` and `client` are built in and cannot be registered.
6460
6484
  *
6461
6485
  * @param {Vectros.NamespaceRequest} request
6462
6486
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6467,7 +6491,8 @@ var IdentityClient = class {
6467
6491
  *
6468
6492
  * @example
6469
6493
  * await client.identity.registerNamespace({
6470
- * namespace: "team"
6494
+ * namespace: "team",
6495
+ * specificityRank: 1500
6471
6496
  * })
6472
6497
  */
6473
6498
  registerNamespace(request, requestOptions) {
@@ -6584,7 +6609,7 @@ var IdentityClient = class {
6584
6609
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/users");
6585
6610
  }
6586
6611
  /**
6587
- * Creates a user identity in your account. The operation is idempotent on `externalId`: if a user with the same `externalId` already exists, the existing record is returned instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing user was returned) tells the two apart. To overwrite an existing user's mutable fields (email, status, payload, schema binding) instead of returning it unchanged, set `?upsert=true` (this also requires the `users:u` scope). Requires the `users:c` scope.
6612
+ * Creates a user identity in your account. The operation is idempotent on `externalId`: if a user with the same `externalId` already exists, the existing record is returned instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing user was returned) tells the two apart. To overwrite an existing user's mutable fields (email, status, payload, schema binding) instead of returning it unchanged, set `?upsert=true` (this also requires the `users:u` scope). Requires the `users:c` scope to create. Being returned the existing user on a collision is a read of that user's data and additionally requires the `users:r` scope — a credential holding `users:c` alone receives a `400` ("already exists") on collision instead of the user.
6588
6613
  *
6589
6614
  * @param {Vectros.CreateUserRequest} request
6590
6615
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -7455,7 +7480,7 @@ var RecordsClient = class {
7455
7480
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/records");
7456
7481
  }
7457
7482
  /**
7458
- * Creates a new record of a given type. The `payload` is validated against that type's schema before the record is stored. Identify the type by sending `typeName`, `schemaId`, or both (they must agree); if you send only `schemaId`, the type is taken from that schema. Optionally supply an `externalId` to make the create idempotent — if a record with the same `externalId` already exists in your context, that existing record is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing record was returned) tells the two apart. To overwrite an existing record's content instead of returning it unchanged, set `?upsert=true` (this also requires the `records:u:<type>` scope). Requires the `records:c:<type>` scope.
7483
+ * Creates a new record of a given type. The `payload` is validated against that type's schema before the record is stored. Identify the type by sending `typeName`, `schemaId`, or both (they must agree); if you send only `schemaId`, the type is taken from that schema. Optionally supply an `externalId` to make the create idempotent — if a record with the same `externalId` already exists in your context, that existing record is returned unchanged instead of a duplicate being created. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing record was returned) tells the two apart. To overwrite an existing record's content instead of returning it unchanged, set `?upsert=true` (this also requires the `records:u:<type>` scope). Requires the `records:c:<type>` scope to create. Being returned the existing record on a collision is a read of that record's data and additionally requires the `records:r:<type>` scope — a credential holding `records:c:<type>` alone receives a `400` ("already exists") on collision instead of the record.
7459
7484
  *
7460
7485
  * @param {Vectros.CreateRecordRequest} request
7461
7486
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8046,6 +8071,8 @@ var SchemasClient = class {
8046
8071
  * @param {Vectros.ListSchemasRequest} request
8047
8072
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
8048
8073
  *
8074
+ * @throws {@link Vectros.BadRequestError}
8075
+ *
8049
8076
  * @example
8050
8077
  * await client.schemas.listSchemas({
8051
8078
  * userId: "550e8400-e29b-41d4-a716-446655440000",
@@ -8092,16 +8119,21 @@ var SchemasClient = class {
8092
8119
  return { data: _response.body, rawResponse: _response.rawResponse };
8093
8120
  }
8094
8121
  if (_response.error.reason === "status-code") {
8095
- throw new VectrosError({
8096
- statusCode: _response.error.statusCode,
8097
- body: _response.error.body,
8098
- rawResponse: _response.rawResponse
8099
- });
8122
+ switch (_response.error.statusCode) {
8123
+ case 400:
8124
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
8125
+ default:
8126
+ throw new VectrosError({
8127
+ statusCode: _response.error.statusCode,
8128
+ body: _response.error.body,
8129
+ rawResponse: _response.rawResponse
8130
+ });
8131
+ }
8100
8132
  }
8101
8133
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas");
8102
8134
  }
8103
8135
  /**
8104
- * Defines a new record type with optional field definitions, validation rules, and lookup indexes. Idempotent by `typeName` within the same ownership scope: re-creating an existing `typeName` returns the existing schema rather than failing. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing schema was returned) tells the two apart. To reconcile an existing schema to the submitted shape instead of returning it unchanged, set `?upsert=true` (this also requires the `schemas:w` scope; only legal schema changes are applied — migration-locked changes are rejected). Requires the `schemas:w` scope.
8136
+ * Defines a new record type with optional field definitions, validation rules, and lookup indexes. Idempotent by `typeName` within the same ownership scope: re-creating an existing `typeName` returns the existing schema rather than failing. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing schema was returned) tells the two apart. To reconcile an existing schema to the submitted shape instead of returning it unchanged, set `?upsert=true` (this also requires the `schemas:u` scope; only legal schema changes are applied — migration-locked changes are rejected). Requires the `schemas:c` scope to create. Being returned the existing schema on a collision is a read of that schema's data and additionally requires the `schemas:r` scope — a credential holding `schemas:c` alone receives a `400` ("already in use") on collision instead of the schema.
8105
8137
  *
8106
8138
  * @param {Vectros.CreateSchemaRequest} request
8107
8139
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8245,7 +8277,7 @@ var SchemasClient = class {
8245
8277
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}");
8246
8278
  }
8247
8279
  /**
8248
- * Updates a record schema. Fields you omit are preserved; `typeName` is immutable and cannot be changed. Collection fields (`fields`, `lookupFields`, `renderHints`, `capabilities`) are replaced in full when supplied. Requires the `schemas:w` scope.
8280
+ * Updates a record schema. Fields you omit are preserved; `typeName` is immutable and cannot be changed. Collection fields (`fields`, `lookupFields`, `renderHints`, `capabilities`) are replaced in full when supplied. Requires the `schemas:u` scope.
8249
8281
  *
8250
8282
  * @param {Vectros.UpdateSchemaRequest} request
8251
8283
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8314,7 +8346,7 @@ var SchemasClient = class {
8314
8346
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/schemas/{id}");
8315
8347
  }
8316
8348
  /**
8317
- * Permanently deletes a record schema. The request is refused with 409 if records of this type still exist — delete those records first, since every record must reference a live schema. Requires the `schemas:w` scope.
8349
+ * Permanently deletes a record schema. The request is refused with 409 if records of this type still exist — delete those records first, since every record must reference a live schema. A lineage base (a schema other schemas declare `basedOn`) also cannot be deleted while any such variant still exists — delete the variant schema(s) first. Requires the `schemas:d` scope.
8318
8350
  *
8319
8351
  * @param {Vectros.DeleteSchemaRequest} request
8320
8352
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8611,8 +8643,8 @@ function warnOnSuboptimalKey(key, log) {
8611
8643
 
8612
8644
  // src/build-info.ts
8613
8645
  var BUILD_INFO = {
8614
- mcpServer: true ? "0.10.0" : "dev",
8615
- sdk: true ? "0.35.0" : "dev"
8646
+ mcpServer: true ? "0.12.0" : "dev",
8647
+ sdk: true ? "0.37.0" : "dev"
8616
8648
  };
8617
8649
  function formatBuildInfo() {
8618
8650
  return `vectros-mcp-server ${BUILD_INFO.mcpServer} (sdk ${BUILD_INFO.sdk})`;
@@ -8819,31 +8851,45 @@ async function consumeStream(stream, onProgress) {
8819
8851
  }
8820
8852
 
8821
8853
  // src/tools/errors.ts
8854
+ function asErrorBody(body) {
8855
+ if (body && typeof body === "object") return body;
8856
+ return void 0;
8857
+ }
8822
8858
  function toolError(toolName, err, docPointer) {
8823
8859
  let summary = `${toolName} failed`;
8824
8860
  let detail = String(err);
8861
+ let errorCode;
8862
+ let requestId;
8825
8863
  if (err instanceof StreamError) {
8826
8864
  summary = `${toolName} stream error`;
8827
8865
  detail = err.message;
8828
8866
  } else if (err instanceof Error) {
8829
8867
  const e = err;
8830
8868
  detail = e.message;
8869
+ const body = asErrorBody(e.body);
8870
+ if (body) {
8871
+ if (typeof body.message === "string" && body.message.trim().length > 0) detail = body.message;
8872
+ if (typeof body.errorCode === "string" && body.errorCode.length > 0) errorCode = body.errorCode;
8873
+ if (typeof body.requestId === "string" && body.requestId.length > 0) requestId = body.requestId;
8874
+ }
8831
8875
  if (e.statusCode) {
8832
- summary = `${toolName} failed: HTTP ${e.statusCode}`;
8876
+ summary = `${toolName} failed: HTTP ${e.statusCode}${errorCode ? ` (${errorCode})` : ""}`;
8833
8877
  } else if (e.name && e.name !== "Error") {
8834
8878
  summary = `${toolName} failed: ${e.name}`;
8835
8879
  }
8836
8880
  }
8837
- const pointer = docPointer ? `
8881
+ const trailer = (errorCode ? `
8882
+ errorCode: ${errorCode}` : "") + (requestId ? `
8883
+ requestId: ${requestId}` : "") + (docPointer ? `
8838
8884
 
8839
- See: ${docPointer}` : "";
8885
+ See: ${docPointer}` : "");
8840
8886
  return {
8841
8887
  isError: true,
8842
8888
  content: [
8843
8889
  {
8844
8890
  type: "text",
8845
8891
  text: `${summary}
8846
- ${detail}${pointer}`
8892
+ ${detail}${trailer}`
8847
8893
  }
8848
8894
  ]
8849
8895
  };
@@ -8920,7 +8966,7 @@ var inputSchema = {
8920
8966
  var hybridSearch = ({ client, log }) => ({
8921
8967
  name: "hybrid_search",
8922
8968
  title: "Hybrid search",
8923
- description: "Search your tenant's indexed content (documents + structured records) using hybrid BM25 + dense ranking. Returns up to `limit` results (default 3, max 50 \u2014 raise it in one call when you can accept the larger result) with citations and surrounding context for grounding follow-up reasoning. Narrow with contentTypes/typeName/filters, ownership (userId/scope), folder scope, a created date window, keyword precision (textMode OR/AND/PHRASE), relevance floors (minSimilarity/minTextRelevance), uniqueDocuments, and requireComplete (fail closed on a degraded backend). Tenant-isolated; the caller's scoped key fully constrains which content is visible. ARCHIVED (soft-retracted) documents never appear in results \u2014 fetch them by id via document_get, or restore them via document_update. To stay within the agent context window each hit returns its matched chunkText + a short snippet by default; set includeContext:true for the broader surrounding passage. If the whole result would be too large it is truncated to the top hits (truncated:true). totalResults is the full matching pool and hasMore:true means results remain past this page \u2014 raise limit or advance offset to fetch them. textLegEmpty:true flags that the keyword leg matched nothing (all textScores 0) \u2014 usually a too-long PHRASE query; retry with textMode:\"OR\".",
8969
+ description: 'Search your tenant\'s indexed content (documents + structured records) using hybrid BM25 + dense ranking. Returns up to `limit` results (default 3, max 50 \u2014 raise it in one call when you can accept the larger result) with citations and surrounding context for grounding follow-up reasoning. Narrow with contentTypes/typeName/filters, ownership (userId/scope), folder scope, a created date window, keyword precision (textMode OR/AND/PHRASE), relevance floors (minSimilarity/minTextRelevance), uniqueDocuments, and requireComplete (fail closed on a degraded backend). Tenant-isolated; the caller\'s scoped key fully constrains which content is visible. ARCHIVED (soft-retracted) documents never appear in results \u2014 fetch them by id via document_get, or restore them via document_update. To stay within the agent context window each hit returns its matched chunkText + a short snippet by default; set includeContext:true for the broader surrounding passage. If the whole result would be too large it is truncated to the top hits (truncated:true). totalResults is the full matching pool and hasMore:true means results remain past this page \u2014 raise limit or advance offset to fetch them. textLegEmpty:true flags that the keyword (BM25) leg matched nothing (all textScores 0) \u2014 typically the default PHRASE mode finding no contiguous match for a long natural-language query. Loosen the keyword leg: shorten the query to its key terms, or set textMode "AND" (all terms, higher precision) or "OR" (any term, broad recall).',
8924
8970
  inputSchema,
8925
8971
  handler: async (args) => {
8926
8972
  const limit = args.limit ?? MCP_DEFAULT_LIMIT;
@@ -9113,14 +9159,14 @@ var record_query_default = recordQuery;
9113
9159
  var import_zod3 = require("zod");
9114
9160
 
9115
9161
  // src/tools/resolve-external-id.ts
9116
- function validateSelector(sel, entity) {
9162
+ function validateSelector(sel, entity, fieldName) {
9117
9163
  const hasId = sel.id !== void 0 && sel.id !== "";
9118
9164
  const hasExt = sel.externalId !== void 0 && sel.externalId !== "";
9119
9165
  if (hasId && hasExt) {
9120
- return `Provide either id or externalId (not both) to identify the ${entity}.`;
9166
+ return `Provide either ${fieldName} or externalId (not both) to identify the ${entity}.`;
9121
9167
  }
9122
9168
  if (!hasId && !hasExt) {
9123
- return `Provide id, or externalId + type, to identify the ${entity}.`;
9169
+ return `Provide ${fieldName}, or externalId + type, to identify the ${entity}.`;
9124
9170
  }
9125
9171
  if (hasExt && (sel.type === void 0 || sel.type === "")) {
9126
9172
  return "type is required when selecting by externalId (externalId is unique within a type).";
@@ -9128,7 +9174,7 @@ function validateSelector(sel, entity) {
9128
9174
  return void 0;
9129
9175
  }
9130
9176
  async function resolveRecordIdByExternalId(client, sel) {
9131
- const err = validateSelector(sel, "record");
9177
+ const err = validateSelector(sel, "record", "id");
9132
9178
  if (err) return { error: err };
9133
9179
  if (sel.id) return { id: sel.id };
9134
9180
  const page = await client.records.lookupRecordsByBody({
@@ -9144,7 +9190,7 @@ async function resolveRecordIdByExternalId(client, sel) {
9144
9190
  return { id: items[0].id };
9145
9191
  }
9146
9192
  async function resolveDocumentIdByExternalId(client, sel) {
9147
- const err = validateSelector(sel, "document");
9193
+ const err = validateSelector(sel, "document", "documentId");
9148
9194
  if (err) return { error: err };
9149
9195
  if (sel.id) return { id: sel.id };
9150
9196
  const page = await client.documents.lookupDocumentsByBody({
@@ -9172,7 +9218,7 @@ var inputSchema3 = {
9172
9218
  var recordGet = ({ client, log }) => ({
9173
9219
  name: "record_get",
9174
9220
  title: "Get a record by id or externalId",
9175
- description: "Fetch a single structured record, including the full payload. Select it EITHER by its Vectros `id` (e.g. from record_query / hybrid_search) OR by your own `externalId` + `type` \u2014 the same key you passed to record_create, resolved for you (no manual record_query lookup needed). Very large payloads are truncated to protect the agent context window.",
9221
+ description: "Fetch a single structured record, including the full payload. Select it EITHER by its Vectros `id` (e.g. from record_query / hybrid_search) OR by your own `externalId` + `type` \u2014 the same key you passed to record_create, resolved for you (no manual record_query lookup needed). Very large payloads are truncated to protect the agent context window. The response carries the record's processing `indexStatus`; when it is FAILED an `indexFailure.code` explains whether the content is still searchable (e.g. VECTOR_LIMIT_EXCEEDED keeps keyword search vs INDEXING_FAILED = not findable at all) \u2014 branch on the `code`, not the message.",
9176
9222
  inputSchema: inputSchema3,
9177
9223
  handler: async (args) => {
9178
9224
  const id = args.id;
@@ -9210,7 +9256,7 @@ var import_zod4 = require("zod");
9210
9256
  var inputSchema4 = {
9211
9257
  type: import_zod4.z.string().min(1, "type is required").describe('Record type / schema name (e.g. "task"). Must match an existing schema \u2014 see list_schemas.'),
9212
9258
  fields: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).describe(
9213
- "The record payload \u2014 a JSON object of field\u2192value, validated against the type schema. Call list_schemas to learn required fields, types, and enum values."
9259
+ "The record payload \u2014 a JSON object of field\u2192value, validated against the type schema. Call list_schemas to learn required fields, types, and enum values. Every number must fall within the signed 64-bit range (a value outside it, or with >38 significant digits, is refused with a 400 naming the field) \u2014 send a larger whole number (e.g. a big external id) as a STRING, which stores it exactly and supports exact-match lookup."
9214
9260
  ),
9215
9261
  externalId: import_zod4.z.string().optional().describe(
9216
9262
  "Stable caller-supplied id. Immutable; unique per type. Re-creating with the same externalId returns the existing record (idempotent) \u2014 use it to make creates safely retryable."
@@ -9228,7 +9274,7 @@ var inputSchema4 = {
9228
9274
  var recordCreate = ({ client, log }) => ({
9229
9275
  name: "record_create",
9230
9276
  title: "Create a record",
9231
- description: "Create a structured record of a given type. Provide `type` and `fields` (the payload, validated against the type schema \u2014 call list_schemas first to learn required fields and enums). Idempotent by `externalId`. Requires the key to allow records:c.",
9277
+ description: "Create a structured record of a given type. Provide `type` and `fields` (the payload, validated against the type schema \u2014 call list_schemas first to learn required fields and enums). Idempotent by `externalId`. Requires the key to allow records:c (and records:r to receive the existing record on a collision).",
9232
9278
  inputSchema: inputSchema4,
9233
9279
  handler: async (args) => {
9234
9280
  const type = args.type;
@@ -9586,7 +9632,7 @@ function isNotAvailable(err) {
9586
9632
  var documentGet = ({ client, log }) => ({
9587
9633
  name: "document_get",
9588
9634
  title: "Get document metadata (and optionally text)",
9589
- description: "Fetch metadata for a single document \u2014 select it by its Vectros `documentId` OR by your own `externalId` + `type` (resolved for you). Pass `includeText: true` to also fetch the text body (capped at ~8K tokens; `truncated: true` flag if cut). Text is available for every text-ingested document and for file-ingested documents unless they were uploaded with `storeText: false` (extracted text discarded after indexing) \u2014 then `textAvailable: false` is set; the original file is still retrievable via `includeDownloadUrl`. Pass `includeDownloadUrl: true` to also get a short-lived presigned `downloadUrl` for the original file (file-backed documents only). Returns the full document metadata, including its lifecycle `status` (ACTIVE, or ARCHIVED when soft-retracted from search \u2014 restorable via document_update) and its processing `indexStatus`.",
9635
+ description: "Fetch metadata for a single document \u2014 select it by its Vectros `documentId` OR by your own `externalId` + `type` (resolved for you). Pass `includeText: true` to also fetch the text body (capped at ~8K tokens; `truncated: true` flag if cut). Text is available for every text-ingested document and for file-ingested documents unless they were uploaded with `storeText: false` (extracted text discarded after indexing) \u2014 then `textAvailable: false` is set; the original file is still retrievable via `includeDownloadUrl`. Pass `includeDownloadUrl: true` to also get a short-lived presigned `downloadUrl` for the original file (file-backed documents only). Returns the full document metadata, including its lifecycle `status` (ACTIVE, or ARCHIVED when soft-retracted from search \u2014 restorable via document_update) and its processing `indexStatus`. When `indexStatus` is FAILED the response also carries `indexFailure` with a machine-readable `code` telling you whether the content is still findable \u2014 e.g. TEXT_INDEX_FAILED / VECTOR_LIMIT_EXCEEDED (one leg still serves it) vs INDEXING_FAILED (not findable by search at all). Branch on `code`, not on the message.",
9590
9636
  inputSchema: inputSchema10,
9591
9637
  handler: async (args) => {
9592
9638
  const documentId = args.documentId;
@@ -9920,7 +9966,7 @@ var inputSchema15 = {
9920
9966
  var folderCreate = ({ client, log }) => ({
9921
9967
  name: "folder_create",
9922
9968
  title: "Create a folder",
9923
- description: "Create a folder to organize documents and records. Pass `parentId` to nest it (create-only \u2014 folders cannot be moved later). Idempotent by `slug` within the parent. Requires the key to allow folders:c.",
9969
+ description: "Create a folder to organize documents and records. Pass `parentId` to nest it (create-only \u2014 folders cannot be moved later). Idempotent by `slug` within the parent. Requires the key to allow folders:c (and folders:r to receive the existing folder on a collision).",
9924
9970
  inputSchema: inputSchema15,
9925
9971
  handler: async (args) => {
9926
9972
  try {
@@ -10019,7 +10065,7 @@ var inputSchema18 = {
10019
10065
  var currentIdentity = ({ log, apiKey, environment }) => ({
10020
10066
  name: "current_identity",
10021
10067
  title: "Current identity (tenant + principal scope)",
10022
- description: "Describe the credential the MCP server is operating under. Returns tenantId, environment (staging|production), principalType (root_key|scoped_key|token), principalKeyId, and (for scoped keys) allowedActions + dataScope. Use this when the user asks 'what can you do here?' or 'what tenant am I in?'. Calls GET /v1/ping under the hood. Backend may still be rolling out the extended /v1/ping response shape \u2014 until then this tool returns a minimal shape; richer fields appear automatically as backend ships.",
10068
+ description: "Describe the credential the MCP server is operating under. Returns tenantId, environment (staging|production), principalType (root_key|scoped_key|token), principalKeyId, principalLabel, and (for scoped credentials) allowedActions plus dataScope \u2014 the credential's reach as { userId, scopes[] }, where each scope is a `namespace:value` string (e.g. \"org:<uuid>\"). Use this when the user asks 'what can you do here?' or 'what tenant am I in?'. Calls GET /v1/ping under the hood.",
10023
10069
  inputSchema: inputSchema18,
10024
10070
  handler: async () => {
10025
10071
  try {
@@ -10117,7 +10163,7 @@ var inputSchema19 = {
10117
10163
  "Index strategy. HYBRID (BM25 + dense, default; best for general retrieval), SEMANTIC (dense only; concept-driven queries), TEXT (BM25 only; exact-match / keyword), NONE (store-only / archival \u2014 retrievable by id and structured-field lookup but never in search results). Omit to inherit the bound schema's default."
10118
10164
  ),
10119
10165
  externalId: import_zod18.z.string().optional().describe(
10120
- "Stable caller-supplied id. Immutable; unique per type within your context. Re-ingesting with the same externalId returns the existing document (idempotent) instead of creating a duplicate \u2014 use it to make ingests safely retryable and as the key other records reference. Mirrors record_create."
10166
+ 'Stable caller-supplied id. Immutable; unique per type within your context. Re-ingesting with the same externalId returns the existing document (idempotent) instead of creating a duplicate \u2014 use it to make ingests safely retryable and as the key other records reference. Mirrors record_create. Receiving the existing document back is a read of it and needs documents:r in addition to documents:c; a create-only key gets an "already exists" error instead of the document.'
10121
10167
  ),
10122
10168
  upsert: import_zod18.z.boolean().optional().describe(
10123
10169
  "When true, re-ingesting an existing externalId OVERWRITES that document and re-indexes the new body (text mode) / re-uploads and re-indexes the new file (file mode), instead of returning the existing one unchanged. This is the curation/re-sync primitive: edit a source, re-ingest with upsert:true, and the search index reflects the new content. Requires the documents:u scope. IMPORTANT: pass the SAME schemaId (and type) you used originally \u2014 externalId is unique WITHIN a type, so omitting schemaId resolves in the untyped namespace and mints a duplicate instead of updating. The response `created` flag confirms which happened (created:true = a new document was minted)."
@@ -10126,12 +10172,12 @@ var inputSchema19 = {
10126
10172
  "Bind this document to a record schema. When set, `payload` is validated against the schema and its lookup fields become directly queryable via document_query (records parity). Resolve a schema id from its type via list_schemas. Omit for an untyped document."
10127
10173
  ),
10128
10174
  payload: import_zod18.z.record(import_zod18.z.string(), import_zod18.z.unknown()).optional().describe(
10129
- "The document's structured data \u2014 a flat key/value object. With `schemaId`, declared fields are validated and lookup fields indexed; undeclared keys pass through as free-form and are searchable via the hybrid_search `filters` param. Without a schema it is stored as free-form metadata."
10175
+ "The document's structured data \u2014 a flat key/value object. With `schemaId`, declared fields are validated and lookup fields indexed; undeclared keys pass through as free-form and are searchable via the hybrid_search `filters` param. Without a schema it is stored as free-form metadata. Every number must fall within the signed 64-bit range \u2014 send a larger whole number as a STRING (stored exactly, exact-match lookup), else the ingest is refused with a 400 naming the field."
10130
10176
  ),
10131
10177
  // Inline text mode (mutually exclusive with filePath):
10132
10178
  text: import_zod18.z.string().min(1).optional().describe("Text body to ingest inline. Mutually exclusive with filePath. Either text or filePath is required."),
10133
10179
  storeText: import_zod18.z.boolean().optional().describe(
10134
- "Whether the document's text is retained after indexing (default true). Applies to BOTH modes and is fixed at ingest time. Text mode: the ingested body is always retained (this flag is effectively always true \u2014 the body is the document). File mode: true keeps the extracted text retrievable via document_get(includeText:true) and usable by document_ask; false discards the extracted text once indexing completes \u2014 search still works and the original file remains downloadable, but includeText returns textAvailable:false and document_ask is unavailable."
10180
+ "FILE MODE ONLY. Whether the uploaded file's EXTRACTED text is retained after indexing (default true), fixed at ingest. true keeps the extracted text retrievable via document_get(includeText:true) and usable by document_ask; false discards it once indexing completes \u2014 search still works and the original file remains downloadable, but includeText returns textAvailable:false and document_ask is unavailable. NOT accepted with `text`: a text-ingested body is the document itself and is ALWAYS retained, so the backend has no storeText knob on the text path \u2014 passing it with `text` is rejected rather than silently ignored."
10135
10181
  ),
10136
10182
  // File upload mode (mutually exclusive with text; stdio-transport-only):
10137
10183
  filePath: import_zod18.z.string().min(1).optional().describe(
@@ -10148,7 +10194,7 @@ var inputSchema19 = {
10148
10194
  var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10149
10195
  name: "document_ingest",
10150
10196
  title: "Ingest a new document (text body or file upload)",
10151
- description: "Create a new document in your Vectros tenant. Two modes:\n \u2022 Text mode: pass `text` (string body). Single-call. Use for crawled content, notes, generated text.\n \u2022 File mode: pass `filePath` (local path on the MCP server's host machine). STDIO-TRANSPORT ONLY \u2014 rejected on HTTP transport. MCP server reads the bytes, requests a presigned upload URL, and PUTs them. Returns when the upload is accepted (indexStatus: PENDING_INDEX); poll with `document_get` until indexStatus is INDEXED.\nEither `text` or `filePath` must be present; both is an error. Idempotent by `externalId` (re-ingest returns the existing document, not a duplicate). To UPDATE an existing document instead \u2014 re-index an edited body \u2014 pass `upsert:true` with the same `externalId` (and the same `schemaId`); this is the re-sync primitive for keeping a knowledge base current. Pass `schemaId` + `payload` for a typed, lookup-queryable document (records parity). indexMode defaults to HYBRID for untyped documents (omit to inherit a bound schema's default). storeText defaults to true and is fixed at ingest: in file mode, false discards the extracted text after indexing (search + file download keep working; text retrieval and document_ask do not). Text-mode bodies are always retained.",
10197
+ description: "Create a new document in your Vectros tenant. Two modes:\n \u2022 Text mode: pass `text` (string body). Single-call. Use for crawled content, notes, generated text.\n \u2022 File mode: pass `filePath` (local path on the MCP server's host machine). STDIO-TRANSPORT ONLY \u2014 rejected on HTTP transport. MCP server reads the bytes, requests a presigned upload URL, and PUTs them. Returns when the upload is accepted (indexStatus: PENDING_INDEX); poll with `document_get` until indexStatus is INDEXED.\nEither `text` or `filePath` must be present; both is an error. Idempotent by `externalId` (re-ingest returns the existing document, not a duplicate \u2014 requires documents:r in addition to documents:c, since being handed the existing document is a read of it). To UPDATE an existing document instead \u2014 re-index an edited body \u2014 pass `upsert:true` with the same `externalId` (and the same `schemaId`); this is the re-sync primitive for keeping a knowledge base current. Pass `schemaId` + `payload` for a typed, lookup-queryable document (records parity). indexMode defaults to HYBRID for untyped documents (omit to inherit a bound schema's default). storeText is a FILE-MODE knob (default true): false discards the uploaded file's extracted text after indexing (search + file download keep working; text retrieval and document_ask do not). Text-mode bodies are always retained, so storeText is not accepted with `text`.",
10152
10198
  inputSchema: inputSchema19,
10153
10199
  handler: async (args) => {
10154
10200
  const title = args.title;
@@ -10185,6 +10231,14 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10185
10231
  )
10186
10232
  );
10187
10233
  }
10234
+ if (text && args.storeText !== void 0) {
10235
+ return toolError(
10236
+ "document_ingest",
10237
+ new Error(
10238
+ "`storeText` is not supported with `text` \u2014 a text-ingested body is the document itself and is always retained; the text path has no storeText control. Omit it (text mode), or use `filePath` mode where storeText:false discards the uploaded file's extracted text after indexing."
10239
+ )
10240
+ );
10241
+ }
10188
10242
  const common = {
10189
10243
  folderId: args.folderId,
10190
10244
  payload: args.payload,
@@ -10489,7 +10543,7 @@ var identityResource = ({ log, apiKey, environment }) => ({
10489
10543
  name: "identity",
10490
10544
  uri: "vectros://identity",
10491
10545
  title: "Current identity (tenant + principal scope)",
10492
- description: "The tenant + principal scope the MCP server is authenticated as. Returns the same payload as the `current_identity` tool: status, environment, principalType, principalKeyId, and (for scoped keys) allowedActions + dataScope. Until backend ships the extended /v1/ping response, returns a minimal derived shape; richer fields appear automatically as backend rolls out.",
10546
+ description: "The tenant + principal scope the MCP server is authenticated as. Returns the same payload as the `current_identity` tool: status, tenantId, environment, principalType, principalKeyId, principalLabel, and (for scoped credentials) allowedActions + dataScope ({ userId, scopes[] }). The /v1/ping backing call ships this extended shape today.",
10493
10547
  mimeType: "application/json",
10494
10548
  read: async () => {
10495
10549
  const identity = await resolveIdentity({ log, apiKey, environment });