UNPKG

casefile-repository-mcp-server

Version:

Vessel casefile management system with MCP integration for maritime operations

50 lines 1.78 kB
import { getMongoClient } from "../utils/mongodb.js"; import { config } from "../utils/config.js"; import { ObjectId } from "mongodb"; // Resource Definitions export const resourceList = [ { uri: "user://details/<user_id>", name: "User Details", description: "Details about the user based on the given user id", mimeType: "application/json" }, { uri: "document://manual/<document_id>", name: "Company Manual", description: "Company manual document content", mimeType: "application/json" } ]; // Resource Handlers export async function getUserDetails(userId) { try { const mongoClient = await getMongoClient(config.mongoUri); const db = mongoClient.db(config.dbName); const collection = db.collection("users"); const user = await collection.findOne({ _id: new ObjectId(userId) }, { projection: { _id: 0, firstName: 1, lastName: 1, email: 1, phone: 1 } }); if (!user) { throw new Error(`User not found with ID: ${userId}`); } return user; } catch (error) { throw new Error(`Error fetching user details: ${error}`); } } export async function getDocumentContent(documentId) { try { const mongoClient = await getMongoClient(config.mongoUri); const db = mongoClient.db(config.dbName); const collection = db.collection("documents"); const document = await collection.findOne({ _id: new ObjectId(documentId) }); if (!document) { throw new Error(`Document not found with ID: ${documentId}`); } return document; } catch (error) { throw new Error(`Error fetching document content: ${error}`); } } //# sourceMappingURL=index.js.map