UNPKG

purchase-mcp-server

Version:

Purchase and budget management server handling requisitions, purchase orders, expenses, budgets, and vendor management with ERP access for data extraction

93 lines 3.75 kB
// import { getMongoClient, logger, getConfig } from "syia-mcp-utils"; // import { ObjectId } from "mongodb"; // import { // ToolResponse, // FindRelevantVendorsArguments, // GetVendorContactDetailsArguments, // ToolArguments // } from "../../types/index.js"; export {}; // export class VendorToolHandler { // constructor() { // // No MongoDB client initialization needed // } // async searchVendors(arguments_: ToolArguments): Promise<ToolResponse> { // const { query, limit = 10 } = arguments_; // try { // const mongoClient = await getMongoClient(getConfig().mongoUri); // const db = mongoClient.db(getConfig().dbName); // const vendors = await db.collection('vendors') // .find({ // $or: [ // { name: { $regex: query, $options: 'i' } }, // { category: { $regex: query, $options: 'i' } }, // { location: { $regex: query, $options: 'i' } } // ] // }) // .limit(limit) // .toArray(); // return [{ // type: "text", // text: JSON.stringify(vendors, null, 2) // }]; // } catch (error) { // logger.error('Error searching vendors:', error); // throw error; // } // } // async findRelevantVendors(arguments_: FindRelevantVendorsArguments): Promise<ToolResponse> { // const { query, category, limit = 10 } = arguments_; // if (!query) { // throw new Error("Query is required"); // } // try { // const mongoClient = await getMongoClient(); // const db = mongoClient.db(getConfig().dbName); // const collection = db.collection('vendors'); // const searchQuery: any = { // $or: [ // { name: { $regex: query, $options: 'i' } }, // { description: { $regex: query, $options: 'i' } } // ] // }; // if (category) { // searchQuery.category = category; // } // const vendors = await collection.find(searchQuery) // .sort({ relevance: -1 }) // .limit(limit) // .toArray(); // return [{ // type: "text", // text: JSON.stringify(vendors, null, 2) // }]; // } catch (error) { // logger.error('Error finding relevant vendors:', error); // throw error; // } // } // async getVendorContactInfo(arguments_: GetVendorContactDetailsArguments): Promise<ToolResponse> { // const { vendorId } = arguments_; // try { // const mongoClient = await getMongoClient(getConfig().mongoUri); // const db = mongoClient.db(getConfig().dbName); // // Using ObjectId from syia-mcp-utils import // const vendor = await db.collection('vendors') // .findOne( // { _id: new ObjectId(vendorId as string) }, // { projection: { contactDetails: 1, name: 1 } } // ); // if (!vendor) { // throw new Error(`Vendor not found: ${vendorId}`); // } // return [{ // type: "text", // text: JSON.stringify(vendor, null, 2) // }]; // } catch (error) { // logger.error('Error getting vendor contact info:', error); // throw error; // } // } // } //# sourceMappingURL=vendorTools.js.map