Skip to main content
Glama

create_function

Define a Function: customer Python that runs on an entity's request lifecycle. This creates METADATA ONLY and deploys nothing — the code comes from the project's bundle, uploaded separately and deployed with deploy_functions.

Read the aaly://platform/functions resource before your first one: it has the payload contract, the repo layout handler paths point into, and runnable examples.

Four axes decide behaviour. trigger_point: before-request can rewrite the payload or reject the request outright; after-request sees the response; endpoint IS the response for a custom-endpoint route (see create_endpoint) rather than wrapping a CRUD operation at all. execution_mode: synchronous blocks the request and shares the trigger's whole-chain budget (2s before, 5s after, 30s for a synchronous endpoint — note this EXCEEDS API Gateway's ~29s hard timeout, so keep endpoint Functions comfortably under 29s in practice); asynchronous is fire-and-forget (5 min budget) with failures visible only in CloudWatch. methods: which HTTP verbs trigger it — irrelevant for trigger_point 'endpoint', where the method lives once on the endpoint record itself. order: Functions on the same trigger run lowest-first in ONE invocation, each receiving the previous one's output.

Metadata edits take effect within 30s with no redeploy — only changing the code bundle requires deploy_functions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesLowercase identifier, unique within the project, e.g. 'validate_order'. Immutable once created.
labelNo
orderNoExecution order within the trigger point, lowest first. Default 100, which leaves room to insert ahead of an existing Function.
enabledNoDefaults to true. Disabling takes effect within 30s with no redeploy.
handlerNoDotted path into the code bundle, e.g. 'orders.before.validate'. Defaults to '{name}.handler'.
methodsNoHTTP methods that trigger this Function. Defaults to all four. Ignored for trigger_point 'endpoint' — the method lives once on the endpoint record.
entity_idYesWhat this Function attaches to: an entity record ID (e.g. 'ENT7') for trigger_point before-request/after-request, or a custom endpoint's id (e.g. 'EPT3', from create_endpoint) for trigger_point 'endpoint'. Must resolve to the right kind for the declared trigger_point, and must belong to the same project.
project_idNoProject record ID (e.g. 'PRJ3'). Optional if whoami returned a default_project_id.
timeout_msNoPer-Function ceiling, capped by the trigger's whole-chain budget.
descriptionNoWhat this Function does — surfaced to agents reading the project's capabilities.
trigger_pointYesImmutable — the payload contract differs entirely between them. 'endpoint' requires entity_id to be a custom endpoint's id, not a real entity's.
error_handlingNofail aborts the chain and rejects the request; log/ignore continue. Forced to fail for synchronous before-request Functions, which exist to be gates.
execution_modeNoDefaults to synchronous. Ignored for trigger_point 'endpoint' — set execution_mode on the endpoint itself (create_endpoint/update_endpoint) instead, since a route's sync/async behaviour is one property of the whole route, not of any one attached Function.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Adds substantial context beyond the annotations: metadata-only with no deploy, 30s propagation for edits, whole-chain budgets (2s/5s/30s, note exceeding API Gateway's ~29s), 5-min async budget with failures only in CloudWatch, and lowest-first chaining semantics. This is far richer than the flat readOnly/destructive/idempotent hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the critical metadata-only distinction and structures the rest by theme (resource pointer, four axes, timing). It is long, but nearly every sentence conveys non-obvious behavior; only the budget aside is somewhat dense, not wasteful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 13-parameter, schema-rich tool with no output schema, the description covers behavior, timing, budgets, chaining, cross-tool dependencies (deploy_functions, create_endpoint), and the resource to consult. Nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 92%, so the baseline is 3, but the description adds semantic meaning the schema does not: methods is irrelevant for trigger_point 'endpoint', execution_mode is ignored there too and lives on the endpoint, and order controls same-trigger chaining where each Function receives the prior output. These resolve real ambiguity between interdependent parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Define a Function: customer Python that runs on an entity's request lifecycle') and immediately scopes it as metadata-only, explicitly naming deploy_functions as the thing that does not happen here. An agent can tell it apart from create_endpoint, deploy_functions, and update_function without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives strong context: read the aaly://platform/functions resource before the first one, and points to create_endpoint for the endpoint trigger_point. It explains the four decision axes and the timing of metadata vs deploy effects, but stops short of an explicit 'use this instead of X when Y' statement against update_function or the code-deploy sibling.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources