Skip to main content
Glama

process-request

Process natural language requests by identifying the best tool through semantic matching and fallbacks, then confirm or execute the tool directly to streamline task handling in software development.

Instructions

Processes natural language requests, determines the best tool using semantic matching and fallbacks, and either asks for confirmation or executes the tool directly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYesNatural language request to process and route to the appropriate tool

Implementation Reference

  • The main executor/handler function for the 'process-request' tool. It processes the natural language request using hybrid matching, decides if confirmation is needed, and either prompts for confirmation or executes the matched tool directly via the tool registry.
    export const processUserRequest: ToolExecutor = async (
      params: Record<string, unknown>, // Use unknown instead of any for better type safety
      config: OpenRouterConfig,
      context?: ToolExecutionContext // Add context parameter
    ): Promise<CallToolResult> => {
      const request = params.request as string; // Assert type after validation
      let matchResult: EnhancedMatchResult; // Use the enhanced type
    
      try {
        logger.info(`Processing request: "${request.substring(0, 50)}..."`);
        // Step 1: Use the hybrid matcher to determine the appropriate tool
        matchResult = await hybridMatch(request, config);
    
        // Step 2: Check if confirmation is needed (unless force flag is set)
        const forceExecution = (context?.metadata as { forceExecution?: boolean })?.forceExecution === true;
        if (matchResult.requiresConfirmation && !forceExecution) {
          logger.info(`Tool execution requires confirmation: ${matchResult.toolName}`);
          const explanation = getMatchExplanation(matchResult);
          return {
            content: [{
              type: "text",
              // Provide a clear confirmation prompt to the user
              text: `I plan to use the '${matchResult.toolName}' tool for your request.\nExplanation: ${explanation}\nConfidence: ${Math.round(matchResult.confidence * 100)}%\n\nDo you want to proceed?`
            }],
            isError: false // Not an error, just needs confirmation
          };
        }
    
        // Step 3: No confirmation needed, execute the determined tool directly
        logger.info(`Executing tool '${matchResult.toolName}' directly based on processed request (Confidence: ${matchResult.confidence.toFixed(3)}).`);
        const toolResult = await executeTool(
          matchResult.toolName,
          matchResult.parameters, // Use parameters determined by hybridMatch
          config,
          context // Pass context down to executeTool
        );
    
        // Step 4: Combine explanation with the actual tool result
        const explanation = getMatchExplanation(matchResult); // Get explanation again for the final message
        return {
          content: [
            {
              type: "text",
              text: `Using ${matchResult.toolName}:\n${explanation}\n\n---\n\n`
            },
            // Spread the content from the actual tool result, handling potential null/undefined content
            ...(toolResult.content || [{ type: 'text', text: '(Tool executed successfully but returned no content)' }])
          ],
          isError: toolResult.isError ?? false // Propagate error status, default to false
        };
    
      } catch (error) {
        logger.error({ err: error, request }, "Error processing user request");
        // Return an error result
        return {
          content: [
            {
              type: "text",
              text: `Error processing request: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }; // End of processUserRequest executor
  • Zod input schema shape for the 'process-request' tool, defining the 'request' parameter.
    const processRequestInputSchemaShape = {
      request: z.string().min(3, { message: "Request must be at least 3 characters." }).describe("Natural language request to process and route to the appropriate tool")
    };
  • Tool definition object and registration call to the central tool registry using registerTool.
    const processRequestToolDefinition: ToolDefinition = {
      name: "process-request",
      description: "Processes natural language requests, determines the best tool using semantic matching and fallbacks, and either asks for confirmation or executes the tool directly.", // Updated description
      inputSchema: processRequestInputSchemaShape, // Use the raw shape
      executor: processUserRequest // Reference the adapted function
    };
    
    // Register the tool with the central registry
    registerTool(processRequestToolDefinition);
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: semantic matching with fallbacks, and conditional execution (confirmation or direct execution). However, it doesn't cover aspects like error handling, performance characteristics, rate limits, or authentication needs. For a routing tool with no annotation coverage, this provides basic but incomplete behavioral 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 a single, well-structured sentence that efficiently conveys the tool's purpose, mechanism, and outcome. It is front-loaded with the core function and avoids unnecessary details, making every word earn its place.

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 complexity (routing with semantic matching) and lack of annotations or output schema, the description is moderately complete. It explains the core behavior but omits details like return values, error cases, or integration with sibling tools. For a routing tool without structured output documentation, it should provide more context on what happens after processing.

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%, with the single parameter 'request' documented as 'Natural language request to process and route to the appropriate tool'. The description adds no additional parameter semantics beyond what the schema provides, such as examples or format details. With high schema coverage, the baseline score of 3 is appropriate.

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 clearly states the tool's function: 'Processes natural language requests, determines the best tool using semantic matching and fallbacks, and either asks for confirmation or executes the tool directly.' This specifies the verb ('processes'), resource ('natural language requests'), and core mechanism ('semantic matching and fallbacks'). However, it doesn't explicitly differentiate from sibling tools like 'analyze-dependencies' or 'generate-prd', which appear to be specialized generators rather than request routers.

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 usage context: it's for processing natural language requests to route to tools. However, it doesn't explicitly state when to use this tool versus alternatives (e.g., direct tool invocation or other routing mechanisms) or provide exclusions. The context is clear but lacks explicit guidance on alternatives or prerequisites.

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/freshtechbro/vibe-coder-mcp'

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