stack-overflow-mcp-light
MCP server for searching Stack Overflow questions and retrieving answers with body content, supporting advanced filters and multiple transport types.
README
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
📦 Installation
Using uvx (Recommended)
uvx stack-overflow-mcp-light
Using uv
uv add stack-overflow-mcp-light
uv run stack-overflow-mcp-light
Using 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.0
Client 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.0
Client 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_size - 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
🧪 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 help
Project 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
- Stack Overflow
- Stack Exchange API Documentation
- Stack Apps - API Key Registration
- Model Context Protocol
- FastMCP Framework
- Claude Desktop
📞 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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。