Skip to main content
Glama
download-openapi.mjs1.18 kB
import fs from 'fs'; const DEFAULT_OPENAPI_URL = 'https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/refs/heads/master/openapi/v1.0/openapi.yaml'; export async function downloadGraphOpenAPI( targetDir, targetFile, openapiUrl = DEFAULT_OPENAPI_URL, forceDownload = false ) { if (!fs.existsSync(targetDir)) { console.log(`Creating directory: ${targetDir}`); fs.mkdirSync(targetDir, { recursive: true }); } if (fs.existsSync(targetFile) && !forceDownload) { console.log(`OpenAPI specification already exists at ${targetFile}`); console.log('Use --force to download again'); return false; } console.log(`Downloading OpenAPI specification from ${openapiUrl}`); try { const response = await fetch(openapiUrl); if (!response.ok) { throw new Error(`Failed to download: ${response.status} ${response.statusText}`); } const content = await response.text(); fs.writeFileSync(targetFile, content); console.log(`OpenAPI specification downloaded to ${targetFile}`); return true; } catch (error) { console.error('Error downloading OpenAPI specification:', error.message); throw error; } }

Latest Blog Posts

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/Softeria/ms-365-mcp-server'

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