CS

ccc0168/second-opinion-mcp-server

API 开发

本页由 AI 翻译,技术细节请以原文为准。 查看原文

1 stars 7 forks 质量 52 趋势 5

An MCP server that provides AI-powered assistance for coding problems by combining insights from: - Google's Gemini AI - Stack Overflow accepted answers - Perplexity AI analysis

概览

An MCP server that provides AI-powered assistance for coding problems by combining insights from: - Google's Gemini AI - Stack Overflow accepted answers - Perplexity AI analysis - Get detailed solutions for coding problems with context from multiple sources - Automatic language detection from file extensions - Code snippet extraction and formatting - Markdown report generation for solutions - Git-aware file context gathering 3. Configure environment variables in MCP settings: Required environment variables: - GEMINI_API_KEY: Google's Gemini AI API key - PERPLEXITY_API_KEY: Perplexity AI API key - STACK_EXCHANGE_KEY: Stack Exchange API key (optional, uses anonymous access if not provided) Get AI-powered insights and solutions for coding problems. The core issue lies in how React's useEffect hook manages side effects and their dependencies.

README

以下为原文 README 节选,完整内容请查看原文。

Second Opinion MCP Server

An MCP server that provides AI-powered assistance for coding problems by combining insights from:

  • Google’s Gemini AI
  • Stack Overflow accepted answers
  • Perplexity AI analysis

Features

  • Get detailed solutions for coding problems with context from multiple sources
  • Automatic language detection from file extensions
  • Code snippet extraction and formatting
  • Markdown report generation for solutions
  • Git-aware file context gathering

Setup

  1. Install dependencies:
npm install
  1. Build the server:
npm run build
  1. Configure environment variables in MCP settings:
{
  "mcpServers": {
    "second-opinion": {
      "command": "node",
      "args": ["/path/to/second-opinion-server/build/index.js"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key",
        "PERPLEXITY_API_KEY": "your-perplexity-api-key",
        "STACK_EXCHANGE_KEY": "your-stack-exchange-key"
      }
    }
  }
}

Required environment variables:

  • GEMINI_API_KEY: Google’s Gemini AI API key
  • PERPLEXITY_API_KEY: Perplexity AI API key
  • STACK_EXCHANGE_KEY: Stack Exchange API key (optional, uses anonymous access if not provided)

Usage

The server provides a single tool:

get_second_opinion

Get AI-powered insights and solutions for coding problems.

Input Schema:

{
  "goal": "string (required) - What you're trying to accomplish",
  "error": "string (optional) - Any error messages you're seeing",
  "code": "string (optional) - Relevant code context",
  "solutionsTried": "string (optional) - What solutions you've already tried",
  "filePath": "string (optional) - Path to the file with the issue"
}

Example Input:

{
  "goal": "Fix React useEffect cleanup error",
  "error": "React Hook useEffect has a missing dependency: 'socket'. Either include it in the dependency array, or remove the dependency array  react-hooks/exhaustive-deps",
  "code": "useEffect(() => {\n  socket.on('message', handleMessage);\n  return () => socket.off('message');\n}, []);",
  "solutionsTried": "I tried adding socket to the dependency array but then it causes infinite re-renders"
}

Example Response:

Understanding the Problem

The core issue lies in how React’s useEffect hook manages side effects and their dependencies. When you provide an empty dependency array ([]), you’re telling React that the effect should only run once when the component mounts and that the cleanup function should run when the component unmounts.

However, in your code, the socket object is used within the effect. This creates a closure where the handleMessage function and the cleanup function (socket.off('message')) implicitly depend on the current value of socket. If socket ever changes (e.g., due to a reconnection or reinitialization), your effect will be using an outdated socket instance.

Common Issues

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "second-opinion": { "command": "node", "args": ["/path/to/second-opinion-server/build/index.js"], "env": { "GEMINI_API_KEY": "your-gemini-api-key", "PERPLEXITY_API_KEY": "your-perplexity-api-key", "STACK_EXCHANGE_KEY": "your-stack-exchange-key" } } } }