Skip to main content
Glama
midodimori

stack-overflow-mcp-light

by midodimori

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

Related MCP server: evo-scry

๐Ÿ“ฆ Installation

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.

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

Available Tools

3 tools
fetch_question_answersA

Fetch specific Stack Overflow question with its answers.

Args: request: Question details request with ID and answer sorting options

Returns: Question item with detailed information including answers sorted by the specified criteria with body content

ParametersJSON Schema
NameRequiredDescriptionDefault
requestYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
linkNoLink to the question
scoreNoQuestion score
titleNoQuestion title
answersNoList of answers for the question
is_answeredNoWhether the question has answers
question_idNoQuestion ID

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the transparency burden. It discloses that answers are sorted and include body content, but does not mention pagination, rate limits, authentication, or potential errors. For a read-only fetch tool, this is moderate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and structured with Args/Returns sections. It contains no fluff, though it could be slightly more efficient. It earns a high score for clarity and brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description explains the tool's return value (question with sorted answers and body content), which is sufficient given the presence of an output schema. It does not mention edge cases or limitations, but for a simple fetch tool it covers the essential context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description only vaguely mentions 'request' with ID and answer sorting options, adding little beyond the input schema which already provides detailed descriptions for question_id, sort, order, and page_size. With 0% schema description coverage, the description should compensate but does not.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool fetches a specific Stack Overflow question with its answers, using a specific verb and resource. This distinguishes it from sibling search tools, which focus on finding questions rather than retrieving a particular question.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you have a specific question ID and want answers, but does not explicitly mention the search siblings or state when not to use this tool. No exclusions or alternatives are provided, so guidance is only implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_questionsC

Search Stack Overflow questions using advanced filters.

Args: request: Question search request with filters and pagination

Returns: List of question items

ParametersJSON Schema
NameRequiredDescriptionDefault
requestYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of disclosing behavioral traits. It only states that the tool searches and returns a list, offering no information about read-only safety, authentication requirements, pagination behavior, or any side effects. This is insufficient for an agent to safely invoke the tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise, using only three short sections (summary, Args, Returns) with no extraneous words. The structure is clean and front-loaded with the main purpose, making it easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a nested request object with many filters, the description is too thin. It fails to explain when to use this tool versus siblings, does not mention important behaviors like pagination limits or read-only status, and offers no guidance on constructing the request. The output schema may exist, but the description itself leaves significant gaps for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds a minimal summary of the 'request' parameter as containing filters and pagination, but since the schema description coverage is 0% for the top-level parameter, it does not fully compensate. The nested schema properties are richly described, so the agent can infer structure, but the description adds little beyond the obvious.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches Stack Overflow questions using advanced filters, which specifies both the verb and resource. However, it does not explicitly differentiate from sibling tools like search_questions_by_tag, so it is clear but not fully distinguishing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as search_questions_by_tag or fetch_question_answers. It does not mention any exclusions or context for choosing this tool over others, leaving the agent to infer usage from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_questions_by_tagA

Search Stack Overflow questions that have a specific tag.

Args: request: Request with tag name, sort options, and pagination

Returns: List of question items with the specified tag

ParametersJSON Schema
NameRequiredDescriptionDefault
requestYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It states that it returns a list of question items, which is useful. However, it does not disclose any potential side effects (though as a search it is read-only), authentication requirements, rate limits, or error behaviors. The description is minimally transparent but not rich in behavioral detail.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, using a clear format with Args and Returns sections. It is easy to scan and not overly verbose. Minor redundancy exists between 'specific tag' and 'with the specified tag', but it does not detract significantly from clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is relatively simple, and the output schema likely covers return values. The description does not mention pagination specifics or any edge cases, but the schema provides details. Without annotations, some additional context (e.g., rate limits, typical usage) would improve completeness, but it is adequate for a straightforward search tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description summarizes the single parameter as 'Request with tag name, sort options, and pagination', which provides a high-level overview. Although schema description coverage is low (0%), the schema itself contains detailed descriptions for each field, so the agent can access those. The description adds some semantic framing but does not elaborate on specific fields like order or page_size.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'Search Stack Overflow questions that have a specific tag', which clearly defines the action (search), the resource (Stack Overflow questions), and the distinguishing qualifier (specific tag). This differentiates it from sibling tools like search_questions (general search) and fetch_question_answers (fetching answers).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description clearly implies the use case: find questions for a specific tag. It does not explicitly mention alternatives or exclusions, but the tag-specific focus is evident from the first line. This provides clear context without stating when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv1.2.0
    • First observedfetch_question_answers
    • First observedsearch_questions
    • First observedsearch_questions_by_tag

TDQS

B3.4/5.0
Disambiguation3/5

search_questions and search_questions_by_tag overlap because search_questions accepts advanced filters that likely include tag filtering, making the distinction unclear. fetch_question_answers is clearly distinct, retrieving a specific question with answers, but the two search tools create ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern: search_questions, search_questions_by_tag, and fetch_question_answers. The 'by_tag' modifier is a clear exception for the second search tool but still follows the same convention, making the naming predictable and uniform.

Tool Count4/5

With 3 tools, the set is on the lean side but appropriate for a 'light' Stack Overflow read-only server. Each tool serves a core purpose without redundancy, and the count is reasonable for the intended narrow scope.

Completeness4/5

The server covers essential read operations: searching questions generically and by tag, and fetching a question with answers. Missing operations like user lookups or comment retrieval are not critical for a lightweight server, but the surface is slightly thin for full Stack Overflow coverage.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for internet search via direct Google and DuckDuckGo HTML scraping with AI-powered result normalization and optional summarization, requiring no API keys for search.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that aggregates web search results from multiple engines and optionally renders pages to Markdown, providing a unified search interface.
    12
    3
    ISC

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/midodimori/stack-overflow-mcp-light'

If you have feedback or need assistance with the MCP directory API, please join our Discord server