@transcend-io/mcp-server-docs 0.2.2

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @transcend-io/mcp-server-docs
2
+
3
+ > **Beta** — this package is under active development. APIs may change without notice.
4
+
5
+ Transcend MCP Server for documentation lookup. Provides tools to list articles from the public docs index and fetch full markdown content on demand.
6
+
7
+ Requires **Node.js ≥ 22.12** (see `engines` in `package.json`).
8
+
9
+ **No authentication required.** This standalone server reads public content from `docs.transcend.io` only. It does not use your Transcend API key or OAuth credentials, even if they are present in the environment (for example when launched via [`scripts/mcp-run.sh`](../../../scripts/mcp-run.sh) with `secret.env` loaded).
10
+
11
+ ## Install
12
+
13
+ Install the CLI globally:
14
+
15
+ ```bash
16
+ npm install -g @transcend-io/mcp-server-docs
17
+ ```
18
+
19
+ Or run from a checkout of this repository (see **Run from the monorepo** below).
20
+
21
+ ## Usage
22
+
23
+ ```bash
24
+ transcend-mcp-docs
25
+ ```
26
+
27
+ The process speaks MCP over **stdio** and is meant to be launched by an MCP client (for example Cursor or Claude Desktop), not used as an interactive shell.
28
+
29
+ ### MCP client configuration
30
+
31
+ `npx` runs the package’s `transcend-mcp-docs` binary (see `bin` in `package.json`). No `env` block is required.
32
+
33
+ ```json
34
+ {
35
+ "mcpServers": {
36
+ "transcend-docs": {
37
+ "command": "npx",
38
+ "args": ["-y", "@transcend-io/mcp-server-docs"]
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ When developing in this repository:
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "transcend-docs-local": {
50
+ "command": "node",
51
+ "args": ["packages/mcp/mcp-server-docs/dist/cli.mjs"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ Build first: `pnpm exec turbo run build --filter="@transcend-io/mcp-server-docs..."`
58
+
59
+ ### Run from the monorepo
60
+
61
+ ```bash
62
+ # from the repository root
63
+ pnpm exec turbo run build --filter="@transcend-io/mcp-server-docs..."
64
+ pnpm -F @transcend-io/mcp-server-docs exec node ./dist/cli.mjs
65
+ ```
66
+
67
+ **Alternative:** `./scripts/mcp-run.sh ./packages/mcp/mcp-server-docs/dist/cli.mjs` (OAuth vars in `secret.env` are ignored by this server).
68
+
69
+ See [CONTRIBUTING.md](../../../CONTRIBUTING.md#mcp-servers) for workspace layout and `pnpm --filter` workflows.
70
+
71
+ ## Tools
72
+
73
+ - `transcend_docs_list` — List/search the Transcend docs index (`llms.txt`); optional `section` and `keyword` filters
74
+ - `transcend_docs_fetch` — Fetch full markdown for a docs article URL (host restricted to `docs.transcend.io`)
75
+
76
+ ## Related packages
77
+
78
+ Also available as part of the unified [`@transcend-io/mcp`](../mcp/README.md), which includes all domains and **does** require authentication. See the [root README](../../../README.md#mcp-servers) for the full list.
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.mjs ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ import { t as getDocsTools } from "./tools-CbLvbjwK.mjs";
3
+ import { createMCPServer } from "@transcend-io/mcp-server-base";
4
+ //#endregion
5
+ //#region src/cli.ts
6
+ createMCPServer({
7
+ name: "transcend-mcp-docs",
8
+ version: "0.2.2",
9
+ requireStartupAuth: false,
10
+ oauthScopes: [],
11
+ getTools: getDocsTools
12
+ });
13
+ //#endregion
14
+ export {};
15
+
16
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","names":["packageJson.version"],"sources":["../package.json","../src/cli.ts"],"sourcesContent":["","#!/usr/bin/env node\nimport { createMCPServer } from '@transcend-io/mcp-server-base';\n\nimport packageJson from '../package.json' with { type: 'json' };\nimport { getDocsTools } from './tools/index.js';\n\ncreateMCPServer({\n name: 'transcend-mcp-docs',\n version: packageJson.version,\n requireStartupAuth: false,\n oauthScopes: [],\n getTools: getDocsTools,\n});\n"],"mappings":";;;;;ACMA,gBAAgB;CACd,MAAM;CACGA;CACT,oBAAoB;CACpB,aAAa,EAAE;CACf,UAAU;CACX,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { ToolClients, ToolDefinition, z } from "@transcend-io/mcp-server-base";
2
+
3
+ //#region src/docsIndex.d.ts
4
+ /** Public docs index URL (llms.txt). */
5
+ declare const LLMS_TXT_URL = "https://docs.transcend.io/llms.txt";
6
+ /** Allowed hostname for fetched documentation articles. */
7
+ declare const DOCS_HOST = "docs.transcend.io";
8
+ /** A single article entry from llms.txt. */
9
+ interface DocEntry {
10
+ /** Section header from llms.txt (e.g. "General", "Use Case Guides"). */
11
+ section: string;
12
+ /** Human-readable article title. */
13
+ title: string;
14
+ /** Absolute URL to the article markdown (.md). */
15
+ url: string;
16
+ }
17
+ /**
18
+ * Parses llms.txt markdown into structured entries.
19
+ * Expects `## Section` headers and `- [Title](url)` list items.
20
+ */
21
+ declare function parseLlmsTxt(raw: string): DocEntry[];
22
+ /** Returns the parsed llms.txt index (cached with TTL). */
23
+ declare function getIndex(): Promise<DocEntry[]>;
24
+ /** Fetches and caches markdown body for a docs.transcend.io article URL. */
25
+ declare function getBody(url: string): Promise<string>;
26
+ /** Validates that a URL targets docs.transcend.io (SSRF guard for fetch). */
27
+ declare function assertDocsHost(url: string): void;
28
+ /** Clears in-memory caches (for tests). */
29
+ declare function resetDocsCachesForTests(): void;
30
+ //#endregion
31
+ //#region src/tools/index.d.ts
32
+ declare function getDocsTools(_clients?: ToolClients): ToolDefinition[];
33
+ //#endregion
34
+ //#region src/tools/docs_fetch.d.ts
35
+ declare const DocsFetchSchema: z.ZodObject<{
36
+ url: z.ZodString;
37
+ }, z.core.$strip>;
38
+ type DocsFetchInput = z.infer<typeof DocsFetchSchema>;
39
+ //#endregion
40
+ //#region src/tools/docs_list.d.ts
41
+ declare const DocsListSchema: z.ZodObject<{
42
+ section: z.ZodOptional<z.ZodString>;
43
+ keyword: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>;
45
+ type DocsListInput = z.infer<typeof DocsListSchema>;
46
+ //#endregion
47
+ export { DOCS_HOST, type DocEntry, type DocsFetchInput, DocsFetchSchema, type DocsListInput, DocsListSchema, LLMS_TXT_URL, assertDocsHost, getBody, getDocsTools, getIndex, parseLlmsTxt, resetDocsCachesForTests };
48
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/docsIndex.ts","../src/tools/index.ts","../src/tools/docs_fetch.ts","../src/tools/docs_list.ts"],"mappings":";;;;cAGa,YAAA;;cAGA,SAAA;;UASI,QAAA;EAZQ;EAcvB,OAAA;EAXW;EAaX,KAAA;;EAEA,GAAA;AAAA;AANF;;;;AAAA,iBAagB,YAAA,CAAa,GAAA,WAAc,QAAA;;iBAuDrB,QAAA,CAAA,GAAY,OAAA,CAAQ,QAAA;;iBASpB,OAAA,CAAQ,GAAA,WAAc,OAAA;AAhE5C;AAAA,iBA0EgB,cAAA,CAAe,GAAA;;iBAaf,uBAAA,CAAA;;;iBC9GA,YAAA,CAAa,QAAA,GAAW,WAAA,GAAc,cAAA;;;cCEzC,eAAA,EAAe,CAAA,CAAA,SAAA;;;KAMhB,cAAA,GAAiB,CAAA,CAAE,KAAA,QAAa,eAAA;;;cCT/B,cAAA,EAAc,CAAA,CAAA,SAAA;;;;KAUf,aAAA,GAAgB,CAAA,CAAE,KAAA,QAAa,cAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { a as LLMS_TXT_URL, c as getIndex, i as DOCS_HOST, l as parseLlmsTxt, n as DocsListSchema, o as assertDocsHost, r as DocsFetchSchema, s as getBody, t as getDocsTools, u as resetDocsCachesForTests } from "./tools-CbLvbjwK.mjs";
2
+ export { DOCS_HOST, DocsFetchSchema, DocsListSchema, LLMS_TXT_URL, assertDocsHost, getBody, getDocsTools, getIndex, parseLlmsTxt, resetDocsCachesForTests };
@@ -0,0 +1,163 @@
1
+ import { LRUCache } from "lru-cache";
2
+ import { createListResult, createToolResult, defineTool, z } from "@transcend-io/mcp-server-base";
3
+ //#region src/docsIndex.ts
4
+ /** Public docs index URL (llms.txt). */
5
+ const LLMS_TXT_URL = "https://docs.transcend.io/llms.txt";
6
+ /** Allowed hostname for fetched documentation articles. */
7
+ const DOCS_HOST = "docs.transcend.io";
8
+ const INDEX_CACHE_KEY = "index";
9
+ const DEFAULT_INDEX_TTL_MS = 1440 * 60 * 1e3;
10
+ const DEFAULT_BODY_TTL_MS = 360 * 60 * 1e3;
11
+ const FETCH_TIMEOUT_MS = 8e3;
12
+ const MAX_BODY_CACHE_ENTRIES = 400;
13
+ /**
14
+ * Parses llms.txt markdown into structured entries.
15
+ * Expects `## Section` headers and `- [Title](url)` list items.
16
+ */
17
+ function parseLlmsTxt(raw) {
18
+ const entries = [];
19
+ let currentSection = "";
20
+ for (const line of raw.split("\n")) {
21
+ const sectionMatch = /^## (.+)$/.exec(line);
22
+ if (sectionMatch?.[1]) {
23
+ currentSection = sectionMatch[1].trim();
24
+ continue;
25
+ }
26
+ const linkMatch = /^- \[(.+)\]\((.+)\)\s*$/.exec(line);
27
+ if (linkMatch?.[1] && linkMatch[2] && currentSection) entries.push({
28
+ section: currentSection,
29
+ title: linkMatch[1].trim(),
30
+ url: linkMatch[2].trim()
31
+ });
32
+ }
33
+ return entries;
34
+ }
35
+ async function fetchText(url, signal) {
36
+ const response = await fetch(url, {
37
+ headers: { Accept: "text/markdown, text/plain" },
38
+ signal: signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS)
39
+ });
40
+ if (!response.ok) throw new Error(`Failed to fetch ${url}: HTTP ${response.status}`);
41
+ return response.text();
42
+ }
43
+ const indexCache = new LRUCache({
44
+ max: 1,
45
+ ttl: DEFAULT_INDEX_TTL_MS,
46
+ allowStale: true,
47
+ allowStaleOnFetchRejection: true,
48
+ fetchMethod: async (_key, _stale, { signal }) => {
49
+ return parseLlmsTxt(await fetchText(LLMS_TXT_URL, signal));
50
+ }
51
+ });
52
+ const bodyCache = new LRUCache({
53
+ max: MAX_BODY_CACHE_ENTRIES,
54
+ ttl: DEFAULT_BODY_TTL_MS,
55
+ allowStale: true,
56
+ allowStaleOnFetchRejection: true,
57
+ fetchMethod: async (url, _stale, { signal }) => fetchText(url, signal)
58
+ });
59
+ /** Returns the parsed llms.txt index (cached with TTL). */
60
+ async function getIndex() {
61
+ const result = await indexCache.fetch(INDEX_CACHE_KEY);
62
+ if (!result) throw new Error("Failed to load documentation index");
63
+ return result;
64
+ }
65
+ /** Fetches and caches markdown body for a docs.transcend.io article URL. */
66
+ async function getBody(url) {
67
+ assertDocsHost(url);
68
+ const result = await bodyCache.fetch(url);
69
+ if (result === void 0) throw new Error(`Failed to fetch documentation: ${url}`);
70
+ return result;
71
+ }
72
+ /** Validates that a URL targets docs.transcend.io (SSRF guard for fetch). */
73
+ function assertDocsHost(url) {
74
+ let parsed;
75
+ try {
76
+ parsed = new URL(url);
77
+ } catch {
78
+ throw new Error(`Invalid documentation URL: ${url}`);
79
+ }
80
+ if (parsed.hostname !== "docs.transcend.io") throw new Error(`URL host must be ${DOCS_HOST}, got ${parsed.hostname}`);
81
+ }
82
+ /** Clears in-memory caches (for tests). */
83
+ function resetDocsCachesForTests() {
84
+ indexCache.clear();
85
+ bodyCache.clear();
86
+ }
87
+ //#endregion
88
+ //#region src/tools/docs_fetch.ts
89
+ /** Maximum markdown characters returned per article (long pages are truncated). */
90
+ const MAX_BODY_CHARS = 12e4;
91
+ const DocsFetchSchema = z.object({ url: z.string().url().describe("Absolute https URL of a docs.transcend.io article (.md) from transcend_docs_list.") });
92
+ function formatBody(body, url) {
93
+ return `${body.length > MAX_BODY_CHARS ? `${body.slice(0, MAX_BODY_CHARS)}\n\n...(truncated)` : body}\n\nSource: ${url}`;
94
+ }
95
+ function createDocsFetchTool(_clients) {
96
+ return defineTool({
97
+ name: "transcend_docs_fetch",
98
+ description: "Fetch full markdown content for a Transcend documentation article by URL. Use urls returned by transcend_docs_list.",
99
+ category: "Documentation",
100
+ readOnly: true,
101
+ requireAuth: false,
102
+ annotations: {
103
+ readOnlyHint: true,
104
+ destructiveHint: false,
105
+ idempotentHint: true
106
+ },
107
+ zodSchema: DocsFetchSchema,
108
+ handler: async ({ url }) => {
109
+ assertDocsHost(url);
110
+ return createToolResult(true, {
111
+ url,
112
+ markdown: formatBody(await getBody(url), url)
113
+ });
114
+ }
115
+ });
116
+ }
117
+ //#endregion
118
+ //#region src/tools/docs_list.ts
119
+ const DocsListSchema = z.object({
120
+ section: z.string().optional().describe("Filter articles to this llms.txt section name (exact match)."),
121
+ keyword: z.string().optional().describe("Case-insensitive substring filter applied to article titles.")
122
+ });
123
+ function filterEntries(entries, section, keyword) {
124
+ let result = entries;
125
+ if (section) result = result.filter((entry) => entry.section === section);
126
+ if (keyword) {
127
+ const lower = keyword.toLowerCase();
128
+ result = result.filter((entry) => entry.title.toLowerCase().includes(lower));
129
+ }
130
+ return result.map(({ title, section: entrySection, url }) => ({
131
+ title,
132
+ section: entrySection,
133
+ url
134
+ }));
135
+ }
136
+ function createDocsListTool(_clients) {
137
+ return defineTool({
138
+ name: "transcend_docs_list",
139
+ description: "List Transcend documentation articles from the public docs index. Pick the best matching url, then call transcend_docs_fetch for full markdown content.",
140
+ category: "Documentation",
141
+ readOnly: true,
142
+ requireAuth: false,
143
+ annotations: {
144
+ readOnlyHint: true,
145
+ destructiveHint: false,
146
+ idempotentHint: true
147
+ },
148
+ zodSchema: DocsListSchema,
149
+ handler: async ({ section, keyword }) => {
150
+ const filtered = filterEntries(await getIndex(), section, keyword);
151
+ return createListResult(filtered, { totalCount: filtered.length });
152
+ }
153
+ });
154
+ }
155
+ //#endregion
156
+ //#region src/tools/index.ts
157
+ function getDocsTools(_clients) {
158
+ return [createDocsListTool(), createDocsFetchTool()];
159
+ }
160
+ //#endregion
161
+ export { LLMS_TXT_URL as a, getIndex as c, DOCS_HOST as i, parseLlmsTxt as l, DocsListSchema as n, assertDocsHost as o, DocsFetchSchema as r, getBody as s, getDocsTools as t, resetDocsCachesForTests as u };
162
+
163
+ //# sourceMappingURL=tools-CbLvbjwK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-CbLvbjwK.mjs","names":[],"sources":["../src/docsIndex.ts","../src/tools/docs_fetch.ts","../src/tools/docs_list.ts","../src/tools/index.ts"],"sourcesContent":["import { LRUCache } from 'lru-cache';\n\n/** Public docs index URL (llms.txt). */\nexport const LLMS_TXT_URL = 'https://docs.transcend.io/llms.txt';\n\n/** Allowed hostname for fetched documentation articles. */\nexport const DOCS_HOST = 'docs.transcend.io';\n\nconst INDEX_CACHE_KEY = 'index';\nconst DEFAULT_INDEX_TTL_MS = 24 * 60 * 60 * 1000;\nconst DEFAULT_BODY_TTL_MS = 6 * 60 * 60 * 1000;\nconst FETCH_TIMEOUT_MS = 8_000;\nconst MAX_BODY_CACHE_ENTRIES = 400;\n\n/** A single article entry from llms.txt. */\nexport interface DocEntry {\n /** Section header from llms.txt (e.g. \"General\", \"Use Case Guides\"). */\n section: string;\n /** Human-readable article title. */\n title: string;\n /** Absolute URL to the article markdown (.md). */\n url: string;\n}\n\n/**\n * Parses llms.txt markdown into structured entries.\n * Expects `## Section` headers and `- [Title](url)` list items.\n */\nexport function parseLlmsTxt(raw: string): DocEntry[] {\n const entries: DocEntry[] = [];\n let currentSection = '';\n\n for (const line of raw.split('\\n')) {\n const sectionMatch = /^## (.+)$/.exec(line);\n if (sectionMatch?.[1]) {\n currentSection = sectionMatch[1].trim();\n continue;\n }\n\n const linkMatch = /^- \\[(.+)\\]\\((.+)\\)\\s*$/.exec(line);\n if (linkMatch?.[1] && linkMatch[2] && currentSection) {\n entries.push({\n section: currentSection,\n title: linkMatch[1].trim(),\n url: linkMatch[2].trim(),\n });\n }\n }\n\n return entries;\n}\n\nasync function fetchText(url: string, signal?: AbortSignal): Promise<string> {\n const response = await fetch(url, {\n headers: { Accept: 'text/markdown, text/plain' },\n signal: signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS),\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: HTTP ${response.status}`);\n }\n return response.text();\n}\n\nconst indexCache = new LRUCache<string, DocEntry[]>({\n max: 1,\n ttl: DEFAULT_INDEX_TTL_MS,\n allowStale: true,\n allowStaleOnFetchRejection: true,\n fetchMethod: async (_key, _stale, { signal }) => {\n const raw = await fetchText(LLMS_TXT_URL, signal);\n return parseLlmsTxt(raw);\n },\n});\n\nconst bodyCache = new LRUCache<string, string>({\n max: MAX_BODY_CACHE_ENTRIES,\n ttl: DEFAULT_BODY_TTL_MS,\n allowStale: true,\n allowStaleOnFetchRejection: true,\n fetchMethod: async (url, _stale, { signal }) => fetchText(url, signal),\n});\n\n/** Returns the parsed llms.txt index (cached with TTL). */\nexport async function getIndex(): Promise<DocEntry[]> {\n const result = await indexCache.fetch(INDEX_CACHE_KEY);\n if (!result) {\n throw new Error('Failed to load documentation index');\n }\n return result;\n}\n\n/** Fetches and caches markdown body for a docs.transcend.io article URL. */\nexport async function getBody(url: string): Promise<string> {\n assertDocsHost(url);\n const result = await bodyCache.fetch(url);\n if (result === undefined) {\n throw new Error(`Failed to fetch documentation: ${url}`);\n }\n return result;\n}\n\n/** Validates that a URL targets docs.transcend.io (SSRF guard for fetch). */\nexport function assertDocsHost(url: string): void {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n throw new Error(`Invalid documentation URL: ${url}`);\n }\n if (parsed.hostname !== DOCS_HOST) {\n throw new Error(`URL host must be ${DOCS_HOST}, got ${parsed.hostname}`);\n }\n}\n\n/** Clears in-memory caches (for tests). */\nexport function resetDocsCachesForTests(): void {\n indexCache.clear();\n bodyCache.clear();\n}\n","import { createToolResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-base';\n\nimport { assertDocsHost, getBody } from '../docsIndex.js';\n\n/** Maximum markdown characters returned per article (long pages are truncated). */\nconst MAX_BODY_CHARS = 120_000;\n\nexport const DocsFetchSchema = z.object({\n url: z\n .string()\n .url()\n .describe('Absolute https URL of a docs.transcend.io article (.md) from transcend_docs_list.'),\n});\nexport type DocsFetchInput = z.infer<typeof DocsFetchSchema>;\n\nfunction formatBody(body: string, url: string): string {\n const truncated =\n body.length > MAX_BODY_CHARS ? `${body.slice(0, MAX_BODY_CHARS)}\\n\\n...(truncated)` : body;\n return `${truncated}\\n\\nSource: ${url}`;\n}\n\nexport function createDocsFetchTool(_clients?: ToolClients) {\n return defineTool({\n name: 'transcend_docs_fetch',\n description:\n 'Fetch full markdown content for a Transcend documentation article by URL. ' +\n 'Use urls returned by transcend_docs_list.',\n category: 'Documentation',\n readOnly: true,\n requireAuth: false,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n zodSchema: DocsFetchSchema,\n handler: async ({ url }) => {\n assertDocsHost(url);\n const body = await getBody(url);\n return createToolResult(true, {\n url,\n markdown: formatBody(body, url),\n });\n },\n });\n}\n","import { createListResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-base';\n\nimport { getIndex, type DocEntry } from '../docsIndex.js';\n\nexport const DocsListSchema = z.object({\n section: z\n .string()\n .optional()\n .describe('Filter articles to this llms.txt section name (exact match).'),\n keyword: z\n .string()\n .optional()\n .describe('Case-insensitive substring filter applied to article titles.'),\n});\nexport type DocsListInput = z.infer<typeof DocsListSchema>;\n\nfunction filterEntries(entries: DocEntry[], section?: string, keyword?: string) {\n let result = entries;\n if (section) {\n result = result.filter((entry) => entry.section === section);\n }\n if (keyword) {\n const lower = keyword.toLowerCase();\n result = result.filter((entry) => entry.title.toLowerCase().includes(lower));\n }\n return result.map(({ title, section: entrySection, url }) => ({\n title,\n section: entrySection,\n url,\n }));\n}\n\nexport function createDocsListTool(_clients?: ToolClients) {\n return defineTool({\n name: 'transcend_docs_list',\n description:\n 'List Transcend documentation articles from the public docs index. ' +\n 'Pick the best matching url, then call transcend_docs_fetch for full markdown content.',\n category: 'Documentation',\n readOnly: true,\n requireAuth: false,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n zodSchema: DocsListSchema,\n handler: async ({ section, keyword }) => {\n const entries = await getIndex();\n const filtered = filterEntries(entries, section, keyword);\n return createListResult(filtered, { totalCount: filtered.length });\n },\n });\n}\n","import type { ToolDefinition, ToolClients } from '@transcend-io/mcp-server-base';\n\nimport { createDocsFetchTool } from './docs_fetch.js';\nimport { createDocsListTool } from './docs_list.js';\n\nexport function getDocsTools(_clients?: ToolClients): ToolDefinition[] {\n return [createDocsListTool(), createDocsFetchTool()];\n}\n"],"mappings":";;;;AAGA,MAAa,eAAe;;AAG5B,MAAa,YAAY;AAEzB,MAAM,kBAAkB;AACxB,MAAM,uBAAuB,OAAU,KAAK;AAC5C,MAAM,sBAAsB,MAAS,KAAK;AAC1C,MAAM,mBAAmB;AACzB,MAAM,yBAAyB;;;;;AAgB/B,SAAgB,aAAa,KAAyB;CACpD,MAAM,UAAsB,EAAE;CAC9B,IAAI,iBAAiB;AAErB,MAAK,MAAM,QAAQ,IAAI,MAAM,KAAK,EAAE;EAClC,MAAM,eAAe,YAAY,KAAK,KAAK;AAC3C,MAAI,eAAe,IAAI;AACrB,oBAAiB,aAAa,GAAG,MAAM;AACvC;;EAGF,MAAM,YAAY,0BAA0B,KAAK,KAAK;AACtD,MAAI,YAAY,MAAM,UAAU,MAAM,eACpC,SAAQ,KAAK;GACX,SAAS;GACT,OAAO,UAAU,GAAG,MAAM;GAC1B,KAAK,UAAU,GAAG,MAAM;GACzB,CAAC;;AAIN,QAAO;;AAGT,eAAe,UAAU,KAAa,QAAuC;CAC3E,MAAM,WAAW,MAAM,MAAM,KAAK;EAChC,SAAS,EAAE,QAAQ,6BAA6B;EAChD,QAAQ,UAAU,YAAY,QAAQ,iBAAiB;EACxD,CAAC;AACF,KAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MAAM,mBAAmB,IAAI,SAAS,SAAS,SAAS;AAE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+ {
2
+ "name": "@transcend-io/mcp-server-docs",
3
+ "version": "0.2.2",
4
+ "description": "Transcend MCP Server — Documentation lookup tools.",
5
+ "homepage": "https://github.com/transcend-io/tools/tree/main/packages/mcp/mcp-server-docs",
6
+ "license": "Apache-2.0",
7
+ "author": "Transcend Inc.",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/transcend-io/tools.git",
11
+ "directory": "packages/mcp/mcp-server-docs"
12
+ },
13
+ "bin": {
14
+ "transcend-mcp-docs": "./dist/cli.mjs"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "types": "./dist/index.d.mts",
22
+ "exports": {
23
+ ".": {
24
+ "@transcend-io/source": "./src/index.ts",
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
27
+ }
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@modelcontextprotocol/sdk": "^1.29.0",
34
+ "lru-cache": "^11.5.1",
35
+ "zod": "^4.3.6",
36
+ "@transcend-io/mcp-server-base": "0.6.0"
37
+ },
38
+ "devDependencies": {
39
+ "@arethetypeswrong/cli": "^0.18.2",
40
+ "@types/node": "^22.19.15",
41
+ "publint": "^0.3.18",
42
+ "tsdown": "^0.21.2",
43
+ "typescript": "^6.0.0",
44
+ "vitest": "^4.0.18"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.12.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsdown",
51
+ "test": "vitest run",
52
+ "typecheck": "tsc -p tsconfig.json --noEmit",
53
+ "check:exports": "attw --pack . --ignore-rules cjs-resolves-to-esm",
54
+ "check:publint": "publint --level warning --strict --pack pnpm"
55
+ }
56
+ }