Skip to main content
Glama

get_secret_by_id

Retrieve a specific secret by its ID from supported secret managers like Vault, AWS, or GCP using the APISIX-MCP server integration.

Instructions

Get a secret by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNosecret id
managerYessecret manager type
pageNopage number
page_sizeNopage size

Implementation Reference

  • Inline handler function for the 'get_secret_by_id' tool, which calls the admin API to fetch a secret by ID or list secrets with pagination.
    server.tool("get_secret_by_id", "Get a secret by ID", GetSecretSchema.shape, async (args) => {
      if (args.id) {
        return await makeAdminAPIRequest(`/secrets/${args.manager}/${args.id}`);
      } else {
        const query = "";
    
        return await makeAdminAPIRequest(`/secrets/${args.manager}?page=${args.page}&page_size=${args.page_size}${query}`);
      }
    });
  • Zod schema defining the input parameters for the 'get_secret_by_id' tool: optional id, manager type, and pagination fields from PaginationSchema.
    export const GetSecretSchema = z
      .object({
        id: z.string().optional().describe("secret id"),
        manager: SecretTypeSchema.describe("secret manager type"),
      })
      .merge(PaginationSchema);
  • Registration of the 'get_secret_by_id' tool on the MCP server using server.tool with description, schema, and handler.
    server.tool("get_secret_by_id", "Get a secret by ID", GetSecretSchema.shape, async (args) => {
      if (args.id) {
        return await makeAdminAPIRequest(`/secrets/${args.manager}/${args.id}`);
      } else {
        const query = "";
    
        return await makeAdminAPIRequest(`/secrets/${args.manager}?page=${args.page}&page_size=${args.page_size}${query}`);
      }
    });
  • Utility function used by the tool handler to perform HTTP requests to the APISIX Admin API and format the response as MCP CallToolResult.
    export async function makeAdminAPIRequest(
      path: string,
      method: string = "GET",
      data?: object
    ): Promise<CallToolResult> {
      const baseUrl = `${APISIX_SERVER_HOST}:${APISIX_ADMIN_API_PORT}${APISIX_ADMIN_API_PREFIX}`;
      const url = `${baseUrl}${path}`;
    
      try {
        const response = await axios({
          method,
          url,
          data,
          headers: {
            "X-API-KEY": APISIX_ADMIN_KEY,
            "Content-Type": "application/json",
          },
        });
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          console.error(`Request failed: ${method} ${url}`);
          console.error(
            `Status: ${error.response?.status}, Error: ${error.message}`
          );
    
          if (error.response?.data) {
            try {
              const stringifiedData = JSON.stringify(error.response.data);
              console.error(`Response data: ${stringifiedData}`);
            } catch {
              console.error(`Response data: [Cannot parse as JSON]`);
            }
          }
    
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  `Status: ${error.response?.status}\nMessage: ${error.message}
    Data:\n${JSON.stringify(error.response?.data || {}, null, 2)}`,
                  null,
                  2
                ),
              },
            ],
          };
        } else {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: JSON.stringify(error, null, 2),
              },
            ],
          };
        }
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Get a secret by ID' implies a read operation, but it doesn't disclose behavioral traits like authentication needs, rate limits, error handling, or what happens if the secret doesn't exist. The description is minimal and fails to provide necessary operational context.

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 with a single sentence, 'Get a secret by ID', which is front-loaded and wastes no words. It's appropriately sized for a simple tool, though this conciseness comes at the cost of detail.

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?

Given the tool has 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error cases, or how parameters interact (e.g., why 'page' and 'page_size' exist for a tool that seems to retrieve a single secret by ID). For a secret-retrieval tool, more context is needed.

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 fully documents all parameters (id, manager, page, page_size). The description adds no meaning beyond what the schema provides, as it doesn't explain parameter relationships or usage. Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get a secret by ID' clearly states the verb ('Get') and resource ('secret'), but it's vague about scope and doesn't differentiate from sibling tools like 'get_resource' or 'get_credential'. It doesn't specify what kind of secret or what system it retrieves from, leaving ambiguity.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. With siblings like 'get_resource' and 'get_credential', there's no indication of how this tool differs or when it's appropriate. The description lacks context about prerequisites or exclusions.

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

Related 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/api7/apisix-mcp'

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