Stackexchange Mcp Server

io.github.cyanheads由 GitHub 帳號 cyanheads 發布v0.2.0更新於 Oct 29, 2026

Search Stack Exchange questions, fetch Q&A threads as markdown, look up tag FAQs and user profiles.

已驗證Streamable HTTP可網頁執行網頁搜尋與抓取開發者工具

概覽

AI 產生的概覽

搜尋 Stack Exchange 各站台,以 Markdown 讀取問答串,並查看標籤常見問題、使用者資料與站台清單。

可以做什麼
  • 列出 Stack Exchange 網路中的站台及其站台參數,可依名稱篩選
  • 依全文關鍵字、標籤、最低分數與排序方式搜尋站台上的問題
  • 以 Markdown 取得完整問答串,已採納答案優先,可選擇附帶留言
  • 瀏覽某個標籤的常見問題,並依 ID 查詢使用者資料
適用情境
適合讓助理查找 Stack Overflow、Server Fault、Unix & Linux 等技術社群的問答內容,並在標註作者出處的前提下引用或摘要答案。
執行需求
可使用公開託管的 HTTP 端點,或透過 npx(Node.js)、Docker、原始碼建置(Bun 1.4.0+ 或 Node.js 24+)在本機執行。選用的 STACKEXCHANGE_API_KEY 可將每 IP 配額從約 300 次/天提高到約 10,000 次/天;未設定時無法翻頁超過 25 頁。需要能連線到 Stack Exchange API 的網路。
安裝前請注意
僅讀取公開內容,不會寫入資料。選用的 STACKEXCHANGE_API_KEY 屬於憑證,應避免放入共用設定。查詢與抓取的內容會送往 Stack Exchange API,使用託管端點時還會經過第三方伺服器。可啟用失敗工具呼叫的酬載記錄,其中自由文字內的密鑰不會被遮蔽。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Stackexchange Mcp Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.cyanheads%2Fstackexchange-mcp-server/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "stackexchange": {
      "type": "http",
      "url": "https://stackexchange.caseyjhand.com/mcp"
    }
  }
}

README

@cyanheads/stackexchange-mcp-server

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.

5 Tools


Overview

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.

Tools

ToolDescription
stackexchange_search_questionsSearch questions across a Stack Exchange site with full-text query, tag filters, score threshold, and sort order
stackexchange_get_threadFetch a question and its answers as markdown, with a configurable answer limit and the accepted answer first
stackexchange_get_tag_faqFetch a tag's frequently asked questions — Stack Exchange's own selection, in its order rather than by score
stackexchange_get_userFetch a user profile by ID: reputation, badge counts, top tags by answer score, and account metadata
stackexchange_list_sitesEnumerate all Stack Exchange network sites and their api_site_parameter values

Agent skill

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.


Capability reference

stackexchange_search_questions tool

  • Full-text query with optional tag filters, minimum score threshold, and accepted-only filter; sort by relevance (default), votes, activity, or newest
  • Up to 30 results per page (default 10); page for more — each page costs one API quota unit, and paging past 25 requires STACKEXCHANGE_API_KEY
  • Returns question ID, title, score, answer count, tags, and a ~300-character excerpt — IDs flow directly into stackexchange_get_thread
  • Quota remaining and max surfaced via enrichment on every response
  • Every response reports appliedSort, the order Stack Exchange actually used; minScore forces votes, and sortOverrideReason says so whenever that replaces the requested sort

