Skip to main content
Glama

MCP Orchestration Server

test.js2.77 kB
// Netlify function to test the environment and configuration const { autoConnect, getConnectionStatus } = require('./utils/mongodb_connection'); exports.handler = async function(event, context) { // Make the database connection reusable across function invocations context.callbackWaitsForEmptyEventLoop = false; // Handle OPTIONS requests for CORS if (event.httpMethod === 'OPTIONS') { return { statusCode: 200, headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', 'Access-Control-Max-Age': '86400', }, body: '', }; } try { // Try to auto-connect to MongoDB let mongodbStatus = 'not checked'; try { await autoConnect(); const status = getConnectionStatus(); mongodbStatus = status.status; } catch (mongoError) { console.error('Error checking MongoDB status:', mongoError); mongodbStatus = 'error'; } // Get environment variables (redact sensitive information) const env = { NODE_ENV: process.env.NODE_ENV, NETLIFY: process.env.NETLIFY, CONTEXT: process.env.CONTEXT, MONGODB_URI: process.env.MONGODB_URI ? '[REDACTED]' : undefined, RENDER_BACKEND_URL: process.env.RENDER_BACKEND_URL ? '[REDACTED]' : undefined }; // Return the test results return { statusCode: 200, headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', }, body: JSON.stringify({ status: 'ok', message: 'Netlify Function is working!', timestamp: new Date().toISOString(), mongodb: mongodbStatus, env: env, runtime: { node: process.version, platform: process.platform, arch: process.arch }, event: { path: event.path, httpMethod: event.httpMethod, headers: event.headers, queryStringParameters: event.queryStringParameters, } }), }; } catch (error) { console.error('Error in test function:', error); return { statusCode: 500, headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', }, body: JSON.stringify({ status: 'error', error: error.message }), }; } };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nisarg-123-web/MCP2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server