Skip to main content
Glama

AroFlo: Get MessageTemplates

aroflo_get_messagetemplates
Read-onlyIdempotent

Retrieve message templates from AroFlo with filtering, sorting, and pagination options to streamline communication workflows.

Instructions

Query the AroFlo MessageTemplates zone (GET). Use pipe-delimited WHERE clauses like "and|field|=|value", ORDER clauses like "field|asc", and JOIN areas like "lineitems". where/order/join accept either a single string or an array. mode: data|verbose|debug|raw (default: data). Set compact=true and optionally select=["field","nested.field"] to reduce payload size. See resource "aroflo://docs/api/" (example: "aroflo://docs/api/quotes") for valid fields/values.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
whereNo
orderNo
joinNo
pageNo
pageSizeNo
autoPaginateNo
maxPagesNo
maxResultsNo
maxItemsTotalNo
validateWhereNo
modeNo
verboseNo
debugNo
rawNo
compactNo
selectNo
maxItemsNo
extraNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for all "get_zone" tools, including "aroflo_get_messagetemplates". It dynamically generates the tool name using `zoneToToolSuffix` and the `AROFLO_ZONES` list.
    server.registerTool(
      toolName,
      {
        title: `AroFlo: Get ${zone}`,
        description:
          `Query the AroFlo ${zone} zone (GET). ` +
          `Use pipe-delimited WHERE clauses like "and|field|=|value", ORDER clauses like "field|asc", and JOIN areas like "lineitems". ` +
          `where/order/join accept either a single string or an array. ` +
          `mode: data|verbose|debug|raw (default: data). ` +
          `Set compact=true and optionally select=[\"field\",\"nested.field\"] to reduce payload size. ` +
          `See resource "aroflo://docs/api/<slug>" (example: "aroflo://docs/api/quotes") for valid fields/values.`,
        inputSchema,
        // MCP SDK expects output schemas to be object schemas (or raw object shapes).
        // `z.any()` causes output validation to crash under the current SDK.
        outputSchema: z.object({}).passthrough(),
        annotations: {
          readOnlyHint: true,
          idempotentHint: true,
          openWorldHint: true
        }
      },
      async (args) => {
        const mode = resolveOutputMode(args);
        const envelopeRequested =
          typeof args.mode === 'string' || Boolean(args.raw) || Boolean(args.verbose);
        try {
          const where = normalizeWhereParam(args.where);
          const order = normalizeOrderParam(args.order);
          const join = normalizeJoinParam(args.join);
    
          if (args.validateWhere !== false) {
            await validateWhereOrThrow({ zone, where });
          }
    
          const autoPaginate = Boolean(args.autoPaginate);
          const startPage = args.page ?? 1;
          const pageSize = args.pageSize ?? (autoPaginate ? 200 : undefined);
          const maxResultsRaw =
            typeof args.maxItemsTotal === 'number' ? args.maxItemsTotal : args.maxResults;
          const maxResults =
            typeof args.maxResults === 'number' && typeof args.maxItemsTotal === 'number'
              ? Math.min(args.maxResults, args.maxItemsTotal)
              : maxResultsRaw;
          const maxPages = args.maxPages ?? (autoPaginate ? 25 : undefined);
    
          const debugInfo: Record<string, unknown> | undefined = args.debug
            ? {
                zone,
                normalized: {
                  where,
                  order,
                  join,
                  page: startPage,
                  pageSize,
                  extra: args.extra
                }
              }
            : undefined;
    
          let response = await client.get(zone, {
            where,
            order,
            join,
            page: startPage,
            pageSize,
            extra: args.extra
          });
    
          let pagesFetched = 1;
          let truncated = false;
          let truncatedReason: string | undefined;
          let nextPage: number | undefined;
    
          if (autoPaginate) {
            let currentPage = startPage;
            let lastPageCount = extractZoneItems(zone, response.data).items.length;
            while (true) {
              const total = extractZoneItems(zone, response.data).items.length;
    
              if (typeof maxResults === 'number' && total >= maxResults) {
                truncated = true;
                truncatedReason = 'maxResults';
                nextPage = currentPage + 1;
                break;
              }
    
              if (typeof maxPages === 'number' && pagesFetched >= maxPages) {
                truncated = true;
                truncatedReason = 'maxPages';
                nextPage = currentPage + 1;
                break;
              }
    
              if (typeof pageSize === 'number' && lastPageCount < pageSize) {
                break;
              }
    
              currentPage += 1;
              const next = await client.get(zone, {
                where,
                order,
                join,
                page: currentPage,
                pageSize,
                extra: args.extra
              });
    
              // If the next page contributes nothing, stop.
              const nextCount = extractZoneItems(zone, next.data).items.length;
              if (nextCount === 0) {
                break;
              }
    
              response = {
                ...response,
                data: mergeZoneResponseData(response.data, next.data).merged
              };
              pagesFetched += 1;
              lastPageCount = nextCount;
    
              // Stop if the last page was short.
              if (typeof pageSize === 'number' && nextCount < pageSize) {
                break;
              }
            }
          }
    
          if (typeof maxResults === 'number') {
            const total = extractZoneItems(zone, response.data).items.length;
            if (total > maxResults) {
              const { truncated: newData } = truncateZoneArrays(response.data, maxResults);
              response = { ...response, data: newData };
              truncated = true;
              truncatedReason = truncatedReason ?? 'maxResults';
            }
          }
    
          let compactApplied = false;
          let effectiveResponse = response;
          const defaultSelect =
            zone === 'Tasks' && args.compact && (!args.select || args.select.length === 0)
              ? [
                  'taskid',
                  'jobnumber',
                  'status',
                  'taskname',
                  'daterequested',
                  'createdutc',
                  'clientid',
                  'org.orgid',
                  'org.orgname',
                  'projectid',
                  'stageid',
                  'project.projectid',
                  'project.projectname',
                  'tasktotals.totalhrs'
                ]
              : undefined;
          const select = args.select ?? defaultSelect;
    
          if (args.compact || (select && select.length > 0) || args.maxItems) {
            compactApplied = true;
            const compactedData = compactZoneResponseData(response.data, {
              select,
              maxItems: args.maxItems
            });
            effectiveResponse = { ...response, data: compactedData };
          }
    
          // Backward compatible default: return the full AroFlo client response, optionally
          // annotated with pagination/debug metadata. The new minimal envelope is opt-in via
          // args.mode / args.verbose / args.raw.
          if (!envelopeRequested) {
            let finalData: unknown = effectiveResponse.data;
            if (autoPaginate || truncated) {
              finalData = withZoneResponseMeta(finalData, {
                pagesFetched,
                truncated,
                truncatedReason,
                nextPage
              });
            }
            if (debugInfo) {
              finalData = withDebug(finalData, debugInfo);
            }
            return successToolResult({ ...effectiveResponse, data: finalData });
          }
    
          const out = buildZoneDataEnvelope({
            zone,
            response: effectiveResponse,
            page: startPage,
            pageSize,
            mode,
            mcp:
              autoPaginate || truncated
                ? {
                    autoPaginate,
                    pagesFetched,
                    truncated,
                    truncatedReason,
                    nextPage
                  }
                : undefined,
            debug: debugInfo,
            compactApplied,
            select,
            maxItems: args.maxItems
          });
    
          return successToolResult(out);
        } catch (error) {
          return errorToolResult(error, { mode, debug: { zone } });
        }
      }
    );
  • The function that registers all zone retrieval tools. It iterates over `AROFLO_ZONES`, builds the tool name `aroflo_get_${zone}`, and registers it with the MCP server.
    export function registerZoneGetTools(server: McpServer, client: AroFloClient): void {
      for (const zone of AROFLO_ZONES) {
        // We already expose a dedicated tool with a richer schema for lastupdate.
        if (zone === 'LastUpdate') {
          continue;
        }
    
        const toolName = `aroflo_get_${zoneToToolSuffix(zone)}`;
        server.registerTool(
          toolName,
          {
            title: `AroFlo: Get ${zone}`,
            description:
              `Query the AroFlo ${zone} zone (GET). ` +
              `Use pipe-delimited WHERE clauses like "and|field|=|value", ORDER clauses like "field|asc", and JOIN areas like "lineitems". ` +
              `where/order/join accept either a single string or an array. ` +
              `mode: data|verbose|debug|raw (default: data). ` +
              `Set compact=true and optionally select=[\"field\",\"nested.field\"] to reduce payload size. ` +
              `See resource "aroflo://docs/api/<slug>" (example: "aroflo://docs/api/quotes") for valid fields/values.`,
            inputSchema,
            // MCP SDK expects output schemas to be object schemas (or raw object shapes).
            // `z.any()` causes output validation to crash under the current SDK.
            outputSchema: z.object({}).passthrough(),
            annotations: {
              readOnlyHint: true,
              idempotentHint: true,
              openWorldHint: true
            }
          },
          async (args) => {
            const mode = resolveOutputMode(args);
            const envelopeRequested =
              typeof args.mode === 'string' || Boolean(args.raw) || Boolean(args.verbose);
            try {
              const where = normalizeWhereParam(args.where);
              const order = normalizeOrderParam(args.order);
              const join = normalizeJoinParam(args.join);
    
              if (args.validateWhere !== false) {
                await validateWhereOrThrow({ zone, where });
              }
    
              const autoPaginate = Boolean(args.autoPaginate);
              const startPage = args.page ?? 1;
              const pageSize = args.pageSize ?? (autoPaginate ? 200 : undefined);
              const maxResultsRaw =
                typeof args.maxItemsTotal === 'number' ? args.maxItemsTotal : args.maxResults;
              const maxResults =
                typeof args.maxResults === 'number' && typeof args.maxItemsTotal === 'number'
                  ? Math.min(args.maxResults, args.maxItemsTotal)
                  : maxResultsRaw;
              const maxPages = args.maxPages ?? (autoPaginate ? 25 : undefined);
    
              const debugInfo: Record<string, unknown> | undefined = args.debug
                ? {
                    zone,
                    normalized: {
                      where,
                      order,
                      join,
                      page: startPage,
                      pageSize,
                      extra: args.extra
                    }
                  }
                : undefined;
    
              let response = await client.get(zone, {
                where,
                order,
                join,
                page: startPage,
                pageSize,
                extra: args.extra
              });
    
              let pagesFetched = 1;
              let truncated = false;
              let truncatedReason: string | undefined;
              let nextPage: number | undefined;
    
              if (autoPaginate) {
                let currentPage = startPage;
                let lastPageCount = extractZoneItems(zone, response.data).items.length;
                while (true) {
                  const total = extractZoneItems(zone, response.data).items.length;
    
                  if (typeof maxResults === 'number' && total >= maxResults) {
                    truncated = true;
                    truncatedReason = 'maxResults';
                    nextPage = currentPage + 1;
                    break;
                  }
    
                  if (typeof maxPages === 'number' && pagesFetched >= maxPages) {
                    truncated = true;
                    truncatedReason = 'maxPages';
                    nextPage = currentPage + 1;
                    break;
                  }
    
                  if (typeof pageSize === 'number' && lastPageCount < pageSize) {
                    break;
                  }
    
                  currentPage += 1;
                  const next = await client.get(zone, {
                    where,
                    order,
                    join,
                    page: currentPage,
                    pageSize,
                    extra: args.extra
                  });
    
                  // If the next page contributes nothing, stop.
                  const nextCount = extractZoneItems(zone, next.data).items.length;
                  if (nextCount === 0) {
                    break;
                  }
    
                  response = {
                    ...response,
                    data: mergeZoneResponseData(response.data, next.data).merged
                  };
                  pagesFetched += 1;
                  lastPageCount = nextCount;
    
                  // Stop if the last page was short.
                  if (typeof pageSize === 'number' && nextCount < pageSize) {
                    break;
                  }
                }
              }
    
              if (typeof maxResults === 'number') {
                const total = extractZoneItems(zone, response.data).items.length;
                if (total > maxResults) {
                  const { truncated: newData } = truncateZoneArrays(response.data, maxResults);
                  response = { ...response, data: newData };
                  truncated = true;
                  truncatedReason = truncatedReason ?? 'maxResults';
                }
              }
    
              let compactApplied = false;
              let effectiveResponse = response;
              const defaultSelect =
                zone === 'Tasks' && args.compact && (!args.select || args.select.length === 0)
                  ? [
                      'taskid',
                      'jobnumber',
                      'status',
                      'taskname',
                      'daterequested',
                      'createdutc',
                      'clientid',
                      'org.orgid',
                      'org.orgname',
                      'projectid',
                      'stageid',
                      'project.projectid',
                      'project.projectname',
                      'tasktotals.totalhrs'
                    ]
                  : undefined;
              const select = args.select ?? defaultSelect;
    
              if (args.compact || (select && select.length > 0) || args.maxItems) {
                compactApplied = true;
                const compactedData = compactZoneResponseData(response.data, {
                  select,
                  maxItems: args.maxItems
                });
                effectiveResponse = { ...response, data: compactedData };
              }
    
              // Backward compatible default: return the full AroFlo client response, optionally
              // annotated with pagination/debug metadata. The new minimal envelope is opt-in via
              // args.mode / args.verbose / args.raw.
              if (!envelopeRequested) {
                let finalData: unknown = effectiveResponse.data;
                if (autoPaginate || truncated) {
                  finalData = withZoneResponseMeta(finalData, {
                    pagesFetched,
                    truncated,
                    truncatedReason,
                    nextPage
                  });
                }
                if (debugInfo) {
                  finalData = withDebug(finalData, debugInfo);
                }
                return successToolResult({ ...effectiveResponse, data: finalData });
              }
    
              const out = buildZoneDataEnvelope({
                zone,
                response: effectiveResponse,
                page: startPage,
                pageSize,
                mode,
                mcp:
                  autoPaginate || truncated
                    ? {
                        autoPaginate,
                        pagesFetched,
                        truncated,
                        truncatedReason,
                        nextPage
                      }
                    : undefined,
                debug: debugInfo,
                compactApplied,
                select,
                maxItems: args.maxItems
              });
    
              return successToolResult(out);
            } catch (error) {
              return errorToolResult(error, { mode, debug: { zone } });
            }
          }
        );
      }
    }
