Skip to main content
Glama

getUsers

Read-onlyIdempotent

Retrieve user lists from external APIs by configuring YAML files in the MCP ecosystem.

Instructions

Retrieve a list of users.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP callTool request handler that executes the 'getUsers' tool by finding its API configuration and invoking the ApiClient to perform the API call based on the tool name.
    const apiClient = new ApiClient();
    this.server.setRequestHandler(CallToolRequestSchema, async (request: any) => {
      
      const tool = this.tools.find(t => t.name === request.params.name)
      if (!tool) { throw new Error(`Tool ${request.params.name} not found`) }
    
      const apiConfig = this.apis.find((api: ApiConfig) => api.name === tool.name)
      if (!apiConfig) { throw new Error(`API configuration for tool ${tool.name} not found`)}
      
      const response = await apiClient.callApi(apiConfig, request.params.arguments);
      console.error("Response:", response);
      
      return {
        content: [
          {
            type: 'text',
            text: typeof response === 'string' ? response : JSON.stringify(response, null, 2),
          },
        ],
      };
    });
  • Builds the tool definitions including inputSchema for 'getUsers' from API config, with specific debug logging for this tool.
    export const buildToolsFromApiConfigArray = (apiConfigArray: any[]): any[] =>
      apiConfigArray.map((apiConfig: any) => {
        // Get parameters and query from a url like http://localhost:3000/users/{id}?page={page}&limit={limit}
        const parametersAndQuerys = getUrlParametersAndQuerys(apiConfig.url);
        const method = apiConfig.method?.toUpperCase();
        const body: ApiBodyProperty[] | undefined = apiConfig.options?.body;
        const schema = getBodyProperties(body);
    
        const properties  = { ...parametersAndQuerys, ...schema }
        if(apiConfig.name === 'getUsers' ) {
          // console.error('parametersAndQuerys', parametersAndQuerys)
          // console.error('schema', getPropertiesFromSchema(schema))
          console.error('parametersAndQuerys', parametersAndQuerys)
          console.error('body', body)
          console.error('properties', properties)
        }
    
        return {
          name: apiConfig.name,
          description: apiConfig.description,
          inputSchema: {
            type: "object",
            properties: properties,
            required: (body || []).filter((p: ApiBodyProperty) => p.required).map((p: ApiBodyProperty) => p.name),
          },
          annotations: {
            title: apiConfig.description,
            readOnlyHint: method === "GET",
            destructiveHint: method === "DELETE",
            idempotentHint: method === "GET" || method === "DELETE",
            openWorldHint: true,
          },
        };
  • src/lib/mcp.ts:35-38 (registration)
    Registers the listTools handler which exposes the 'getUsers' tool schema to MCP clients.
    private registerListToolsHandler() {
      this.server.setRequestHandler(ListToolsRequestSchema, async () => {
        return { tools: this.tools };
      });
  • Helper function that performs the actual API call for the 'getUsers' tool using fetch, interpolating parameters, handling body and headers from the apiConfig.
    async callApi(apiConfig: ApiConfig, args?: Record<string, any>): Promise<any> {
      const { url, method, options } = apiConfig;
    
      let endpoint = url;
      let headers: Record<string, string> = {};
      let body: Record<string, any> = {};
    
      // Interpolación de path & query params
      if (endpoint && args) {
        endpoint = endpoint.replace(/\{(\w+)\}/g, (_: string, key: string) => args[key] ?? `{${key}}`);
      }
    
      // Headers
      if (options?.headers) {
        for (const [k, v] of Object.entries(options.headers)) {
          headers[k] = String(v);
        }
      }
      // API Token
      if ('api-token' in apiConfig && apiConfig['api-token']) {
        headers['Authorization'] = `Bearer ${process.env.API_TOKEN || ''}`;
      }
    
      // Body
      if (options?.body) {
        for (const b of options.body) {
          if (args && args[b.name] !== undefined) {
            body[b.name] = args[b.name];
          } else if (b.default !== undefined) {
            body[b.name] = b.default;
          }
        }
      }
    
      const fetchOptions: RequestInit = {
        method: method,
        headers,
      };
      
      if (["POST", "PUT", "PATCH"].includes((method || '').toUpperCase())) {
        fetchOptions.body = JSON.stringify(body);
      }
    
      try {
        const response = await fetch(endpoint, fetchOptions);
        const contentType = response.headers.get('content-type') || '';
        if (contentType.includes('application/json')) {
          return await response.json();
        } else {
          return await response.text();
        }
      } catch (error: any) {
        return { error: error.message };
      }
    }
Behavior4/5

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

Annotations already provide strong behavioral hints (readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true), so the bar is lower. The description doesn't contradict these annotations, as 'Retrieve' aligns with read-only and non-destructive behavior. However, it adds minimal context beyond annotations—it doesn't specify if retrieval is paginated, sorted, or limited in scope, which could be useful for an agent. The description is consistent but adds limited behavioral detail.

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, clear sentence ('Retrieve a list of users.') that efficiently states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse. There's no wasted text, and it earns its place by providing the essential information in a minimal format.

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?

Given the tool's simplicity (0 parameters, no output schema) and rich annotations, the description is adequate but incomplete. It covers the basic purpose but lacks context about sibling tools, return format (e.g., list structure, fields), or any limitations (e.g., pagination). For a retrieval tool with no output schema, more detail on what 'list of users' entails would be helpful, though annotations provide safety assurances.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, but it implicitly suggests no filtering or customization is required for this retrieval. This aligns with the schema, and with 0 parameters, a baseline of 4 is appropriate as the description doesn't mislead about inputs.

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 'Retrieve a list of users' clearly states the verb ('Retrieve') and resource ('users'), making the basic purpose understandable. However, it doesn't distinguish this tool from its siblings like 'getUsersWithQueryParameters' or 'getUserWithPathParameters', leaving ambiguity about when to use this specific retrieval method versus others. The purpose is clear but lacks sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'getUsersWithQueryParameters' and 'getUserWithPathParameters', it's unclear if this tool retrieves all users by default, uses a specific filtering method, or serves a different purpose. There's no mention of prerequisites, exclusions, or comparative context, leaving usage decisions ambiguous.

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/molavec/mcp-yaml-api'

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