stackexchange_get_thread tool

  • Accepts a numeric question ID or a full Stack Exchange question URL; fetches the question and a page of maxAnswers answers (1–100, default 10), adding the accepted answer if it falls outside that page
  • A URL is read from the site its host names (unix.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_site
  • HTML→markdown normalization built in — code blocks, links, lists, headers, and blockquotes all converted
  • Optional includeComments fetches up to 20 comments per post, newest first, using two extra API calls (one when there are no answers); commentsTruncated reports partial lists
  • Attribution (author name, profile link, score) on every answer per CC BY-SA 4.0
  • Quota remaining and max surfaced via enrichment; truncated when more answers exist upstream than maxAnswers returned

stackexchange_get_tag_faq tool

  • A tag's frequently asked questions — maps to /tags/{tag}/faq, Stack Exchange's own selection, returned in its order and not sorted by score
  • Up to 30 results per page (default 10); page for more — each page costs one API quota unit, and paging past 25 requires STACKEXCHANGE_API_KEY
  • Returns a question list without bodies; pipe any questionId into stackexchange_get_thread for full content
  • Quota remaining and max surfaced via enrichment on every response

stackexchange_get_user tool

  • userId must be at most 2,147,483,647 (32-bit) — typically the authorUserId from stackexchange_get_thread output
  • Fetches the profile and top tags in two upstream API calls
  • Returns reputation, badge counts (gold/silver/bronze), location, website, answer/question counts, and up to 10 top tags by answer score (empty array for users with no answers)
  • An unknown user ID returns a typed user_not_found error — Stack Exchange answers HTTP 200 with empty results rather than 404

stackexchange_list_sites tool

  • Fetches every site in the Stack Exchange network, walking pages of 100 up to a 10-page cap; an enrichment notice flags a partial list if the network still has more
  • Optional case-insensitive name filter matches against site name and api_site_parameter, applied client-side after the fetch
  • Returns the api_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 too

Features

Built 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:

  • HTML→markdown conversion preserves code blocks, tables, links, images, and nested lists
  • Shared upstream queue honors response backoff, stated throttle waits, and HTTP 429 cooldowns; each operation has a 50-second budget covering queue time, backoff, requests, and retries, a backoff that cannot fit it fails at once, and a queued call sheds before the budget ends, both with retryAfter instead of running out the clock
  • Quota logging: quota_remaining and quota_max surfaced via enrichment on every tool call
  • Typed 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, throttled, pacer_shed, and upstream_unavailable
  • Optional STACKEXCHANGE_API_KEY lifts 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
  • The accepted answer appears first, followed by the remaining answers sorted by score
  • Each answer includes attribution under CC BY-SA 4.0
  • Typed not_found errors for missing questions and users (SE returns HTTP 200 with empty items[] rather than 404)

Getting started

Connect to the hosted instance, no install:

sh
claude mcp add --transport http stackexchange-mcp-server https://stackexchange.caseyjhand.com/mcp

Or run it locally:

sh
claude mcp add stackexchange-mcp-server -- npx -y @cyanheads/stackexchange-mcp-server

For other clients, add this to the MCP config file:

json
{  "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.


Configuration

VariableDescriptionDefault
STACKEXCHANGE_API_KEYOptional. Stack Exchange API key — lifts per-IP quota from ~300/day to ~10,000/day.—
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_HTTP_PORTPort for HTTP server.3010
MCP_HTTP_HOSTHost for HTTP server.127.0.0.1
MCP_SESSION_MODEHTTP 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_MODEAuth mode: none, jwt, or oauth.none
MCP_LOG_LEVELLog level (RFC 5424).info
LOGS_DIRDirectory for log files (Node.js only).<project-root>/logs
LOG_TOOL_FAILURE_PAYLOADSLog 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_TYPEStorage backend.in-memory
OTEL_ENABLEDEnable OpenTelemetry instrumentation (spans, metrics, completion logs).false
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTOpt-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.


Running the server

Local development

Requires Bun v1.4.0 or higher (or Node.js v24+).

  • Clone and install:

    sh
    git clone https://github.com/cyanheads/stackexchange-mcp-server.gitcd stackexchange-mcp-server && bun installcp .env.example .env   # optionally set STACKEXCHANGE_API_KEY
  • Build and run:

    sh
    # One-time buildbun run rebuild
    # Run the built serverbun run start:stdio# orbun run start:http
  • Run checks and tests:

    sh
    bun run devcheck   # Lint, format, typecheck, securitybun run test       # Vitest test suitebun run lint:mcp   # Validate MCP definitions against spec

Docker

sh
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.


Project structure

PathPurpose
src/index.tscreateApp() 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.

Development guide

See CLAUDE.md/AGENTS.md for development guidelines and architectural rules. The short version:

  • Handlers throw, framework catches — no try/catch in tool logic
  • Use ctx.log for request-scoped logging, ctx.state for tenant-scoped storage
  • Register new tools via the barrel in src/mcp-server/tools/definitions/index.ts
  • Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields

Contributing

Issues are welcome. Run checks and tests before submitting:

sh
bun run devcheckbun run test

License

Apache-2.0 — see LICENSE for details.

來源:README.md,提交 0d0336f

工具

5

stackexchange_list_sites

List Stack Exchange Sites

Enumerate all sites in the Stack Exchange network — name, api_site_parameter, audience, and URL. The api_site_parameter value is what other tools accept as the `site` input (e.g. "stackoverflow", "superuser", "serverfault"). Results are fetched live and optionally filtered by name. Use this tool to discover valid site parameters before calling other stackexchange_* tools.

輸入參數filter

stackexchange_search_questions

Search Stack Exchange Questions

Search questions across a Stack Exchange site. Returns ranked questions with title, score, answer count, accepted status, tags, ask and last-activity dates, and a short excerpt of the question body — not the full body. Results supply question_id values for stackexchange_get_thread, which fetches the full question body and all answers. Results past the pageSize cap are reachable with the `page` parameter. Use the `site` parameter to target a specific community (e.g. "stackoverflow", "superuser", "unix"); call stackexchange_list_sites to discover valid site values.

輸入參數pagesitesorttagsquery必填minScorepageSizeacceptedOnly

stackexchange_get_tag_faq

Get Stack Exchange Tag FAQ

Fetch the frequently asked questions for a tag on a Stack Exchange site — Stack Exchange's own "frequently asked" selection, returned in its order, not ranked by score; compare the scores yourself. Returns a question list without bodies; use stackexchange_get_thread to read the full body and answers for any result. Results past the pageSize cap are reachable with the `page` parameter. Use this tool to find the questions a community keeps coming back to on a topic (e.g. tag "javascript" on stackoverflow). Use stackexchange_search_questions for free-text search rather than tag-based browsing.

輸入參數tag必填pagesitepageSize

stackexchange_get_user

Get Stack Exchange User Profile

Fetch a Stack Exchange user profile by numeric user ID: reputation, badge counts, answer and question counts, account and last-access dates, and top tags by answer score. Useful for credibility context on an answer author — pass the authorUserId from any question or answer in stackexchange_get_thread output. Returns profile fields plus up to 10 top tags by answer score.

輸入參數siteuserId必填

stackexchange_get_thread

Get Stack Exchange Q&A Thread

Fetch a complete Q&A thread — question body and all answers, accepted answer first then sorted by score, rendered as clean markdown with fenced code blocks. Accepts a full Stack Exchange question URL, which is read from the site its host names (e.g. "https://unix.stackexchange.com/questions/88490/how-do-i-use-a-heredoc"), or an integer question ID read from site (e.g. "11227809"). HTML is normalized to markdown automatically; attribution (author + link) included per CC BY-SA 4.0. Get question IDs from stackexchange_search_questions or stackexchange_get_tag_faq.

輸入參數sitemaxAnswersincludeCommentsquestionIdOrUrl必填

版本歷史

5
  1. v0.2.0最新Oct 29, 2026
  2. v0.1.17Oct 25, 2026
  3. v0.1.16Oct 9, 2026
  4. v0.1.15Sep 19, 2026
  5. v0.1.14Sep 16, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分