@cyanheads/stackexchange-mcp-server 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +360 -0
- package/CLAUDE.md +360 -0
- package/Dockerfile +99 -0
- package/LICENSE +201 -0
- package/README.md +307 -0
- package/changelog/0.1.x/0.1.1.md +27 -0
- package/changelog/template.md +127 -0
- package/dist/config/server-config.d.ts +11 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +21 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/index.d.ts +176 -0
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/index.js +22 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-tag-faq.tool.d.ts +37 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-tag-faq.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-tag-faq.tool.js +118 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-tag-faq.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-thread.tool.d.ts +54 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-thread.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-thread.tool.js +205 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-thread.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-user.tool.d.ts +48 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-user.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-user.tool.js +151 -0
- package/dist/mcp-server/tools/definitions/stackexchange-get-user.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-list-sites.tool.d.ts +20 -0
- package/dist/mcp-server/tools/definitions/stackexchange-list-sites.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-list-sites.tool.js +94 -0
- package/dist/mcp-server/tools/definitions/stackexchange-list-sites.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-search-questions.tool.d.ts +45 -0
- package/dist/mcp-server/tools/definitions/stackexchange-search-questions.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/stackexchange-search-questions.tool.js +145 -0
- package/dist/mcp-server/tools/definitions/stackexchange-search-questions.tool.js.map +1 -0
- package/dist/services/stackexchange/html-normalizer.d.ts +18 -0
- package/dist/services/stackexchange/html-normalizer.d.ts.map +1 -0
- package/dist/services/stackexchange/html-normalizer.js +143 -0
- package/dist/services/stackexchange/html-normalizer.js.map +1 -0
- package/dist/services/stackexchange/stackexchange-service.d.ts +143 -0
- package/dist/services/stackexchange/stackexchange-service.d.ts.map +1 -0
- package/dist/services/stackexchange/stackexchange-service.js +336 -0
- package/dist/services/stackexchange/stackexchange-service.js.map +1 -0
- package/dist/services/stackexchange/types.d.ts +104 -0
- package/dist/services/stackexchange/types.d.ts.map +1 -0
- package/dist/services/stackexchange/types.js +7 -0
- package/dist/services/stackexchange/types.js.map +1 -0
- package/package.json +101 -0
- package/server.json +111 -0
package/README.md
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>@cyanheads/stackexchange-mcp-server</h1>
|
|
3
|
+
<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>
|
|
4
|
+
<div>5 Tools</div>
|
|
5
|
+
</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div align="center">
|
|
9
|
+
|
|
10
|
+
[](./CHANGELOG.md) [](./LICENSE) [](https://github.com/users/cyanheads/packages/container/package/stackexchange-mcp-server) [](https://modelcontextprotocol.io/) [](https://www.npmjs.com/package/@cyanheads/stackexchange-mcp-server) [](https://www.typescriptlang.org/) [](https://bun.sh/)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div align="center">
|
|
15
|
+
|
|
16
|
+
[](https://github.com/cyanheads/stackexchange-mcp-server/releases/latest/download/stackexchange-mcp-server.mcpb) [](https://cursor.com/en/install-mcp?name=stackexchange-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvc3RhY2tleGNoYW5nZS1tY3Atc2VydmVyIl19) [](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)
|
|
17
|
+
|
|
18
|
+
[](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Tools
|
|
25
|
+
|
|
26
|
+
Five tools for working with Stack Overflow and the wider Stack Exchange network:
|
|
27
|
+
|
|
28
|
+
| Tool | Description |
|
|
29
|
+
|:---|:---|
|
|
30
|
+
| `stackexchange_search_questions` | Search questions across a Stack Exchange site with full-text query, tag filters, score threshold, and sort order |
|
|
31
|
+
| `stackexchange_get_thread` | Fetch a complete Q&A thread — question body and all answers as clean markdown, accepted answer first |
|
|
32
|
+
| `stackexchange_get_tag_faq` | Fetch the highest-voted answered questions for a tag — the canonical "best answers in X" list |
|
|
33
|
+
| `stackexchange_get_user` | Fetch a user profile by ID: reputation, badge counts, top tags by answer score, and account metadata |
|
|
34
|
+
| `stackexchange_list_sites` | Enumerate all Stack Exchange network sites and their `api_site_parameter` values |
|
|
35
|
+
|
|
36
|
+
### `stackexchange_search_questions`
|
|
37
|
+
|
|
38
|
+
Search questions across any Stack Exchange site.
|
|
39
|
+
|
|
40
|
+
- Full-text search with optional tag filters, minimum score threshold, and accepted-only filter
|
|
41
|
+
- Sort by relevance, votes, activity, or newest
|
|
42
|
+
- Returns question ID, title, score, answer count, tags, and excerpt — IDs flow directly into `stackexchange_get_thread`
|
|
43
|
+
- Quota remaining surfaced on every response so agents can plan around rate limits
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### `stackexchange_get_thread`
|
|
48
|
+
|
|
49
|
+
Fetch a complete Q&A thread in one call — the server's primary value-add.
|
|
50
|
+
|
|
51
|
+
- Accepts a numeric question ID or a full Stack Exchange question URL
|
|
52
|
+
- Fetches question body + all answers in parallel (two upstream calls via `Promise.all`)
|
|
53
|
+
- HTML→markdown normalization baked in: `<pre><code>` → fenced code blocks, `<p>`, `<a>`, lists, headers, blockquotes all converted
|
|
54
|
+
- Accepted answer always first, then sorted by score descending
|
|
55
|
+
- Attribution (author display name + profile link + score) included on each answer per CC BY-SA 4.0
|
|
56
|
+
- Configurable `maxAnswers` (default 10, up to 100)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### `stackexchange_get_tag_faq`
|
|
61
|
+
|
|
62
|
+
Browse the authoritative community answers on a topic.
|
|
63
|
+
|
|
64
|
+
- Maps to `/tags/{tag}/faq` — the highest-voted answered questions in a tag
|
|
65
|
+
- Returns question list without bodies; pipe any result into `stackexchange_get_thread` for full content
|
|
66
|
+
- Useful for "what are the canonical resources on Python async?" type queries
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### `stackexchange_get_user`
|
|
71
|
+
|
|
72
|
+
Credibility context for an answer author.
|
|
73
|
+
|
|
74
|
+
- Fetches profile + top tags in parallel (two upstream calls)
|
|
75
|
+
- Returns reputation, badge counts (gold/silver/bronze), location, website, post counts, and top 10 tags by answer score
|
|
76
|
+
- `owner.user_id` from `stackexchange_get_thread` output can be passed directly
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### `stackexchange_list_sites`
|
|
81
|
+
|
|
82
|
+
Discover `api_site_parameter` values for any Stack Exchange community.
|
|
83
|
+
|
|
84
|
+
- Fetches the full ~190-site network list live; optional case-insensitive name filter applied client-side
|
|
85
|
+
- The `api_site_parameter` value (e.g. `stackoverflow`, `superuser`, `serverfault`) is what every other tool's `site` parameter accepts
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Features
|
|
90
|
+
|
|
91
|
+
Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):
|
|
92
|
+
|
|
93
|
+
- Declarative tool definitions — single file per primitive, framework handles registration and validation
|
|
94
|
+
- Unified error handling — handlers throw, framework catches, classifies, and formats
|
|
95
|
+
- Pluggable auth: `none`, `jwt`, `oauth`
|
|
96
|
+
- Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
|
|
97
|
+
- Structured logging with optional OpenTelemetry tracing
|
|
98
|
+
- STDIO and Streamable HTTP transports
|
|
99
|
+
|
|
100
|
+
Stack Exchange-specific:
|
|
101
|
+
|
|
102
|
+
- Custom HTML→markdown normalizer covers the full SE post tag set with no external dependencies
|
|
103
|
+
- Backoff tracking: respects the `backoff` field in SE API responses to avoid throttling
|
|
104
|
+
- Quota logging: `quota_remaining` and `quota_max` surfaced via enrichment on every tool call
|
|
105
|
+
- Typed error contracts for `invalid_site`, `question_not_found`, `user_not_found`, `invalid_id_or_url`, and `quota_exceeded`
|
|
106
|
+
- Parallel upstream calls in `get_thread` and `get_user` via `Promise.all`
|
|
107
|
+
- Optional `STACKEXCHANGE_API_KEY` lifts the per-IP quota from ~300/day to ~10,000/day with no OAuth required
|
|
108
|
+
|
|
109
|
+
Agent-friendly output:
|
|
110
|
+
|
|
111
|
+
- Quota remaining on every response — agents can plan around rate limits without the server needing to fail
|
|
112
|
+
- Accepted-answer-first ordering is hardcoded — the community's explicit quality signal, not a preference
|
|
113
|
+
- Attribution on every answer per CC BY-SA 4.0 — provenance preserved without agent effort
|
|
114
|
+
- Typed `not_found` errors for missing questions and users (SE returns HTTP 200 with empty `items[]` — the server handles this correctly)
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Getting started
|
|
119
|
+
|
|
120
|
+
Add the following to your MCP client configuration file.
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"stackexchange": {
|
|
126
|
+
"type": "stdio",
|
|
127
|
+
"command": "bunx",
|
|
128
|
+
"args": ["@cyanheads/stackexchange-mcp-server@latest"],
|
|
129
|
+
"env": {
|
|
130
|
+
"MCP_TRANSPORT_TYPE": "stdio",
|
|
131
|
+
"MCP_LOG_LEVEL": "info"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Or with npx (no Bun required):
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"mcpServers": {
|
|
143
|
+
"stackexchange": {
|
|
144
|
+
"type": "stdio",
|
|
145
|
+
"command": "npx",
|
|
146
|
+
"args": ["-y", "@cyanheads/stackexchange-mcp-server@latest"],
|
|
147
|
+
"env": {
|
|
148
|
+
"MCP_TRANSPORT_TYPE": "stdio",
|
|
149
|
+
"MCP_LOG_LEVEL": "info"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or with Docker:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"mcpServers": {
|
|
161
|
+
"stackexchange": {
|
|
162
|
+
"type": "stdio",
|
|
163
|
+
"command": "docker",
|
|
164
|
+
"args": [
|
|
165
|
+
"run", "-i", "--rm",
|
|
166
|
+
"-e", "MCP_TRANSPORT_TYPE=stdio",
|
|
167
|
+
"ghcr.io/cyanheads/stackexchange-mcp-server:latest"
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
For Streamable HTTP, set the transport and start the server:
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
|
|
178
|
+
# Server listens at http://localhost:3010/mcp
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**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).
|
|
182
|
+
|
|
183
|
+
### Prerequisites
|
|
184
|
+
|
|
185
|
+
- [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+)
|
|
186
|
+
- A `STACKEXCHANGE_API_KEY` is optional but strongly recommended for any sustained use
|
|
187
|
+
|
|
188
|
+
### Installation
|
|
189
|
+
|
|
190
|
+
1. **Clone the repository:**
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
git clone https://github.com/cyanheads/stackexchange-mcp-server.git
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
2. **Navigate into the directory:**
|
|
197
|
+
|
|
198
|
+
```sh
|
|
199
|
+
cd stackexchange-mcp-server
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
3. **Install dependencies:**
|
|
203
|
+
|
|
204
|
+
```sh
|
|
205
|
+
bun install
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
4. **Configure environment:**
|
|
209
|
+
|
|
210
|
+
```sh
|
|
211
|
+
cp .env.example .env
|
|
212
|
+
# edit .env and set STACKEXCHANGE_API_KEY if desired
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Configuration
|
|
218
|
+
|
|
219
|
+
| Variable | Description | Default |
|
|
220
|
+
|:---------|:------------|:--------|
|
|
221
|
+
| `STACKEXCHANGE_API_KEY` | Optional. Stack Exchange API key — lifts per-IP quota from ~300/day to ~10,000/day. | — |
|
|
222
|
+
| `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
|
|
223
|
+
| `MCP_HTTP_PORT` | Port for HTTP server. | `3010` |
|
|
224
|
+
| `MCP_HTTP_HOST` | Host for HTTP server. | `127.0.0.1` |
|
|
225
|
+
| `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
|
|
226
|
+
| `MCP_LOG_LEVEL` | Log level (RFC 5424). | `info` |
|
|
227
|
+
| `LOGS_DIR` | Directory for log files (Node.js only). | `<project-root>/logs` |
|
|
228
|
+
| `STORAGE_PROVIDER_TYPE` | Storage backend. | `in-memory` |
|
|
229
|
+
| `OTEL_ENABLED` | Enable [OpenTelemetry instrumentation](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry) (spans, metrics, completion logs). | `false` |
|
|
230
|
+
|
|
231
|
+
See [`.env.example`](./.env.example) for the full list of optional overrides.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Running the server
|
|
236
|
+
|
|
237
|
+
### Local development
|
|
238
|
+
|
|
239
|
+
- **Build and run:**
|
|
240
|
+
|
|
241
|
+
```sh
|
|
242
|
+
# One-time build
|
|
243
|
+
bun run rebuild
|
|
244
|
+
|
|
245
|
+
# Run the built server
|
|
246
|
+
bun run start:stdio
|
|
247
|
+
# or
|
|
248
|
+
bun run start:http
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
- **Run checks and tests:**
|
|
252
|
+
|
|
253
|
+
```sh
|
|
254
|
+
bun run devcheck # Lint, format, typecheck, security
|
|
255
|
+
bun run test # Vitest test suite
|
|
256
|
+
bun run lint:mcp # Validate MCP definitions against spec
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Docker
|
|
260
|
+
|
|
261
|
+
```sh
|
|
262
|
+
docker build -t stackexchange-mcp-server .
|
|
263
|
+
docker run --rm -e STACKEXCHANGE_API_KEY=your-key -p 3010:3010 stackexchange-mcp-server
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
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.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Project structure
|
|
271
|
+
|
|
272
|
+
| Path | Purpose |
|
|
273
|
+
|:-----|:--------|
|
|
274
|
+
| `src/index.ts` | `createApp()` entry point — registers tools and inits services. |
|
|
275
|
+
| `src/config/` | Server-specific environment variable parsing with Zod (`STACKEXCHANGE_API_KEY`). |
|
|
276
|
+
| `src/mcp-server/tools/` | Tool definitions (`*.tool.ts`). |
|
|
277
|
+
| `src/services/stackexchange/` | Stack Exchange API v2.3 HTTP client, backoff tracking, quota logging, HTML→markdown normalizer. |
|
|
278
|
+
| `tests/` | Vitest unit and integration tests. |
|
|
279
|
+
| `docs/` | Design document and directory tree. |
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Development guide
|
|
284
|
+
|
|
285
|
+
See [`CLAUDE.md`/`AGENTS.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
|
|
286
|
+
|
|
287
|
+
- Handlers throw, framework catches — no `try/catch` in tool logic
|
|
288
|
+
- Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage
|
|
289
|
+
- Register new tools via the barrel in `src/mcp-server/tools/definitions/index.ts`
|
|
290
|
+
- Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Contributing
|
|
295
|
+
|
|
296
|
+
Issues and pull requests are welcome. Run checks and tests before submitting:
|
|
297
|
+
|
|
298
|
+
```sh
|
|
299
|
+
bun run devcheck
|
|
300
|
+
bun run test
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
Apache-2.0 — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Initial public release — 5 Stack Exchange tools covering question search, Q&A threads, tag FAQs, user profiles, and site discovery; error bodies stripped from service errors"
|
|
3
|
+
breaking: false
|
|
4
|
+
security: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.1.1 — 2026-06-05
|
|
8
|
+
|
|
9
|
+
Initial public release of `@cyanheads/stackexchange-mcp-server`. Provides 5 MCP tools over the [Stack Exchange API v2.3](https://api.stackexchange.com/docs):
|
|
10
|
+
|
|
11
|
+
- **`stackexchange_search_questions`** — full-text search across any Stack Exchange site with tag, sort, and date filters
|
|
12
|
+
- **`stackexchange_get_thread`** — fetch a complete Q&A thread (question body + all answers) as clean markdown with code blocks preserved
|
|
13
|
+
- **`stackexchange_get_tag_faq`** — retrieve the most frequently-linked questions for a tag on any site
|
|
14
|
+
- **`stackexchange_get_user`** — fetch a user profile: reputation, badge counts, top tags by answer score, and account metadata
|
|
15
|
+
- **`stackexchange_list_sites`** — enumerate all ~190 Stack Exchange network sites with name, audience, and API parameter
|
|
16
|
+
|
|
17
|
+
## Added
|
|
18
|
+
|
|
19
|
+
- **`stackexchange_search_questions`**, **`stackexchange_get_thread`**, **`stackexchange_get_tag_faq`**, **`stackexchange_get_user`**, **`stackexchange_list_sites`** — full 5-tool surface over the Stack Exchange API v2.3
|
|
20
|
+
- **`html-normalizer.ts`** — converts SE HTML post bodies to markdown with code block preservation (fenced blocks from `<pre><code>`, inline backticks from `<code>`)
|
|
21
|
+
- **`stackexchange-service.ts`** — SE API v2.3 HTTP client with gzip decompression, exponential backoff on `backoff` field, quota exhaustion detection, and `withRetry` for transient failures
|
|
22
|
+
- **Keyless operation** — server functions without an API key (~300 req/day per IP); `STACKEXCHANGE_API_KEY` lifts quota to ~10,000/day
|
|
23
|
+
- **Quota enrichment** — all tools surface `quotaRemaining` in the MCP enrichment block so clients can track daily API budget
|
|
24
|
+
|
|
25
|
+
## Security
|
|
26
|
+
|
|
27
|
+
- **`stackexchange-service.ts`** — response bodies no longer included in `serviceUnavailable` error payloads; errors now carry only `status` code to prevent upstream response data from leaking through error channels
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
# FORMAT REFERENCE — do not edit. Copy this file to
|
|
3
|
+
# `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.8.x/0.8.6.md`)
|
|
4
|
+
# to author a new release. Set that file's H1 to `# <version> — YYYY-MM-DD`
|
|
5
|
+
# with a concrete date.
|
|
6
|
+
|
|
7
|
+
# Required. One-line GitHub Release-style headline. 350 character cap.
|
|
8
|
+
# Default short and scannable. Don't pad, don't stitch unrelated changes with
|
|
9
|
+
# semicolons — pick the headline. Quotes required: unquoted YAML treats `: `
|
|
10
|
+
# inside the value as a key separator and fails GitHub's strict parser.
|
|
11
|
+
summary: ""
|
|
12
|
+
|
|
13
|
+
# Set `true` when consumers must change code to upgrade: API removals,
|
|
14
|
+
# signature changes, config renames, behavior changes that break existing
|
|
15
|
+
# usage. Flagged as `Breaking` in the rollup.
|
|
16
|
+
breaking: false
|
|
17
|
+
|
|
18
|
+
# Set `true` if this release contains any security fix. Pairs with the
|
|
19
|
+
# `## Security` section below. Flagged as `Security` in the rollup so
|
|
20
|
+
# users can triage upgrade urgency at a glance.
|
|
21
|
+
security: false
|
|
22
|
+
|
|
23
|
+
# Optional free-form notes for maintenance agents processing this release.
|
|
24
|
+
# Not rendered in CHANGELOG — consumed by agents running `maintenance` on
|
|
25
|
+
# downstream servers. Use for adoption instructions that don't fit the
|
|
26
|
+
# human-facing sections: new files to create, fields to populate, one-time
|
|
27
|
+
# migration steps. Omit the field entirely when there's nothing to say.
|
|
28
|
+
# agent-notes: |
|
|
29
|
+
# <instructions for downstream maintenance agents>
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# <version> — YYYY-MM-DD
|
|
33
|
+
|
|
34
|
+
<!--
|
|
35
|
+
AUTHORING GUIDE — applies to the new per-version file you create from this
|
|
36
|
+
template.
|
|
37
|
+
|
|
38
|
+
Audience: someone scanning release notes to decide what affects them. Lead
|
|
39
|
+
each bullet with the symbol or concept name in **bold** so they can skip
|
|
40
|
+
what's irrelevant and zoom in on what's not.
|
|
41
|
+
|
|
42
|
+
Tone: terse, fact-dense, not verbose. Default to one sentence per bullet —
|
|
43
|
+
name the symbol, state what changed, stop. Use a second sentence only when
|
|
44
|
+
it carries weight. If a bullet feels long, it is.
|
|
45
|
+
|
|
46
|
+
Cut: mechanism walkthroughs (those belong in JSDoc, CLAUDE.md/AGENTS.md, or the
|
|
47
|
+
relevant skill), ceremonial framings ("This release introduces…",
|
|
48
|
+
backwards-compat paragraphs), file-by-file test enumerations, internal
|
|
49
|
+
implementation notes. Prefer code/symbol names over English re-explanations.
|
|
50
|
+
|
|
51
|
+
Narrative intro: skip by default. Add one short sentence only when the
|
|
52
|
+
release theme genuinely needs framing the bullets can't carry.
|
|
53
|
+
|
|
54
|
+
Sections: Keep a Changelog order — Added, Changed, Deprecated, Removed,
|
|
55
|
+
Fixed, Security. Include only sections with entries; delete the rest
|
|
56
|
+
(including the commented-out scaffolding below). Don't ship empty headers.
|
|
57
|
+
|
|
58
|
+
Include: every distinct fact a reader needs to adopt or audit the release —
|
|
59
|
+
new exports, signatures, lint rule IDs, env vars, breaking changes, version
|
|
60
|
+
bumps on shipped skills. Nothing more.
|
|
61
|
+
|
|
62
|
+
Links: link issues, PRs, docs, or skills where they help a reader jump to
|
|
63
|
+
context. Once per item per entry — don't re-link the same issue in summary,
|
|
64
|
+
narrative, and bullet. Skip links for inline symbol names; code spans speak
|
|
65
|
+
for themselves.
|
|
66
|
+
|
|
67
|
+
Issue/PR URLs: use full URLs. GitHub's bare `#NN` auto-link only resolves
|
|
68
|
+
inside its own UI, not in npm reads or local editors.
|
|
69
|
+
|
|
70
|
+
[#38](https://github.com/cyanheads/mcp-ts-core/issues/38) ← issue
|
|
71
|
+
[#42](https://github.com/cyanheads/mcp-ts-core/pull/42) ← PR
|
|
72
|
+
|
|
73
|
+
Verify numbers exist before linking (`gh issue view NN`, `gh pr view NN`).
|
|
74
|
+
Never speculate on a future number — `#42` for an upcoming PR silently
|
|
75
|
+
resolves to whatever real item already owns 42, and timeline previews pull
|
|
76
|
+
in that unrelated item's metadata.
|
|
77
|
+
|
|
78
|
+
TAG ANNOTATIONS — the annotated tag body renders as the GitHub Release body
|
|
79
|
+
via `gh release create --notes-from-tag`. The tag is a derivative of this
|
|
80
|
+
changelog entry — a condensed, scannable version, not a copy. Format:
|
|
81
|
+
|
|
82
|
+
<theme — omit version number, GitHub prepends it>
|
|
83
|
+
← blank line
|
|
84
|
+
<1-2 sentence context: what this release does>
|
|
85
|
+
← blank line
|
|
86
|
+
Dependency bumps: ← section header
|
|
87
|
+
← blank line
|
|
88
|
+
- `@cyanheads/mcp-ts-core` ^0.9.1 → ^0.9.6 ← bullet
|
|
89
|
+
← blank line
|
|
90
|
+
Changed: ← only sections with entries
|
|
91
|
+
← blank line
|
|
92
|
+
- `format()` output includes `query` in text mode
|
|
93
|
+
← blank line
|
|
94
|
+
Added:
|
|
95
|
+
← blank line
|
|
96
|
+
- `manifest.json` scaffolded for MCPB bundle support
|
|
97
|
+
- Install badges (Claude Desktop, Cursor, VS Code)
|
|
98
|
+
← blank line
|
|
99
|
+
<N> tests pass; `bun run devcheck` clean. ← footer
|
|
100
|
+
|
|
101
|
+
Never a flat comma-separated string. Always structured markdown with
|
|
102
|
+
sections. The tag must scan well as a rendered GitHub Release page.
|
|
103
|
+
-->
|
|
104
|
+
|
|
105
|
+
## Added
|
|
106
|
+
|
|
107
|
+
-
|
|
108
|
+
|
|
109
|
+
## Changed
|
|
110
|
+
|
|
111
|
+
-
|
|
112
|
+
|
|
113
|
+
<!-- ## Deprecated
|
|
114
|
+
|
|
115
|
+
- -->
|
|
116
|
+
|
|
117
|
+
<!-- ## Removed
|
|
118
|
+
|
|
119
|
+
- -->
|
|
120
|
+
|
|
121
|
+
## Fixed
|
|
122
|
+
|
|
123
|
+
-
|
|
124
|
+
|
|
125
|
+
<!-- ## Security
|
|
126
|
+
|
|
127
|
+
- -->
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-specific configuration schema for the Stack Exchange MCP server.
|
|
3
|
+
* @module config/server-config
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
declare const ServerConfigSchema: z.ZodObject<{
|
|
7
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare function getServerConfig(): z.infer<typeof ServerConfigSchema>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=server-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;iBAQtB,CAAC;AAIH,wBAAgB,eAAe,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAKpE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-specific configuration schema for the Stack Exchange MCP server.
|
|
3
|
+
* @module config/server-config
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
|
|
7
|
+
const ServerConfigSchema = z.object({
|
|
8
|
+
apiKey: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('Stack Exchange API key — lifts per-IP quota from ~300/day to ~10,000/day. ' +
|
|
12
|
+
'Register at https://stackapps.com/apps/oauth/register (OAuth flow for write access only; key-only is read-only).'),
|
|
13
|
+
});
|
|
14
|
+
let _config;
|
|
15
|
+
export function getServerConfig() {
|
|
16
|
+
_config ??= parseEnvConfig(ServerConfigSchema, {
|
|
17
|
+
apiKey: 'STACKEXCHANGE_API_KEY',
|
|
18
|
+
});
|
|
19
|
+
return _config;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=server-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,4EAA4E;QAC1E,kHAAkH,CACrH;CACJ,CAAC,CAAC;AAEH,IAAI,OAAuD,CAAC;AAE5D,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,MAAM,EAAE,uBAAuB;KAChC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview stackexchange-mcp-server MCP server entry point.
|
|
4
|
+
* @module index
|
|
5
|
+
*/
|
|
6
|
+
import { createApp } from '@cyanheads/mcp-ts-core';
|
|
7
|
+
import { getServerConfig } from './config/server-config.js';
|
|
8
|
+
import { allToolDefinitions } from './mcp-server/tools/definitions/index.js';
|
|
9
|
+
import { initStackExchangeService } from './services/stackexchange/stackexchange-service.js';
|
|
10
|
+
await createApp({
|
|
11
|
+
tools: allToolDefinitions,
|
|
12
|
+
resources: [],
|
|
13
|
+
prompts: [],
|
|
14
|
+
instructions: 'Stack Exchange network access — Stack Overflow, Super User, Server Fault, Unix & Linux, and 180+ more sites.\n' +
|
|
15
|
+
'Workflow: use stackexchange_list_sites to find a site api_site_parameter, then stackexchange_search_questions ' +
|
|
16
|
+
'or stackexchange_get_tag_faq to discover question IDs, then stackexchange_get_thread for full Q&A content with ' +
|
|
17
|
+
'markdown-normalized bodies. stackexchange_get_user resolves an answer author by user_id.\n' +
|
|
18
|
+
'Rate limit: ~300 requests/day keyless per IP; set STACKEXCHANGE_API_KEY for ~10,000/day.',
|
|
19
|
+
setup(core) {
|
|
20
|
+
const serverConfig = getServerConfig();
|
|
21
|
+
initStackExchangeService(core.config, core.storage, serverConfig.apiKey);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAE7F,MAAM,SAAS,CAAC;IACd,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,YAAY,EACV,gHAAgH;QAChH,gHAAgH;QAChH,iHAAiH;QACjH,4FAA4F;QAC5F,0FAA0F;IAC5F,KAAK,CAAC,IAAI;QACR,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,wBAAwB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;CACF,CAAC,CAAC"}
|