@rainfall-devkit/sdk 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/dist/mcp.mjs ADDED
@@ -0,0 +1,181 @@
1
+ import {
2
+ AuthenticationError,
3
+ NetworkError,
4
+ NotFoundError,
5
+ Rainfall,
6
+ RainfallError,
7
+ RateLimitError,
8
+ ServerError,
9
+ TimeoutError,
10
+ ToolNotFoundError,
11
+ ValidationError,
12
+ parseErrorResponse
13
+ } from "./chunk-UP45HOXN.mjs";
14
+
15
+ // src/mcp.ts
16
+ function createRainfallMCPServer(config) {
17
+ const rainfall = new Rainfall(config);
18
+ const serverName = config.name || "rainfall-mcp-server";
19
+ const serverVersion = config.version || "0.1.0";
20
+ let toolCache = null;
21
+ async function getTools() {
22
+ if (toolCache) return toolCache;
23
+ const tools = await rainfall.listTools();
24
+ let filteredTools = tools;
25
+ if (config.tools) {
26
+ const toolSet = new Set(config.tools);
27
+ filteredTools = filteredTools.filter((t) => toolSet.has(t.id));
28
+ }
29
+ if (config.excludeTools) {
30
+ const excludeSet = new Set(config.excludeTools);
31
+ filteredTools = filteredTools.filter((t) => !excludeSet.has(t.id));
32
+ }
33
+ toolCache = filteredTools.map((t) => ({
34
+ name: t.id,
35
+ description: t.description,
36
+ inputSchema: {
37
+ type: "object",
38
+ properties: {},
39
+ required: []
40
+ }
41
+ }));
42
+ return toolCache;
43
+ }
44
+ async function handleRequest(request) {
45
+ const { id, method, params = {} } = request;
46
+ try {
47
+ switch (method) {
48
+ case "initialize":
49
+ return {
50
+ jsonrpc: "2.0",
51
+ id,
52
+ result: {
53
+ protocolVersion: "2024-11-05",
54
+ capabilities: {
55
+ tools: {}
56
+ },
57
+ serverInfo: {
58
+ name: serverName,
59
+ version: serverVersion
60
+ }
61
+ }
62
+ };
63
+ case "tools/list":
64
+ const tools = await getTools();
65
+ return {
66
+ jsonrpc: "2.0",
67
+ id,
68
+ result: { tools }
69
+ };
70
+ case "tools/call":
71
+ const { name, arguments: args = {} } = params;
72
+ if (!name) {
73
+ return {
74
+ jsonrpc: "2.0",
75
+ id,
76
+ error: {
77
+ code: -32602,
78
+ message: "Missing tool name"
79
+ }
80
+ };
81
+ }
82
+ const result = await rainfall.executeTool(name, args);
83
+ const content = typeof result === "string" ? [{ type: "text", text: result }] : [{ type: "text", text: JSON.stringify(result, null, 2) }];
84
+ return {
85
+ jsonrpc: "2.0",
86
+ id,
87
+ result: { content }
88
+ };
89
+ case "resources/list":
90
+ return {
91
+ jsonrpc: "2.0",
92
+ id,
93
+ result: { resources: [] }
94
+ };
95
+ case "prompts/list":
96
+ return {
97
+ jsonrpc: "2.0",
98
+ id,
99
+ result: { prompts: [] }
100
+ };
101
+ default:
102
+ return {
103
+ jsonrpc: "2.0",
104
+ id,
105
+ error: {
106
+ code: -32601,
107
+ message: `Method not found: ${method}`
108
+ }
109
+ };
110
+ }
111
+ } catch (error) {
112
+ const message = error instanceof Error ? error.message : String(error);
113
+ return {
114
+ jsonrpc: "2.0",
115
+ id,
116
+ error: {
117
+ code: -32603,
118
+ message,
119
+ data: error instanceof Error ? { stack: error.stack } : void 0
120
+ }
121
+ };
122
+ }
123
+ }
124
+ async function start() {
125
+ const { stdin, stdout } = process;
126
+ stdin.setEncoding("utf8");
127
+ let buffer = "";
128
+ stdin.on("data", async (chunk) => {
129
+ buffer += chunk;
130
+ let newlineIndex;
131
+ while ((newlineIndex = buffer.indexOf("\n")) !== -1) {
132
+ const line = buffer.slice(0, newlineIndex);
133
+ buffer = buffer.slice(newlineIndex + 1);
134
+ if (line.trim()) {
135
+ try {
136
+ const request = JSON.parse(line);
137
+ const response = await handleRequest(request);
138
+ stdout.write(JSON.stringify(response) + "\n");
139
+ } catch (error) {
140
+ const message = error instanceof Error ? error.message : String(error);
141
+ const errorResponse = {
142
+ jsonrpc: "2.0",
143
+ id: null,
144
+ error: {
145
+ code: -32700,
146
+ message: `Parse error: ${message}`
147
+ }
148
+ };
149
+ stdout.write(JSON.stringify(errorResponse) + "\n");
150
+ }
151
+ }
152
+ }
153
+ });
154
+ process.on("SIGINT", () => {
155
+ process.exit(0);
156
+ });
157
+ process.on("SIGTERM", () => {
158
+ process.exit(0);
159
+ });
160
+ }
161
+ return {
162
+ handleRequest,
163
+ start,
164
+ getTools,
165
+ rainfall
166
+ };
167
+ }
168
+ export {
169
+ AuthenticationError,
170
+ NetworkError,
171
+ NotFoundError,
172
+ Rainfall,
173
+ RainfallError,
174
+ RateLimitError,
175
+ ServerError,
176
+ TimeoutError,
177
+ ToolNotFoundError,
178
+ ValidationError,
179
+ createRainfallMCPServer,
180
+ parseErrorResponse
181
+ };
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@rainfall-devkit/sdk",
3
+ "version": "0.1.1",
4
+ "description": "Official SDK for Rainfall API - 200+ tools for building AI-powered applications",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "rainfall": "./dist/cli.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./mcp": {
18
+ "import": "./dist/mcp.mjs",
19
+ "require": "./dist/mcp.js",
20
+ "types": "./dist/mcp.d.ts"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsup src/index.ts src/mcp.ts src/cli/index.ts --format cjs,esm --dts --shims",
30
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
31
+ "test": "bun test",
32
+ "lint": "tsc --noEmit",
33
+ "prepublishOnly": "bun run build"
34
+ },
35
+ "keywords": [
36
+ "rainfall",
37
+ "api",
38
+ "sdk",
39
+ "ai",
40
+ "tools",
41
+ "mcp",
42
+ "automation",
43
+ "github",
44
+ "notion",
45
+ "linear",
46
+ "slack",
47
+ "figma",
48
+ "stripe"
49
+ ],
50
+ "author": "Pragma Digital",
51
+ "license": "MIT",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/Holistic-Dogma/rainfall-devkit.git"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/Holistic-Dogma/rainfall-devkit/issues"
58
+ },
59
+ "homepage": "https://github.com/Holistic-Dogma/rainfall-devkit#readme",
60
+ "devDependencies": {
61
+ "@types/bun": "latest",
62
+ "@types/node": "^20",
63
+ "tsup": "^8",
64
+ "typescript": "^5"
65
+ },
66
+ "engines": {
67
+ "node": ">=18"
68
+ }
69
+ }