Skip to main content
Glama
generateDefaultActionFuncs.ts1.34 kB
import _ from "lodash"; import { ExpandedPkgSpec } from "../../spec/pkgs.ts"; import { CfHandlerKind } from "../types.ts"; import { createActionFuncSpec } from "../../spec/funcs.ts"; import { FuncSpec } from "../../bindings/FuncSpec.ts"; import { ActionFuncSpecKind } from "../../bindings/ActionFuncSpecKind.ts"; export function generateDefaultActionFuncs( specs: ExpandedPkgSpec[], fn: Fn, ): ExpandedPkgSpec[] { const defaultActionFuncs = fn(); for (const spec of specs) { const { funcs, schemas: [{ variants: [variant] }], } = spec; const { actionFuncs, superSchema } = variant; for (const { spec: actionFunc, kind } of defaultActionFuncs) { // Make sure the Cloud Formation can handle the action too! let handlerKind: CfHandlerKind; switch (kind) { case "refresh": case "other": handlerKind = "read"; break; default: handlerKind = kind; } if (!superSchema.handlers?.[handlerKind]) continue; // clone otherwise modifications to these cause changes on all // specs funcs.push(_.cloneDeep(actionFunc)); // Generic actionFuncs.push(createActionFuncSpec(kind, actionFunc.uniqueId)); } } return specs; } export type Fn = () => { spec: FuncSpec; kind: ActionFuncSpecKind }[];

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/systeminit/si'

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