> ## Documentation Index
> Fetch the complete documentation index at: https://glasser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Power your product's Agent

Connect through MCP, the CLI, or your own tools. Your Agent chooses the data;
Glasser retrieves it.

## Choose an integration method

<Tabs>
  <Tab title="MCP">
    For Agent frameworks that support remote MCP.

    <div className="integration-map" role="img" aria-label="In your product, the Agent uses an MCP client to call Glasser's MCP tools.">
      <div className="integration-map-product">
        <span className="integration-map-label">Your product</span>

        <div className="integration-map-row">
          <span className="integration-map-node">Agent</span>
          <span className="integration-map-arrow">→</span>
          <span className="integration-map-node">MCP client</span>
        </div>
      </div>

      <div className="integration-map-destinations">
        <div className="integration-map-route">
          <span className="integration-map-arrow">→</span>
          <span className="integration-map-node integration-map-glasser"><strong>Glasser</strong><span>MCP tools</span></span>
        </div>
      </div>
    </div>

    <Steps>
      <Step title="Configure the connection">
        Add this server to your MCP client using **Streamable HTTP**:

        ```text wrap theme={null}
        https://api.glasser.ai/mcp
        ```

        **Your product's account:** create a [Key](https://app.glasser.ai/keys)
        and send `Authorization: Bearer <your Key>`.

        **Your user's account:** connect their Key with the same header, or use
        [MCP browser sign-in](/docs/mcp-server/other) with an OAuth-capable client.
      </Step>

      <Step title="Give the tools to your Agent">
        Discover Glasser's tools with `tools/list` and register them with your
        Agent. See the [tool reference](/docs/mcp-server#tools).
      </Step>

      <Step title="Check the connection">
        Call `balance` with no arguments. A balance response confirms the
        connection, even if the balance is zero. This check is free.
      </Step>
    </Steps>
  </Tab>

  <Tab title="CLI">
    For Agents that can execute shell commands.

    <div className="integration-map" role="img" aria-label="In your product's runtime, the Agent executes Glasser CLI commands through its shell tool. The CLI calls Glasser.">
      <div className="integration-map-product">
        <span className="integration-map-label">Your runtime</span>

        <div className="integration-map-row">
          <span className="integration-map-node">Agent</span>
          <span className="integration-map-arrow">→</span>
          <span className="integration-map-node"><strong>Glasser CLI</strong><span>via shell</span></span>
        </div>
      </div>

      <div className="integration-map-destinations">
        <div className="integration-map-route">
          <span className="integration-map-arrow">→</span>
          <span className="integration-map-node integration-map-glasser"><strong>Glasser</strong><span>HTTP API</span></span>
        </div>
      </div>
    </div>

    <Steps>
      <Step title="Install the CLI">
        Install in your Agent's runtime. Requires Node.js 22 or newer.

        ```bash wrap theme={null}
        npm install -g @glasser-ai/cli
        ```
      </Step>

      <Step title="Connect an account">
        Set `GLASSER_API_KEY` through your runtime's secret store.

        **Your product's account:** use a [Key](https://app.glasser.ai/keys) from
        your Workspace.<br />
        **Your user's account:** load that user's Key in their isolated runtime.
      </Step>

      <Step title="Check the connection">
        Give the Agent a shell tool, then run this free check:

        ```bash wrap theme={null}
        glasser balance --json
        ```

        Use `--json` for machine-readable results.
      </Step>
    </Steps>

    **Reference:** [CLI setup](/docs/cli) · [Search](/docs/cli/search) ·
    [Inspect](/docs/cli/inspect) · [Run](/docs/cli/run)
  </Tab>

  <Tab title="Custom tools · API">
    For products with their own tools or existing data Providers.

    <div className="integration-map" role="img" aria-label="The Agent calls your backend tools. Your backend routes requests to Glasser's HTTP API or your existing Providers.">
      <div className="integration-map-product">
        <span className="integration-map-label">Your backend</span>

        <div className="integration-map-row">
          <span className="integration-map-node">Agent</span>
          <span className="integration-map-arrow">→</span>
          <span className="integration-map-node">Your tools</span>
        </div>
      </div>

      <div className="integration-map-destinations">
        <div className="integration-map-route">
          <span className="integration-map-arrow">→</span>
          <span className="integration-map-node integration-map-glasser"><strong>Glasser</strong><span>HTTP API</span></span>
        </div>

        <div className="integration-map-route">
          <span className="integration-map-arrow">→</span>
          <span className="integration-map-node"><strong>Providers</strong><span>Your existing APIs</span></span>
        </div>
      </div>
    </div>

    <Steps>
      <Step title="Connect your backend">
        **Base URL:** `https://api.glasser.ai`<br />
        **Header:** `Authorization: Bearer <your Key>`

        **Your product's account:** use your Workspace's [Key](https://app.glasser.ai/keys).<br />
        **Your user's account:** select that user's Key for each request.
      </Step>

      <Step title="Define your Agent's tools">
        Wrap [Glasser API requests](/docs/api-reference/overview#search-inspect-run)
        in a tool such as `get_instagram_posts(username)` and register it with
        your Agent. Your backend controls Provider selection and output format.
      </Step>

      <Step title="Check the connection">
        Send an authenticated [GET /v1/balance](/docs/api-reference/balance/get)
        request. This check is free.
      </Step>
    </Steps>

    **Reference:** [API authentication](/docs/api-reference/overview#authenticate) ·
    [API workflow](/docs/api-reference/overview#search-inspect-run)
  </Tab>
</Tabs>

Runs use the connected Workspace's balance. Keep Keys and access tokens out of
model messages and frontend code.

## Give the Agent a workflow

**Search** for an Endpoint → **Inspect** its input and Price → **Run** to get data.

See the [Instagram example](/docs/integrations/overview#example-check-an-instagram-creator)
for the query, matching Endpoint, and input. Search and Inspect are free;
your backend applies spending rules before a Run.

## Implementation details

<AccordionGroup>
  <Accordion title="Skill and Agent instructions">
    Explain when to use Glasser and which tools to call. For CLI-based Agents,
    start with the [Glasser Skill](https://glasser.ai/SKILL.md). For custom tools,
    use your own tool names and Provider preferences.

    Search requires the user's request as `use_case` (CLI: `--use-case`). Pass
    its returned `task_id` to later searches, inspections, and Runs for the same
    task (CLI: `--task`).

    For local CLI development with a user present, [glasser login](/docs/cli/login)
    can store a Key through browser sign-in.
  </Accordion>

  <Accordion title="Retries and unfinished Runs">
    Generate an idempotency key for each intended execution and keep it with
    the request. Retry the same request with the same key:

    * MCP: the `idempotency_key` tool argument.
    * CLI: `--idempotency-key` (required with `run --json`).
    * HTTP API: the `Idempotency-Key` header.

    For `QUEUED` or `RUNNING`, read the existing Run until it reaches a terminal
    state: MCP `runs_get`, CLI `glasser runs get -r <runId> --wait`, or
    [HTTP Get Run](/docs/api-reference/runs/get). Resume the Agent with the result.

    Check both Run `status` and `provider_response` before using `output`.
    `COMPLETED` can include a Provider error; a failed Run can still have a charge.
  </Accordion>

  <Accordion title="Access, spending, and usage tracking">
    * For user-connected accounts, keep credentials separate and select them
      from the signed-in user's connection, not from model arguments.
    * Use the Key's Policy to restrict allowed Endpoints. Enforce per-user
      spending limits in your backend; a shared Key spends one Workspace balance.
    * Keep the Run ID and `charge_usd` with your product's task record.
    * Attach optional customer metadata from your backend for tracking, not
      access control. With MCP, use the request's `_meta["glasser.ai/metadata"]`;
      metadata is not a model tool argument.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.