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.
- 🔍 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
- Python 3.12+
- uv (recommended) or pip
- Stack Exchange API key (see below)
- 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
# Clone the repository
git clone <your-repo-url>
cd stackoverflow-mcp
# Install dependencies
uv pip install -e .
# For development
uv pip install -e ".[dev]"pip install -e .
# For development
pip install -e ".[dev]"Create a .env file in the project root:
cp .env.example .envEdit .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# Using uv
uv run main.py
# Using python
python main.py# Build the Docker image
docker-compose build
# Run the server
docker-compose run --rm stackoverflow-mcpAdd 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"
}
}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)
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)
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")