Skip to main content

StackOverflow MCP server for querying programming Q&A using FastMCP framework

Project description

StackOverflow MCP Server

npm version License: MIT

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/stackoverflow-mcp

# Skip installation prompts (useful for automation)
npx -y @notalk/stackoverflow-mcp

# Or install globally
npm install -g @notalk/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

๐Ÿ“‹ 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-mcp)
  • Handle environment setup and configuration

Installation

Option 1: NPX (No Installation)

npx @notalk/stackoverflow-mcp --help

Option 2: Global NPM Installation

npm install -g @notalk/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 (only implementation)

Usage

Basic Usage

# Start the MCP server with default settings
npx @notalk/stackoverflow-mcp

# Auto-confirm installation (useful for scripts/CI)
npx -y @notalk/stackoverflow-mcp

# Start on a specific port
npx @notalk/stackoverflow-mcp --port 8080

# Development mode with debug logging
npx @notalk/stackoverflow-mcp --dev --log-level DEBUG

# Use custom configuration file
npx @notalk/stackoverflow-mcp --config-file ./my-config.json

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

# Development mode with uv
uv run python -m stackoverflow_mcp --log-level DEBUG

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:

{
  "host": "localhost",
  "port": 3000,
  "log_level": "INFO",
  "stackoverflow_api_key": "your_api_key_here"
}

Command Line Options

Options:
  --host TEXT                     Host to bind the server to
  --port INTEGER                  Port to bind the server to (auto-detect if not specified)
  --log-level [DEBUG|INFO|WARNING|ERROR]
                                  Logging level
  --config-file PATH              Path to configuration file (auto-discover if not specified)
  --working-dir DIRECTORY         Working directory (auto-detect if not specified)
  --auto-port / --no-auto-port    Automatically find an available port if specified port is in use
  --dev / --prod                  Run in development mode (more verbose logging, auto-reload)
  --health-check / --no-health-check
                                  Enable startup health checks
  --version                       Show the version and exit.
  --help                          Show this message and exit.

๐Ÿ”ง Configuration Files

The server automatically discovers configuration files in the following order:

  1. .stackoverflow-mcp.json
  2. stackoverflow-mcp.config.json
  3. config/stackoverflow-mcp.json
  4. .config/stackoverflow-mcp.json

Example Configuration

{
  "host": "localhost",
  "port": 3000,
  "log_level": "INFO",
  "stackoverflow_api_key": "your_optional_api_key",
  "max_requests_per_minute": 30,
  "enable_caching": true
}

๐ŸŒ API Endpoints

Once running, the MCP server provides the following tools:

  • search_questions: Search StackOverflow questions by keywords
  • get_question_details: Get detailed information about a specific question
  • search_by_tags: Find questions filtered by programming language tags
  • get_user_info: Get information about StackOverflow users

๐Ÿงช 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 -- --dev

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)

Release Process

# Update version
npm version patch|minor|major

# Publish to npm
npm publish

# Create GitHub release
git push --tags

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

๐Ÿ™ Acknowledgments


Made with โค๏ธ for the developer community

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

stackoverflow_fastmcp-0.2.3.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackoverflow_fastmcp-0.2.3-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file stackoverflow_fastmcp-0.2.3.tar.gz.

File metadata

  • Download URL: stackoverflow_fastmcp-0.2.3.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for stackoverflow_fastmcp-0.2.3.tar.gz
Algorithm Hash digest
SHA256 f6b582bf7a8bf300b51aeef70c203d243d1f63e08a4dcad99fa9a3e83a6d2f83
MD5 285f4d02bdb49adb8ebe080db9ed8237
BLAKE2b-256 9b9771dfb4fe234bd7134020413b3bfe1c0591ae00d51c67604cef96d03abe9d

See more details on using hashes here.

File details

Details for the file stackoverflow_fastmcp-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for stackoverflow_fastmcp-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d1d01d9c3e976b685d9526d2d1e24287f4887dc376a3c130096df3abbb0e2380
MD5 af11778bdc6b6f6cb03b4bd4112569de
BLAKE2b-256 551f95f825d25b7559e7a1acd7f2a1393894955094e80f1401538911a3afddbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page