stackexchange-mcp
Searches and reads Server Fault discussions by passing it as the site, e.g. finding recent threads about infrastructure topics like Docker networking.
Searches and reads content across Stack Exchange sites via the Stack Exchange API, including tag lookup, tag overviews, question search and retrieval with best answers, error/stack-trace searching, and API quota status.
Searches Stack Overflow questions, reads questions with their top/accepted answers (HTML converted to Markdown, code blocks preserved), and finds threads matching a pasted error message or stack trace.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@stackexchange-mcp search Stack Overflow for the best fix for a Python KeyError"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
stackexchange-mcp
An MCP server that lets your AI assistant search Stack Overflow and other Stack Exchange sites, read questions with their best answers, and ground its debugging help in real, voted answers instead of guessing.
Read-only: it never posts, votes or edits anything.
Model-friendly output: short summaries, Markdown instead of HTML, code blocks preserved, long posts truncated with a link.
Respects the API: optional API key, backoff handling, request spacing, retries, caching and quota tracking.
Clear errors: every failure tells the model what happened and what to try next.
Not affiliated with Stack Exchange, Inc. Content returned by the API is licensed CC BY-SA (3.0 or 4.0 depending on the post). The server returns the author, link and license so assistants can attribute it.
What it provides
[project] name = "mcp-server" version = "0.1.0" requires-python = ">=3.12" dependencies = [ "httpx>=0.28.1", "mcp[cli]>=1.0,<2", "pydantic>=2.14.2", ]
[dependency-groups] dev = [ "pytest>=9.2.0", ]
Tools
Tool | Use it to |
| Find discussions about a topic. Filter by tags, site, sort order, accepted answers only. |
| Read one question with its best answers (accepted answer first). |
| Find threads for a pasted error or stack trace. File paths, line numbers and addresses are stripped before searching. |
| Find exact tag names (so the assistant does not guess tags). |
| Get a technology's summary, question count and top-voted questions. |
| See the remaining API quota and any active rate-limit wait. |
Resources
URI | Contents |
| Site slugs you can pass as |
| Guidance on effective searches. |
| Live quota snapshot (JSON). |
Prompts
Prompt | What it does |
| Searches for your error, reads the best two threads, explains the likely fix with links. |
| Compares two approaches using highly voted discussions. |
| Builds a beginner overview of a technology from its tag. |
Related MCP server: Hivemind
Quick start
1. Get a free API key (recommended)
The server works without a key, but the anonymous quota is small: the API reported 300 requests per day without a key and 10,000 with one. Register an app on Stack Apps to get a key; you do not need OAuth for read-only use.
2. Install
You need uv. The server runs straight from PyPI:
uvx stackexchange-mcp(That starts a stdio server and waits; you normally let your AI app launch it using one of the configs below.)
3. Connect your AI app
Use the full path to uvx if your app cannot find it (which uvx).
VS Code (GitHub Copilot, Agent mode) - .vscode/mcp.json:
{
"servers": {
"stackexchange": {
"type": "stdio",
"command": "uvx",
"args": ["stackexchange-mcp"],
"env": { "STACKEXCHANGE_KEY": "${input:se_key}" }
}
},
"inputs": [
{
"type": "promptString",
"id": "se_key",
"description": "Stack Exchange API key",
"password": true
}
]
}Antigravity CLI - .agents/mcp_config.json in your project (or ~/.gemini/config/mcp_config.json globally):
{
"mcpServers": {
"stackexchange": {
"command": "uvx",
"args": ["stackexchange-mcp"],
"env": { "STACKEXCHANGE_KEY": "your-key" }
}
}
}Start agy and run /mcp to confirm it is connected.
Claude Code:
claude mcp add --env STACKEXCHANGE_KEY=your-key stackexchange -- uvx stackexchange-mcpClaude Desktop (macOS/Windows) and Cursor - same JSON shape as Antigravity (mcpServers), in claude_desktop_config.json or ~/.cursor/mcp.json.
Keep your key out of files you commit.
Configuration
Variable | Default | Purpose |
| none | API key. Raises the daily quota. |
|
| Site used when a tool call does not specify one. |
|
| How long identical requests are cached ( |
|
| Maximum characters of any question or answer body returned. |
Rate limits and errors
Identical requests within the cache window cost no quota.
If the API sends a
backoffvalue, the server waits it out (up to 10 seconds) before the next call; longer waits are reported instead of blocking.Requests are spaced at least 0.2 seconds apart.
Timeouts, network errors and 5xx responses are retried twice with exponential delay (0.5 s, then 1 s).
When the daily quota is exhausted the server stops calling the API until the next UTC day.
Situation | What the assistant is told |
Invalid input (bad site, bad tag) | Which parameter is wrong and how to fix it. |
Question or tag not found | It may be deleted or on another site; use |
No search results | Broaden the query, remove tags, or use |
Rate limited | How long to wait. |
Quota exhausted | Set |
Invalid API key | Check or unset |
Stack Exchange unavailable | Usually temporary; try again shortly. |
The API key is never written to logs or error messages.
Example prompts
You do not need to name a tool. Things that should make the assistant use this server:
"What's the difference between
asyncio.sleepandtime.sleep? Check Stack Overflow.""I get
AttributeError: 'NoneType' object has no attribute 'foo'- find help on Stack Overflow." (paste the traceback)"Is there a Stack Overflow tag for testing async code with pytest?"
"I'm new to python-asyncio. Give me an overview from Stack Overflow."
"Find recent discussions about Docker networking on Server Fault."
Tested with
Results for each prompt are in TESTING.md.
Antigravity CLI: connects and lists all 6 tools. In a 10-prompt run, the model picked the expected tool without being told its name in 9 of 10 prompts (one prompt still needs a re-run) and chose sensible arguments such as
site,sortandaccepted_only. It correctly used no tool for an unrelated question.VS Code (Copilot Agent mode): the server starts and 6 tools are discovered; tool-call results are not recorded yet.
MCP Inspector: connects and lists the server's tools (re-check all resources and prompts before release).
Troubleshooting
Server "anonymous (low quota)" in the log: the key did not reach the server. Put
STACKEXCHANGE_KEYin theenvblock of your client's config.Command not found: use the absolute path of
uvxin the config.VS Code shows no tools: use a normal Copilot Agent mode chat session in a workspace that contains
.vscode/mcp.json; some session types keep their own separate server list.The assistant never calls a tool: ask it explicitly once ("search Stack Overflow for ...") and check the tool list in your client.
Logs: the server writes logs to stderr (never stdout, which carries the protocol). In VS Code, open the Output panel and choose the server.
Development
git clone https://github.com/YashLimbani/stackexchange-mcp
cd stackexchange-mcp
uv sync
uv run pytest -q
npx @modelcontextprotocol/inspector uv run stackexchange-mcpTests need no network: the API is mocked using real saved responses in samples/. See DESIGN.md for the design and CONTRIBUTING.md for how to help.
License
MIT for the code (see LICENSE). Stack Exchange content is CC BY-SA; attribute the author and link when you reuse it.
Available Tools
6 toolsget_questionARead-onlyIdempotent
Read one question in full, together with its best answers.
The question and answer bodies are returned as Markdown with code blocks preserved. Long posts are truncated and end with a link to the full text. Each item includes its author, link and license, so cite them when you use the content.
Inputs: question_id (required), site, max_answers. Returns: A question with its body and its best answers: the output of get_question.
get_quota_statusARead-onlyIdempotent
Show the remaining Stack Exchange API quota and any active rate-limit wait.
Call this if requests start failing, or before a large batch of searches.
Inputs: site. Returns: Output of get_quota_status.
get_tag_overviewARead-onlyIdempotent
Get a short description of a tag (a technology or topic) and its most-voted questions.
Use this to get oriented on an unfamiliar technology: it returns the tag's summary, how many questions use it, and the classic high-vote questions with links.
Inputs: tag (required), site, top_questions. Returns: Output of get_tag_overview.
search_by_error_messageARead-onlyIdempotent
Find Stack Overflow discussions that match an error message or stack trace.
Use this when the user pastes an error. The tool picks the most informative line and strips file paths, line numbers and memory addresses before searching; the query it actually used is returned as cleaned_query. Adding a language tag helps. Use get_question on a promising result to read the answers.
Inputs: error_message (required), site, tags, limit. Returns: Output of search_by_error_message: shows what was actually searched.
search_questionsARead-onlyIdempotent
Search Stack Overflow (or another Stack Exchange site) for questions about a topic.
Use this to find existing discussions and solutions. It returns short summaries (title, score, tags, link), not full text. To read a question and its answers, pass a question_id from the results to get_question.
Inputs: query (required), site, sort, tags, +2 more. Returns: note, results, has_more
search_tagsARead-onlyIdempotent
Find valid tag names containing some text, most popular first.
Use this before filtering other searches by tag, so you use tags that really exist instead of guessing (for example 'python-asyncio', not 'asyncio-python').
Inputs: query (required), site, limit. Returns: tags, has_more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
The set is mostly distinct: search_questions and search_by_error_message are the only close pair, but the error-specific input and cleaned_query output make the boundary clear. get_question, search_tags, get_tag_overview, and get_quota_status each serve a separate stage of discovery, retrieval, or runtime awareness.
All tool names use snake_case with a consistent verb_noun shape such as search_questions, get_question, and get_tag_overview. search_by_error_message is slightly longer but still follows the same readable convention.
Six tools is well scoped for a read-only Stack Exchange client. Each tool earns its place by covering a distinct workflow, and the set avoids unnecessary redundancy.
The surface covers discovery, full question and answer retrieval, tag lookup, and quota awareness. Minor gaps remain around explicit site discovery or fetching a single answer by ID, but get_question and search_tags cover the primary workflows.
Related MCP Connectors
Search Stack Exchange questions, fetch Q&A threads as markdown, look up tag FAQs and user profiles.
Access Stack Overflow's trusted and verified technical questions and answers.
Web search, Google SERP, page extraction to markdown and cited answers for AI agents.
Search verified Claude Code plugins and skills; fetch portable SKILL.md sources. Read-only.
Related MCP Servers
- AlicenseAqualityDmaintenanceFacilitates searching and accessing programming resources across platforms like Stack Overflow, MDN, GitHub, npm, and PyPI, aiding LLMs in finding code examples and documentation.14642AGPL 3.0
- FlicenseNot gradedqualityDmaintenanceProvides instant access to a searchable knowledge base of 16,000+ community-driven troubleshooting solutions for common coding problems. Includes community feedback and smart ranking to help AI assistants find the most effective solutions.-
- AlicenseNot gradedqualityCmaintenanceWraps the StackExchange API v2.3 to enable reading StackExchange data (questions, answers, etc.) without authentication. Allows AI agents to query StackExchange content through natural language or direct tool calls.286 npm1MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to search and access Stack Overflow content, including questions, answers, and error solutions.57MIT