Skip to main content
Glama

datatype-update

Create or update custom data types including structs, collections, and domain types for connectors and business objects in the Simplifier platform.

Instructions

#Create or update custom data types

Custom datatypes can be either

  • a struct type, which requires the definition of fields and their types (parameter "fields")

  • a collection type, which requires a datatype for its elements (parameter "collectionDatatype")

  • a domain type, which requires a parent type it is derived from (parameter "derivedFrom") These are mutually exclusive, so only specify exactly one of the three parameters.

In these parameters, referenced datatypes are specified by name. If it isn't a global datatype, the name must be prefixed with the namespace, separated with a slash.

Datatypes for connectors should be in the namespace "con/$name_of_connector", those for business objects in "bo/$name_of_bo".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qualifiedNameYes
descriptionNo
derivedFromNo
collectionDatatypeNo
fieldsNo
tagsYes
projectAssignmentsNo

Implementation Reference

  • The asynchronous handler function that implements the core logic of the 'datatype-update' tool. It processes input parameters, determines the datatype category, resolves namespaces and fields, constructs the SimplifierDataTypeUpdate object, checks if the datatype exists, and calls createDataType or updateDataType accordingly.
    }, async ({ qualifiedName: qualifiedName, description, derivedFrom, collectionDatatype, fields, tags, projectAssignments }) => { return wrapToolResult(`create or update data type ${qualifiedName}`, async () => { const { name: newTypeName, namespace: newTypeNamespace } = splitNamespace(qualifiedName); const category = determineCategory(fields, derivedFrom, collectionDatatype) if (category === 'base') { throw new Error("creating base types is not allowed") } const { name: derivedFromName, namespace: derivedFromNamespace } = derivedFrom ? splitNamespace(derivedFrom) : { name: undefined, namespace: undefined }; const { name: collectionDtName, namespace: collectionDtNamespace } = collectionDatatype ? splitNamespace(collectionDatatype) : { name: undefined, namespace: undefined }; const resolvedFields: SimplifierDataTypeFieldUpdate[] | undefined = fields?.map(f => { const { name: dtName, namespace: dtNamespace } = splitNamespace(f.dataType); return { name: f.name, dtName: dtName, dtNameSpace: dtNamespace, optional: f.optional, description: f.description, } }) const data: SimplifierDataTypeUpdate = { name: newTypeName, nameSpace: newTypeNamespace, category: category, derivedFrom: derivedFromName, derivedFromNS: derivedFromNamespace, collDtName: collectionDtName, collDtNS: collectionDtNamespace, isStruct: category === 'struct', fields: resolvedFields || [], description: description, properties: [], editable: true, tags: tags || [], assignedProjects: projectAssignments || { projectsBefore: [], projectsAfterChange: [] }, } const trackingKey = trackingToolPrefix + toolNameDatatypeUpdate let oExisting: any; try { oExisting = await simplifier.getSingleDataType(newTypeName, newTypeNamespace, trackingKey) } catch {} if (oExisting?.id) { return simplifier.updateDataType(data); } else { return simplifier.createDataType(data); } }) });
  • Zod input schema defining parameters for 'datatype-update': qualifiedName (required), description, derivedFrom, collectionDatatype, fields (array of field objects), tags, and projectAssignments.
    { qualifiedName: z.string(), description: z.string().optional().default(""), derivedFrom: z.string().optional(), collectionDatatype: z.string().optional(), fields: z.array(z.object({ name: z.string(), optional: z.boolean(), description: z.string().optional(), dataType: z.string(), })).optional(), tags: z.array(z.string()), projectAssignments: z.object({ projectsBefore: z.array(z.string()), projectsAfterChange: z.array(z.string()), }).optional() },
  • Tool registration using McpServer.tool() for 'datatype-update', specifying name, description, input schema, hints, and inline handler function.
    const toolNameDatatypeUpdate = "datatype-update" server.tool(toolNameDatatypeUpdate, datatypeUpdateDescription, { qualifiedName: z.string(), description: z.string().optional().default(""), derivedFrom: z.string().optional(), collectionDatatype: z.string().optional(), fields: z.array(z.object({ name: z.string(), optional: z.boolean(), description: z.string().optional(), dataType: z.string(), })).optional(), tags: z.array(z.string()), projectAssignments: z.object({ projectsBefore: z.array(z.string()), projectsAfterChange: z.array(z.string()), }).optional() }, { title: "Create or update a Data Type", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true }, async ({ qualifiedName: qualifiedName, description, derivedFrom, collectionDatatype, fields, tags, projectAssignments }) => { return wrapToolResult(`create or update data type ${qualifiedName}`, async () => { const { name: newTypeName, namespace: newTypeNamespace } = splitNamespace(qualifiedName); const category = determineCategory(fields, derivedFrom, collectionDatatype) if (category === 'base') { throw new Error("creating base types is not allowed") } const { name: derivedFromName, namespace: derivedFromNamespace } = derivedFrom ? splitNamespace(derivedFrom) : { name: undefined, namespace: undefined }; const { name: collectionDtName, namespace: collectionDtNamespace } = collectionDatatype ? splitNamespace(collectionDatatype) : { name: undefined, namespace: undefined }; const resolvedFields: SimplifierDataTypeFieldUpdate[] | undefined = fields?.map(f => { const { name: dtName, namespace: dtNamespace } = splitNamespace(f.dataType); return { name: f.name, dtName: dtName, dtNameSpace: dtNamespace, optional: f.optional, description: f.description, } }) const data: SimplifierDataTypeUpdate = { name: newTypeName, nameSpace: newTypeNamespace, category: category, derivedFrom: derivedFromName, derivedFromNS: derivedFromNamespace, collDtName: collectionDtName, collDtNS: collectionDtNamespace, isStruct: category === 'struct', fields: resolvedFields || [], description: description, properties: [], editable: true, tags: tags || [], assignedProjects: projectAssignments || { projectsBefore: [], projectsAfterChange: [] }, } const trackingKey = trackingToolPrefix + toolNameDatatypeUpdate let oExisting: any; try { oExisting = await simplifier.getSingleDataType(newTypeName, newTypeNamespace, trackingKey) } catch {} if (oExisting?.id) { return simplifier.updateDataType(data); } else { return simplifier.createDataType(data); } }) });
  • Helper function determineCategory that classifies the datatype as 'struct', 'domain', 'collection', or 'base' based on the presence of fields, derivedFrom, and collectionDatatype parameters.
    const determineCategory = ( fields: any[] | undefined, derivedFrom: string | undefined, collectionDatatype: string | undefined ): SimplifierDataTypeCategory => { const nonEmpty = (x: { length: number } | undefined) => (x?.length || 0) > 0 const isStruct = nonEmpty(fields) && !derivedFrom && !collectionDatatype const isBase = !isStruct && !derivedFrom && !collectionDatatype const isDomain = !isStruct && nonEmpty(derivedFrom) && !collectionDatatype const isCollection = !isStruct && !derivedFrom && nonEmpty(collectionDatatype) if (isStruct) return 'struct'; else if (isBase) return 'base' else if (isDomain) return 'domain' else if (isCollection) return 'collection'; else throw new Error("Data type must either be a struct (have fields), a domain type (be derived from another type), a collection (with a collectionDatatype), or a base type (none of the above). Combinations are not allowed.") }
  • Helper function splitNamespace that parses a qualified name into namespace and name components, splitting on the last '/'.
    const splitNamespace = (qualifiedName: string): { namespace: string | undefined, name: string } => { const nameStart = qualifiedName.lastIndexOf('/') const namespace = nameStart > 0 ? qualifiedName.substring(0, nameStart) : undefined const name = qualifiedName.substring(nameStart + 1) return { namespace, name } }
  • Top-level registration in tools index that invokes registerServerDatatypeTools, thereby registering the 'datatype-update' tool among others.
    registerServerDatatypeTools(server, simplifier)

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/SimplifierIO/simplifier-mcp'

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