Skip to main content
Glama

GenAIScript

Official
by microsoft
MIT License
43
2,820
  • Linux
  • Apple
build.ts1.79 kB
import { uniq } from "es-toolkit" import { GENAI_ANY_REGEX, GENAI_ANYJS_GLOB, GENAISCRIPT_FOLDER, } from "../../core/src/constants" import { host, runtimeHost } from "../../core/src/host" import { parseProject } from "../../core/src/parser" import { arrayify } from "../../core/src/util" /** * Asynchronously builds a project by parsing tool files. * * @param options - Optional configuration for building the project. * @param options.toolFiles - Specific tool files to include in the build. * @param options.toolsPath - Path or paths to search for tool files if none are provided. * @returns A promise that resolves to the newly parsed project structure. */ export async function buildProject(options?: { toolFiles?: string[] toolsPath?: string | string[] }) { const { toolFiles, toolsPath } = options || {} let scriptFiles: string[] = [] if (toolFiles?.length) { scriptFiles = toolFiles } else { let tps = arrayify(toolsPath) if (!tps?.length) { const config = await runtimeHost.config tps = [GENAI_ANYJS_GLOB, ...arrayify(config.include)] } tps = arrayify(tps) scriptFiles = [] for (const tp of tps) { const fs = await host.findFiles(tp, { ignore: `**/${GENAISCRIPT_FOLDER}/**`, }) scriptFiles.push(...fs) } } // filter out unwanted files scriptFiles = scriptFiles.filter((f) => GENAI_ANY_REGEX.test(f)) // Ensure that the script files are unique scriptFiles = uniq(scriptFiles) // Parse the project using the determined script files const newProject = await parseProject({ scriptFiles, }) // Return the newly parsed project structure return newProject }

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/microsoft/genaiscript'

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