stack-overflow-mcp-light
Provides tools for accessing Stack Exchange network data, including questions and answers, via the Stack Exchange API.
Provides tools for searching questions, fetching answers, and exploring content on Stack Overflow through the Stack Exchange API.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@stack-overflow-mcp-light search for Python async await examples"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Stack Overflow MCP Server
A Model Context Protocol (MCP) server that provides comprehensive tools for interacting with Stack Overflow through the Stack Exchange API. This server enables AI assistants to search questions, get detailed answers, and explore Stack Overflow content through a standardized interface.
๐ Features
Question Search - Advanced search with multiple filters and sorting options
Question Details - Get comprehensive information including answers with body content
Tag-based Search - Find questions by specific tags
Top Answers - Retrieve highly-voted answers from the community
Type Safety - Full Pydantic validation with structured response models
Error Handling - Comprehensive error reporting and graceful failure modes
Related MCP server: evo-scry
๐ฆ Installation
Using uvx (Recommended)
uvx stack-overflow-mcp-lightUsing uv
uv add stack-overflow-mcp-light
uv run stack-overflow-mcp-lightUsing pip
pip install stack-overflow-mcp-light
stack-overflow-mcp-lightโ๏ธ Configuration
Environment Variables
STACK_EXCHANGE_API_KEY(Optional): Stack Exchange API key for increased rate limits. Get one at Stack AppsSTACK_OVERFLOW_MCP_SHOW_LOGS(Optional): Set to"true"to enable detailed logging
๐ก API Key: While optional, an API key significantly increases your rate limits from 300 to 10,000 requests per day.
Transport Types
stdio(default) - Standard input/output, client launches server automaticallyhttp(recommended for remote) - Modern HTTP transport (aliases:streamable-http,streamable_http)sse(legacy) - Server-Sent Events transport (deprecated)
๐ Quick Start (uvx)
Stdio Transport
{
"mcpServers": {
"stack-overflow": {
"command": "uvx",
"args": ["--no-progress", "stack-overflow-mcp-light"],
"env": {
"STACK_EXCHANGE_API_KEY": "your_api_key_here",
"STACK_OVERFLOW_MCP_SHOW_LOGS": "false"
}
}
}
}HTTP Transport
Start server:
export STACK_EXCHANGE_API_KEY="your_api_key_here"
uvx --no-progress stack-overflow-mcp-light --transport http --port 8000 --host 0.0.0.0Client config:
{
"mcpServers": {
"stack-overflow": {
"url": "http://localhost:8000/mcp",
"transport": "http"
}
}
}SSE Transport
Start server:
export STACK_EXCHANGE_API_KEY="your_api_key_here"
uvx --no-progress stack-overflow-mcp-light --transport sse --port 8000 --host 0.0.0.0Client config:
{
"mcpServers": {
"stack-overflow": {
"url": "http://localhost:8000/sse",
"transport": "sse"
}
}
}๐ง Alternative Commands
Stdio with uv run --with
{
"mcpServers": {
"stack-overflow": {
"command": "uv",
"args": ["run", "--with", "stack-overflow-mcp-light", "stack-overflow-mcp-light"],
"env": {
"STACK_EXCHANGE_API_KEY": "your_api_key_here",
"STACK_OVERFLOW_MCP_SHOW_LOGS": "false"
}
}
}
}Stdio with uv run --directory (Local Development)
{
"mcpServers": {
"stack-overflow": {
"command": "uv",
"args": ["run", "--directory", "/path/to/stack-overflow-mcp-light", "stack-overflow-mcp-light"],
"env": {
"STACK_EXCHANGE_API_KEY": "your_api_key_here",
"STACK_OVERFLOW_MCP_SHOW_LOGS": "true"
}
}
}
}Stdio with pip Install
{
"mcpServers": {
"stack-overflow": {
"command": "stack-overflow-mcp-light",
"args": [],
"env": {
"STACK_EXCHANGE_API_KEY": "your_api_key_here",
"STACK_OVERFLOW_MCP_SHOW_LOGS": "false"
}
}
}
}HTTP/SSE Alternative Commands
All transport types can use these alternative commands:
# Using uv run --with
export STACK_EXCHANGE_API_KEY="your_api_key_here"
uv run --with stack-overflow-mcp-light stack-overflow-mcp-light --transport http --port 8000
# Using uv run --directory (local development)
export STACK_EXCHANGE_API_KEY="your_api_key_here"
cd /path/to/stack-overflow-mcp-light
uv run stack-overflow-mcp-light --transport http --port 8000
# Using pip install
export STACK_EXCHANGE_API_KEY="your_api_key_here"
stack-overflow-mcp-light --transport http --port 8000๐ ๏ธ Available Tools
โ Question Tools (3 tools)
search_questions
Search Stack Overflow questions with advanced filters.
Input: Search parameters including:
q- Free-form text searchtagged- Semi-colon delimited list of tagsintitle- Search in question titlesnottagged- Exclude these tagsbody- Text in question bodyaccepted- Has accepted answer (boolean)closed- Question is closed (boolean)answers- Minimum number of answersviews- Minimum view countsort- Sort criteria ("activity", "votes", "creation", "hot", "week", "month", "relevance")order- Sort order ("asc" or "desc")page- Page number (1-25)page_size- Items per page (1-100)
Output: Array of question items with essential fields:
question_id- Question IDis_answered- Whether the question has answersscore- Question scorelink- Link to the questiontitle- Question title
fetch_question_answers
Fetch a specific question, always including answers with body content sorted by the specified criteria.
Input: Question details request including:
question_id- Question ID (required)sort- Answer sort criteria ("activity", "votes", "creation") - defaults to "votes"order- Sort order ("asc" or "desc") - defaults to "desc"page_size- Maximum number of answers to return (1-100) - defaults to 30
Output: QuestionItem with detailed information including:
question_id- Question IDis_answered- Whether the question has answersscore- Question scorelink- Link to the questiontitle- Question titleanswers- Array of AnswerItem objects with:answer_id- Answer IDis_accepted- Whether the answer is acceptedscore- Answer scorebody- Answer body content
search_questions_by_tag
Search questions that have a specific tag.
Input:
tag(tag name),sort,order,page,page_sizeOutput: Array of question items with essential fields:
question_id- Question IDis_answered- Whether the question has answersscore- Question scorelink- Link to the questiontitle- Question title
๐งช Testing
The project includes comprehensive tests covering all tools:
# Run all tests
make test
# Run with coverage
make test-cov
# Run specific test categories
uv run pytest tests/test_server.py::TestQuestionTools -v๐ง Development
Setup Development Environment
# Clone the repository
git clone https://github.com/midodimori/stack-overflow-mcp-light.git
cd stack-overflow-mcp-light
# Install with development dependencies
make install-dev
# Run tests
make test
# Format and lint code
make format
# Check code style and types
make lint
# Run the server locally
make run
# See all available commands
make helpProject Structure
stack-overflow-mcp-light/
โโโ src/stack_overflow_mcp_light/
โ โโโ __init__.py
โ โโโ server.py # MCP server implementation
โ โโโ logging_config.py # Logging configuration
โ โโโ models/ # Pydantic models
โ โ โโโ __init__.py
โ โ โโโ requests.py # Request models
โ โ โโโ responses.py # Response models
โ โโโ tools/ # Tool implementations
โ โโโ __init__.py
โ โโโ base_client.py # Base client for Stack Exchange API
โ โโโ questions.py # Question search and retrieval tools
โโโ tests/
โ โโโ test_server.py # Tool function tests
โ โโโ test_mcp_integration.py # MCP integration tests
โโโ pyproject.toml # Project configuration
โโโ README.md๐ API Reference
Question Sort Options
activity: Sort by last activity date (default)
votes: Sort by question score
creation: Sort by creation date
hot: Sort by current hotness
week: Sort by weekly activity
month: Sort by monthly activity
relevance: Sort by search relevance
Answer Sort Options
activity: Sort by last activity date (default)
votes: Sort by answer score
creation: Sort by creation date
Sort Order
desc: Descending order (default)
asc: Ascending order
๐ค Contributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
โ ๏ธ Disclaimer
This software is provided for educational and informational purposes only. This tool interacts with Stack Overflow's public API and respects their rate limits and terms of service. The authors are not responsible for any misuse of the Stack Exchange API or violation of their terms of service.
๐ Links
๐ Support
For questions, issues, or contributions:
Open an issue on GitHub
Check the Stack Overflow Meta for API-related questions
Review the comprehensive test suite for usage examples
Available Tools
3 toolsfetch_question_answersA
Fetch specific Stack Overflow question with its answers.
Args: request: Question details request with ID and answer sorting options
Returns: Question item with detailed information including answers sorted by the specified criteria with body content
Inputs: request (required). Returns: Model for a question item.
search_questionsC
Search Stack Overflow questions using advanced filters.
Args: request: Question search request with filters and pagination
Returns: List of question items
Inputs: request (required). Returns: result
search_questions_by_tagA
Search Stack Overflow questions that have a specific tag.
Args: request: Request with tag name, sort options, and pagination
Returns: List of question items with the specified tag
Inputs: request (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 3 tools
search_questions and search_questions_by_tag overlap because search_questions accepts advanced filters that likely include tag filtering, making the distinction unclear. fetch_question_answers is clearly distinct, retrieving a specific question with answers, but the two search tools create ambiguity.
All tool names follow a consistent verb_noun pattern: search_questions, search_questions_by_tag, and fetch_question_answers. The 'by_tag' modifier is a clear exception for the second search tool but still follows the same convention, making the naming predictable and uniform.
With 3 tools, the set is on the lean side but appropriate for a 'light' Stack Overflow read-only server. Each tool serves a core purpose without redundancy, and the count is reasonable for the intended narrow scope.
The server covers essential read operations: searching questions generically and by tag, and fetching a question with answers. Missing operations like user lookups or comment retrieval are not critical for a lightweight server, but the surface is slightly thin for full Stack Overflow coverage.
Maintenance
Related MCP Connectors
An MCP server that provides congressional transcripts
MCP server for searching Airweave collections with natural language queries.
MCP server for querying Forkast documentation
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides seamless access to StackOverflow's Q\&A database through MCP, enabling advanced search, question/answer retrieval, and rate-limit management.564 npm2MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for internet search via direct Google and DuckDuckGo HTML scraping with AI-powered result normalization and optional summarization, requiring no API keys for search.MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that aggregates web search results from multiple engines and optionally renders pages to Markdown, providing a unified search interface.6 npm3ISC
- AlicenseAqualityDmaintenanceMCP server for Metaso Search API, providing multi-scope search and webpage reading tools.213 npm2Apache 2.0