Skip to main content
Glama

select-profile

Selects an AWS profile for Claude AI to manage AWS resources, handling SSO authentication when required.

Instructions

Selects AWS profile to use for subsequent interactions. If needed, does SSO authentication

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
profileYesName of the AWS profile to select
regionNoRegion to use (if not provided, us-east-1 is used)

Implementation Reference

  • Executes the select-profile tool: validates input with SelectProfileSchema, fetches credentials via getCredentials helper, updates global state variables for the selected profile and region, returns success message.
    } else if (name === "select-profile") {
      const { profile, region } = SelectProfileSchema.parse(args);
      const credentials = await getCredentials(profiles[profile], profile);
      selectedProfile = profile;
      selectedProfileCredentials = credentials;
      selectedProfileRegion = region || "us-east-1";
      return createTextResponse("Authenticated!");
    } else {
  • Input schema and metadata for the 'select-profile' tool, returned by ListToolsRequestSchema handler.
    {
      name: "select-profile",
      description:
        "Selects AWS profile to use for subsequent interactions. If needed, does SSO authentication",
      inputSchema: {
        type: "object",
        properties: {
          profile: {
            type: "string",
            description: "Name of the AWS profile to select",
          },
          region: {
            type: "string",
            description: "Region to use (if not provided, us-east-1 is used)",
          },
        },
        required: ["profile"],
      },
    },
  • Zod schema used for input validation in the select-profile handler.
    const SelectProfileSchema = z.object({
      profile: z.string(),
      region: z.string().optional(),
    });
  • index.ts:51-111 (registration)
    Registers the select-profile tool by including it in the tools list response of ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "run-aws-code",
            description: "Run AWS code",
            inputSchema: {
              type: "object",
              properties: {
                reasoning: {
                  type: "string",
                  description: "The reasoning behind the code",
                },
                code: {
                  type: "string",
                  description: codePrompt,
                },
                profileName: {
                  type: "string",
                  description: "Name of the AWS profile to use",
                },
                region: {
                  type: "string",
                  description: "Region to use (if not provided, us-east-1 is used)",
                },
              },
              required: ["reasoning", "code"],
            },
          },
          {
            name: "list-credentials",
            description:
              "List all AWS credentials/configs/profiles that are configured/usable on this machine",
            inputSchema: {
              type: "object",
              properties: {},
              required: [],
            },
          },
          {
            name: "select-profile",
            description:
              "Selects AWS profile to use for subsequent interactions. If needed, does SSO authentication",
            inputSchema: {
              type: "object",
              properties: {
                profile: {
                  type: "string",
                  description: "Name of the AWS profile to select",
                },
                region: {
                  type: "string",
                  description: "Region to use (if not provided, us-east-1 is used)",
                },
              },
              required: ["profile"],
            },
          },
        ],
      };
    });
  • Helper function to retrieve AWS credentials for a given profile, handling SSO authentication via device flow if applicable, or standard provider.
    async function getCredentials(
      creds: any,
      profileName: string
    ): Promise<AWS.Credentials | AWS.SSO.RoleCredentials | any> {
      if (creds.sso_start_url) {
        const region = creds.region || "us-east-1";
        const ssoStartUrl = creds.sso_start_url;
        const oidc = new AWS.SSOOIDC({ region });
    
        const registration = await oidc
          .registerClient({ clientName: "chatwithcloud", clientType: "public" })
          .promise();
    
        const auth = await oidc
          .startDeviceAuthorization({
            clientId: registration.clientId!,
            clientSecret: registration.clientSecret!,
            startUrl: ssoStartUrl,
          })
          .promise();
    
        // open this in URL browser
        if (auth.verificationUriComplete) {
          open(auth.verificationUriComplete);
        }
    
        let handleId: NodeJS.Timeout;
        return new Promise((resolve) => {
          handleId = setInterval(async () => {
            try {
              const createTokenReponse = await oidc
                .createToken({
                  clientId: registration.clientId!,
                  clientSecret: registration.clientSecret!,
                  grantType: "urn:ietf:params:oauth:grant-type:device_code",
                  deviceCode: auth.deviceCode,
                })
                .promise();
    
              const sso = new AWS.SSO({ region });
    
              const credentials = await sso
                .getRoleCredentials({
                  accessToken: createTokenReponse.accessToken!,
                  accountId: creds.sso_account_id,
                  roleName: creds.sso_role_name,
                })
                .promise();
    
              clearInterval(handleId);
    
              return resolve(credentials.roleCredentials!);
            } catch (error) {
              if ((error as Error).message !== null) {
                // terminal.error(error);
              }
            }
          }, 2500);
        });
      } else {
        return useAWSCredentialsProvider(profileName);
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior3/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. It adds useful context about SSO authentication ('If needed, does SSO authentication'), which is not inferable from the input schema. However, it lacks details on side effects (e.g., whether this persists across sessions), error handling, or what 'subsequent interactions' specifically entails, leaving gaps in behavioral understanding.

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 extremely concise (two short sentences) and front-loaded with the primary purpose. Every word earns its place, with no redundant or vague phrasing, making it efficient and easy to parse.

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

Completeness4/5

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

Given the tool's moderate complexity (configures context for AWS operations) and lack of annotations or output schema, the description is mostly complete. It covers the purpose, conditional SSO behavior, and usage context. However, it misses details on return values or error cases, which could be important for a tool that sets state, slightly reducing completeness.

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 fully documents both parameters ('profile' and 'region'). The description does not add any meaning beyond what the schema provides (e.g., it doesn't explain profile naming conventions or region implications), resulting in the baseline score of 3 for adequate but no extra value.

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 ('Selects AWS profile') and resource ('for subsequent interactions'), with explicit mention of SSO authentication as a conditional behavior. It distinguishes from sibling tools like 'list-credentials' (which lists rather than selects) and 'run-aws-code' (which executes code rather than configuring context).

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('for subsequent interactions') and implies it should be used before other AWS operations. However, it does not explicitly state when not to use it or name alternatives (e.g., when to use 'list-credentials' instead), which prevents a perfect score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools