A server that exposes a set of tools for interacting with Stack Overflow API. It provides functionality for searching questions, answers, tags, and retrieving detailed information from Stack Overflow.
Project description
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
Configure the following environment variables:
# Optional: Stack Exchange API key for higher rate limits
export STACK_EXCHANGE_API_KEY="your_api_key_here"
# Optional: Show detailed logs for debugging (default: false)
export STACK_OVERFLOW_MCP_SHOW_LOGS="false"
๐ก API Key: While optional, an API key significantly increases your rate limits from 300 to 10,000 requests per day.
Environment Variable Details
STACK_EXCHANGE_API_KEY(Optional): Your 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 for debugging and development
Claude Desktop Configuration
Add to your Claude Desktop claude_desktop_config.json:
{
"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"
},
"transport": "stdio"
}
}
}
Alternative Configurations
Using uv directly:
{
"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"
},
"transport": "stdio"
}
}
}
Local development:
{
"mcpServers": {
"stack-overflow": {
"command": "uv",
"args": ["run", "stack-overflow-mcp-light"],
"cwd": "/path/to/stack-overflow-mcp-light",
"env": {
"STACK_EXCHANGE_API_KEY": "your_api_key_here",
"STACK_OVERFLOW_MCP_SHOW_LOGS": "true"
},
"transport": "stdio"
}
}
}
๐ ๏ธ 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stack_overflow_mcp_light-1.1.0.tar.gz.
File metadata
- Download URL: stack_overflow_mcp_light-1.1.0.tar.gz
- Upload date:
- Size: 92.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c60bf60d005b172fd238af276b863d17a119904e15e1bbac0902e84e77b58761
|
|
| MD5 |
0b1c5cd3ca1260d63988a7a14c881526
|
|
| BLAKE2b-256 |
fe299aa32f96df48d19147f0d932637b0774b4b1bf0e5883fc938ac4eaefad9d
|
Provenance
The following attestation bundles were made for stack_overflow_mcp_light-1.1.0.tar.gz:
Publisher:
publish.yml on midodimori/stack-overflow-mcp-light
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stack_overflow_mcp_light-1.1.0.tar.gz -
Subject digest:
c60bf60d005b172fd238af276b863d17a119904e15e1bbac0902e84e77b58761 - Sigstore transparency entry: 556202257
- Sigstore integration time:
-
Permalink:
midodimori/stack-overflow-mcp-light@1bb047497bee1361f253f382efec2688b3d13a57 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/midodimori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bb047497bee1361f253f382efec2688b3d13a57 -
Trigger Event:
release
-
Statement type:
File details
Details for the file stack_overflow_mcp_light-1.1.0-py3-none-any.whl.
File metadata
- Download URL: stack_overflow_mcp_light-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dd38d8c3f2e4941c41ec9632f01d6a0487c79fb61b1c04f6fe7b59c82820919
|
|
| MD5 |
a8a03cf56f9e6ea85a4b23d36ac0b828
|
|
| BLAKE2b-256 |
7eba6608666ca1251284d476448ef28fbdd862b615ff756be52e510c37f30f64
|
Provenance
The following attestation bundles were made for stack_overflow_mcp_light-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on midodimori/stack-overflow-mcp-light
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stack_overflow_mcp_light-1.1.0-py3-none-any.whl -
Subject digest:
7dd38d8c3f2e4941c41ec9632f01d6a0487c79fb61b1c04f6fe7b59c82820919 - Sigstore transparency entry: 556202292
- Sigstore integration time:
-
Permalink:
midodimori/stack-overflow-mcp-light@1bb047497bee1361f253f382efec2688b3d13a57 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/midodimori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bb047497bee1361f253f382efec2688b3d13a57 -
Trigger Event:
release
-
Statement type: