Skip to main content

How AI agents discover and call your APIs — a technical walkthrough with Zerq

From MCP initialize to tools/call: sessions, headers, Gateway MCP tools, and how requests hit the same gateway path as REST. For engineers wiring assistants and coding agents.

  • mcp
  • ai
  • api-management
  • engineering
Zerq team

This post is for engineers who need to understand the request path end-to-end: how an MCP client establishes a session, lists tools, and executes a real HTTP operation through Zerq without a parallel integration stack. It mirrors how Gateway MCP is documented in Zerq’s product documentation—conceptual detail here; exact URL paths and environment variables follow your deployment and docs version.

If you are new to MCP itself, read What is the Model Context Protocol (MCP) and why should every API team care? first.

Mental model: Gateway MCP vs Management MCP

Zerq exposes two MCP surfaces:

SurfaceTypical callerPurpose
Gateway MCPAI agents, IDEs, assistants calling published APIstools/list → discover endpoints; tools/callexecute through the gateway
Management MCPOperators, CI, Zerq Copilot changing platform configCollections, proxies, workflows—same RBAC as the admin UI

This walkthrough focuses on Gateway MCP—the path API consumers use. For operations, see Platform automation.

Transport and session

Gateway MCP speaks JSON-RPC over HTTP to the gateway MCP endpoint (commonly under the same host as your API traffic, e.g. a path like /mcpconfirm in your environment). A typical flow:

  1. initialize — Client and server agree on protocol version and capabilities.
  2. Session — The server returns an Mcp-Session-Id (or equivalent) that clients must send on subsequent requests.
  3. tools/list — Returns available tools for the authenticated context.
  4. tools/call — Invokes a named tool with arguments (e.g. execute a specific published endpoint with params).

Some deployments also support SSE (GET) streams for long-lived sessions—check your ops docs for what is enabled in your build.

Headers: the same gateway context as REST

Gateway MCP requests are not exempt from identity. Clients send the same context you use for ordinary gateway calls—commonly including:

  • X-Client-ID — Which API client (application / partner identity) is acting.
  • X-Profile-ID — Which access profile (e.g. sandbox vs production) applies.
  • Authorization — The profile’s gateway credential (e.g. Bearer token), aligned with the Developer Portal testing console.

That alignment matters: a tool call should not use a different secret than what the partner would use in production integrations—otherwise you are testing fiction.

The four Gateway MCP tools (conceptual)

Zerq’s Gateway MCP surface exposes tools that map directly to discovering and running published work:

ToolRole
list_collectionsCollections the caller may see, with signals like published endpoint counts
list_endpointsFlat list of published proxiespaths, methods, identifiers for later calls
endpoint_detailsSchemas, examples, params—what agents need to construct valid requests
execute_endpointRuns a real gateway requestsubject to rate limits, logging, and policy; errors surface as tool results

Nothing here replaces your upstream validation; the gateway still terminates TLS, applies authZ, and records telemetry as usual.

End-to-end sequence (simplified)

  1. Client initialize → receives session id.
  2. tools/list → client learns list_collections, execute_endpoint, etc.
  3. Agent reasoning (or user prompt) selects an operation and builds arguments from endpoint_details.
  4. tools/call with execute_endpointgateway routes to upstream like any other allowed request.
  5. Logs and metrics record the call in the same pipelines as REST—see Observability.

For Management MCP, tool names and scopes differ—they mutate configuration and require operator identity (OIDC / service accounts per your setup).

Operational tips

  • Treat session ids like short-lived contextretry initialize on 401/400 from stale sessions.
  • Do not embed long-lived secrets in prompts; use server-side credential wallets where your client architecture allows it.
  • Load-test agents like any automationtool loops can amplify QPS; see Rate limits that protect upstreams without punishing partners.

Where to go next


Summary: Discovery (tools/list) and execution (tools/call) over MCP map cleanly to published API operations when the gateway owns auth and policy. Zerq implements that path so agents do not need a second integration model.

Request an enterprise demo for a guided walkthrough on your environment.