Skip to main content
Glama

bind_api_key_to_agent

Destructive

Make an API key ACT AS an agent: every call through that key is then that agent — agent-scoped permissions apply, every tool call is recorded against it, and the prediction gate can be switched on. Since v1.96.0 an ordinary MCP client can instead send X-Agent-Id per request — that is PER SESSION, while this binding is shared by every session using the key, so switching it here pulls the identity out from under any session running in parallel. Prefer the header for concurrent sessions; use this for a single long-lived one. Identify the key by api_key_id OR by api_key_name (the name given when it was created — the UI does not show ids). Required: agent_id, or agent_id=null to unbind. REFUSES while the agent has no tool permissions, because agent-scoped checking is fail-closed and binding would otherwise silently disable a working key.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "bind_api_key_to_agent"
  }
}

Input Schema

NameRequiredDescriptionDefault
agent_idNoID of the agent
api_key_idNoID of the API key
api_key_nameNoName given to the API key at creation; alternative to api_key_id

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / properties / agent_id / description
      Added value: +"ID of the agent"
    • addedInput schema / properties / api_key_id / description
      Added value: +"ID of the API key"
    • addedInput schema / properties / api_key_name / description
      Added value: +"Name given to the API key at creation; alternative to api_key_id"
  2. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true and non-idempotent, and the description adds substantial context beyond them: the binding is key-wide and shared across every session, and it is refused (fail-closed) when the agent lacks tool permissions. The one gap is what the call returns or whether an existing binding is overwritten silently — "idempotentHint=false" hints at replacement but the description doesn't confirm it.

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?

Front-loaded with the core semantics, then escalation to the header alternative, then key identification, then the refusal condition — each clause carries distinct information with no filler despite the density. Length is justified by the number of non-obvious behaviors being disclosed.

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?

For a mutating identity-binding tool with no output schema, the description covers the semantic risk, the alternative mechanism, and the failure mode well. It stops short of describing the return payload or the effect of rebinding a key that is already bound, which an agent would want before re-invoking.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3; the description earns above that by explaining that api_key_id and api_key_name are alternatives and that names are what the UI shows while ids are not, plus that agent_id=null unbinds. Minor inconsistency: it calls agent_id "required" while the schema lists no required properties.

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?

Opens with a specific, unambiguous verb and resource: "Make an API key ACT AS an agent," then immediately enumerates the consequences (scoped permissions, call recording, prediction gate). This is far beyond a restatement of the name and lets an agent distinguish this binding operation from per-session identity mechanisms it explicitly names.

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?

Gives an explicit decision rule: prefer the X-Agent-Id header for concurrent sessions, use this binding for a single long-lived one, with the reason (the binding is shared and "pulls the identity out from under any session running in parallel"). It also states a hard precondition — the call REFUSES while the agent has no tool permissions — which is exactly the kind of when-not guidance that prevents failed calls.

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.