We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/luchiniatwork/openai-websearch-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
config.ts•944 B
import type { ServerConfig } from "../types/config.js";
import { DEFAULT_MODEL } from "../constants.js";
import { ConfigurationError } from "./errors.js";
export function loadConfig(): ServerConfig {
const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) {
throw new ConfigurationError(
"OPENAI_API_KEY environment variable is required. Please set it to your OpenAI API key."
);
}
return {
openaiApiKey: apiKey,
defaultModel: process.env.OPENAI_DEFAULT_MODEL || DEFAULT_MODEL,
};
}
export function validateConfig(config: ServerConfig): void {
if (!config.openaiApiKey) {
throw new ConfigurationError("OpenAI API key is required");
}
if (!config.openaiApiKey.startsWith("sk-")) {
throw new ConfigurationError(
"Invalid OpenAI API key format. API keys should start with 'sk-'"
);
}
if (!config.defaultModel) {
throw new ConfigurationError("Default model is required");
}
}