Skip to main content
Glama

getUserWithPathParameters

Read-onlyIdempotent

Retrieve user data by specifying a user ID through path parameters. This tool enables API integration without coding by fetching user information from external sources.

Instructions

Retrieve a user by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo

Implementation Reference

  • The call tool handler that executes any tool, including 'getUserWithPathParameters'. It matches the tool name to an API config and invokes the API client with the provided arguments.
      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),
            },
          ],
        };
      });
    }
  • Generates input schemas for all tools by parsing URL path/query parameters and body properties from the API configuration. Used to create the tool definition for 'getUserWithPathParameters'.
    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-39 (registration)
    Registers the listTools handler, which returns the list of available tools including 'getUserWithPathParameters'.
    private registerListToolsHandler() {
      this.server.setRequestHandler(ListToolsRequestSchema, async () => {
        return { tools: this.tools };
      });
    }
  • src/lib/mcp.ts:21-33 (registration)
    In the McpServer constructor, builds the tools array from API configs (including schema and name for getUserWithPathParameters) and sets up the MCP server with tools capability, registering handlers.
      this.tools = buildToolsFromApiConfigArray(this.apis);
      this.server = new Server({
        name: this.metadata.name || 'mcp-yaml-api',
        description: this.metadata.description || 'MCP Yaml API',
        version: this.metadata.version || '1.0.0'
      }, {
        capabilities: {
          tools: {}
        }
      });
      this.registerListToolsHandler();
      this.registerCallToolHandler();
    }
  • The API client that performs the actual HTTP request for the tool, handling path parameter replacement, body construction, headers, etc. Invoked by the tool handler for 'getUserWithPathParameters'.
    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 };
      }
    }
Behavior3/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, openWorldHint=true, and idempotentHint=true, covering safety and idempotency. The description adds no behavioral context beyond what annotations declare, such as authentication needs, rate limits, or error handling. However, it doesn't contradict annotations, so it meets the baseline for annotations-heavy tools.

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 with zero waste—'Retrieve a user by ID' is front-loaded and appropriately sized for a simple tool. Every word serves a purpose, making it highly concise and well-structured.

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 low complexity (1 parameter, no output schema) and rich annotations (covering safety and idempotency), the description is minimally adequate. It states the purpose but lacks usage guidelines, detailed parameter info, or output expectations, leaving gaps that could hinder agent selection in a multi-tool context.

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 input schema has 1 parameter with 0% description coverage, but the description implies the 'id' parameter is for user identification. It doesn't specify format (e.g., UUID, numeric) or constraints. Since schema coverage is low, the description partially compensates but lacks detailed semantics, aligning with the baseline for minimal param info.

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

Purpose4/5

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

The description 'Retrieve a user by ID' clearly states the verb (retrieve) and resource (user), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'getUsers' or 'getUsersWithQueryParameters', which also retrieve users but with different approaches (list vs single, path vs query parameters).

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. It doesn't mention that this is for retrieving a single user by ID (vs 'getUsers' for listing multiple users or 'getUsersWithQueryParameters' for query-based retrieval), nor does it specify any prerequisites or exclusions for usage.

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