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. This package serves as an NPX-compatible wrapper for the Python-based StackOverflow MCP server.
Quick Start
Using NPX (Recommended)
# Run directly with npx (no installation required)
npx @notalk-tech/stackoverflow-mcp
# Skip installation prompts (useful for automation)
npx -y @notalk-tech/stackoverflow-mcp
# Or install globally
npm install -g @notalk-tech/stackoverflow-mcp
stackoverflow-mcp
Using Python Module Directly
# If you have the Python package installed
python -m stackoverflow_mcp
# Using uv (recommended for Python development)
uv run python -m stackoverflow_mcp
Integrating with Cursor
To add StackOverflow MCP as a Model Context Protocol server in Cursor, add the following configuration to your Cursor settings:
{
"mcp_servers": {
"stackoverflow": {
"command": "npx",
"args": [
"-y",
"@notalk-tech/stackoverflow-mcp",
"--api-key", "your_stackoverflow_api_key",
]
}
}
}
๐ Prerequisites
- Node.js 14.0.0 or higher
- Python 3.12 or higher
- uv (recommended) or pip (Python package manager)
The NPX wrapper will automatically:
- Detect your Python installation
- Install the required Python package (
stackoverflow-fastmcp) - Handle environment setup and configuration
Installation
Option 1: NPX (No Installation)
npx @notalk-tech/stackoverflow-mcp --help
Option 2: Global NPM Installation
npm install -g @notalk-tech/stackoverflow-mcp
stackoverflow-mcp --help
Option 3: Local Development
git clone https://github.com/NoTalkTech/stackoverflow-mcp.git
cd stackoverflow-mcp
npm install
node cli.js --help
๐ฏ Features
- ๐ Question Search: Search StackOverflow questions by keywords
- ๐ Question Details: Get detailed question content, answers, and metadata
- ๐ท๏ธ Tag-based Search: Find questions by programming language tags
- โก Rate Limit Management: Automatic detection and handling of API limits
- ๐ API Authentication: Support for StackOverflow API keys
- ๐ Auto-deployment: NPX-compatible with automatic Python environment setup
- ๐ Smart Configuration: Auto-discovery of config files and working directories
- ๐ง Development Mode: Enhanced logging and debugging features
- โก FastMCP Implementation: Simplified, elegant server using FastMCP framework
About MCP Mode
This server is specifically designed to operate in Model Context Protocol (MCP) mode, which means:
- Communication occurs through standard input/output (stdio) rather than HTTP
- The server integrates seamlessly with AI assistants supporting the MCP standard
- No traditional server ports or network connections are used
- The server provides a consistent, structured interface for querying StackOverflow
MCP mode makes this tool ideal for integration with AI models, allowing them to search and retrieve programming knowledge programmatically.
Usage
Basic Usage
# Start the MCP server with default settings
npx @notalk-tech/stackoverflow-mcp
# Auto-confirm installation (useful for scripts/CI)
npx -y @notalk-tech/stackoverflow-mcp
# Provide an API key directly
npx @notalk-tech/stackoverflow-mcp --api-key your_stackoverflow_api_key
# Specify a working directory
npx @notalk-tech/stackoverflow-mcp --working-dir /path/to/your/project
Python Development with uv
For Python development, we recommend using uv for faster dependency management:
# Install dependencies with uv
uv sync
# Run the server with uv
uv run python -m stackoverflow_mcp
# Run with API key
uv run python -m stackoverflow_mcp --api-key your_stackoverflow_api_key
FastMCP Benefits:
- ๐ฅ Simplified Code: Clean, maintainable implementation
- ๐ฏ Decorator-based: Clean tool registration with
@mcp.tool() - ๐ Auto-schema: Type hints automatically generate schemas
- ๐ก๏ธ Built-in Error Handling: Consistent error responses
- ๐ฆ Better Separation: Clean architecture with focused responsibilities
Configuration
Create a .stackoverflow-mcp.json file in your project directory:
{
"stackoverflow_api_key": "your_api_key_here",
"log_level": "CRITICAL"
}
Command Line Options
Options:
--working-dir DIRECTORY Working directory (auto-detect if not specified)
--api-key TEXT StackOverflow API key
--version Show the version and exit.
--help Show this message and exit.
๐ง Configuration Files
The server automatically discovers configuration files in the following order:
.stackoverflow-mcp.jsonstackoverflow-mcp.config.jsonconfig/stackoverflow-mcp.json.config/stackoverflow-mcp.json
๐ API Endpoints
Once running, the MCP server provides the following tools:
search_questions: Search StackOverflow questions by keywordssearch_by_tags: Find questions filtered by programming language tagsget_question: Get detailed information about a specific questionget_question_with_answers: Get comprehensive question details including answersget_rate_limit_status: Get current rate limiting status and quotasget_authentication_status: Get current API authentication statusget_queue_status: Get current request queue status and statistics
๐งช Testing
# Test the npm package
npm test
# Test npm packaging
npm run test:npm
# Test global installation
npm run test:install
# Test Python module directly
python -m pytest tests/ -v
๐ Development
Local Development Setup
# Clone the repository
git clone https://github.com/NoTalkTech/stackoverflow-mcp.git
cd stackoverflow-mcp
# Install Node.js dependencies
npm install
# Install Python dependencies
pip install -e .
# Run in development mode
npm start
Project Structure
@notalk/stackoverflow-mcp/
โโโ cli.js # NPX wrapper (Node.js)
โโโ package.json # NPM 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
โ โโโ stackoverflow_client.py # StackOverflow API client
โโโ tests/ # Test files
โโโ README.md # This file
๐ฆ Publishing
Semantic Versioning
This package follows Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Current Versions
- Python Package:
stackoverflow-fastmcpv0.2.6 - NPM Package:
@notalk-tech/stackoverflow-mcpv1.2.5
Version Synchronization
When publishing new versions, it's important to keep version numbers synchronized:
- Python Package Version: Defined in
src/stackoverflow_mcp/__init__.pyandpyproject.toml - NPM Package Version: Defined in
package.json - CLI Version Reference: Defined in
cli.js(expectedVersion variable)
All three should be updated together when making a release to ensure consistency.
Release Process
This project provides a unified publishing script to simultaneously release both NPM and Python packages.
# Option 1: Using the publish script (recommended)
./publish.sh # Publish both NPM and Python packages
./publish.sh --npm-only # Publish only the NPM package
./publish.sh --pypi-only # Publish only the Python package
./publish.sh --dry-run # Test the publishing process without actual uploads
# Option 2: Manual process
# Update version
npm version patch|minor|major
# Publish to npm
npm publish
# Create GitHub release
git push --tags
Prerequisites for Publishing
- PyPI API token (environment variable
PYPI_API_TOKENor configured in~/.pypirc) - NPM authentication (
npm loginor using automation tokens) - Git credentials for pushing tags
๐ค 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 Wiki
- Discussions: GitHub Discussions
๐ Acknowledgments
- Model Context Protocol for the MCP specification
- StackOverflow for providing the API
- The open-source community for inspiration and contributions
Made with โค๏ธ 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-0.2.7.tar.gz.
File metadata
- Download URL: stackoverflow_fastmcp-0.2.7.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a40f43cb6136f2c90e5105d21e83a1b6c3fa2092c7634f197191845e35414680
|
|
| MD5 |
7bc06bc1f31962b9189f28f77e27a5df
|
|
| BLAKE2b-256 |
cfb90b1c639b0e1b35ac7012670ffd98f2627a4e8d4d5a319863dde405a5e18d
|
File details
Details for the file stackoverflow_fastmcp-0.2.7-py3-none-any.whl.
File metadata
- Download URL: stackoverflow_fastmcp-0.2.7-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0268a3177afb52487819dba862446ba6df3c2e91a265031c37eb3e9c9f2d102d
|
|
| MD5 |
0b1e7aa124e5f4a8afd83bf4f2ff76ad
|
|
| BLAKE2b-256 |
00075ff17bfe6c2c1a550d7547ae6cc06e1104b9356a70e2fa7b843c871e50a1
|