Skip to main content
Glama
MIT License
27,120
19,780
  • Linux
  • Apple
loadLanguage.ts•916 B
import fs from 'node:fs/promises'; import { createRequire } from 'node:module'; import { Language } from 'web-tree-sitter'; const require = createRequire(import.meta.url); export async function loadLanguage(langName: string): Promise<Language> { if (!langName) { throw new Error('Invalid language name'); } try { const wasmPath = await getWasmPath(langName); return await Language.load(wasmPath); } catch (error: unknown) { const message = error instanceof Error ? error.message : String(error); throw new Error(`Failed to load language ${langName}: ${message}`); } } async function getWasmPath(langName: string): Promise<string> { const wasmPath = require.resolve(`tree-sitter-wasms/out/tree-sitter-${langName}.wasm`); try { await fs.access(wasmPath); return wasmPath; } catch { throw new Error(`WASM file not found for language ${langName}: ${wasmPath}`); } }

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/yamadashy/repomix'

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