# Scripting

Tenant Lua scripts, custom actions and script validation.

## Operations

```graphql
# Scripting (scripting)
# Tenant Lua scripts, custom actions and script validation.
# Query
analyzeMCPToolSource: MCPToolAnalysis!  # Infer and decorate a tool contract without saving or running it
compileSchemaXML: String!  # Compile standalone XML schema syntax into JSON Schema without persisting it; host restrictions apply when embedded
generateDefaultDataQuery: String  # Generate a default GraphQL data query for an event topic
getCustomWorkflowAction: CustomWorkflowActionState  # Fetch a single custom action by id within the caller's tenant
getLuaSample: LuaSample  # Fetch one Lua sample with its runnable source
getMagicQueryGraphQL: MagicQueryOperation!  # Resolves a Magic Query string to the real GraphQL operation and variables it runs, so consumers can graduate from the façade to raw GraphQL
getMagicQuerySchema: MagicQuerySchema!  # Returns the input JSON Schema and output introspection for a Magic Query noun, so consumers (especially LLMs) can learn its contract before calling magicQuery
getScript: ScriptState  # Fetch a script by ID
getScriptByName: ScriptState  # Fetch a script by name
getScriptVersion: ScriptVersionState  # Fetch one version of a script
getTemplate: TemplateState  # Fetch a template by ID
getTemplateByHandle: TemplateState  # Fetch a template by handle
getTemplateVersion: TemplateVersionState  # Fetch one template version by ID
helpChapter: HelpChapter  # Read a chapter of the current published manual edition
helpChapters: [HelpChapterInfo!]!  # List human-facing manual chapters from the running deployment
iacGuides: [IaCGuide!]!  # Every authoring guide, for a tool that syncs them to a folder
iacSchema: IaCSchemaDocument!  # The infrastructure-only view of this schema, for declarative tooling
iacSchemaDocument: IaCSchemaDocumentPayload!  # Fetch the JSON Schema document a SCHEMA-kind validator references, for declarative tooling
iacValidate: IaCValidationResult!  # Validate an infrastructure artifact
listAvailableActions: AvailableActionConnection!  # The tenant's unified action catalog: every active custom action plus every action declared by an active integration instance, ordered by label and keyset-paginated
listCustomWorkflowActions: CustomWorkflowActionConnection!  # List the caller's tenant's custom actions, filtered and sorted
listDataChangeEventTopics: [DataChangeEventGroup!]!  # List all valid data change event topics, grouped by resource
listLuaSamples: [LuaSampleSummary!]!  # List the platform's Lua sample scripts
listMagicQueries: [MagicQueryInfo!]!  # Lists every available Magic Query noun with a short description and its options — the discovery entry point
listScriptVersions: ScriptVersionConnection!  # A script's history, newest first
listScripts: ScriptConnection!  # List scripts with pagination and filtering
listTemplateVersions: TemplateVersionConnection!  # List versions of a template with pagination
listTemplates: TemplateConnection!  # List templates with pagination and filtering
luaApiSurface: [LuaApiEntry!]!  # Structured ctx
luaTypeDefinitions: String!  # Type definitions for a scripting role, rendered from the surface the validator checks against
magicQuery: JSON!  # Executes a Magic Query string and returns the predefined query's JSON result
mcpTool: MCPTool  # Read the authoring definition and assignments
mcpToolVersions: [MCPToolVersion!]!  # Read immutable publication history
mcpTools: [MCPTool!]!  # List tenant tools for administration; not the end-user catalog
ping: String!  # Health check endpoint
renderSchemaXML: String!  # Render JSON Schema as native XML without dropping unsupported keywords or changing a saved document
schemaAuthoringCatalog: JSON!  # Compiler-owned vocabulary for the standalone XML JSON Schema dialect, including native form annotations
searchHelp: HelpSearchResult!  # Search human-facing manuals using shared semantic and text retrieval
# Mutation
createCustomWorkflowAction: UpsertCustomWorkflowActionPayload!  # Create a new custom action
createMCPTool: MCPToolPayload!  # Create a tool definition
createScript: UpsertScriptPayload!  # Create a new script
createTemplate: UpsertTemplatePayload!  # Create a new template
deleteCustomWorkflowAction: DeletePayload!  # Permanently delete a custom action from the caller's tenant
deleteMCPTool: DeletePayload!  # Delete a tool and its versions and assignments
deleteScript: DeletePayload!  # Delete a script
deleteTemplate: DeleteTemplatePayload!  # Delete a template and all its versions
deleteTemplateVersion: DeletePayload!  # Delete one version from a template's history
executeLuaScript: ExecuteScriptPayload!  # Execute a Lua script in the playground sandbox
publishMCPTool: MCPToolPayload!  # Analyze and publish the current draft atomically
publishTemplateVersion: PublishTemplateVersionPayload!  # Publish current template content as a new version
renderTemplate: RenderTemplatePayload!  # Render a template with context data
restoreScriptVersion: RestoreScriptVersionPayload!  # Put an old version's source back on the script
restoreTemplateVersion: UpsertTemplatePayload!  # Restore template content from a previous version
testMCPTool: String!  # Run the current draft as the authenticated developer; also requires mcpTool:read
updateCustomWorkflowAction: UpsertCustomWorkflowActionPayload!  # Update a custom action
updateMCPTool: MCPToolPayload!  # Update a tool definition
updateScript: UpsertScriptPayload!  # Update a script
updateTemplate: UpsertTemplatePayload!  # Update a template
upsertCustomWorkflowAction: UpsertCustomWorkflowActionPayload!  # Create a custom action, or overwrite an existing one when input
upsertMCPTool: MCPToolPayload!  # Upsert a tool definition
upsertScript: UpsertScriptPayload!  # Create or update a script
upsertTemplate: UpsertTemplatePayload!  # Create or update a template
validateLua: ValidateLuaResult!  # Type-check Lua source against the ambient typedef for the chosen role without persisting anything
validateLuaScript: ValidateScriptPayload!  # Validate a Lua script for syntax errors
validateTemplate: ValidateTemplatePayload!  # Validate template syntax without saving
# Subscription
dataChangeEvents: DataChangeEvent!  # Subscribe to real-time data change events

# Call describe_operation(name) for arguments and input types.
```

## Exact schema

Download [complete SDL](/schemas/scripting.graphql) (110044 bytes). Use the SDL to validate operations; the digest omits argument signatures.

## Guides
- [Where scripts run](/docs/scripting/where-scripts-run)
- [What is a workflow](/docs/workflows/introduction)
- [Calling CoCoCo](/docs/scripting/calling-cococo)
- [Pure scripts](/docs/scripting/pure-scripts)
- [Values and expressions](/docs/workflows/values)
- [Workflows, webhooks and apps](/docs/scripting/workflows-and-apps)
- [Connections and branches](/docs/workflows/branches)
- [Lua scripts and data access](/docs/workflows/scripts)
- [Troubleshooting and safe operation](/docs/workflows/diagnostics)
- [The ctx reference](/docs/scripting/ctx-reference)
- [The SwiftLua Language Guide](/docs/scripting/language)
- [Workflow node config reference](/docs/workflows/node-reference)
- [Getting started with SwiftLua](/docs/scripting/getting-started)
- [Getting started](/docs/workflows/getting-started)