Skip to main content
Glama

Cirra AI Salesforce Admin MCP Server

tooling_api_query

Read-onlyIdempotent

Run a SOQL query against the Salesforce Tooling API to retrieve metadata objects like Apex classes, triggers, custom fields, and field definitions. To read Apex debug log text, query ApexLog and include Body in fields.

Input Schema

NameRequiredDescriptionDefault
limitNoThe maximum number of records to return. The default is 200. Note: LIMIT is automatically omitted for aggregate queries without GROUP BY.
fieldsYesList of fields to retrieve. May include relationship fields and aggregates. For ApexLog, include Body to retrieve the raw debug log text (Body is a blob and is fetched after the query; at most 5 logs with Body per call).
formatNoWhen the query selects the Metadata field, or the queried Tooling sObject is metadata-backed (CustomField, CustomObject, ApexClass, Flow, Layout, PermissionSet, …), `xml` / `source` attach Metadata API retrieve files per record as `metadataXml` or `sourceFiles`. The Tooling `Metadata` JSON is left unchanged. `json` (default) is current behavior. Same retrieve path as `metadata_read` — not a conversion of the Tooling JSON.json
groupByNoGROUP BY clause for aggregate queries. Required when using aggregate functions with grouping, optional otherwise
orderByNo(optional) ORDER BY clause
sObjectYesThe name of the Tooling API object to query
sf_userNo(optional) Salesforce username to identify the connection to use. Omit this to use the current default connection.
pageSizeNo(optional) Maximum number of records to return per page when the response requires pagination, including the first page. If omitted, the first page is a short preview and later pages use an automatically calculated size.
whereClauseYesWHERE clause. May include conditions on related objects
cirra_ai_teamNo(optional) Cirra team ID or name that owns the Salesforce connection to use for this call. Must be provided together with 'sf_user'. Use it to run against a specific team's connection without changing your default team — e.g. to keep separate chats on Salesforce orgs in different teams. Omit it when this call carries the context_handle from cirra_ai_init, which names the team for the conversation. A user with more than one place to work (several teams, or a team and a personal account) must pass either the context_handle or 'cirra_ai_team' + 'sf_user'.
context_handleNo(recommended) The conversation context handle returned by cirra_ai_init in this conversation. Pass the exact context_handle value from the most recent cirra_ai_init result so this call runs against the team and Salesforce connection selected for this conversation. A user with more than one place to work (several Cirra AI teams, or a team and a personal account) must pass either this handle or 'cirra_ai_team' + 'sf_user'; a call with neither is refused.

Output Schema

