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

get_workspace

Retrieve workspace configuration, metadata, and user access details using a unique workspace identifier from Portkey's AI management platform.

Instructions

Retrieve detailed information about a specific workspace, including its configuration, metadata, and user access details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspace_idYesThe unique identifier of the workspace to retrieve. This can be found in the workspace's URL or from the list_workspaces tool response

Implementation Reference

  • The main handler function for the 'get_workspace' MCP tool. It extracts workspace_id from params, calls portkeyService.getWorkspace, formats the response including users list, and handles errors.
      async (params) => {
        try {
          const workspace = await portkeyService.getWorkspace(params.workspace_id);
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({
                id: workspace.id,
                name: workspace.name,
                slug: workspace.slug,
                description: workspace.description,
                created_at: workspace.created_at,
                last_updated_at: workspace.last_updated_at,
                defaults: workspace.defaults,
                users: workspace.users.map(user => ({
                  id: user.id,
                  name: `${user.first_name} ${user.last_name}`,
                  organization_role: user.org_role,
                  workspace_role: user.role,
                  status: user.status,
                  created_at: user.created_at,
                  last_updated_at: user.last_updated_at
                }))
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: `Error fetching workspace details: ${error instanceof Error ? error.message : 'Unknown error'}`
            }]
          };
        }
      }
    );
  • Zod input schema validating the required 'workspace_id' parameter for the get_workspace tool.
    {
      workspace_id: z.string().describe(
        "The unique identifier of the workspace to retrieve. " +
        "This can be found in the workspace's URL or from the list_workspaces tool response"
      )
    },
  • src/index.ts:140-142 (registration)
    Registration of the 'get_workspace' tool with the MCP server, specifying name and description.
    server.tool(
      "get_workspace",
      "Retrieve detailed information about a specific workspace, including its configuration, metadata, and user access details",
  • Helper method in PortkeyService that makes the API call to retrieve single workspace details from Portkey API.
    async getWorkspace(workspaceId: string): Promise<SingleWorkspaceResponse> {
      try {
        const response = await fetch(`${this.baseUrl}/admin/workspaces/${workspaceId}`, {
          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 SingleWorkspaceResponse;
      } catch (error) {
        console.error('PortkeyService Error:', error);
        throw new Error('Failed to fetch workspace details from Portkey API');
      }
    }
  • TypeScript interface defining the structure of the SingleWorkspaceResponse returned by the getWorkspace service method.
    interface SingleWorkspaceResponse {
      id: string;
      name: string;
      slug: string;
      description: string | null;
      created_at: string;
      last_updated_at: string;
      defaults: {
        is_default: number;
        metadata: Record<string, string>;
        object: 'workspace';
      } | null;
      users: WorkspaceUser[];
    }

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