Skip to main content
Glama
spec.ts1.9 kB
import { ExpandedPkgSpec } from "../../spec/pkgs.ts"; import { OnlyProperties } from "../../spec/props.ts"; import { makeModule } from "../generic/index.ts"; import { CfProperty, SuperSchema } from "../types.ts"; import { DUMMY_PROVIDER_CONFIG } from "./provider.ts"; import { databaseSchema, DummySchema, serverSchema } from "./schema.ts"; import { htmlToMarkdown } from "../../util.ts"; function splitDummyProperties( schema: SuperSchema | DummySchema, onlyProperties: OnlyProperties, ): { domainProperties: Record<string, CfProperty>; resourceValueProperties: Record<string, CfProperty>; } { if (!("properties" in schema)) throw new Error("Not DummySchema"); const readOnlySet = new Set(onlyProperties.readOnly); const domainProperties: Record<string, CfProperty> = {}; const resourceValueProperties: Record<string, CfProperty> = {}; for (const [name, prop] of Object.entries(schema.properties)) { if (readOnlySet.has(name)) { resourceValueProperties[name] = prop as CfProperty; } else { domainProperties[name] = prop as CfProperty; } } return { domainProperties, resourceValueProperties }; } export function pkgSpecFromDummy(): ExpandedPkgSpec[] { const schemas = [serverSchema, databaseSchema]; const specs: ExpandedPkgSpec[] = []; for (const schema of schemas) { const onlyProperties: OnlyProperties = { createOnly: [], readOnly: ["id", "ipAddress", "status"], writeOnly: [], primaryIdentifier: ["id"], }; const { domainProperties, resourceValueProperties } = splitDummyProperties( schema, onlyProperties, ); const module = makeModule( schema, htmlToMarkdown(schema.description) ?? schema.description, onlyProperties, DUMMY_PROVIDER_CONFIG, domainProperties, resourceValueProperties, ); specs.push(module); } return specs; }

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