NameRequiredDescriptionDefault
formatNo
messageYes
recordsNo
resultsNo
successYes
warningNo
errorCodeNo
apiVersionNoAPI version used for the retrieve. Match this to sourceApiVersion in sfdx-project.json.
componentsNoPresent when format is xml or source. Retrieved files grouped by Metadata API type and fullName.
errorCountNo
resultCountNo
artifactTypeNo
requestCountNo
skippedCountNo
successCountNo
artifactCategoryNo
packageDirectoryNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changed
    • addedInput schema / additionalProperties
      Added value: +false
    • changedInput schema / properties / cirra_ai_team / description
      Previous value: -"(optional) Cirra team ID or name that owns the Salesforce connection to use for this call. Must be provided together with 'sf_user'. Use it to run against a specific team's connection without changing your default team — e.g. to keep separate chats on Salesforce orgs in different teams. Omit to use your current/default team."New value: +"(optional) Cirra team ID or name that owns the Salesforce connection to use for this call. Must be provided together with 'sf_user'. Use it to run against a specific team's connection without changing your default team — e.g. to keep separate chats on Salesforce orgs in different teams. Omit it when this call carries the context_handle from cirra_ai_init, which names the team for the conversation. A user with more than one place to work (several teams, or a team and a personal account) must pass either the context_handle or 'cirra_ai_team' + 'sf_user'."
    • addedInput schema / properties / context_handle
      Added value: +{
      +  "description": "(recommended) The conversation context handle returned by cirra_ai_init in this conversation. Pass the exact context_handle value from the most recent cirra_ai_init result so this call runs against the team and Salesforce connection selected for this conversation. A user with more than one place to work (several Cirra AI teams, or a team and a personal account) must pass either this handle or 'cirra_ai_team' + 'sf_user'; a call with neither is refused.",
      +  "type": "string"
      +}
    • changedInput schema / properties / fields / description
      Previous value: -"List of fields to retrieve. May include relationship fields and aggregates"New value: +"List of fields to retrieve. May include relationship fields and aggregates. For ApexLog, include Body to retrieve the raw debug log text (Body is a blob and is fetched after the query; at most 5 logs with Body per call)."
    • addedInput schema / properties / format
      Added value: +{
      +  "default": "json",
      +  "description": "When the query selects the Metadata field, or the queried Tooling sObject is metadata-backed (CustomField, CustomObject, ApexClass, Flow, Layout, PermissionSet, …), `xml` / `source` attach Metadata API retrieve files per record as `metadataXml` or `sourceFiles`. The Tooling `Metadata` JSON is left unchanged. `json` (default) is current behavior. Same retrieve path as `metadata_read` — not a conversion of the Tooling JSON.",
      +  "enum": [
      +    "json",
      +    "xml",
      +    "source"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / pageSize / description
      Previous value: -"(optional) Maximum number of records to return per page when the response requires pagination. If omitted, page size is calculated automatically."New value: +"(optional) Maximum number of records to return per page when the response requires pagination, including the first page. If omitted, the first page is a short preview and later pages use an automatically calculated size."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": true,
      +  "properties": {
      +    "apiVersion": {
      +      "description": "API version used for the retrieve. Match this to sourceApiVersion in sfdx-project.json.",
      +      "type": "string"
      +    },
      +    "artifactCategory": {
      +      "type": "string"
      +    },
      +    "artifactType": {
      +      "type": "string"
      +    },
      +    "components": {
      +      "description": "Present when format is xml or source. Retrieved files grouped by Metadata API type and fullName.",
      +      "items": {
      +        "additionalProperties": true,
      +        "properties": {},
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "errorCode": {
      +      "type": "string"
      +    },
      +    "errorCount": {
      +      "type": "number"
      +    },
      +    "format": {
      +      "enum": [
      +        "json",
      +        "xml",
      +        "source"
      +      ],
      +      "type": "string"
      +    },
      +    "message": {
      +      "type": "string"
      +    },
      +    "packageDirectory": {
      +      "type": "string"
      +    },
      +    "records": {
      +      "items": {
      +        "additionalProperties": true,
      +        "properties": {},
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "requestCount": {
      +      "type": "number"
      +    },
      +    "resultCount": {
      +      "type": "number"
      +    },
      +    "results": {
      +      "items": {
      +        "additionalProperties": true,
      +        "properties": {},
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "skippedCount": {
      +      "type": "number"
      +    },
      +    "success": {
      +      "type": "boolean"
      +    },
      +    "successCount": {
      +      "type": "number"
      +    },
      +    "warning": {
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "success",
      +    "message"
      +  ],
      +  "type": "object"
      +}
  2. Changed1 schema field changed
    • addedInput schema / properties / cirra_ai_team
      Added value: +{
      +  "description": "(optional) Cirra team ID or name that owns the Salesforce connection to use for this call. Must be provided together with 'sf_user'. Use it to run against a specific team's connection without changing your default team — e.g. to keep separate chats on Salesforce orgs in different teams. Omit to use your current/default team.",
      +  "type": "string"
      +}
  3. Added
  4. Removed
  5. Changed1 schema field changed
    • addedInput schema / properties / pageSize
      Added value: +{
      +  "description": "(optional) Maximum number of records to return per page when the response requires pagination. If omitted, page size is calculated automatically.",
      +  "maximum": 9007199254740991,
      +  "minimum": -9007199254740991,
      +  "type": "integer"
      +}
  6. Changed2 schema fields changed
    • changedInput schema / properties / limit / default
      Previous value: -100New value: +200
    • changedInput schema / properties / limit / description
      Previous value: -"The maximum number of records to return. The default is 100. Note: LIMIT is automatically omitted for aggregate queries without GROUP BY."New value: +"The maximum number of records to return. The default is 200. Note: LIMIT is automatically omitted for aggregate queries without GROUP BY."
  7. Added
  8. Removed
  9. Changed3 schema fields changed
    • changedInput schema / properties / groupBy / description
      Previous value: -"GROUP BY clause for aggregate queries. Required when using aggregate functions with grouping. Example: 'NamespacePrefix' or 'NamespacePrefix, TableEnumOrId'"New value: +"GROUP BY clause for aggregate queries. Required when using aggregate functions with grouping, optional otherwise"
    • changedInput schema / properties / orderBy / description
      Previous value: -"ORDER BY clause"New value: +"(optional) ORDER BY clause"
    • changedInput schema / required
      Previous value: -[
      -  "sObject",
      -  "fields",
      -  "whereClause",
      -  "orderBy",
      -  "groupBy"
      -]New value: +[
      +  "sObject",
      +  "fields",
      +  "whereClause"
      +]
  10. First observed

TDQS

A3.7/5.0
Behavior4/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), so the bar is lower; the description still adds real operational detail beyond them, notably that Body is a blob fetched after the query and capped at 5 logs with Body per call, plus what format=xml/source attaches. It omits the pagination behavior implied by pageSize/fetch_more.

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?

Two tight sentences, zero filler, with the primary capability front-loaded and the ApexLog special case as a secondary note. Nothing could be removed without losing information.

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

Completeness3/5

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

The presence of an output schema removes the need to explain return values, and the schema covers the connection-selection parameters. But for an 11-parameter tool with paging (pageSize, limit) and a sibling fetch_more, the description says nothing about how continuation works or how this relates to the non-Tooling query tools — a meaningful gap for an agent choosing among 45 siblings.

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?

Schema description coverage is 100%, so the schema already documents all 11 parameters; baseline is 3. The description duplicates the ApexLog/Body guidance that the fields parameter schema already states, and adds no syntax or format detail for whereClause, orderBy, or the context_handle requirement.

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

Purpose4/5

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

States a specific verb and resource: run a SOQL query against the Salesforce Tooling API, naming concrete targets (Apex classes, triggers, custom fields). The 'Tooling API' scoping implicitly separates it from soql_query/bulk_query, but the description never names those siblings, so the differentiation is left to inference.

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

Usage Guidelines3/5

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

Provides one concrete usage trigger ('To read Apex debug log text, query ApexLog and include Body in fields'), which is genuinely actionable. However, there is no explicit guidance on when to use this versus soql_query (data records) or tooling_api_search, and no mention of pagination/fetch_more for multi-page results.

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