
Wraps the Stack Exchange API to let Claude search questions, pull complete Q&A threads as markdown, browse tag FAQs, and look up user profiles across the entire network. The get_thread tool is the centerpiece: it fetches a question and all its answers in parallel, normalizes HTML to clean markdown, and sorts by accepted answer first. Built on the author's mcp-ts-core framework with backoff tracking and quota surfacing on every response so agents can plan around rate limits. Ships with a public hosted instance at stackexchange.caseyjhand.com, or run it locally via npx or Bun. Optional API key lifts the daily quota from 300 to 10,000 requests. Reach for this when you need programmatic access to Stack Overflow content with proper attribution.
Sponsors
STACKEXCHANGE_API_KEYStack Exchange API key — lifts per-IP quota from ~300/day to ~10,000/day. Register at https://stackapps.com/apps/oauth/register.
MCP_LOG_LEVELdefault: infoSets the minimum log level for output (e.g., 'debug', 'info', 'warn').
MCP_HTTP_HOSTdefault: 127.0.0.1The hostname for the HTTP server.
MCP_HTTP_PORTdefault: 3010The port to run the HTTP server on.
MCP_HTTP_ENDPOINT_PATHdefault: /mcpThe endpoint path for the MCP server.
MCP_AUTH_MODEdefault: noneAuthentication mode to use: 'none', 'jwt', or 'oauth'.
Search Stack Exchange questions, fetch complete Q&A threads as clean markdown, browse tag FAQs, and look up user profiles via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://stackexchange.caseyjhand.com/mcp
Stack Overflow and the rest of the Stack Exchange network, from Super User and Server Fault to Unix & Linux. Search questions, read complete Q&A threads as clean markdown, browse tag FAQs, and look up user profiles.
| Tool | Description |
|---|---|
stackexchange_search_questions | Search questions across a Stack Exchange site with full-text query, tag filters, score threshold, and sort order |
stackexchange_get_thread | Fetch a question and its answers as markdown, with a configurable answer limit and the accepted answer first |
stackexchange_get_tag_faq | Fetch a tag's frequently asked questions — Stack Exchange's own selection, in its order rather than by score |
stackexchange_get_user | Fetch a user profile by ID: reputation, badge counts, top tags by answer score, and account metadata |
stackexchange_list_sites | Enumerate all Stack Exchange network sites and their api_site_parameter values |
skills/stackexchange-guide covers what the tool schemas don't: why IDs never carry across sites and which site a URL or ID is read from, search syntax for error messages and tags, choosing which answer to quote, and what each call costs against the daily quota. Plugin installs (Claude Code, Codex) and the Claude Desktop bundle load it from the package, and MCP clients that support the Skills extension read it from the server through skills/list.
stackexchange_search_questions toolpage for more — each page costs one API quota unit, and paging past 25 requires STACKEXCHANGE_API_KEYstackexchange_get_threadappliedSort, the order Stack Exchange actually used; minScore forces votes, and sortOverrideReason says so whenever that replaces the requested sortstackexchange_get_thread toolmaxAnswers answers (1–100, default 10), adding the accepted answer if it falls outside that pageunix.stackexchange.com, ru.stackoverflow.com, arqade.com, …), so site applies only to a numeric ID or a hostless /questions/ path; a site naming a different site than the URL is ignored, and a URL whose host is not a Stack Exchange site (a translation proxy) is read from site instead — either way reported as siteConflict on both surfaces. Such a URL sent without site fails as invalid_siteincludeComments fetches up to 20 comments per post, newest first, using two extra API calls (one when there are no answers); commentsTruncated reports partial liststruncated when more answers exist upstream than maxAnswers returnedstackexchange_get_tag_faq tool/tags/{tag}/faq, Stack Exchange's own selection, returned in its order and not sorted by scorepage for more — each page costs one API quota unit, and paging past 25 requires STACKEXCHANGE_API_KEYquestionId into stackexchange_get_thread for full contentstackexchange_get_user tooluserId must be at most 2,147,483,647 (32-bit) — typically the authorUserId from stackexchange_get_thread outputuser_not_found error — Stack Exchange answers HTTP 200 with empty results rather than 404stackexchange_list_sites toolapi_site_parameter, applied client-side after the fetchapi_site_parameter value (e.g. stackoverflow, superuser, serverfault) that every other tool's site parameter accepts; the site's domain (e.g. serverfault.com) works there tooBuilt on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
Stack Exchange-specific:
retryAfter instead of running out the clockquota_remaining and quota_max surfaced via enrichment on every tool callinvalid_site, invalid_parameter, invalid_api_key, invalid_id_or_url, invalid_user_id, question_not_found, user_not_found, paging_depth_limit, quota_exceeded, throttled, pacer_shed, and upstream_unavailableSTACKEXCHANGE_API_KEY lifts the per-IP quota from ~300/day to ~10,000/day with no OAuth requiredAgent-friendly output:
not_found errors for missing questions and users (SE returns HTTP 200 with empty items[] rather than 404)Connect to the hosted instance, no install:
claude mcp add --transport http stackexchange-mcp-server https://stackexchange.caseyjhand.com/mcp
Or run it locally:
claude mcp add stackexchange-mcp-server -- npx -y @cyanheads/stackexchange-mcp-server
For other clients, add this to the MCP config file:
{
"mcpServers": {
"stackexchange-mcp-server": {
"command": "npx",
"args": ["-y", "@cyanheads/stackexchange-mcp-server"]
}
}
}
Without a key, the Stack Exchange API allows ~300 requests/day per IP; set STACKEXCHANGE_API_KEY to lift this to ~10,000/day. Register a key at stackapps.com/apps/oauth/register — a key alone covers read-only use. For Docker or a source build, see Running the server.
| Variable | Description | Default |
|---|---|---|
STACKEXCHANGE_API_KEY | Optional. Stack Exchange API key — lifts per-IP quota from ~300/day to ~10,000/day. | — |
MCP_TRANSPORT_TYPE | Transport: stdio or http. | stdio |
MCP_HTTP_PORT | Port for HTTP server. | 3010 |
MCP_HTTP_HOST | Host for HTTP server. | 127.0.0.1 |
MCP_SESSION_MODE | HTTP session mode: auto, stateful, or stateless. auto resolves to stateful. A meaningful env value overrides this server's stateless source default; blank or unsubstituted placeholders use the source default. | stateless |
MCP_AUTH_MODE | Auth mode: none, jwt, or oauth. | none |
MCP_LOG_LEVEL | Log level (RFC 5424). | info |
LOGS_DIR | Directory for log files (Node.js only). | <project-root>/logs |
LOG_TOOL_FAILURE_PAYLOADS | Log each failed tool call's arguments and result, redacted by key name and capped at LOG_TOOL_FAILURE_PAYLOAD_MAX_BYTES (default 16384). A secret inside a free-form value is not redacted. | false |
STORAGE_PROVIDER_TYPE | Storage backend. | in-memory |
OTEL_ENABLED | Enable OpenTelemetry instrumentation (spans, metrics, completion logs). | false |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | Opt-in OTLP log export (e.g. http://localhost:4318/v1/logs); the base OTEL_EXPORTER_OTLP_ENDPOINT never enables it. | — |
See .env.example for the full list of optional overrides.
Requires Bun v1.4.0 or higher (or Node.js v24+).
Clone and install:
git clone https://github.com/cyanheads/stackexchange-mcp-server.git
cd stackexchange-mcp-server && bun install
cp .env.example .env # optionally set STACKEXCHANGE_API_KEY
Build and run:
# One-time build
bun run rebuild
# Run the built server
bun run start:stdio
# or
bun run start:http
Run 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 run --rm -e STACKEXCHANGE_API_KEY=your-key -p 3010:3010 ghcr.io/cyanheads/stackexchange-mcp-server:latest
The image defaults to HTTP transport, stateless session mode, and logs to /var/log/stackexchange-mcp-server. To run it over stdio from an MCP client, use "command": "docker" with "args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/stackexchange-mcp-server:latest"]. To build locally, docker build -t stackexchange-mcp-server .; OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
| Path | Purpose |
|---|---|
src/index.ts | createApp() entry point — registers tools and inits services. |
src/config/ | Server-specific environment variable parsing with Zod (STACKEXCHANGE_API_KEY). |
src/mcp-server/tools/ | Tool definitions (*.tool.ts). |
src/services/stackexchange/ | Stack Exchange API v2.3 HTTP client, backoff tracking, quota logging, HTML→markdown normalizer. |
skills/ | The stackexchange-guide agent skill, published to installing and connecting clients. |
tests/ | Vitest unit and integration tests. |
docs/ | Design document and directory tree. |
See CLAUDE.md/AGENTS.md for development guidelines and architectural rules. The short version:
try/catch in tool logicctx.log for request-scoped logging, ctx.state for tenant-scoped storagesrc/mcp-server/tools/definitions/index.tsIssues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
Apache-2.0 — see LICENSE for details.
@cyanheads/stackexchange-mcp-server