@cyanheads/stackexchange-mcp-server
Provides tools for searching questions, retrieving Q&A threads, browsing tag FAQs, and fetching user profiles across the entire Stack Exchange network.
Provides tools for searching questions, retrieving Q&A threads, browsing tag FAQs, and fetching user profiles on Stack Overflow, the flagship site of the Stack Exchange network.
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., "@@cyanheads/stackexchange-mcp-serversearch Stack Overflow for 'async/await'"
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.
Public Hosted Server: https://stackexchange.caseyjhand.com/mcp
Tools
Five tools for working with Stack Overflow and the wider Stack Exchange network:
Tool | Description |
| Search questions across a Stack Exchange site with full-text query, tag filters, score threshold, and sort order |
| Fetch a complete Q&A thread — question body and all answers as clean markdown, accepted answer first |
| Fetch the highest-voted answered questions for a tag — the canonical "best answers in X" list |
| Fetch a user profile by ID: reputation, badge counts, top tags by answer score, and account metadata |
| Enumerate all Stack Exchange network sites and their |
stackexchange_search_questions
Search questions across any Stack Exchange site.
Full-text search with optional tag filters, minimum score threshold, and accepted-only filter
Sort by relevance, votes, activity, or newest
Returns question ID, title, score, answer count, tags, and excerpt — IDs flow directly into
stackexchange_get_threadQuota remaining surfaced on every response so agents can plan around rate limits
stackexchange_get_thread
Fetch a complete Q&A thread in one call — the server's primary value-add.
Accepts a numeric question ID or a full Stack Exchange question URL
Fetches question body + all answers in parallel (two upstream calls via
Promise.all)HTML→markdown normalization baked in:
<pre><code>→ fenced code blocks,<p>,<a>, lists, headers, blockquotes all convertedAccepted answer always first, then sorted by score descending
Attribution (author display name + profile link + score) included on each answer per CC BY-SA 4.0
Configurable
maxAnswers(default 10, up to 100)
stackexchange_get_tag_faq
Browse the authoritative community answers on a topic.
Maps to
/tags/{tag}/faq— the highest-voted answered questions in a tagReturns question list without bodies; pipe any result into
stackexchange_get_threadfor full contentUseful for "what are the canonical resources on Python async?" type queries
stackexchange_get_user
Credibility context for an answer author.
Fetches profile + top tags in parallel (two upstream calls)
Returns reputation, badge counts (gold/silver/bronze), location, website, post counts, and top 10 tags by answer score
owner.user_idfromstackexchange_get_threadoutput can be passed directly
stackexchange_list_sites
Discover api_site_parameter values for any Stack Exchange community.
Fetches the full ~190-site network list live; optional case-insensitive name filter applied client-side
The
api_site_parametervalue (e.g.stackoverflow,superuser,serverfault) is what every other tool'ssiteparameter accepts
Related MCP server: StackOverflow MCP Server
Features
Built on @cyanheads/mcp-ts-core:
Declarative tool definitions — single file per primitive, framework handles registration and validation
Unified error handling — handlers throw, framework catches, classifies, and formats
Pluggable auth:
none,jwt,oauthSwappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1Structured logging with optional OpenTelemetry tracing
STDIO and Streamable HTTP transports
Stack Exchange-specific:
Custom HTML→markdown normalizer covers the full SE post tag set with no external dependencies
Backoff tracking: respects the
backofffield in SE API responses to avoid throttlingQuota logging:
quota_remainingandquota_maxsurfaced via enrichment on every tool callTyped error contracts on every tool —
invalid_site,invalid_parameter,invalid_api_key,invalid_id_or_url,invalid_user_id,question_not_found,user_not_found,paging_depth_limit,quota_exceeded, andupstream_unavailableParallel upstream calls in
get_threadandget_userviaPromise.allOptional
STACKEXCHANGE_API_KEYlifts the per-IP quota from ~300/day to ~10,000/day with no OAuth required
Agent-friendly output:
Quota remaining on every response — agents can plan around rate limits without the server needing to fail
Accepted-answer-first ordering is hardcoded — the community's explicit quality signal, not a preference
Attribution on every answer per CC BY-SA 4.0 — provenance preserved without agent effort
Typed
not_founderrors for missing questions and users (SE returns HTTP 200 with emptyitems[]— the server handles this correctly)
Getting started
Public Hosted Instance
A public instance is available at https://stackexchange.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"stackexchange-mcp-server": {
"type": "streamable-http",
"url": "https://stackexchange.caseyjhand.com/mcp"
}
}
}Self-Hosted / Local
Add the following to your MCP client configuration file.
{
"mcpServers": {
"stackexchange": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/stackexchange-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"stackexchange": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/stackexchange-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with Docker:
{
"mcpServers": {
"stackexchange": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"ghcr.io/cyanheads/stackexchange-mcp-server:latest"
]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
# Server listens at http://localhost:3010/mcpRate limits: The Stack Exchange API allows ~300 requests/day per IP without a key. Set STACKEXCHANGE_API_KEY in env to lift this to ~10,000/day. Register a key at stackapps.com/apps/oauth/register (the OAuth flow is only required for write access — a key alone is sufficient for read-only use).
Prerequisites
Bun v1.3.0 or higher (or Node.js v24+)
A
STACKEXCHANGE_API_KEYis optional but strongly recommended for any sustained use
Installation
Clone the repository:
git clone https://github.com/cyanheads/stackexchange-mcp-server.gitNavigate into the directory:
cd stackexchange-mcp-serverInstall dependencies:
bun installConfigure environment:
cp .env.example .env
# edit .env and set STACKEXCHANGE_API_KEY if desiredConfiguration
Variable | Description | Default |
| Optional. Stack Exchange API key — lifts per-IP quota from ~300/day to ~10,000/day. | — |
| Transport: |
|
| Port for HTTP server. |
|
| Host for HTTP server. |
|
| HTTP session mode: |
|
| Auth mode: |
|
| Log level (RFC 5424). |
|
| Directory for log files (Node.js only). |
|
| Storage backend. |
|
| Enable OpenTelemetry instrumentation (spans, metrics, completion logs). |
|
See .env.example for the full list of optional overrides.
Running the server
Local development
Build and run:
# One-time build bun run rebuild # Run the built server bun run start:stdio # or bun run start:httpRun checks and tests:
bun run devcheck # Lint, format, typecheck, security bun run test # Vitest test suite bun run lint:mcp # Validate MCP definitions against spec
Docker
docker build -t stackexchange-mcp-server .
docker run --rm -e STACKEXCHANGE_API_KEY=your-key -p 3010:3010 stackexchange-mcp-serverThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/stackexchange-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Path | Purpose |
|
|
| Server-specific environment variable parsing with Zod ( |
| Tool definitions ( |
| Stack Exchange API v2.3 HTTP client, backoff tracking, quota logging, HTML→markdown normalizer. |
| Vitest unit and integration tests. |
| Design document and directory tree. |
Development guide
See CLAUDE.md/AGENTS.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storageRegister new tools via the barrel in
src/mcp-server/tools/definitions/index.tsWrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues and pull requests are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
StackExchange MCP — wraps the StackExchange API v2.3 (free, no auth required for read)
Search GitHub, npm, PyPI, StackOverflow, ArXiv from one MCP — built for coding agents.
Query any docs site via MCP. Submit a URL, ask questions, get cited answers.
OrganiKPI MCP: search and fetch services, posts and tools as clean markdown (read-only).
Related MCP Servers
- AlicenseBqualityCmaintenanceMCP server for searching Stack Overflow questions and retrieving answers with body content, supporting advanced filters and multiple transport types.3MIT
- AlicenseAqualityDmaintenanceProvides seamless access to StackOverflow's Q\&A database through MCP, enabling advanced search, question/answer retrieval, and rate-limit management.511 npm2MIT
- FlicenseNot gradedqualityCmaintenanceProvides MCP tools for searching, retrieving, and answering questions about indexed Nextcloud developer documentation from multiple sources.-
- AlicenseNot gradedqualityDmaintenanceWeb search, page fetching, and research from the terminal or any MCP client — no API key required.1MIT