@vectros-ai/mcp-server 0.11.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/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/server.ts
2
2
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
 
4
- // ../../node_modules/@vectros-ai/sdk/dist/index.mjs
4
+ // node_modules/@vectros-ai/sdk/dist/index.mjs
5
5
  var __defProp = Object.defineProperty;
6
6
  var __export = (target, all) => {
7
7
  for (var name in all)
@@ -4611,7 +4611,7 @@ var DocumentsClient = class {
4611
4611
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents");
4612
4612
  }
4613
4613
  /**
4614
- * 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.
4614
+ * 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.
4615
4615
  *
4616
4616
  * @param {Vectros.IngestDocumentRequest} request
4617
4617
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4937,25 +4937,29 @@ var DocumentsClient = class {
4937
4937
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v1/documents/{id}");
4938
4938
  }
4939
4939
  /**
4940
- * 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.
4940
+ * 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.
4941
4941
  *
4942
4942
  * @param {Vectros.LookupDocumentsRequest} request
4943
4943
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
4944
4944
  *
4945
+ * @throws {@link Vectros.BadRequestError}
4946
+ *
4945
4947
  * @example
4946
4948
  * await client.documents.lookupDocuments({
4947
4949
  * type: "invoice",
4948
4950
  * field: "po_number",
4949
4951
  * value: "PO-1001",
4950
4952
  * prefix: "PO-2024",
4951
- * startFrom: "550e8400-e29b-41d4-a716-446655440000"
4953
+ * startFrom: "550e8400-e29b-41d4-a716-446655440000",
4954
+ * userId: "550e8400-e29b-41d4-a716-446655440000",
4955
+ * scope: "org:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
4952
4956
  * })
4953
4957
  */
4954
4958
  lookupDocuments(request, requestOptions) {
4955
4959
  return HttpResponsePromise.fromPromise(this.__lookupDocuments(request, requestOptions));
4956
4960
  }
4957
4961
  async __lookupDocuments(request, requestOptions) {
4958
- const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order } = request;
4962
+ const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order, userId, scope } = request;
4959
4963
  const _queryParams = {
4960
4964
  type: type_,
4961
4965
  field,
@@ -4965,7 +4969,9 @@ var DocumentsClient = class {
4965
4969
  prefix,
4966
4970
  startFrom,
4967
4971
  limit,
4968
- order: order != null ? order : void 0
4972
+ order: order != null ? order : void 0,
4973
+ userId,
4974
+ scope
4969
4975
  };
4970
4976
  const _authRequest = await this._options.authProvider.getAuthRequest();
4971
4977
  const _headers = mergeHeaders(
@@ -4991,11 +4997,16 @@ var DocumentsClient = class {
4991
4997
  return { data: _response.body, rawResponse: _response.rawResponse };
4992
4998
  }
4993
4999
  if (_response.error.reason === "status-code") {
4994
- throw new VectrosError({
4995
- statusCode: _response.error.statusCode,
4996
- body: _response.error.body,
4997
- rawResponse: _response.rawResponse
4998
- });
5000
+ switch (_response.error.statusCode) {
5001
+ case 400:
5002
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
5003
+ default:
5004
+ throw new VectrosError({
5005
+ statusCode: _response.error.statusCode,
5006
+ body: _response.error.body,
5007
+ rawResponse: _response.rawResponse
5008
+ });
5009
+ }
4999
5010
  }
5000
5011
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents/lookup");
5001
5012
  }
@@ -5363,7 +5374,7 @@ var FoldersClient = class {
5363
5374
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/folders");
5364
5375
  }
5365
5376
  /**
5366
- * 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.
5377
+ * 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.
5367
5378
  *
5368
5379
  * @param {Vectros.CreateFolderRequest} request
5369
5380
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -5821,7 +5832,7 @@ var IdentityClient = class {
5821
5832
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}");
5822
5833
  }
5823
5834
  /**
5824
- * 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.
5835
+ * 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.
5825
5836
  *
5826
5837
  * @param {Vectros.CreateEntityRequest} request
5827
5838
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6265,7 +6276,7 @@ var IdentityClient = class {
6265
6276
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces/{namespace}");
6266
6277
  }
6267
6278
  /**
6268
- * 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.
6279
+ * 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.
6269
6280
  *
6270
6281
  * @param {Vectros.UpdateNamespaceRequest} request
6271
6282
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6278,7 +6289,8 @@ var IdentityClient = class {
6278
6289
  * await client.identity.updateNamespace({
6279
6290
  * namespace: "team",
6280
6291
  * body: {
6281
- * namespace: "team"
6292
+ * namespace: "team",
6293
+ * specificityRank: 1500
6282
6294
  * }
6283
6295
  * })
6284
6296
  */
@@ -6443,7 +6455,7 @@ var IdentityClient = class {
6443
6455
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces");
6444
6456
  }
6445
6457
  /**
6446
- * 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.
6458
+ * 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.
6447
6459
  *
6448
6460
  * @param {Vectros.NamespaceRequest} request
6449
6461
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6454,7 +6466,8 @@ var IdentityClient = class {
6454
6466
  *
6455
6467
  * @example
6456
6468
  * await client.identity.registerNamespace({
6457
- * namespace: "team"
6469
+ * namespace: "team",
6470
+ * specificityRank: 1500
6458
6471
  * })
6459
6472
  */
6460
6473
  registerNamespace(request, requestOptions) {
@@ -6571,7 +6584,7 @@ var IdentityClient = class {
6571
6584
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/users");
6572
6585
  }
6573
6586
  /**
6574
- * 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.
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 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.
6575
6588
  *
6576
6589
  * @param {Vectros.CreateUserRequest} request
6577
6590
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -7442,7 +7455,7 @@ var RecordsClient = class {
7442
7455
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/records");
7443
7456
  }
7444
7457
  /**
7445
- * 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.
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 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.
7446
7459
  *
7447
7460
  * @param {Vectros.CreateRecordRequest} request
7448
7461
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8033,6 +8046,8 @@ var SchemasClient = class {
8033
8046
  * @param {Vectros.ListSchemasRequest} request
8034
8047
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
8035
8048
  *
8049
+ * @throws {@link Vectros.BadRequestError}
8050
+ *
8036
8051
  * @example
8037
8052
  * await client.schemas.listSchemas({
8038
8053
  * userId: "550e8400-e29b-41d4-a716-446655440000",
@@ -8079,16 +8094,21 @@ var SchemasClient = class {
8079
8094
  return { data: _response.body, rawResponse: _response.rawResponse };
8080
8095
  }
8081
8096
  if (_response.error.reason === "status-code") {
8082
- throw new VectrosError({
8083
- statusCode: _response.error.statusCode,
8084
- body: _response.error.body,
8085
- rawResponse: _response.rawResponse
8086
- });
8097
+ switch (_response.error.statusCode) {
8098
+ case 400:
8099
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
8100
+ default:
8101
+ throw new VectrosError({
8102
+ statusCode: _response.error.statusCode,
8103
+ body: _response.error.body,
8104
+ rawResponse: _response.rawResponse
8105
+ });
8106
+ }
8087
8107
  }
8088
8108
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas");
8089
8109
  }
8090
8110
  /**
8091
- * 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.
8111
+ * 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.
8092
8112
  *
8093
8113
  * @param {Vectros.CreateSchemaRequest} request
8094
8114
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8232,7 +8252,7 @@ var SchemasClient = class {
8232
8252
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}");
8233
8253
  }
8234
8254
  /**
8235
- * 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.
8255
+ * 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.
8236
8256
  *
8237
8257
  * @param {Vectros.UpdateSchemaRequest} request
8238
8258
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8301,7 +8321,7 @@ var SchemasClient = class {
8301
8321
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/schemas/{id}");
8302
8322
  }
8303
8323
  /**
8304
- * 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.
8324
+ * 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.
8305
8325
  *
8306
8326
  * @param {Vectros.DeleteSchemaRequest} request
8307
8327
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8603,8 +8623,8 @@ function warnOnSuboptimalKey(key, log) {
8603
8623
 
8604
8624
  // src/build-info.ts
8605
8625
  var BUILD_INFO = {
8606
- mcpServer: true ? "0.11.0" : "dev",
8607
- sdk: true ? "0.36.0" : "dev"
8626
+ mcpServer: true ? "0.12.0" : "dev",
8627
+ sdk: true ? "0.37.0" : "dev"
8608
8628
  };
8609
8629
 
8610
8630
  // src/log.ts
@@ -9116,14 +9136,14 @@ var record_query_default = recordQuery;
9116
9136
  import { z as z3 } from "zod";
9117
9137
 
9118
9138
  // src/tools/resolve-external-id.ts
9119
- function validateSelector(sel, entity) {
9139
+ function validateSelector(sel, entity, fieldName) {
9120
9140
  const hasId = sel.id !== void 0 && sel.id !== "";
9121
9141
  const hasExt = sel.externalId !== void 0 && sel.externalId !== "";
9122
9142
  if (hasId && hasExt) {
9123
- return `Provide either id or externalId (not both) to identify the ${entity}.`;
9143
+ return `Provide either ${fieldName} or externalId (not both) to identify the ${entity}.`;
9124
9144
  }
9125
9145
  if (!hasId && !hasExt) {
9126
- return `Provide id, or externalId + type, to identify the ${entity}.`;
9146
+ return `Provide ${fieldName}, or externalId + type, to identify the ${entity}.`;
9127
9147
  }
9128
9148
  if (hasExt && (sel.type === void 0 || sel.type === "")) {
9129
9149
  return "type is required when selecting by externalId (externalId is unique within a type).";
@@ -9131,7 +9151,7 @@ function validateSelector(sel, entity) {
9131
9151
  return void 0;
9132
9152
  }
9133
9153
  async function resolveRecordIdByExternalId(client, sel) {
9134
- const err = validateSelector(sel, "record");
9154
+ const err = validateSelector(sel, "record", "id");
9135
9155
  if (err) return { error: err };
9136
9156
  if (sel.id) return { id: sel.id };
9137
9157
  const page = await client.records.lookupRecordsByBody({
@@ -9147,7 +9167,7 @@ async function resolveRecordIdByExternalId(client, sel) {
9147
9167
  return { id: items[0].id };
9148
9168
  }
9149
9169
  async function resolveDocumentIdByExternalId(client, sel) {
9150
- const err = validateSelector(sel, "document");
9170
+ const err = validateSelector(sel, "document", "documentId");
9151
9171
  if (err) return { error: err };
9152
9172
  if (sel.id) return { id: sel.id };
9153
9173
  const page = await client.documents.lookupDocumentsByBody({