UNPKG

simple-milvus-mcp

Version:

MCP server for Milvus vector database with semantic and full-text search capabilities

199 lines 9.63 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Database = void 0; const BaseClient_1 = require("./BaseClient"); const __1 = require("../"); class Database extends BaseClient_1.BaseClient { constructor() { super(...arguments); // alias for alterDatabase /* istanbul ignore next */ this.alterDatabaseProperties = this.alterDatabase; } /** * Creates a new database. * * @param {CreateDatabaseRequest} data - The data for the new database. * @param {string} data.db_name - The name of the new database. * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined. * * @returns {Promise<ResStatus>} The response status of the operation. * @returns {string} status.error_code - The error code of the operation. * @returns {string} status.reason - The reason for the error, if any. * * @example * ``` * const milvusClient = new milvusClient(MILUVS_ADDRESS); * const resStatus = await milvusClient.createDatabase({ db_name: 'new_db' }); * ``` */ createDatabase(data) { return __awaiter(this, void 0, void 0, function* () { // check compatibility yield this.checkCompatibility({ message: `createDatabase is not supported on this version of milvus.`, }); const promise = yield (0, __1.promisify)(this.channelPool, 'CreateDatabase', { db_name: data.db_name, properties: (0, __1.parseToKeyValue)(data.properties), }, data.timeout || this.timeout); return promise; }); } /** * Lists all databases. * * @param {ListDatabasesRequest} data - The request parameters. * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined. * * @returns {Promise<ListDatabasesResponse>} The response from the server. * @returns {string} status.error_code - The error code of the operation. * @returns {string} status.reason - The reason for the error, if any. * * @example * ``` * const milvusClient = new milvusClient(MILUVS_ADDRESS); * const res = await milvusClient.listDatabases(); * ``` */ listDatabases(data) { return __awaiter(this, void 0, void 0, function* () { // check compatibility yield this.checkCompatibility({ message: `listDatabases is not supported on this version of milvus.`, }); const promise = yield (0, __1.promisify)(this.channelPool, 'ListDatabases', {}, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout); return promise; }); } /** * Describes a database. * * @param {DescribeDatabaseRequest} data - The request parameters. * @param {string} data.db_name - The name of the database to describe. * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined. * * @returns {Promise<DescribeDatabaseResponse>} The response from the server. * @returns {string} status.error_code - The error code of the operation. * @returns {string} status.reason - The reason for the error, if any. * @returns {string} db_name - The name of the database. * @returns {number} dbID - The ID of the database. * @returns {number} created_timestamp - The timestamp of when the database was created. * @returns {KeyValuePair[]} properties - The properties of the database. * * @example * ``` * const milvusClient = new milvusClient(MILUVS_ADDRESS); * const res = await milvusClient.describeDatabase({ db_name: 'db_to_describe' }); * ``` */ describeDatabase(data) { return __awaiter(this, void 0, void 0, function* () { // check compatibility yield this.checkCompatibility({ message: `describeDatabase is not supported on this version of milvus.`, }); const promise = yield (0, __1.promisify)(this.channelPool, 'DescribeDatabase', data, data.timeout || this.timeout); return promise; }); } /** * Drops a database. * * @param {DropDatabasesRequest} data - The request parameters. * @param {string} data.db_name - The name of the database to drop. * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined. * * @returns {Promise<ResStatus>} The response status of the operation. * @returns {string} status.error_code - The error code of the operation. * @returns {string} status.reason - The reason for the error, if any. * * @example * ``` * const milvusClient = new milvusClient(MILUVS_ADDRESS); * const resStatus = await milvusClient.dropDatabase({ db_name: 'db_to_drop' }); * ``` */ dropDatabase(data) { return __awaiter(this, void 0, void 0, function* () { // check compatibility yield this.checkCompatibility({ message: `dropDatabase is not supported on this version of milvus.`, }); const promise = yield (0, __1.promisify)(this.channelPool, 'DropDatabase', data, data.timeout || this.timeout); return promise; }); } /** * Modifies database properties. * * @param {AlterDatabaseRequest} data - The request parameters. * @param {string} data.db_name - The name of the database to modify. * @param {Object} data.properties - The properties to modify. For example, to change the TTL, use {"database.replica.number": 18000}. * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined. * * @returns {Promise<ResStatus>} The response status of the operation. * @returns {string} status.error_code - The error code of the operation. * @returns {string} status.reason - The reason for the error, if any. * * @example * ``` * const milvusClient = new milvusClient(MILUVS_ADDRESS); * const resStatus = await milvusClient.alterDatabase({ * database: 'my-db', * properties: {"database.replica.number": 18000} * }); * ``` */ alterDatabase(data) { return __awaiter(this, void 0, void 0, function* () { const promise = yield (0, __1.promisify)(this.channelPool, 'AlterDatabase', { db_name: data.db_name, properties: (0, __1.parseToKeyValue)(data.properties), }, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout); return promise; }); } /** * Drops database properties. * * @param {DropDatabasePropertiesRequest} * @param {string} data.db_name - The name of the database to modify. * @param {string[]} data.delete_properties - The properties to delete. For example, to delete the TTL, use ["database.replica.number"]. * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined. * * @returns {Promise<ResStatus>} The response status of the operation. * @returns {string} status.error_code - The error code of the operation. * @returns {string} status.reason - The reason for the error, if any. * * @example * * ``` * const milvusClient = new milvusClient(MILUVS_ADDRESS); * const resStatus = await milvusClient.dropDatabaseProperties({ * db_name: 'my-db', * delete_properties: ["database.replica.number"] * }); * ``` */ dropDatabaseProperties(data) { return __awaiter(this, void 0, void 0, function* () { const promise = yield (0, __1.promisify)(this.channelPool, 'AlterDatabase', { db_name: data.db_name, delete_keys: data.properties, }, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout); return promise; }); } } exports.Database = Database; //# sourceMappingURL=Database.js.map