@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.
README
<div align="center"> <h1>@cyanheads/stackexchange-mcp-server</h1> <p><b>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.</b> <div>5 Tools</div> </p> </div>
<div align="center">
</div>
<div align="center">
</div>
<div align="center">
Public Hosted Server: https://stackexchange.caseyjhand.com/mcp
</div>
Tools
Five tools for working with Stack Overflow and the wider Stack Exchange network:
| 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 complete Q&A thread — question body and all answers as clean markdown, accepted answer first |
stackexchange_get_tag_faq |
Fetch the highest-voted answered questions for a tag — the canonical "best answers in X" list |
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 |
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_thread - Quota 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 converted - Accepted 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 tag - Returns question list without bodies; pipe any result into
stackexchange_get_threadfor full content - Useful 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
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,oauth - Swappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1 - Structured 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 throttling - Quota logging:
quota_remainingandquota_maxsurfaced via enrichment on every tool call - Typed error contracts for
invalid_site,question_not_found,user_not_found,invalid_id_or_url, andquota_exceeded - Parallel upstream calls in
get_threadandget_userviaPromise.all - Optional
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/mcp
Rate 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.git
- Navigate into the directory:
cd stackexchange-mcp-server
- Install dependencies:
bun install
- Configure environment:
cp .env.example .env
# edit .env and set STACKEXCHANGE_API_KEY if desired
Configuration
| 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_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 |
STORAGE_PROVIDER_TYPE |
Storage backend. | in-memory |
OTEL_ENABLED |
Enable OpenTelemetry instrumentation (spans, metrics, completion logs). | false |
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: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
docker build -t stackexchange-mcp-server .
docker run --rm -e STACKEXCHANGE_API_KEY=your-key -p 3010:3010 stackexchange-mcp-server
The 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 |
|---|---|
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. |
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/catchin tool logic - Use
ctx.logfor request-scoped logging,ctx.statefor 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 and pull requests are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
License
Apache-2.0 — see LICENSE for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。