gigai-tools-mcp 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.
Files changed (3) hide show
  1. package/README.md +46 -0
  2. package/package.json +23 -0
  3. package/server.mjs +110 -0
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # gigai-tools-mcp
2
+
3
+ MCP server for the [GigAI Tools API](https://gigai.tools/developers). Gives AI agents (Claude Desktop, Claude Code, anything that speaks MCP) real file tools: merge PDFs, convert and compress images, extract PDF text, generate QR codes and more. The free plan gives 1,000 tasks a month.
4
+
5
+ The tool list comes from the live API catalog at startup, so the server never offers a tool the API cannot run, and new engines appear without updating this package.
6
+
7
+ ## Setup
8
+
9
+ Get an API key at [gigai.tools/developers](https://gigai.tools/developers) (free account, keys in the dashboard).
10
+
11
+ Claude Desktop (`claude_desktop_config.json`) or any MCP client:
12
+
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "gigai-tools": {
17
+ "command": "npx",
18
+ "args": ["-y", "github:cbsshekhawat18-lab/gigai-tools-mcp"],
19
+ "env": {
20
+ "GIGAI_API_KEY": "gk_live_...",
21
+ "GIGAI_MCP_OUT_DIR": "/path/where/results/go"
22
+ }
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ Claude Code:
29
+
30
+ ```
31
+ claude mcp add gigai-tools -e GIGAI_API_KEY=gk_live_... -- npx -y github:cbsshekhawat18-lab/gigai-tools-mcp
32
+ ```
33
+
34
+ ## What the agent can do
35
+
36
+ Every engine becomes a tool: `merge_pdf`, `split_pdf`, `rotate_pdf`, `pdf_to_text`, `convert_image`, `resize_image`, `compress_image`, `optimize_svg`, `markdown_to_html`, `generate_qr`. Tools take local file paths (or URLs the server fetches), and results are saved to `GIGAI_MCP_OUT_DIR` - file bytes never pass through the model's context, only the saved paths do.
37
+
38
+ ## Environment
39
+
40
+ - `GIGAI_API_KEY` - required.
41
+ - `GIGAI_API_BASE` - optional, defaults to the public API.
42
+ - `GIGAI_MCP_OUT_DIR` - where results are saved (default: the working directory).
43
+
44
+ ## Privacy
45
+
46
+ Files go to the GigAI API for processing. Contents are never logged, results are deleted after the retention window, and deletion is verified. Details: [gigai.tools/developers/docs](https://gigai.tools/developers/docs).
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "gigai-tools-mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for the GigAI Tools API - lets AI agents merge PDFs, convert images, generate QR codes and more. Free plan.",
5
+ "type": "module",
6
+ "bin": {
7
+ "gigai-mcp": "./server.mjs"
8
+ },
9
+ "files": [
10
+ "server.mjs",
11
+ "README.md"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "license": "MIT",
17
+ "author": "Gigai Kripa Services <hello@gigaikripaservices.com>",
18
+ "homepage": "https://gigai.tools/developers",
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "^1.12.0",
21
+ "gigai-tools": "^0.1.0"
22
+ }
23
+ }
package/server.mjs ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * gigai-mcp - MCP server for the GigAI Tools API (stdio transport).
4
+ *
5
+ * Exposes every engine from GET /v1/tools as an MCP tool, so agents can
6
+ * merge PDFs, convert images, generate QR codes and the rest. The tool list
7
+ * is fetched from the live catalog at startup: an engine the API cannot run
8
+ * is never offered, and new engines appear without a package update.
9
+ *
10
+ * Config (env): GIGAI_API_KEY (required), GIGAI_API_BASE (optional),
11
+ * GIGAI_MCP_OUT_DIR (where results are saved, default: the working dir).
12
+ *
13
+ * File handling: tools take local file PATHS. Results are saved to the out
14
+ * dir and the tool answer names the saved paths - file bytes never pass
15
+ * through the model's context.
16
+ */
17
+
18
+ import path from "node:path";
19
+ import { mkdir } from "node:fs/promises";
20
+
21
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
22
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
23
+ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
24
+ import { Client, GigaiError } from "gigai-tools";
25
+
26
+ const OUT_DIR = process.env.GIGAI_MCP_OUT_DIR || process.cwd();
27
+
28
+ let client;
29
+ try {
30
+ client = new Client();
31
+ } catch (err) {
32
+ console.error(err.message);
33
+ process.exit(1);
34
+ }
35
+
36
+ let catalog;
37
+ try {
38
+ catalog = await client.tools();
39
+ } catch (err) {
40
+ console.error(`Could not load the tool catalog from ${client.baseUrl}: ${err.message}`);
41
+ process.exit(1);
42
+ }
43
+
44
+ /** Engine manifest entry -> MCP tool definition (plain JSON Schema). */
45
+ function toMcpTool(engine) {
46
+ const properties = { ...(engine.options_schema.properties ?? {}) };
47
+ const required = [...(engine.options_schema.required ?? [])];
48
+ if (!engine.no_input) {
49
+ properties.files = {
50
+ type: "array",
51
+ items: { type: "string" },
52
+ description: `Local ${engine.input_formats.join("/")} file path(s)` +
53
+ (engine.multi_input ? "" : " (exactly one)") +
54
+ ", or http(s) URLs the server fetches.",
55
+ };
56
+ required.unshift("files");
57
+ }
58
+ properties.output_dir = {
59
+ type: "string",
60
+ description: `Directory to save results into (default: ${OUT_DIR}).`,
61
+ };
62
+ return {
63
+ name: engine.slug.replaceAll("-", "_"),
64
+ description: `${engine.description} Output: ${engine.output_formats.join("/")}.`,
65
+ inputSchema: { type: "object", properties, required },
66
+ };
67
+ }
68
+
69
+ const bySlug = new Map(catalog.map((e) => [e.slug.replaceAll("-", "_"), e]));
70
+
71
+ const server = new Server(
72
+ { name: "gigai-tools", version: "0.1.0" },
73
+ { capabilities: { tools: {} } },
74
+ );
75
+
76
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
77
+ tools: catalog.map(toMcpTool),
78
+ }));
79
+
80
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
81
+ const engine = bySlug.get(request.params.name);
82
+ if (!engine) {
83
+ return { content: [{ type: "text", text: `Unknown tool '${request.params.name}'.` }], isError: true };
84
+ }
85
+ const { files, output_dir: outputDir, ...options } = request.params.arguments ?? {};
86
+ const out = outputDir || OUT_DIR;
87
+ try {
88
+ await mkdir(out, { recursive: true });
89
+ const saved = await client.run(engine.slug, {
90
+ files: engine.no_input ? undefined : files,
91
+ options,
92
+ output: out,
93
+ });
94
+ const lines = saved.map((p) => path.resolve(p));
95
+ return {
96
+ content: [{
97
+ type: "text",
98
+ text: `Done. Saved:\n${lines.join("\n")}\n\nFiles were processed by the GigAI API and the server copies are deleted after the retention window.`,
99
+ }],
100
+ };
101
+ } catch (err) {
102
+ const message = err instanceof GigaiError
103
+ ? `${err.code}: ${err.apiMessage}${err.param ? ` (${err.param})` : ""}`
104
+ : err.message;
105
+ return { content: [{ type: "text", text: `Failed - ${message}` }], isError: true };
106
+ }
107
+ });
108
+
109
+ await server.connect(new StdioServerTransport());
110
+ console.error(`gigai-mcp up: ${catalog.length} tools from ${client.baseUrl}, saving to ${OUT_DIR}`);