Skip to main content
Glama

get_usage_limit

Read-onlyIdempotent

Retrieve a usage limit by ID to view its full budget, threshold, grouping, and reset details. Useful after listing limits to inspect a specific policy.

Instructions

Get one usage limit by id and return its full budget, threshold, grouping, and reset details. Use list_usage_limits to discover ids or compare policies first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe unique identifier of the usage limit

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYesWhether the tool call succeeded and returned structured data
dataNoStructured success payload when ok is true
errorNoStructured error payload when ok is false

Implementation Reference

  • The service-layer handler for get_usage_limit - makes a GET request to /policies/usage-limits/{id} and returns a UsageLimit object. Validates that the ID is non-empty before making the API call.
    async getUsageLimit(id: string): Promise<UsageLimit> {
    	if (!id?.trim()) {
    		throw new Error("Usage limit ID is required");
    	}
    	return this.get<UsageLimit>(
    		`/policies/usage-limits/${this.encodePathSegment(id)}`,
    	);
    }
  • Registers the 'get_usage_limit' tool on the MCP server with its schema, description, and handler that calls the service layer and formats the result.
    // Get usage limit
    server.tool(
    	"get_usage_limit",
    	"Get one usage limit by id and return its full budget, threshold, grouping, and reset details. Use list_usage_limits to discover ids or compare policies first.",
    	LIMITS_TOOL_SCHEMAS.getUsageLimit,
    	async (params) => {
    		const result = await service.limits.getUsageLimit(params.id);
    		return {
    			content: [
    				{
    					type: "text",
    					text: JSON.stringify(formatUsageLimit(result), null, 2),
    				},
    			],
    		};
    	},
    );
  • Zod schema for the get_usage_limit tool input - requires a single 'id' field (string) as the unique identifier of the usage limit.
    getUsageLimit: {
    	id: z.string().describe("The unique identifier of the usage limit"),
    },
  • Helper function that formats a UsageLimit object into a clean JSON-serializable shape for the tool response, extracting only the relevant fields.
    function formatUsageLimit(limit: UsageLimit): {
    	id: string;
    	name?: string;
    	type: "cost" | "tokens";
    	credit_limit: number;
    	alert_threshold?: number;
    	periodic_reset?: "monthly" | "weekly";
    	status: string;
    	conditions: UsageLimit["conditions"];
    	group_by: string[];
    	workspace_id?: string;
    	organisation_id?: string;
    	created_at: string;
    	last_updated_at: string;
    } {
    	return {
    		id: limit.id,
    		name: limit.name,
    		type: limit.type,
    		credit_limit: limit.credit_limit,
    		alert_threshold: limit.alert_threshold,
    		periodic_reset: limit.periodic_reset,
    		status: limit.status,
    		conditions: limit.conditions,
    		group_by: limit.group_by,
    		workspace_id: limit.workspace_id,
    		organisation_id: limit.organisation_id,
    		created_at: limit.created_at,
    		last_updated_at: limit.last_updated_at,
    	};
    }
  • The PortkeyService facade that exposes service.limits.getUsageLimit() via the 'limits' property, which is an instance of LimitsService.
    }
    
    export function getSharedPortkeyService(apiKey?: string): PortkeyService {
    	const cacheKey = getSharedServiceCacheKey(apiKey);
    	const cached = sharedPortkeyServices.get(cacheKey);
    	if (cached) {
    		return cached;
    	}
    
    	const service = new PortkeyService(apiKey);
    	sharedPortkeyServices.set(cacheKey, service);
    	return service;
    }
Behavior5/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false. The description adds value by specifying the exact return fields (budget, threshold, grouping, reset details), making the tool's behavior fully transparent without contradicting annotations.

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?

Two sentences: the first front-loads purpose and return details, the second provides usage guidance. No unnecessary words; every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (1 parameter, no nested objects) and the existence of an output schema, the description adequately covers what the tool does, what it returns, and when to use it. No gaps remain.

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% for the single parameter 'id'. The description does not add any new meaning beyond what the schema already provides, so baseline score of 3 is appropriate.

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 action ('Get one usage limit by id') and specifies the returned data ('full budget, threshold, grouping, and reset details'). It distinguishes itself from sibling tool list_usage_limits by referencing it for discovery.

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?

Explicitly says 'Use list_usage_limits to discover ids or compare policies first,' providing clear when-to-use and when-not-to-use guidance with a named alternative.

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/s-b-e-n-s-o-n/portkey-admin-mcp'

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