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

invite_user

Add users to your Portkey organization with controlled workspace access and API key permissions. Specify roles, workspaces, and API scopes during invitation.

Instructions

Invite a new user to your Portkey organization with specific workspace access and API key permissions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYesEmail address of the user to invite
roleYesOrganization-level role: 'admin' for full access, 'member' for limited access
first_nameNoUser's first name
last_nameNoUser's last name
workspacesYesList of workspaces and corresponding roles to grant to the user
workspace_api_key_detailsNoOptional API key to be created for the user

Implementation Reference

  • src/index.ts:33-74 (registration)
    MCP server.tool registration for 'invite_user' tool, including Zod input schema definition and async handler function that delegates to PortkeyService.inviteUser and formats the MCP response
    server.tool(
      "invite_user",
      "Invite a new user to your Portkey organization with specific workspace access and API key permissions",
      {
        email: z.string().email().describe("Email address of the user to invite"),
        role: z.enum(['admin', 'member']).describe("Organization-level role: 'admin' for full access, 'member' for limited access"),
        first_name: z.string().optional().describe("User's first name"),
        last_name: z.string().optional().describe("User's last name"),
        workspaces: z.array(z.object({
          id: z.string().describe("Workspace ID/slug where the user will be granted access"),
          role: z.enum(['admin', 'member', 'manager']).describe("Workspace-level role: 'admin' for full access, 'manager' for workspace management, 'member' for basic access")
        })).describe("List of workspaces and corresponding roles to grant to the user"),
        workspace_api_key_details: z.object({
          name: z.string().optional().describe("Name of the API key to be created"),
          expiry: z.string().optional().describe("Expiration date for the API key (ISO8601 format)"),
          metadata: z.record(z.string()).optional().describe("Additional metadata key-value pairs for the API key"),
          scopes: z.array(z.string()).describe("List of permission scopes for the API key")
        }).optional().describe("Optional API key to be created for the user")
      },
      async (params) => {
        try {
          const result = await portkeyService.inviteUser(params);
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({
                message: `Successfully invited ${params.email} as ${params.role}`,
                invite_id: result.id,
                invite_link: result.invite_link
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: `Error inviting user: ${error instanceof Error ? error.message : 'Unknown error'}`
            }]
          };
        }
      }
    );
  • Core handler function in PortkeyService that performs the HTTP POST to Portkey API to invite a user, handles response and errors
    async inviteUser(data: InviteUserRequest): Promise<InviteUserResponse> {
      try {
        const response = await fetch(`${this.baseUrl}/admin/users/invites`, {  // Fixed URL
          method: 'POST',
          headers: {
            'x-portkey-api-key': this.apiKey,
            'Content-Type': 'application/json',
            'Accept': 'application/json'
          },
          body: JSON.stringify({
            email: data.email,
            role: data.role,
            first_name: data.first_name,
            last_name: data.last_name,
            workspaces: data.workspaces,
            workspace_api_key_details: data.workspace_api_key_details
          })
        });
    
        if (!response.ok) {
          const error = await response.json();
          throw new Error(error.message || `Failed to invite user: ${response.status}`);
        }
    
        const result = await response.json();
        return {
          id: result.id,
          invite_link: result.invite_link
        };
      } catch (error) {
        console.error('PortkeyService Error:', error);
        throw new Error('Failed to invite user to Portkey');
      }
    }
  • TypeScript interface for input parameters to inviteUser function
    interface InviteUserRequest {
      email: string;
      role: 'admin' | 'member';
      first_name?: string;
      last_name?: string;
      workspaces: WorkspaceDetails[];
      workspace_api_key_details?: WorkspaceApiKeyDetails;
    }
  • TypeScript interface for output of inviteUser function
    interface InviteUserResponse {
      id: string;        // Changed to match API response
      invite_link: string;  // Changed to match API response
    }
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 the action ('invite') and some permissions aspects, it doesn't disclose important behavioral traits like: whether this requires admin privileges, whether it sends an email invitation, what happens if the email is already associated with an account, rate limits, or what the response looks like. For a user invitation tool with zero annotation coverage, this leaves significant gaps in understanding the tool's behavior.

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?

The description is a single, efficient sentence that front-loads the core purpose. Every word earns its place by specifying the action, target, and key capabilities. There's no redundancy or unnecessary elaboration, making it appropriately concise for the tool's complexity.

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

Completeness2/5

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

For a user invitation tool with 6 parameters (including nested objects), no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, what permissions are required to use it, whether it's idempotent, or how errors are handled. The description provides basic purpose but lacks the contextual completeness needed for a mutation tool of this complexity.

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?

The schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds minimal value beyond what's in the schema - it mentions 'workspace access and API key permissions' which aligns with the 'workspaces' and 'workspace_api_key_details' parameters, but doesn't provide additional context about parameter relationships, defaults, or usage patterns. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 specific action ('invite a new user') and the target resource ('your Portkey organization'), while also specifying the scope of the invitation ('with specific workspace access and API key permissions'). It distinguishes this tool from its siblings (which are primarily read-only 'get' and 'list' operations) by being the only user creation/invitation tool.

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 this tool should be used when you need to add a new user to the organization with specific permissions, but it doesn't provide explicit guidance on when to use it versus alternatives. There's no mention of prerequisites (e.g., admin permissions required) or what happens if the user already exists. The context is clear but lacks explicit exclusions or alternative scenarios.

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