stack-overflow-mcp-light

stack-overflow-mcp-light

MCP server for searching Stack Overflow questions and retrieving answers with body content, supporting advanced filters and multiple transport types.

Category
Visit Server

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.

License: MIT Python 3.11+ FastMCP

๐Ÿš€ 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 Apps
  • STACK_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

  1. stdio (default) - Standard input/output, client launches server automatically
  2. http (recommended for remote) - Modern HTTP transport (aliases: streamable-http, streamable_http)
  3. 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 search
    • tagged - Semi-colon delimited list of tags
    • intitle - Search in question titles
    • nottagged - Exclude these tags
    • body - Text in question body
    • accepted - Has accepted answer (boolean)
    • closed - Question is closed (boolean)
    • answers - Minimum number of answers
    • views - Minimum view count
    • sort - 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 ID
    • is_answered - Whether the question has answers
    • score - Question score
    • link - Link to the question
    • title - 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 ID
    • is_answered - Whether the question has answers
    • score - Question score
    • link - Link to the question
    • title - Question title
    • answers - Array of AnswerItem objects with:
      • answer_id - Answer ID
      • is_accepted - Whether the answer is accepted
      • score - Answer score
      • body - 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 ID
    • is_answered - Whether the question has answers
    • score - Question score
    • link - Link to the question
    • title - 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

  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.

โš ๏ธ 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

๐Ÿ“ž 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured