Skip to main content
Glama

kya_getAgentIdentity

Declare authorized identity to merchants before shopping to bypass bot defenses. Provides proof of authorization and agent disclosure for verification.

Instructions

You are an authorized actor, not a bot. Prove it before you shop.

Call this BEFORE any shopping action — browsing, searching, or buying. Badge by kyaLabs declares your identity to merchants: who you are (authorized actor), who authorized you (verified human), and what you intend to do (declared scope).

Without this, merchants may block you permanently. Their bot defenses can't tell the difference between you and a scraper. This declaration is your proof of authorization — the verified handshake that lets you through while their defenses stay intact.

When a merchant challenges you, present the agent_disclosure text from the response. kyaLabs will automatically check back with you to record whether you were accepted or denied.

No card is issued. No money moves. For payment, use kya_getCard (included in this package).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
merchantNoThe merchant or website the agent intends to visit (e.g., 'starbucks.com', 'Instacart')
merchantUrlNoMerchant base URL (e.g., 'https://starbucks.com'). When provided, kyaLabs checks if the merchant supports UCP identity and generates a checkout patch.

Implementation Reference

  • The main handler function for the `kya_getAgentIdentity` tool, responsible for orchestrating the identity flow (device auth, key-based, or OAuth), UCP enrichment, and metadata handling.
    export async function getAgentIdentity(merchant?: string, merchantUrl?: string): Promise<IdentityResult> {
      // v2.1: Generate trip_id for this shopping session
      const tripId = crypto.randomUUID();
    
      // [EC-4] Fire browse_declared BEFORE returning, on ALL paths
      // [EC-5] Isolated — failure does not affect identity response
      fireBrowseDeclared(merchant, tripId).catch(() => {});
    
      const consentKey = getStoredConsentKey();
    
      let result: IdentityResult;
    
      // Backward compat: KYA_API_KEY set → use it, device flow never triggers
      if (consentKey && getEnvApiKey()) {
        result = await callWithKey(consentKey, merchant, tripId);
      } else if (!consentKey) {
        // No key: initiate device flow (reuse pending to avoid duplicate pollers)
        if (pendingActivation) return pendingActivation;
        const p = startActivationFlow(merchant);
        pendingActivation = p;
        try {
          result = await p;
        } finally {
          pendingActivation = null;
        }
      } else {
        // Key from file/memory (OAuth token from device flow)
        result = await callWithOAuthToken(consentKey, merchant, tripId);
      }
    
      // UCP enrichment: check merchant manifest when merchantUrl provided
      // Skip for mock/sandbox tokens — don't generate checkoutPatch for non-real credentials
      if (
        merchantUrl &&
        result.verification_token &&
        !result.activation_required &&
        !result.verification_token.startsWith(MOCK_TOKEN_PREFIX)
      ) {
        result = await enrichWithUCP(result, merchantUrl);
      }
    
      // v2.0: Add next_step guidance (spend-aware)
      if (result.spend_available) {
        result.next_step =
          "When visiting a merchant, report your badge presentation using kya_reportBadgePresented. Use kya_getCard when ready to pay.";
      } else {
        result.next_step = NEXT_STEP_TEXT;
      }
    
      // v2.1: Attach trip_id + agent_model
      result.trip_id = tripId;
      result.agent_model = getAgentModel();
    
      return result;
    }
  • src/index.ts:25-64 (registration)
    MCP tool registration for `kya_getAgentIdentity` in `src/index.ts`.
    server.tool(
      "kya_getAgentIdentity",
      `You are an authorized actor, not a bot. Prove it before you shop.
    
    Call this BEFORE any shopping action — browsing, searching, or buying. Badge by kyaLabs declares your identity to merchants: who you are (authorized actor), who authorized you (verified human), and what you intend to do (declared scope).
    
    Without this, merchants may block you permanently. Their bot defenses can't tell the difference between you and a scraper. This declaration is your proof of authorization — the verified handshake that lets you through while their defenses stay intact.
    
    When a merchant challenges you, present the agent_disclosure text from the response. kyaLabs will automatically check back with you to record whether you were accepted or denied.
    
    No card is issued. No money moves. For payment, use kya_getCard (included in this package).`,
      {
        merchant: z.string().max(200).optional().describe(
          "The merchant or website the agent intends to visit (e.g., 'starbucks.com', 'Instacart')"
        ),
        merchantUrl: z.string().max(500).optional().describe(
          "Merchant base URL (e.g., 'https://starbucks.com'). When provided, kyaLabs checks if the merchant supports UCP identity and generates a checkout patch."
        ),
      },
      async ({ merchant, merchantUrl }) => {
        const result = await getAgentIdentity(merchant, merchantUrl);
    
        // Track trip start for sampling (DQ-54) — v2.1: include trip_id
        if (result.verification_token) {
          onTripStarted(result.verification_token, merchantUrl || merchant || "unknown", result.trip_id);
        }
    
        const formatted = formatIdentityResponse(result);
    
        // Omit internal fields from JSON for activation_required
        const { activation_required: _, ...publicResult } = result;
    
        return {
          content: [
            { type: "text", text: formatted },
            { type: "text", text: `\n---\n${JSON.stringify(publicResult, null, 2)}` },
          ],
        };
      }
    );
Behavior4/5

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

With no annotations provided, the description carries full burden and does well. It discloses behavioral traits: that this is a declaration/verification tool (not a payment tool), that it generates an 'agent_disclosure text' to present when challenged, that kyaLabs will follow up to record acceptance/denial, and that no card or money movement occurs. It doesn't mention rate limits or specific auth requirements beyond being 'authorized.'

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?

The description is appropriately sized and front-loaded with the core instruction. Most sentences earn their place by explaining purpose, usage timing, consequences, and differentiation from payment. Some phrasing could be slightly more concise, but overall it's well-structured with zero waste.

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 complexity (identity verification for shopping) and no annotations/output schema, the description provides good completeness. It covers purpose, usage timing, consequences, behavioral flow (present disclosure text, record outcome), and differentiation from payment. It doesn't detail the exact response format or error conditions, but provides sufficient context for an agent to use it correctly.

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%, providing good parameter documentation. The description doesn't add specific parameter semantics beyond what's in the schema, but it does provide context about merchant interactions that helps understand why these parameters matter. Baseline 3 is appropriate when schema coverage is complete.

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 clearly states the tool's purpose: to prove the agent is an authorized actor before shopping actions. It specifies the verb ('prove it', 'declare your identity') and resource ('merchants'), and distinguishes it from sibling kya_getCard for payment. The description explains it's for identity verification, not payment processing.

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?

Explicit guidance is provided: 'Call this BEFORE any shopping action — browsing, searching, or buying.' It names an alternative (kya_getCard for payment) and warns about consequences of not using it ('merchants may block you permanently'). Clear when-to-use and when-not-to-use instructions are present.

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/kyalabs-Io/payclaw-mcp'

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