Behavior4/5

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

The description confirms the GET/read-only nature which aligns with annotations (readOnlyHint: true, idempotentHint: true). It adds valuable behavioral context not in annotations: pipe-delimited syntax requirements, mode options with defaults, and payload optimization strategies. It does not disclose pagination behavior or rate limiting details.

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

Conciseness5/5

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

The description is efficiently structured in 6 information-dense sentences with zero filler. Critical information (verb, resource, syntax examples, defaults, documentation reference) is front-loaded and immediately actionable.

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?

Given the high complexity (18 parameters, nested objects, custom query syntax) and presence of an output schema, the description adequately covers the primary querying functionality and syntax. However, it lacks explanation of pagination controls (autoPaginate, maxPages) and utility flags (validateWhere, debug) necessary for full operational context.

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

Parameters3/5

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

With 0% schema description coverage across 18 parameters, the description partially compensates by explaining the complex query syntax for where/order/join, mode options, and select/compact usage. However, it leaves 12 parameters unexplained (page, pageSize, autoPaginate, maxPages, maxResults, validateWhere, verbose, debug, raw, maxItems, extra), creating significant gaps given the schema provides no descriptions.

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?

The description explicitly states 'Query the AroFlo MessageTemplates zone (GET)', providing a specific verb (Query), resource (MessageTemplates), and HTTP method. The zone-specific naming clearly distinguishes it from 40+ sibling tools like aroflo_get_quotes or aroflo_query_zone.

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?

The description provides detailed syntax examples for WHERE, ORDER, and JOIN clauses, explains payload reduction via compact/select, and references external documentation for valid fields. However, it does not explicitly contrast when to use this specific zone getter versus the generic aroflo_query_zone or single-record retrieval tools.

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

Install Server

Other Tools

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/0x1NotMe/aroflo-mcp'

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