Skip to main content
Glama
r-huijts
by r-huijts

list_virtual_keys

Retrieve all virtual keys in your Portkey organization to view usage limits, rate limits, and status information.

Instructions

Retrieve all virtual keys in your Portkey organization, including their usage limits, rate limits, and status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler function for 'list_virtual_keys' that fetches data via portkeyService and returns formatted JSON text response.
    async () => {
      try {
        const virtualKeys = await portkeyService.listVirtualKeys();
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({
              total: virtualKeys.total,
              virtual_keys: virtualKeys.data.map(key => ({
                name: key.name,
                slug: key.slug,
                status: key.status,
                note: key.note,
                usage_limits: key.usage_limits ? {
                  credit_limit: key.usage_limits.credit_limit,
                  alert_threshold: key.usage_limits.alert_threshold,
                  periodic_reset: key.usage_limits.periodic_reset
                } : null,
                rate_limits: key.rate_limits?.map(limit => ({
                  type: limit.type,
                  unit: limit.unit,
                  value: limit.value
                })) ?? null,
                reset_usage: key.reset_usage,
                created_at: key.created_at,
                model_config: key.model_config
              }))
            }, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{ 
            type: "text", 
            text: `Error fetching virtual keys: ${error instanceof Error ? error.message : 'Unknown error'}`
          }]
        };
      }
    }
  • src/index.ts:226-269 (registration)
    Registration of the 'list_virtual_keys' tool using server.tool, including name, description, empty input schema, and handler reference.
    server.tool(
      "list_virtual_keys",
      "Retrieve all virtual keys in your Portkey organization, including their usage limits, rate limits, and status",
      {},
      async () => {
        try {
          const virtualKeys = await portkeyService.listVirtualKeys();
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({
                total: virtualKeys.total,
                virtual_keys: virtualKeys.data.map(key => ({
                  name: key.name,
                  slug: key.slug,
                  status: key.status,
                  note: key.note,
                  usage_limits: key.usage_limits ? {
                    credit_limit: key.usage_limits.credit_limit,
                    alert_threshold: key.usage_limits.alert_threshold,
                    periodic_reset: key.usage_limits.periodic_reset
                  } : null,
                  rate_limits: key.rate_limits?.map(limit => ({
                    type: limit.type,
                    unit: limit.unit,
                    value: limit.value
                  })) ?? null,
                  reset_usage: key.reset_usage,
                  created_at: key.created_at,
                  model_config: key.model_config
                }))
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: `Error fetching virtual keys: ${error instanceof Error ? error.message : 'Unknown error'}`
            }]
          };
        }
      }
    );
  • TypeScript interface defining the structure of the listVirtualKeys API response.
    interface ListVirtualKeysResponse {
      object: 'list';
      total: number;
      data: VirtualKey[];
    }
  • PortkeyService method that performs the HTTP GET request to retrieve virtual keys from the Portkey API.
    async listVirtualKeys(): Promise<ListVirtualKeysResponse> {
      try {
        const response = await fetch(`${this.baseUrl}/virtual-keys`, {
          method: 'GET',
          headers: {
            'x-portkey-api-key': this.apiKey,
            'Accept': 'application/json'
          }
        });
    
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
    
        return await response.json() as ListVirtualKeysResponse;
      } catch (error) {
        console.error('PortkeyService Error:', error);
        throw new Error('Failed to fetch virtual keys from Portkey API');
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions what information is retrieved (usage limits, rate limits, status), it doesn't describe important behavioral aspects like whether this requires authentication, how results are returned (pagination, format), rate limits on the operation itself, or what happens if no virtual keys exist. The description provides some context about what's included but misses key operational details.

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 a single, efficient sentence that packs substantial information about what's retrieved. It's appropriately sized for a zero-parameter tool and front-loads the core purpose immediately. There's no wasted verbiage, though it could potentially be structured to include usage guidance.

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?

For a zero-parameter list operation with no output schema, the description provides adequate but incomplete coverage. It specifies what resource is retrieved and what information is included, but lacks details about the return format, authentication requirements, error conditions, or relationship to other tools. The absence of annotations means the description should do more heavy lifting than it currently does.

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?

The tool has zero parameters with 100% schema description coverage, so the baseline is 4. The description appropriately doesn't discuss parameters since none exist, and it focuses on what the tool retrieves rather than parameter details.

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 verb 'retrieve' and the resource 'all virtual keys in your Portkey organization', with specific details about what information is included (usage limits, rate limits, status). It distinguishes itself from sibling tools like list_all_users or list_workspaces by focusing specifically on virtual keys.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. While it's clear this is for retrieving virtual keys, there's no mention of when you'd use this versus other list_* tools or how it relates to other Portkey management tools. No exclusions or prerequisites are mentioned.

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/r-huijts/portkey-admin-mcp-server'

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