@pipeworx/mcp-rubygems 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,55 @@
1
+ # mcp-rubygems
2
+
3
+ RubyGems MCP — wraps the RubyGems.org public API (free, no auth)
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 965+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "rubygems": {
20
+ "url": "https://gateway.pipeworx.io/rubygems/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 965+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Rubygems data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-rubygems",
3
+ "version": "0.1.0",
4
+ "description": "RubyGems MCP — wraps the RubyGems.org public API (free, no auth)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "rubygems"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-rubygems"
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/rubygems",
4
+ "title": "Rubygems",
5
+ "description": "RubyGems MCP — wraps the RubyGems.org public API (free, no auth)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/rubygems",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-rubygems",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/rubygems/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,305 @@
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
+ * RubyGems MCP — wraps the RubyGems.org public API (free, no auth)
21
+ *
22
+ * API: https://guides.rubygems.org/rubygems-org-api/
23
+ *
24
+ * Tools:
25
+ * - get_gem: metadata for a gem (latest version + URLs + downloads)
26
+ * - search_gems: keyword search across all published gems
27
+ * - get_versions: full version history for a gem
28
+ * - get_dependencies: runtime + development dependencies for a specific version
29
+ * - get_reverse_dependencies: which other gems depend on this one
30
+ */
31
+
32
+
33
+ const BASE_URL = 'https://rubygems.org/api/v1';
34
+
35
+ // ── Raw API types ────────────────────────────────────────────────────
36
+
37
+ interface RawGem {
38
+ name: string;
39
+ version: string;
40
+ version_created_at?: string;
41
+ authors?: string;
42
+ info?: string;
43
+ licenses?: string[] | null;
44
+ metadata?: Record<string, string>;
45
+ sha?: string;
46
+ project_uri?: string;
47
+ gem_uri?: string;
48
+ homepage_uri?: string | null;
49
+ wiki_uri?: string | null;
50
+ documentation_uri?: string | null;
51
+ mailing_list_uri?: string | null;
52
+ source_code_uri?: string | null;
53
+ bug_tracker_uri?: string | null;
54
+ changelog_uri?: string | null;
55
+ funding_uri?: string | null;
56
+ downloads?: number;
57
+ version_downloads?: number;
58
+ }
59
+
60
+ interface RawVersion {
61
+ number: string;
62
+ authors?: string;
63
+ built_at?: string;
64
+ created_at?: string;
65
+ description?: string;
66
+ downloads_count?: number;
67
+ summary?: string;
68
+ platform?: string;
69
+ ruby_version?: string;
70
+ rubygems_version?: string;
71
+ prerelease?: boolean;
72
+ licenses?: string[] | null;
73
+ metadata?: Record<string, string>;
74
+ }
75
+
76
+ interface RawDependency {
77
+ name: string;
78
+ requirements: string;
79
+ }
80
+
81
+ interface RawDependencies {
82
+ development?: RawDependency[];
83
+ runtime?: RawDependency[];
84
+ }
85
+
86
+ interface RawReverseDep {
87
+ name: string;
88
+ }
89
+
90
+ // ── Helpers ──────────────────────────────────────────────────────────
91
+
92
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
93
+ const v = args[key];
94
+ if (typeof v !== 'string' || !v.trim()) {
95
+ throw new Error(`Required argument "${key}" is missing or empty. Pass a string like ${example}.`);
96
+ }
97
+ return v;
98
+ }
99
+
100
+ async function rgFetch<T>(path: string): Promise<T | { error: string; status: number }> {
101
+ const res = await fetch(`${BASE_URL}${path}`, {
102
+ headers: { 'User-Agent': 'Pipeworx/1.0 (pipeworx.io)' },
103
+ });
104
+ if (res.status === 404) return { error: 'not_found', status: 404 };
105
+ if (!res.ok) throw new Error(`RubyGems API error: ${res.status}`);
106
+ return res.json() as Promise<T>;
107
+ }
108
+
109
+ function formatGem(g: RawGem) {
110
+ return {
111
+ name: g.name,
112
+ latest_version: g.version,
113
+ version_created_at: g.version_created_at ?? null,
114
+ authors: g.authors ?? null,
115
+ info: g.info ?? null,
116
+ licenses: g.licenses ?? null,
117
+ downloads_total: g.downloads ?? null,
118
+ downloads_latest_version: g.version_downloads ?? null,
119
+ project_uri: g.project_uri ?? null,
120
+ gem_uri: g.gem_uri ?? null,
121
+ homepage: g.homepage_uri ?? null,
122
+ documentation: g.documentation_uri ?? null,
123
+ source_code: g.source_code_uri ?? null,
124
+ bug_tracker: g.bug_tracker_uri ?? null,
125
+ changelog: g.changelog_uri ?? null,
126
+ };
127
+ }
128
+
129
+ function formatVersion(v: RawVersion) {
130
+ return {
131
+ number: v.number,
132
+ prerelease: v.prerelease ?? false,
133
+ platform: v.platform ?? null,
134
+ created_at: v.created_at ?? null,
135
+ downloads: v.downloads_count ?? null,
136
+ ruby_version: v.ruby_version ?? null,
137
+ licenses: v.licenses ?? null,
138
+ summary: v.summary ?? null,
139
+ };
140
+ }
141
+
142
+ // ── Tool definitions ─────────────────────────────────────────────────
143
+
144
+ const tools: McpToolExport['tools'] = [
145
+ {
146
+ name: 'get_gem',
147
+ description:
148
+ 'Get full metadata for a published Ruby gem by name. Returns latest version, authors, license, descriptions, download counts, and project/source URLs. Use for "what is gem X?", "tell me about Ruby gem Y", or before calling get_versions/get_dependencies.',
149
+ inputSchema: {
150
+ type: 'object',
151
+ properties: {
152
+ name: { type: 'string', description: 'Gem name (e.g., "rails", "devise", "rspec")' },
153
+ },
154
+ required: ['name'],
155
+ },
156
+ },
157
+ {
158
+ name: 'search_gems',
159
+ description:
160
+ 'Search RubyGems by keyword in name/description. Returns matching gems sorted by relevance with name, version, downloads, and info text.',
161
+ inputSchema: {
162
+ type: 'object',
163
+ properties: {
164
+ query: { type: 'string', description: 'Keyword(s) to search for (e.g., "authentication", "json parser")' },
165
+ limit: { type: 'number', description: 'Max results to return (1–30, default 10). API caps at 30/page.' },
166
+ page: { type: 'number', description: 'Page number (1-based, default 1).' },
167
+ },
168
+ required: ['query'],
169
+ },
170
+ },
171
+ {
172
+ name: 'get_versions',
173
+ description:
174
+ 'Get full version history for a Ruby gem. Returns every published version with release date, download count, Ruby version compatibility, and licenses. Use for "what versions of X exist?" or "when did Y release version Z?".',
175
+ inputSchema: {
176
+ type: 'object',
177
+ properties: {
178
+ name: { type: 'string', description: 'Gem name (e.g., "rails")' },
179
+ limit: { type: 'number', description: 'Max versions to return (default 25, max 200). Latest first.' },
180
+ },
181
+ required: ['name'],
182
+ },
183
+ },
184
+ {
185
+ name: 'get_dependencies',
186
+ description:
187
+ 'Get the runtime and development dependencies for a specific version of a Ruby gem. Returns each dependency with its version requirement string. Omit version to get the latest.',
188
+ inputSchema: {
189
+ type: 'object',
190
+ properties: {
191
+ name: { type: 'string', description: 'Gem name (e.g., "devise")' },
192
+ version: { type: 'string', description: 'Version string (e.g., "5.0.4"). Omit for latest.' },
193
+ },
194
+ required: ['name'],
195
+ },
196
+ },
197
+ {
198
+ name: 'get_reverse_dependencies',
199
+ description:
200
+ 'List gems that depend on this gem. Useful for understanding ecosystem impact ("what depends on Rack?") or risk surface ("how many gems would break if this one had a vulnerability?"). API caps at 50 names per request.',
201
+ inputSchema: {
202
+ type: 'object',
203
+ properties: {
204
+ name: { type: 'string', description: 'Gem name (e.g., "rack")' },
205
+ },
206
+ required: ['name'],
207
+ },
208
+ },
209
+ ];
210
+
211
+ // ── Tool implementations ─────────────────────────────────────────────
212
+
213
+ async function getGem(args: Record<string, unknown>) {
214
+ const name = reqStr(args, 'name', '"rails"');
215
+ const data = await rgFetch<RawGem>(`/gems/${encodeURIComponent(name)}.json`);
216
+ if ('error' in data) return { found: false, name, hint: 'Gem not found on rubygems.org.' };
217
+ return { found: true, ...formatGem(data) };
218
+ }
219
+
220
+ async function searchGems(args: Record<string, unknown>) {
221
+ const query = reqStr(args, 'query', '"authentication"');
222
+ const limit = Math.min(30, Math.max(1, (args.limit as number | undefined) ?? 10));
223
+ const page = (args.page as number | undefined) ?? 1;
224
+ const params = new URLSearchParams({ query, page: String(page) });
225
+
226
+ const data = await rgFetch<RawGem[]>(`/search.json?${params}`);
227
+ if ('error' in data) return { query, count: 0, gems: [] };
228
+ const limited = data.slice(0, limit);
229
+ return {
230
+ query,
231
+ page,
232
+ count: limited.length,
233
+ gems: limited.map(formatGem),
234
+ };
235
+ }
236
+
237
+ async function getVersions(args: Record<string, unknown>) {
238
+ const name = reqStr(args, 'name', '"rails"');
239
+ const limit = Math.min(200, Math.max(1, (args.limit as number | undefined) ?? 25));
240
+ const data = await rgFetch<RawVersion[]>(`/versions/${encodeURIComponent(name)}.json`);
241
+ if ('error' in data) return { found: false, name, hint: 'Gem not found.' };
242
+ return {
243
+ found: true,
244
+ name,
245
+ total_versions: data.length,
246
+ returned: Math.min(limit, data.length),
247
+ versions: data.slice(0, limit).map(formatVersion),
248
+ };
249
+ }
250
+
251
+ async function getDependencies(args: Record<string, unknown>) {
252
+ const name = reqStr(args, 'name', '"devise"');
253
+ const version = args.version as string | undefined;
254
+ // Get all versions, pick the requested or the latest non-prerelease
255
+ const versions = await rgFetch<RawVersion[]>(`/versions/${encodeURIComponent(name)}.json`);
256
+ if ('error' in versions) return { found: false, name, hint: 'Gem not found.' };
257
+
258
+ const targetVersion = version
259
+ ? versions.find((v) => v.number === version)
260
+ : versions.find((v) => !v.prerelease) ?? versions[0];
261
+ if (!targetVersion) {
262
+ return { found: false, name, version, hint: 'Version not found. Use get_versions to list available versions.' };
263
+ }
264
+
265
+ const deps = await rgFetch<RawGem & { dependencies?: RawDependencies }>(
266
+ `/versions/${encodeURIComponent(name)}/${encodeURIComponent(targetVersion.number)}.json`,
267
+ );
268
+ if ('error' in deps) return { found: false, name, version: targetVersion.number };
269
+ return {
270
+ found: true,
271
+ name,
272
+ version: targetVersion.number,
273
+ runtime: deps.dependencies?.runtime ?? [],
274
+ development: deps.dependencies?.development ?? [],
275
+ };
276
+ }
277
+
278
+ async function getReverseDependencies(args: Record<string, unknown>) {
279
+ const name = reqStr(args, 'name', '"rack"');
280
+ // The reverse_dependencies endpoint returns just a list of names
281
+ const data = await rgFetch<string[]>(`/gems/${encodeURIComponent(name)}/reverse_dependencies.json`);
282
+ if ('error' in data) return { found: false, name, hint: 'Gem not found.' };
283
+ return {
284
+ found: true,
285
+ name,
286
+ count: data.length,
287
+ dependents: data.slice(0, 50), // API caps at 50 per request
288
+ has_more: data.length > 50,
289
+ };
290
+ }
291
+
292
+ // ── callTool router ──────────────────────────────────────────────────
293
+
294
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
295
+ switch (name) {
296
+ case 'get_gem': return getGem(args);
297
+ case 'search_gems': return searchGems(args);
298
+ case 'get_versions': return getVersions(args);
299
+ case 'get_dependencies': return getDependencies(args);
300
+ case 'get_reverse_dependencies': return getReverseDependencies(args);
301
+ default: throw new Error(`Unknown tool: ${name}`);
302
+ }
303
+ }
304
+
305
+ 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
+ }