feat: add allowed Linear API operations to MCP config

This commit is contained in:
Do Siki
2025-09-05 03:10:17 +02:00
parent 7e7d3fb1cc
commit b6365543ef
36 changed files with 14648 additions and 1 deletions
+55
View File
@@ -0,0 +1,55 @@
import { MongoClient, Db } from 'mongodb'
if (!process.env.MONGODB_URI) {
throw new Error('Please add MONGODB_URI to your environment variables')
}
const uri = process.env.MONGODB_URI
const options = {
maxPoolSize: 10,
serverSelectionTimeoutMS: 5000,
socketTimeoutMS: 45000,
}
let client: MongoClient
let clientPromise: Promise<MongoClient>
// In development mode, use a global variable so that the client is not recreated between hot reloads
if (process.env.NODE_ENV === 'development') {
// @ts-ignore
if (!global._mongoClientPromise) {
client = new MongoClient(uri, options)
// @ts-ignore
global._mongoClientPromise = client.connect()
}
// @ts-ignore
clientPromise = global._mongoClientPromise
} else {
// In production mode, it's best to not use a global variable
client = new MongoClient(uri, options)
clientPromise = client.connect()
}
export default clientPromise
export async function getDb(): Promise<Db> {
const client = await clientPromise
return client.db(process.env.MONGODB_DB || 'mozdit')
}
export async function getCollection(collectionName: string) {
const db = await getDb()
return db.collection(collectionName)
}
// Health check for MongoDB connection
export async function checkMongoConnection(): Promise<boolean> {
try {
const db = await getDb()
await db.admin().ping()
return true
} catch (error) {
console.error('MongoDB connection check failed:', error)
return false
}
}