apphud-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/.env.example +23 -0
- package/CHANGELOG.md +21 -0
- package/CODE_OF_CONDUCT.md +27 -0
- package/CONTRIBUTING.md +73 -0
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/SECURITY.md +25 -0
- package/SUPPORT.md +26 -0
- package/assets/apphud-mcp-logo.svg +6 -0
- package/dist/src/app.js +31 -0
- package/dist/src/cli.js +94 -0
- package/dist/src/config/env.js +249 -0
- package/dist/src/domain/constants.js +56 -0
- package/dist/src/domain/models.js +1 -0
- package/dist/src/errors/toolError.js +40 -0
- package/dist/src/http/server.js +24 -0
- package/dist/src/index.js +47 -0
- package/dist/src/mcp/server.js +435 -0
- package/dist/src/security/authResolver.js +43 -0
- package/dist/src/security/rateLimiter.js +22 -0
- package/dist/src/security/rbac.js +11 -0
- package/dist/src/security/secretStore.js +14 -0
- package/dist/src/services/analyticsService.js +934 -0
- package/dist/src/services/appService.js +15 -0
- package/dist/src/services/apphudClient.js +1632 -0
- package/dist/src/services/auditService.js +12 -0
- package/dist/src/services/toolGuard.js +30 -0
- package/package.json +61 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class AuditService {
|
|
2
|
+
_config;
|
|
3
|
+
constructor(_config) {
|
|
4
|
+
this._config = _config;
|
|
5
|
+
}
|
|
6
|
+
async logSuccess(_auth, _toolName, _options) {
|
|
7
|
+
return Promise.resolve();
|
|
8
|
+
}
|
|
9
|
+
async logError(_auth, _toolName, _errorCode, _options) {
|
|
10
|
+
return Promise.resolve();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isApphudMcpError } from "../errors/toolError.js";
|
|
2
|
+
import { assertToolAccess } from "../security/rbac.js";
|
|
3
|
+
export class ToolGuard {
|
|
4
|
+
rateLimiter;
|
|
5
|
+
auditService;
|
|
6
|
+
constructor(rateLimiter, auditService) {
|
|
7
|
+
this.rateLimiter = rateLimiter;
|
|
8
|
+
this.auditService = auditService;
|
|
9
|
+
}
|
|
10
|
+
async run(auth, toolName, callback, options) {
|
|
11
|
+
assertToolAccess(auth, toolName);
|
|
12
|
+
this.rateLimiter.assertLimit(`${auth.tenantId}:${toolName}`);
|
|
13
|
+
try {
|
|
14
|
+
const result = await callback();
|
|
15
|
+
await this.auditService.logSuccess(auth, toolName, {
|
|
16
|
+
appId: options?.appId,
|
|
17
|
+
subjectUserId: options?.subjectUserId,
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const code = isApphudMcpError(error) ? error.code : "INTERNAL_ERROR";
|
|
23
|
+
await this.auditService.logError(auth, toolName, code, {
|
|
24
|
+
appId: options?.appId,
|
|
25
|
+
subjectUserId: options?.subjectUserId,
|
|
26
|
+
});
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "apphud-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "MCP server for Apphud dashboard analytics",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20.0.0"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"mcp",
|
|
12
|
+
"apphud",
|
|
13
|
+
"analytics",
|
|
14
|
+
"revenue",
|
|
15
|
+
"subscriptions"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"apphud-mcp": "dist/src/cli.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"assets",
|
|
26
|
+
"README.md",
|
|
27
|
+
"CHANGELOG.md",
|
|
28
|
+
"CONTRIBUTING.md",
|
|
29
|
+
"SECURITY.md",
|
|
30
|
+
"CODE_OF_CONDUCT.md",
|
|
31
|
+
"SUPPORT.md",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
".env.example"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "tsx src/cli.ts start",
|
|
37
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
38
|
+
"start": "node dist/src/cli.js start",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
40
|
+
"ci": "npm run typecheck && npm test && npm run build",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest",
|
|
43
|
+
"init-config": "tsx src/cli.ts init-config",
|
|
44
|
+
"prepack": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.17.0",
|
|
48
|
+
"dotenv": "^16.4.5",
|
|
49
|
+
"express": "^4.19.2",
|
|
50
|
+
"zod": "^3.23.8"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/express": "^4.17.21",
|
|
54
|
+
"@types/node": "^20.16.5",
|
|
55
|
+
"@types/supertest": "^2.0.16",
|
|
56
|
+
"supertest": "^7.0.0",
|
|
57
|
+
"tsx": "^4.19.1",
|
|
58
|
+
"typescript": "^5.6.2",
|
|
59
|
+
"vitest": "^2.1.3"
|
|
60
|
+
}
|
|
61
|
+
}
|