StackOverflow MCP server for querying programming Q&A using FastMCP framework
Project description
StackOverflow MCP Server
A Model Context Protocol (MCP) server that provides seamless access to StackOverflow's programming Q&A database using the FastMCP framework.
Quick Start
Using with Cursor (Recommended)
Add this configuration to your Cursor MCP settings:
{
"mcp_servers": {
"stackoverflow": {
"command": "npx",
"args": [
"-y",
"@notalk-tech/stackoverflow-mcp",
"--api-key", "your_stackoverflow_api_key"
]
}
}
}
Using NPX
# Run directly (no installation required)
npx @notalk-tech/stackoverflow-mcp
# With API key
npx @notalk-tech/stackoverflow-mcp --api-key your_key
# Skip installation prompts
npx -y @notalk-tech/stackoverflow-mcp
Using Python Module
# Direct execution
python -m stackoverflow_mcp
# With uv (recommended)
uv run python -m stackoverflow_mcp --api-key your_key
๐ฏ Features
- ๐ Advanced Search: Search by keywords, tags, accepted status, score threshold, and date ranges
- ๐ Question Details: Get detailed content with automatic HTML-to-Markdown conversion
- ๐ท๏ธ Tag-based Search: Convenient tag-only search (proxies to main search)
- ๐ก Related Questions: Discover related and linked questions for deeper exploration
- โก Rate Limit Management: Intelligent retry, backoff, and auto-switching between authenticated/unauthenticated access
- ๐ API Authentication: Full support for StackOverflow API keys with automatic quota tracking
- ๐ฆ Unified Response Format: All tools return consistent
{success, data, meta}structure - ๐ Auto-deployment: NPX-compatible with automatic Python environment setup
๐ Getting Your API Key
To use this MCP server with higher rate limits, you'll need a StackOverflow API key:
Steps
-
Register Your Application
- Visit https://stackapps.com/applications/register
- Log in with your Stack Exchange account
- Fill in application details (name, description, OAuth domain)
- Submit the registration
-
Generate Your API Key
- Go to your application management page
- Click "Generate a new API key"
- Copy and save the generated key securely
Rate Limits
- Without API key: 300 requests/day per IP
- With API key: 10,000 requests/day
For read-only operations (searching and retrieving Q&A), a simple API key is sufficient. OAuth is only needed for write operations.
Learn more: https://api.stackexchange.com/docs/authentication
โ๏ธ Configuration
Create a .stackoverflow-mcp.json file in your working directory:
{
"stackoverflow_api_key": "your_api_key_here",
"log_level": "CRITICAL"
}
The server auto-discovers config files in this order:
.stackoverflow-mcp.jsonstackoverflow-mcp.config.jsonconfig/stackoverflow-mcp.json.config/stackoverflow-mcp.json
Command Line Options
--working-dir DIRECTORY Working directory (auto-detect if not specified)
--api-key TEXT StackOverflow API key
--version Show version and exit
--help Show help message
๐ Available Tools
Once running, the MCP server provides these tools:
search_questions: Search StackOverflow questions by keywords with optional filters โtags,accepted_only,min_score,from_date,to_datesearch_by_tags: Convenience wrapper for tag-only search (proxies tosearch_questions)get_question: Get detailed question content with optional answer limiting (max_answers) and automatic HTML-to-Markdown conversionget_answers: Fetch answers independently without re-fetching the question bodyget_related: Discover related and linked questions for further exploration
Resource
stackoverflow://status: Server status including version, authentication state, rate limit status, and queue statistics
๐ Prerequisites
- Node.js 14.0.0 or higher
- Python 3.12 or higher
- uv (recommended) or pip
The NPX wrapper automatically handles Python package installation and environment setup.
๐ Development
Local Setup
git clone https://github.com/NoTalkTech/stackoverflow-mcp.git
cd stackoverflow-mcp
# Install dependencies
npm install
pip install -e .
# Run in development mode
npm start
Project Structure
stackoverflow-mcp/
โโโ cli.js # NPX wrapper (Node.js)
โโโ package.json # NPM package configuration
โโโ pyproject.toml # Python package configuration
โโโ src/stackoverflow_mcp/ # Python MCP server
โ โโโ __main__.py # Python module entry point
โ โโโ main.py # CLI and server management
โ โโโ server.py # MCP server implementation (5 tools + resource)
โ โโโ config.py # Server configuration management
โ โโโ logging.py # Logging configuration
โ โโโ stackoverflow_client.py # StackOverflow API client (rate limiting, caching, content formatting)
โโโ tests/ # Test files
Testing
# Run all tests
.venv/bin/python -m pytest tests/ -v
# Test npm package
npm test
๐ค 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.
๐ Support
- Issues: GitHub Issues
- Documentation: GitHub README
๐ Acknowledgments
- Model Context Protocol for the MCP specification
- StackOverflow for providing the API
- The open-source community for inspiration and contributions
Made for the developer community
Project details
Release history Release notifications | RSS feed
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 stackoverflow_fastmcp-1.3.1.tar.gz.
File metadata
- Download URL: stackoverflow_fastmcp-1.3.1.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
418b2c5681924eaf1556e94afec781c5e5636acbb62d53afbce7065f3fe4db2a
|
|
| MD5 |
b7d7495096f43022c07b5ba2e1d51639
|
|
| BLAKE2b-256 |
909d085075f1fda8f50e28d1c748212f610fa9e8b49533fed8f0ecf380c4319f
|
File details
Details for the file stackoverflow_fastmcp-1.3.1-py3-none-any.whl.
File metadata
- Download URL: stackoverflow_fastmcp-1.3.1-py3-none-any.whl
- Upload date:
- Size: 26.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9db2efa784d27d834c7f6c745ae739d41fb6c8116c7618420bd5347a6be2018
|
|
| MD5 |
aaba9ffc80b6d63d4889ed7255fdec6d
|
|
| BLAKE2b-256 |
d37c7c2d006684a3523bf933b65f13f2eed1f0667f4c0c61474c191657cac9a7
|