Qvakk/stackoverflow-mcp
If you are the rightful owner of stackoverflow-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Stack Overflow MCP Server is a modular server designed to facilitate AI assistants in accessing Stack Overflow content for technical solutions, error handling, and programming knowledge.
Stack Overflow MCP Server
A modular Model Context Protocol (MCP) server that enables AI assistants to search and access Stack Overflow content for technical solutions, error handling, and programming knowledge.
Features
- 🔍 Multiple Search Methods: Search by query, error message, or specific question ID
- 📊 Advanced Filtering: Filter results by tags, score, and accepted answers
- 🧩 Error Analysis: Parse error messages and find relevant solutions
- 📝 Flexible Formatting: Get results in Markdown or JSON format
- 💬 Comments Support: Optionally include question and answer comments
- ⚡ Rate Limiting: Built-in protection to respect Stack Exchange API quotas
- 🏗️ Modular Architecture: Clean separation of concerns for easy maintenance
Prerequisites
- Python 3.12+
- uv (recommended) or pip
- Stack Exchange API key (see below)
Getting a Stack Exchange API Key
- Go to Stack Apps OAuth Registration
- Fill out the form:
- Name: "Stack Overflow MCP" (or your preferred name)
- Description: "MCP server for accessing Stack Overflow"
- OAuth Domain: "localhost" (for local usage)
- Submit and copy your API Key
Installation
Using uv (recommended)
# Clone the repository
git clone <your-repo-url>
cd stackoverflow-mcp
# Install dependencies
uv pip install -e .
# For development
uv pip install -e ".[dev]"
Using pip
pip install -e .
# For development
pip install -e ".[dev]"
Configuration
Environment Variables
Create a .env file in the project root:
cp .env.example .env
Edit .env with your configuration:
# Required
STACK_EXCHANGE_API_KEY=your_api_key_here
# Optional: Rate limiting (defaults shown)
MAX_REQUEST_PER_WINDOW=30
RATE_LIMIT_WINDOW_MS=60000
RETRY_AFTER_MS=2000
Usage
Running the Server Locally
# Using uv
uv run main.py
# Using python
python main.py
Running with Docker
# Build the Docker image
docker-compose build
# Run the server
docker-compose run --rm stackoverflow-mcp
Adding to VS Code MCP
Add to your User mcp.json file (File > Preferences > Settings > search for "mcp" > Edit in settings.json):
Using Docker (recommended):
"stackoverflow-mcp": {
"type": "stdio",
"command": "docker",
"args": [
"compose",
"-f",
"C:/Users/YourUser/path/to/stackoverflow-mcp/docker-compose.yml",
"run",
"--rm",
"-T",
"stackoverflow-mcp"
],
"env": {
"STACK_EXCHANGE_API_KEY": "your_api_key_here"
}
}
Without Docker:
"stackoverflow-mcp": {
"type": "stdio",
"command": "python",
"args": ["C:/Users/YourUser/path/to/stackoverflow-mcp/main.py"],
"env": {
"STACK_EXCHANGE_API_KEY": "your_api_key_here"
}
}
Available Tools
1. search_by_query
Advanced search with comprehensive filtering options.
Parameters:
query(required): Search query stringtags: Filter by tags (e.g.,["python", "pandas"])- ⚠️ Note: Invalid tags are automatically detected and removed. The search continues with only valid tags and displays which tags were removed.
- ℹ️ Note: If no results are found with tags, the search automatically retries without tag filtering to find relevant content.
excluded_tags: Exclude specific tagsmin_score: Minimum score threshold (default: 0)has_accepted_answer: Require accepted answer (default: false)title: Text that must appear in titlebody: Text that must appear in bodymin_answers: Minimum number of answerssort_by: Sort byactivity,creation,votes, orrelevance(default: "relevance")include_comments: Include comments (default: false)response_format:"json"or"markdown"(default: "markdown")limit: Max results (default: 10)
2. search_by_error
Parse error messages and find solutions.
Parameters:
error_message(required): Error message or stack tracelanguage: Programming language (e.g., "python", "javascript")technologies: Related technologies (e.g.,["react", "django"])min_score: Minimum score threshold (default: 1)include_comments: Include comments (default: false)response_format:"json"or"markdown"(default: "markdown")limit: Max results (default: 5)
3. get_question
Fetch specific question with all answers by ID.
Parameters:
question_id(required): Stack Overflow question IDinclude_comments: Include comments (default: false)response_format:"json"or"markdown"(default: "markdown")