{
  "markdown": "<div align=\"center\">\n  <h1>@cyanheads/stackexchange-mcp-server</h1>\n  <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>\n  <div>5 Tools</div>\n  </p>\n</div>\n\n<div align=\"center\">\n\n[![Version](https://img.shields.io/badge/Version-0.1.10-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/stackexchange-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20Server-2.0.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/stackexchange-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/stackexchange-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^7.0.2-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.4.0-blueviolet.svg?style=flat-square)](https://bun.sh/)\n\n</div>\n\n<div align=\"center\">\n\n[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/stackexchange-mcp-server/releases/latest/download/stackexchange-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=stackexchange-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvc3RhY2tleGNoYW5nZS1tY3Atc2VydmVyIl19) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22stackexchange-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fstackexchange-mcp-server%22%5D%7D)\n\n[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)\n\n</div>\n\n<div align=\"center\">\n\n**Public Hosted Server:** [https://stackexchange.caseyjhand.com/mcp](https://stackexchange.caseyjhand.com/mcp)\n\n</div>\n\n---\n\n## Tools\n\nFive tools for working with Stack Overflow and the wider Stack Exchange network:\n\n| Tool | Description |\n|:---|:---|\n| `stackexchange_search_questions` | Search questions across a Stack Exchange site with full-text query, tag filters, score threshold, and sort order |\n| `stackexchange_get_thread` | Fetch a complete Q&A thread — question body and all answers as clean markdown, accepted answer first |\n| `stackexchange_get_tag_faq` | Fetch the highest-voted answered questions for a tag — the canonical \"best answers in X\" list |\n| `stackexchange_get_user` | Fetch a user profile by ID: reputation, badge counts, top tags by answer score, and account metadata |\n| `stackexchange_list_sites` | Enumerate all Stack Exchange network sites and their `api_site_parameter` values |\n\n### `stackexchange_search_questions`\n\nSearch questions across any Stack Exchange site.\n\n- Full-text search with optional tag filters, minimum score threshold, and accepted-only filter\n- Sort by relevance, votes, activity, or newest\n- Returns question ID, title, score, answer count, tags, and excerpt — IDs flow directly into `stackexchange_get_thread`\n- Quota remaining surfaced on every response so agents can plan around rate limits\n\n---\n\n### `stackexchange_get_thread`\n\nFetch a complete Q&A thread in one call — the server's primary value-add.\n\n- Accepts a numeric question ID or a full Stack Exchange question URL\n- Fetches question body + all answers in parallel (two upstream calls via `Promise.all`)\n- HTML→markdown normalization baked in: `<pre><code>` → fenced code blocks, `<p>`, `<a>`, lists, headers, blockquotes all converted\n- Accepted answer always first, then sorted by score descending\n- Attribution (author display name + profile link + score) included on each answer per CC BY-SA 4.0\n- Configurable `maxAnswers` (default 10, up to 100)\n\n---\n\n### `stackexchange_get_tag_faq`\n\nBrowse the authoritative community answers on a topic.\n\n- Maps to `/tags/{tag}/faq` — the highest-voted answered questions in a tag\n- Returns question list without bodies; pipe any result into `stackexchange_get_thread` for full content\n- Useful for \"what are the canonical resources on Python async?\" type queries\n\n---\n\n### `stackexchange_get_user`\n\nCredibility context for an answer author.\n\n- Fetches profile + top tags in parallel (two upstream calls)\n- Returns reputation, badge counts (gold/silver/bronze), location, website, post counts, and top 10 tags by answer score\n- `owner.user_id` from `stackexchange_get_thread` output can be passed directly\n\n---\n\n### `stackexchange_list_sites`\n\nDiscover `api_site_parameter` values for any Stack Exchange community.\n\n- Fetches the full ~190-site network list live; optional case-insensitive name filter applied client-side\n- The `api_site_parameter` value (e.g. `stackoverflow`, `superuser`, `serverfault`) is what every other tool's `site` parameter accepts\n\n---\n\n## Features\n\nBuilt on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):\n\n- Declarative tool definitions — single file per primitive, framework handles registration and validation\n- Unified error handling — handlers throw, framework catches, classifies, and formats\n- Pluggable auth: `none`, `jwt`, `oauth`\n- Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`\n- Structured logging with optional OpenTelemetry tracing\n- STDIO and Streamable HTTP transports\n\nStack Exchange-specific:\n\n- Custom HTML→markdown normalizer covers the full SE post tag set with no external dependencies\n- Backoff tracking: respects the `backoff` field in SE API responses to avoid throttling\n- Quota logging: `quota_remaining` and `quota_max` surfaced via enrichment on every tool call\n- Typed error contracts for `invalid_site`, `question_not_found`, `user_not_found`, `invalid_id_or_url`, and `quota_exceeded`\n- Parallel upstream calls in `get_thread` and `get_user` via `Promise.all`\n- Optional `STACKEXCHANGE_API_KEY` lifts the per-IP quota from ~300/day to ~10,000/day with no OAuth required\n\nAgent-friendly output:\n\n- Quota remaining on every response — agents can plan around rate limits without the server needing to fail\n- Accepted-answer-first ordering is hardcoded — the community's explicit quality signal, not a preference\n- Attribution on every answer per CC BY-SA 4.0 — provenance preserved without agent effort\n- Typed `not_found` errors for missing questions and users (SE returns HTTP 200 with empty `items[]` — the server handles this correctly)\n\n---\n\n## Getting started\n\n### Public Hosted Instance\n\nA public instance is available at `https://stackexchange.caseyjhand.com/mcp` — no installation required. Point any MCP client at it via Streamable HTTP:\n\n```json\n{\n  \"mcpServers\": {\n    \"stackexchange-mcp-server\": {\n      \"type\": \"streamable-http\",\n      \"url\": \"https://stackexchange.caseyjhand.com/mcp\"\n    }\n  }\n}\n```\n\n### Self-Hosted / Local\n\nAdd the following to your MCP client configuration file.\n\n```json\n{\n  \"mcpServers\": {\n    \"stackexchange\": {\n      \"type\": \"stdio\",\n      \"command\": \"bunx\",\n      \"args\": [\"@cyanheads/stackexchange-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\"\n      }\n    }\n  }\n}\n```\n\nOr with npx (no Bun required):\n\n```json\n{\n  \"mcpServers\": {\n    \"stackexchange\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@cyanheads/stackexchange-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\"\n      }\n    }\n  }\n}\n```\n\nOr with Docker:\n\n```json\n{\n  \"mcpServers\": {\n    \"stackexchange\": {\n      \"type\": \"stdio\",\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\", \"-i\", \"--rm\",\n        \"-e\", \"MCP_TRANSPORT_TYPE=stdio\",\n        \"ghcr.io/cyanheads/stackexchange-mcp-server:latest\"\n      ]\n    }\n  }\n}\n```\n\nFor Streamable HTTP, set the transport and start the server:\n\n```sh\nMCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http\n# Server listens at http://localhost:3010/mcp\n```\n\n**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](https://stackapps.com/apps/oauth/register) (the OAuth flow is only required for write access — a key alone is sufficient for read-only use).\n\n### Prerequisites\n\n- [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+)\n- A `STACKEXCHANGE_API_KEY` is optional but strongly recommended for any sustained use\n\n### Installation\n\n1. **Clone the repository:**\n\n```sh\ngit clone https://github.com/cyanheads/stackexchange-mcp-server.git\n```\n\n2. **Navigate into the directory:**\n\n```sh\ncd stackexchange-mcp-server\n```\n\n3. **Install dependencies:**\n\n```sh\nbun install\n```\n\n4. **Configure environment:**\n\n```sh\ncp .env.example .env\n# edit .env and set STACKEXCHANGE_API_KEY if desired\n```\n\n---\n\n## Configuration\n\n| Variable | Description | Default |\n|:---------|:------------|:--------|\n| `STACKEXCHANGE_API_KEY` | Optional. Stack Exchange API key — lifts per-IP quota from ~300/day to ~10,000/day. | — |\n| `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |\n| `MCP_HTTP_PORT` | Port for HTTP server. | `3010` |\n| `MCP_HTTP_HOST` | Host for HTTP server. | `127.0.0.1` |\n| `MCP_SESSION_MODE` | HTTP session mode: `auto`, `stateful`, or `stateless`. `auto` resolves to stateful; this server sets stateless explicitly. | `stateless` |\n| `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |\n| `MCP_LOG_LEVEL` | Log level (RFC 5424). | `info` |\n| `LOGS_DIR` | Directory for log files (Node.js only). | `<project-root>/logs` |\n| `STORAGE_PROVIDER_TYPE` | Storage backend. | `in-memory` |\n| `OTEL_ENABLED` | Enable [OpenTelemetry instrumentation](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry) (spans, metrics, completion logs). | `false` |\n\nSee [`.env.example`](./.env.example) for the full list of optional overrides.\n\n---\n\n## Running the server\n\n### Local development\n\n- **Build and run:**\n\n  ```sh\n  # One-time build\n  bun run rebuild\n\n  # Run the built server\n  bun run start:stdio\n  # or\n  bun run start:http\n  ```\n\n- **Run checks and tests:**\n\n  ```sh\n  bun run devcheck   # Lint, format, typecheck, security\n  bun run test       # Vitest test suite\n  bun run lint:mcp   # Validate MCP definitions against spec\n  ```\n\n### Docker\n\n```sh\ndocker build -t stackexchange-mcp-server .\ndocker run --rm -e STACKEXCHANGE_API_KEY=your-key -p 3010:3010 stackexchange-mcp-server\n```\n\nThe 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.\n\n---\n\n## Project structure\n\n| Path | Purpose |\n|:-----|:--------|\n| `src/index.ts` | `createApp()` entry point — registers tools and inits services. |\n| `src/config/` | Server-specific environment variable parsing with Zod (`STACKEXCHANGE_API_KEY`). |\n| `src/mcp-server/tools/` | Tool definitions (`*.tool.ts`). |\n| `src/services/stackexchange/` | Stack Exchange API v2.3 HTTP client, backoff tracking, quota logging, HTML→markdown normalizer. |\n| `tests/` | Vitest unit and integration tests. |\n| `docs/` | Design document and directory tree. |\n\n---\n\n## Development guide\n\nSee [`CLAUDE.md`/`AGENTS.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:\n\n- Handlers throw, framework catches — no `try/catch` in tool logic\n- Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage\n- Register new tools via the barrel in `src/mcp-server/tools/definitions/index.ts`\n- Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields\n\n---\n\n## Contributing\n\nIssues and pull requests are welcome. Run checks and tests before submitting:\n\n```sh\nbun run devcheck\nbun run test\n```\n\n---\n\n## License\n\nApache-2.0 — see [LICENSE](LICENSE) for details.\n",
  "bytes": 12445,
  "sha": "e4c52af27145c0e1654ffd92432cd229df80a69ae0106f72910e34dc78cd6120",
  "repo_slug": "cyanheads/stackexchange-mcp-server",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_cyanheads_stackexchange_mcp_se_03cfff29/readme"
}