@pipeworx/mcp-tldr-pages 0.1.0

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # mcp-tldr-pages
2
+
3
+ tldr-pages community simplified man pages (cached 24h)
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `page` | Render tldr page for a command. |
12
+ | `commands` | List commands. |
13
+ | `platforms` | List supported platforms. |
14
+ | `search` | Substring search across page titles. |
15
+
16
+ ## Quick Start
17
+
18
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "tldr-pages": {
24
+ "url": "https://gateway.pipeworx.io/tldr-pages/mcp"
25
+ }
26
+ }
27
+ }
28
+ ```
29
+
30
+ Or connect to the full Pipeworx gateway for access to all 250+ data sources:
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "pipeworx": {
36
+ "url": "https://gateway.pipeworx.io/mcp"
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Using with ask_pipeworx
43
+
44
+ Instead of calling tools directly, you can ask questions in plain English:
45
+
46
+ ```
47
+ ask_pipeworx({ question: "your question about Tldr Pages data" })
48
+ ```
49
+
50
+ The gateway picks the right tool and fills the arguments automatically.
51
+
52
+ ## More
53
+
54
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
55
+ - [pipeworx.io](https://pipeworx.io)
56
+
57
+ ## License
58
+
59
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-tldr-pages",
3
+ "version": "0.1.0",
4
+ "description": "tldr-pages community simplified man pages (cached 24h)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "tldr-pages"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-tldr-pages"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/tldr-pages",
4
+ "title": "Tldr Pages",
5
+ "description": "tldr-pages community simplified man pages (cached 24h)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/tldr-pages",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-tldr-pages",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/tldr-pages/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,139 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * tldr-pages MCP — fetched from the canonical github repo.
21
+ */
22
+
23
+
24
+ const REPO = 'https://raw.githubusercontent.com/tldr-pages/tldr/main';
25
+ const INDEX = 'https://tldr.sh/assets/index.json';
26
+ const UA = 'pipeworx-mcp-tldr-pages/1.0 (+https://pipeworx.io)';
27
+ const TTL_MS = 24 * 60 * 60 * 1000;
28
+ let INDEX_CACHE: { at: number; data: { commands: { name: string; platform: string[]; language: string[]; targets?: { os: string; language: string }[] }[] } } | null = null;
29
+
30
+ const tools: McpToolExport['tools'] = [
31
+ {
32
+ name: 'page',
33
+ description: 'Render tldr page for a command.',
34
+ inputSchema: {
35
+ type: 'object',
36
+ properties: {
37
+ command: { type: 'string' },
38
+ platform: { type: 'string', description: 'common (default) | linux | osx | windows | android | sunos | freebsd' },
39
+ language: { type: 'string', description: 'ISO 639-1, default "en".' },
40
+ },
41
+ required: ['command'],
42
+ },
43
+ },
44
+ {
45
+ name: 'commands',
46
+ description: 'List commands.',
47
+ inputSchema: {
48
+ type: 'object',
49
+ properties: {
50
+ platform: { type: 'string' },
51
+ language: { type: 'string' },
52
+ },
53
+ },
54
+ },
55
+ {
56
+ name: 'platforms',
57
+ description: 'List supported platforms.',
58
+ inputSchema: { type: 'object', properties: {} },
59
+ },
60
+ {
61
+ name: 'search',
62
+ description: 'Substring search across page titles.',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {
66
+ query: { type: 'string' },
67
+ platform: { type: 'string' },
68
+ language: { type: 'string' },
69
+ limit: { type: 'number' },
70
+ },
71
+ required: ['query'],
72
+ },
73
+ },
74
+ ];
75
+
76
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
77
+ switch (name) {
78
+ case 'page': {
79
+ const cmd = reqStr(args, 'command', '"tar"');
80
+ const platform = String(args.platform ?? 'common');
81
+ const lang = String(args.language ?? 'en');
82
+ const dir = lang === 'en' ? 'pages' : `pages.${lang}`;
83
+ const url = `${REPO}/${dir}/${platform}/${cmd}.md`;
84
+ const res = await fetch(url, { headers: { 'User-Agent': UA } });
85
+ if (res.status === 404) {
86
+ // Fall back to common.
87
+ if (platform !== 'common') {
88
+ const fb = await fetch(`${REPO}/${dir}/common/${cmd}.md`, { headers: { 'User-Agent': UA } });
89
+ if (fb.ok) return { command: cmd, platform: 'common', language: lang, body: await fb.text() };
90
+ }
91
+ throw new Error(`tldr: ${cmd} not found on ${platform}/${lang}.`);
92
+ }
93
+ if (!res.ok) throw new Error(`tldr: ${res.status}`);
94
+ return { command: cmd, platform, language: lang, body: await res.text() };
95
+ }
96
+ case 'commands': {
97
+ const idx = await loadIndex();
98
+ const platform = (args.platform as string | undefined) ?? 'common';
99
+ const lang = (args.language as string | undefined) ?? 'en';
100
+ const cmds = idx.commands.filter((c) => c.platform.includes(platform) && c.language.includes(lang)).map((c) => c.name);
101
+ return { platform, language: lang, count: cmds.length, commands: cmds };
102
+ }
103
+ case 'platforms': {
104
+ const idx = await loadIndex();
105
+ const set = new Set<string>();
106
+ for (const c of idx.commands) for (const p of c.platform) set.add(p);
107
+ return { platforms: [...set].sort() };
108
+ }
109
+ case 'search': {
110
+ const idx = await loadIndex();
111
+ const q = reqStr(args, 'query', '"compress"').toLowerCase();
112
+ const platform = args.platform as string | undefined;
113
+ const lang = (args.language as string | undefined) ?? 'en';
114
+ const limit = Math.min(500, Math.max(1, (args.limit as number) ?? 50));
115
+ const matches = idx.commands.filter((c) => c.name.toLowerCase().includes(q) && (!platform || c.platform.includes(platform)) && c.language.includes(lang)).slice(0, limit);
116
+ return { query: q, count: matches.length, commands: matches };
117
+ }
118
+ default:
119
+ throw new Error(`Unknown tool: ${name}`);
120
+ }
121
+ }
122
+
123
+ async function loadIndex() {
124
+ const now = Date.now();
125
+ if (INDEX_CACHE && now - INDEX_CACHE.at < TTL_MS) return INDEX_CACHE.data;
126
+ const res = await fetch(INDEX, { headers: { Accept: 'application/json', 'User-Agent': UA } });
127
+ if (!res.ok) throw new Error(`tldr index: ${res.status}`);
128
+ const data = (await res.json()) as typeof INDEX_CACHE['data'];
129
+ INDEX_CACHE = { at: now, data };
130
+ return data;
131
+ }
132
+
133
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
134
+ const v = args[key];
135
+ if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
136
+ return v;
137
+ }
138
+
139
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }