@fload-ai/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.
package/README.md ADDED
@@ -0,0 +1,359 @@
1
+ # @fload/mcp
2
+
3
+ **Fload MCP Server** - Model Context Protocol server for AI agents to access Fload's mobile app analytics, reviews, and growth insights.
4
+
5
+ ## What is MCP?
6
+
7
+ [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is an open standard by Anthropic that enables AI applications to securely connect to data sources and tools. This package implements an MCP server that exposes Fload's mobile analytics capabilities to AI agents like Claude, ChatGPT, and custom AI tools.
8
+
9
+ ## Features
10
+
11
+ - **🎯 Core Tools (Phase 1)**
12
+ - `list_apps` - List all apps in your organization
13
+ - `get_app_details` - Get detailed app information
14
+ - `get_reviews` - Query reviews with flexible filters
15
+ - `get_analytics_summary` - Get metric summaries with timeseries data
16
+
17
+ - **🔒 Authentication**
18
+ - API key-based authentication
19
+ - Organization-scoped access
20
+ - Secure credential management
21
+
22
+ - **🚀 Fast & Reliable**
23
+ - Direct database queries (Drizzle ORM)
24
+ - TimescaleDB for analytics
25
+ - Optimized for AI agent workflows
26
+
27
+ ## Installation
28
+
29
+ ### From Monorepo (Development)
30
+
31
+ ```bash
32
+ cd ~/www/fload
33
+ pnpm install
34
+ pnpm build
35
+ ```
36
+
37
+ ### From NPM (Production)
38
+
39
+ ```bash
40
+ npm install -g @fload/mcp
41
+ # or
42
+ npx @fload/mcp
43
+ ```
44
+
45
+ ## Setup
46
+
47
+ ### 1. Generate API Key
48
+
49
+ 🚧 **Coming Soon:** API key management UI in Fload web app.
50
+
51
+ For now, contact your Fload admin to generate an API key.
52
+
53
+ ### 2. Configure Environment
54
+
55
+ **Option A: Environment Variables (Recommended)**
56
+
57
+ ```bash
58
+ export FLOAD_API_KEY=fload_sk_your_key_here
59
+ export DATABASE_URL=postgresql://user:pass@host:port/fload
60
+ ```
61
+
62
+ **Option B: Config File**
63
+
64
+ Create `~/.fload/config.json`:
65
+
66
+ ```json
67
+ {
68
+ "apiKey": "fload_sk_your_key_here",
69
+ "databaseUrl": "postgresql://user:pass@host:port/fload",
70
+ "organizationId": "your-org-id"
71
+ }
72
+ ```
73
+
74
+ ### 3. Test the Server
75
+
76
+ ```bash
77
+ # From monorepo
78
+ pnpm --filter @fload/mcp dev
79
+
80
+ # Or via npx
81
+ npx @fload/mcp
82
+ ```
83
+
84
+ You should see:
85
+ ```
86
+ [Fload MCP] Starting server...
87
+ [Fload MCP] Configuration loaded
88
+ [Fload MCP] Database connected
89
+ [Fload MCP] Server running on stdio
90
+ ```
91
+
92
+ ## Usage
93
+
94
+ ### With Claude Desktop
95
+
96
+ Add to your `claude_desktop_config.json`:
97
+
98
+ **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
99
+ **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
100
+
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "fload": {
105
+ "command": "npx",
106
+ "args": ["@fload/mcp"],
107
+ "env": {
108
+ "FLOAD_API_KEY": "fload_sk_your_key_here",
109
+ "DATABASE_URL": "postgresql://..."
110
+ }
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ Restart Claude Desktop, and you'll see the Fload tools available!
117
+
118
+ ### With Custom MCP Client
119
+
120
+ ```typescript
121
+ import { McpClient } from '@modelcontextprotocol/sdk/client/mcp.js';
122
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
123
+
124
+ const client = new McpClient({
125
+ name: 'my-client',
126
+ version: '1.0.0',
127
+ });
128
+
129
+ const transport = new StdioClientTransport({
130
+ command: 'npx',
131
+ args: ['@fload/mcp'],
132
+ env: {
133
+ FLOAD_API_KEY: 'fload_sk_...',
134
+ DATABASE_URL: 'postgresql://...',
135
+ },
136
+ });
137
+
138
+ await client.connect(transport);
139
+
140
+ // List apps
141
+ const result = await client.callTool('list_apps', { limit: 10 });
142
+ console.log(result);
143
+ ```
144
+
145
+ ## Tools Reference
146
+
147
+ ### `list_apps`
148
+
149
+ List all mobile apps in your organization.
150
+
151
+ **Input:**
152
+ ```typescript
153
+ {
154
+ platform?: 'ios' | 'android', // Filter by platform
155
+ limit?: number // Max results (1-100, default: 50)
156
+ }
157
+ ```
158
+
159
+ **Output:**
160
+ ```json
161
+ {
162
+ "total": 2,
163
+ "apps": [
164
+ {
165
+ "id": "uuid",
166
+ "name": "My Awesome App",
167
+ "bundleId": "com.example.app",
168
+ "platform": "ios",
169
+ "iconUrl": "https://...",
170
+ "category": "Games",
171
+ "addedAt": "2024-01-15T10:30:00Z"
172
+ }
173
+ ]
174
+ }
175
+ ```
176
+
177
+ ### `get_app_details`
178
+
179
+ Get detailed information about a specific app.
180
+
181
+ **Input:**
182
+ ```typescript
183
+ {
184
+ assetId?: string, // App UUID (provide either this or bundleId)
185
+ bundleId?: string // App bundle ID
186
+ }
187
+ ```
188
+
189
+ **Output:** Full app metadata + connected data sources + sync status
190
+
191
+ ### `get_reviews`
192
+
193
+ Get app reviews with flexible filtering.
194
+
195
+ **Input:**
196
+ ```typescript
197
+ {
198
+ assetId?: string, // App UUID
199
+ bundleId?: string, // App bundle ID
200
+ platform?: 'ios' | 'android',
201
+ rating?: 1 | 2 | 3 | 4 | 5, // Filter by star rating
202
+ replied?: boolean, // Has reply?
203
+ startDate?: string, // ISO date (YYYY-MM-DD)
204
+ endDate?: string,
205
+ limit?: number, // Max results (1-200, default: 50)
206
+ sortBy?: 'date' | 'rating' // Sort order
207
+ }
208
+ ```
209
+
210
+ **Output:**
211
+ ```json
212
+ {
213
+ "summary": {
214
+ "totalReviews": 25,
215
+ "averageRating": "4.20",
216
+ "repliedCount": 10,
217
+ "unrepliedCount": 15
218
+ },
219
+ "reviews": [
220
+ {
221
+ "id": "uuid",
222
+ "rating": 5,
223
+ "title": "Great app!",
224
+ "body": "Love the new features...",
225
+ "author": "John Doe",
226
+ "date": "2024-02-20T14:30:00Z",
227
+ "version": "2.1.0",
228
+ "country": "US",
229
+ "hasReply": true,
230
+ "reply": "Thank you for your feedback!",
231
+ "replyDate": "2024-02-21T09:00:00Z"
232
+ }
233
+ ]
234
+ }
235
+ ```
236
+
237
+ ### `get_analytics_summary`
238
+
239
+ Get analytics summary with timeseries data.
240
+
241
+ **Input:**
242
+ ```typescript
243
+ {
244
+ assetId?: string,
245
+ bundleId?: string,
246
+ metric: 'downloads' | 'revenue' | 'active_users' | 'sessions' | 'retention' | 'crashes',
247
+ period?: '7d' | '30d' | '90d', // Default: '30d'
248
+ granularity?: 'day' | 'week' | 'month' // Default: 'day'
249
+ }
250
+ ```
251
+
252
+ **Output:**
253
+ ```json
254
+ {
255
+ "app": {
256
+ "id": "uuid",
257
+ "name": "My App",
258
+ "bundleId": "com.example.app",
259
+ "platform": "ios"
260
+ },
261
+ "metric": "downloads",
262
+ "period": "30d",
263
+ "dateRange": {
264
+ "start": "2024-01-25",
265
+ "end": "2024-02-25"
266
+ },
267
+ "summary": {
268
+ "total": 125000,
269
+ "average": 4167,
270
+ "min": 3200,
271
+ "max": 5800,
272
+ "trend": "+12.5%"
273
+ },
274
+ "timeseries": [
275
+ { "date": "2024-01-25", "value": 4200 },
276
+ { "date": "2024-01-26", "value": 4350 }
277
+ ]
278
+ }
279
+ ```
280
+
281
+ ## Development
282
+
283
+ ### Project Structure
284
+
285
+ ```
286
+ packages/fload-mcp/
287
+ ├── src/
288
+ │ ├── index.ts # Main entry point (STDIO)
289
+ │ ├── server.ts # MCP server setup
290
+ │ ├── config.ts # Configuration loading
291
+ │ ├── auth.ts # API key validation
292
+ │ ├── tools/ # Tool implementations
293
+ │ │ ├── apps.ts
294
+ │ │ ├── reviews.ts
295
+ │ │ └── analytics.ts
296
+ │ └── lib/
297
+ │ ├── db-client.ts # Database connection
298
+ │ └── format.ts # Response formatting
299
+ ├── bin/
300
+ │ └── fload-mcp.js # CLI executable
301
+ └── package.json
302
+ ```
303
+
304
+ ### Build
305
+
306
+ ```bash
307
+ pnpm build
308
+ ```
309
+
310
+ ### Test
311
+
312
+ ```bash
313
+ pnpm test
314
+ ```
315
+
316
+ ### Typecheck
317
+
318
+ ```bash
319
+ pnpm typecheck
320
+ ```
321
+
322
+ ### Lint
323
+
324
+ ```bash
325
+ pnpm lint
326
+ ```
327
+
328
+ ## Roadmap
329
+
330
+ - **Phase 1** ✅ - Core tools (apps, reviews, analytics)
331
+ - **Phase 2** 🚧 - Full tool suite (revenue, ratings, ASO, competitors, growth audit)
332
+ - **Phase 3** 📋 - Resources & Prompts
333
+ - **Phase 4** 📋 - CLI wrapper
334
+ - **Phase 5** 📋 - HTTP/SSE transport (hosted MCP server)
335
+
336
+ ## Security
337
+
338
+ - **API keys** should be kept secret and never committed to version control
339
+ - **Scoped access** - API keys only access their organization's data
340
+ - **Audit logging** - All tool calls are logged for compliance
341
+ - **Rate limiting** - Prevents abuse (coming in Phase 2)
342
+
343
+ ## Contributing
344
+
345
+ This package is part of the Fload monorepo. See [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.
346
+
347
+ ## License
348
+
349
+ MIT © Fload
350
+
351
+ ## Support
352
+
353
+ - **Documentation:** [Design Doc](../../docs/cli-mcp-design.md)
354
+ - **Issues:** GitHub Issues
355
+ - **Email:** support@fload.io
356
+
357
+ ---
358
+
359
+ **Built with ❤️ for AI agents**