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, 25s for a synchronous endpoint, which stays under API Gateway's 29s timeout); 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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "entity_id": "<entity_id>",
      "name": "<name>",
      "trigger_point": "<trigger_point>"
    },
    "name": "create_function"
  }
}

Input 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.8/5.0
Behavior5/5

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

Annotations only say non-read-only, non-destructive, non-idempotent; the description adds what that actually means at runtime: metadata edits go live within 30s with no redeploy, whole-chain budgets (2s/5s/25s vs 29s gateway cap, 5 min async), failures in async mode only visible in CloudWatch, and same-trigger functions run lowest-first in ONE invocation. This is exactly the context annotations cannot carry.

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-loaded with the most important constraint (metadata only, nothing deployed), then the four axes, then the 30s/no-redeploy fact. Dense but consistently earning its place for a 13-parameter tool; the minor 'customer Python' typo and sheer length keep it just below top marks.

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

Completeness4/5

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

With 13 parameters, three enums, and no output schema, the description covers almost everything an agent needs: immutability of trigger_point, the entity_id vs endpoint-id fork, execution semantics, and deploy path. The only gap is that it never says what the call returns (a function id to feed into deploy_functions), which matters when there is no output schema.

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

Parameters5/5

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

Schema coverage is 92%, so baseline is 3, but the description adds semantics the schema only hints at: the four behavioural axes, why methods is irrelevant for trigger_point 'endpoint', why execution_mode is ignored for endpoint (route-level property), and why order matters (chaining, each receives prior output). It explains interactions between parameters rather than restating them.

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?

"Define a Function: custom Python that runs on an entity's request lifecycle" states a specific verb and resource, and the very next clause carves out the boundary against siblings by declaring it creates METADATA ONLY and deploys nothing. The agent can immediately tell this apart from upload_file (code) and deploy_functions (deployment) without opening any schema.

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

Usage Guidelines5/5

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

Explicitly routes the agent: code lives in the bundle uploaded separately and deployed with deploy_functions; read the aaly://platform/functions resource before the first one; use create_endpoint for custom-endpoint routes. When-to-use, prerequisites, and named alternatives are all present.

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