Skip to main content
Glama

second_opinion

Analyzes user requests with an LLM to identify critical considerations and provide alternative perspectives for improved decision-making.

Instructions

Provides a second opinion on a user's request by analyzing it with an LLM and listing critical considerations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_requestYesThe user's original request (e.g., 'Explain Python to me' or 'Build a login system')

Implementation Reference

  • The main handler function implementing the core logic: rate limiting, input validation, prompt creation, Deepseek API call, and response handling with optional reasoning.
    export async function handler(args: unknown) {
      // Check rate limit first
      if (!checkRateLimit()) {
        return {
          content: [
            {
              type: 'text',
              text: 'Rate limit exceeded. Please try again later.',
            },
          ],
          isError: true,
        };
      }
    
      try {
        // Type guard for SecondOpinionArgs
        if (!args || typeof args !== 'object' || !('user_request' in args) || 
            typeof args.user_request !== 'string') {
          return {
            content: [
              {
                type: 'text',
                text: 'Missing or invalid user_request parameter.',
              },
            ],
            isError: true,
          };
        }
    
        const typedArgs = args as SecondOpinionArgs;
    
        // Create the complete prompt
        const prompt = createPrompt(PROMPT_TEMPLATE, {
          user_request: typedArgs.user_request
        });
    
        // Make the API call
        const response = await makeDeepseekAPICall(prompt, SYSTEM_PROMPT);
    
        if (response.isError) {
          return {
            content: [
              {
                type: 'text',
                text: `Error generating second opinion: ${response.errorMessage || 'Unknown error'}`,
              },
            ],
            isError: true,
          };
        }
    
        // Return both the reasoning and the final response
        return {
          content: [
            {
              type: 'text',
              text: response.text,
            },
          ],
          // Include the Chain of Thought reasoning if available
          ...(response.reasoning ? {
            reasoning: [
              {
                type: 'text',
                text: `<reasoning>\n${response.reasoning}\n</reasoning>`,
              },
            ],
          } : {}),
        };
      } catch (error) {
        console.error('Second opinion tool error:', error);
        return {
          content: [
            {
              type: 'text',
              text: `Error processing request: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
          isError: true,
        };
      }
  • ToolDefinition object defining the tool's name, description, and input schema for MCP validation.
    export const definition: ToolDefinition = {
      name: 'second_opinion',
      description: 'Provides a second opinion on a user\'s request by analyzing it with an LLM and listing critical considerations.',
      inputSchema: {
        type: 'object',
        properties: {
          user_request: {
            type: 'string',
            description: 'The user\'s original request (e.g., \'Explain Python to me\' or \'Build a login system\')',
          },
        },
        required: ['user_request'],
      },
    };
  • TypeScript interface for input arguments used in type guarding within the handler.
    export interface SecondOpinionArgs {
      user_request: string;
    }
  • src/server.ts:56-64 (registration)
    Registration of the second_opinion.definition in the MCP server's list of available tools.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        secondOpinion.definition,
        codeReview.definition,
        designCritique.definition,
        writingFeedback.definition,
        brainstormEnhancements.definition,
      ],
    }));
  • src/server.ts:81-89 (registration)
    Switch case dispatching calls to 'second_opinion' tool to the imported handler function with input validation.
    case "second_opinion": {
      if (!args || !('user_request' in args) || typeof args.user_request !== 'string') {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Missing required parameter: user_request"
        );
      }
      response = await secondOpinion.handler({ user_request: args.user_request });
      break;

Tool Definition Quality

Score is being calculated. Check back soon.

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/cyanheads/mentor-mcp-server'

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