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

list_workspaces

Retrieve all workspaces in your Portkey organization to view configurations and metadata for managing AI settings and API usage.

Instructions

Retrieve all workspaces in your Portkey organization, including their configurations and metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_sizeNoNumber of workspaces to return per page (default varies by endpoint)
current_pageNoPage number to retrieve when results are paginated

Implementation Reference

  • The MCP tool handler function for 'list_workspaces' that calls the Portkey service method and formats the response as text content or handles errors.
    async (params) => {
      try {
        const workspaces = await portkeyService.listWorkspaces(params);
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify(workspaces, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{ 
            type: "text", 
            text: `Error fetching workspaces: ${error instanceof Error ? error.message : 'Unknown error'}`
          }]
        };
      }
    }
  • Zod input schema defining optional pagination parameters for the list_workspaces tool.
      page_size: z.number().positive().optional().describe("Number of workspaces to return per page (default varies by endpoint)"),
      current_page: z.number().positive().optional().describe("Page number to retrieve when results are paginated")
    },
  • src/index.ts:112-137 (registration)
    MCP server registration of the 'list_workspaces' tool, specifying name, description, input schema, and handler function.
    server.tool(
      "list_workspaces",
      "Retrieve all workspaces in your Portkey organization, including their configurations and metadata",
      {
        page_size: z.number().positive().optional().describe("Number of workspaces to return per page (default varies by endpoint)"),
        current_page: z.number().positive().optional().describe("Page number to retrieve when results are paginated")
      },
      async (params) => {
        try {
          const workspaces = await portkeyService.listWorkspaces(params);
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify(workspaces, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: `Error fetching workspaces: ${error instanceof Error ? error.message : 'Unknown error'}`
            }]
          };
        }
      }
    );
  • Helper method in PortkeyService that performs the actual API request to list workspaces with optional pagination and error handling.
    async listWorkspaces(params?: ListWorkspacesParams): Promise<ListWorkspacesResponse> {
      try {
        const queryParams = new URLSearchParams();
        if (params?.page_size) {
          queryParams.append('page_size', params.page_size.toString());
        }
        if (params?.current_page) {
          queryParams.append('current_page', params.current_page.toString());
        }
    
        const url = `${this.baseUrl}/admin/workspaces${queryParams.toString() ? '?' + queryParams.toString() : ''}`;
        
        const response = await fetch(url, {
          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 ListWorkspacesResponse;
      } catch (error) {
        console.error('PortkeyService Error:', error);
        throw new Error('Failed to fetch workspaces from Portkey API');
      }
    }
  • TypeScript interface defining input parameters for the listWorkspaces service method.
    interface ListWorkspacesParams {
      page_size?: number;
      current_page?: number;
    }
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the scope ('all workspaces', 'configurations and metadata') but lacks critical behavioral details: pagination behavior (implied by parameters but not explained), rate limits, authentication requirements, error conditions, or response format. The description doesn't contradict annotations since none exist.

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?

Single sentence efficiently conveys core purpose with zero waste. Front-loaded with main action ('Retrieve all workspaces'), followed by scope details. Every word earns its place without redundancy or unnecessary elaboration.

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 read-only list tool with 2 documented parameters but no annotations and no output schema, the description is minimally adequate. It covers what the tool retrieves but lacks behavioral context (pagination, authentication, response format) that would be helpful given the absence of structured metadata. Completeness is borderline for a tool that presumably returns complex workspace objects.

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%, so the schema already fully documents both pagination parameters. The description adds no parameter-specific information beyond what's in the schema. Baseline 3 is appropriate when schema does all parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/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 resource 'all workspaces in your Portkey organization', specifying scope with 'including their configurations and metadata'. It distinguishes from sibling 'get_workspace' (singular) by indicating retrieval of multiple workspaces. However, it doesn't explicitly differentiate from other list tools like 'list_all_users' or 'list_configs' beyond resource type.

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

Usage Guidelines3/5

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

The description implies usage for retrieving workspace collections rather than single workspaces (contrasting with 'get_workspace'), but doesn't provide explicit when-to-use guidance, alternatives, or exclusions. No mention of prerequisites, authentication needs, or comparison with other list tools is provided.

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