@selfhost.dev/mcp-server 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 (59) hide show
  1. package/README.md +382 -0
  2. package/dist/auth.d.ts +18 -0
  3. package/dist/auth.js +204 -0
  4. package/dist/auth.js.map +1 -0
  5. package/dist/client.d.ts +10 -0
  6. package/dist/client.js +84 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/config.d.ts +13 -0
  9. package/dist/config.js +20 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +71 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/rate-limiter.d.ts +22 -0
  15. package/dist/rate-limiter.js +124 -0
  16. package/dist/rate-limiter.js.map +1 -0
  17. package/dist/session.d.ts +25 -0
  18. package/dist/session.js +48 -0
  19. package/dist/session.js.map +1 -0
  20. package/dist/tools/alerts.d.ts +2 -0
  21. package/dist/tools/alerts.js +372 -0
  22. package/dist/tools/alerts.js.map +1 -0
  23. package/dist/tools/auth.d.ts +2 -0
  24. package/dist/tools/auth.js +142 -0
  25. package/dist/tools/auth.js.map +1 -0
  26. package/dist/tools/backups.d.ts +2 -0
  27. package/dist/tools/backups.js +294 -0
  28. package/dist/tools/backups.js.map +1 -0
  29. package/dist/tools/credentials.d.ts +2 -0
  30. package/dist/tools/credentials.js +187 -0
  31. package/dist/tools/credentials.js.map +1 -0
  32. package/dist/tools/instances.d.ts +2 -0
  33. package/dist/tools/instances.js +555 -0
  34. package/dist/tools/instances.js.map +1 -0
  35. package/dist/tools/networking.d.ts +2 -0
  36. package/dist/tools/networking.js +240 -0
  37. package/dist/tools/networking.js.map +1 -0
  38. package/dist/tools/organizations.d.ts +2 -0
  39. package/dist/tools/organizations.js +260 -0
  40. package/dist/tools/organizations.js.map +1 -0
  41. package/dist/tools/pg-config.d.ts +2 -0
  42. package/dist/tools/pg-config.js +59 -0
  43. package/dist/tools/pg-config.js.map +1 -0
  44. package/dist/types/api.d.ts +20 -0
  45. package/dist/types/api.js +2 -0
  46. package/dist/types/api.js.map +1 -0
  47. package/dist/types/models.d.ts +44 -0
  48. package/dist/types/models.js +3 -0
  49. package/dist/types/models.js.map +1 -0
  50. package/dist/types/tiers.d.ts +15 -0
  51. package/dist/types/tiers.js +91 -0
  52. package/dist/types/tiers.js.map +1 -0
  53. package/dist/utils/formatters.d.ts +1 -0
  54. package/dist/utils/formatters.js +28 -0
  55. package/dist/utils/formatters.js.map +1 -0
  56. package/dist/utils/validators.d.ts +14 -0
  57. package/dist/utils/validators.js +9 -0
  58. package/dist/utils/validators.js.map +1 -0
  59. package/package.json +51 -0
@@ -0,0 +1,20 @@
1
+ export interface ApiSuccessResponse<T> {
2
+ status: "success";
3
+ data: T;
4
+ message: string;
5
+ status_code: number;
6
+ }
7
+ export interface ApiErrorResponse {
8
+ status: "error";
9
+ data: null;
10
+ message: string;
11
+ status_code: number;
12
+ }
13
+ export type ApiResponse<T> = ApiSuccessResponse<T> | ApiErrorResponse;
14
+ export interface ClientResult<T> {
15
+ success: boolean;
16
+ data: T | null;
17
+ message: string;
18
+ statusCode: number;
19
+ }
20
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ export interface User {
2
+ id: string;
3
+ email: string;
4
+ display_name: string | null;
5
+ email_verified: boolean;
6
+ create_organization: boolean;
7
+ invite_credits: number;
8
+ created_at: string;
9
+ updated_at: string;
10
+ }
11
+ export interface Organization {
12
+ id: string;
13
+ name: string;
14
+ description: string | null;
15
+ is_creator: boolean;
16
+ members_count: number;
17
+ billing_plan: string | null;
18
+ }
19
+ export interface CloudCredential {
20
+ id: string;
21
+ name: string;
22
+ description: string | null;
23
+ cloud_provider: string;
24
+ auth_method: string;
25
+ status: string;
26
+ is_default: boolean;
27
+ is_platform_managed: boolean;
28
+ last_validated_at: string | null;
29
+ validation_error: string | null;
30
+ metadata: Record<string, unknown> | null;
31
+ data_directory: string | null;
32
+ created_at: string;
33
+ updated_at: string;
34
+ created_by: {
35
+ pid: string;
36
+ email: string;
37
+ display_name: string | null;
38
+ } | null;
39
+ updated_by: {
40
+ pid: string;
41
+ email: string;
42
+ display_name: string | null;
43
+ } | null;
44
+ }
@@ -0,0 +1,3 @@
1
+ // Domain model types — expanded per module
2
+ export {};
3
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/types/models.ts"],"names":[],"mappings":"AAAA,2CAA2C"}
@@ -0,0 +1,15 @@
1
+ export type TierName = "FREE" | "STARTER" | "PRO" | "ENTERPRISE" | "ADMIN";
2
+ export interface BucketConfig {
3
+ burst: number;
4
+ ratePerSecond: number;
5
+ }
6
+ export interface TierConfig {
7
+ readBucket: BucketConfig;
8
+ writeBucket: BucketConfig;
9
+ maxConcurrent: number;
10
+ }
11
+ export declare const TIER_CONFIGS: Record<Exclude<TierName, "ADMIN">, TierConfig>;
12
+ export type OperationCategory = "exempt" | "read" | "write";
13
+ export declare const EXEMPT_TOOLS: Set<string>;
14
+ export declare const WRITE_TOOLS: Set<string>;
15
+ export declare function categorizeOperation(toolName: string): OperationCategory;
@@ -0,0 +1,91 @@
1
+ export const TIER_CONFIGS = {
2
+ FREE: {
3
+ readBucket: { burst: 20, ratePerSecond: 1 },
4
+ writeBucket: { burst: 10, ratePerSecond: 0.33 },
5
+ maxConcurrent: 3,
6
+ },
7
+ STARTER: {
8
+ readBucket: { burst: 40, ratePerSecond: 2.5 },
9
+ writeBucket: { burst: 15, ratePerSecond: 0.83 },
10
+ maxConcurrent: 5,
11
+ },
12
+ PRO: {
13
+ readBucket: { burst: 80, ratePerSecond: 5 },
14
+ writeBucket: { burst: 30, ratePerSecond: 2 },
15
+ maxConcurrent: 10,
16
+ },
17
+ ENTERPRISE: {
18
+ readBucket: { burst: 150, ratePerSecond: 10 },
19
+ writeBucket: { burst: 50, ratePerSecond: 5 },
20
+ maxConcurrent: Infinity,
21
+ },
22
+ };
23
+ export const EXEMPT_TOOLS = new Set([
24
+ "list_regions",
25
+ "get_instance_types_for_region",
26
+ "list_storage_types",
27
+ ]);
28
+ export const WRITE_TOOLS = new Set([
29
+ "create_or_login_user",
30
+ "send_platform_invite",
31
+ "create_organization",
32
+ "update_organization",
33
+ "delete_organization",
34
+ "remove_member",
35
+ "invite_to_org",
36
+ "cancel_invitation",
37
+ "add_credential",
38
+ "update_credential",
39
+ "delete_credential",
40
+ "set_default_credential",
41
+ "create_vpc",
42
+ "delete_vpc",
43
+ "create_subnet",
44
+ "create_security_group",
45
+ "update_security_group",
46
+ "create_instance",
47
+ "update_instance",
48
+ "stop_instance",
49
+ "start_instance",
50
+ "reboot_instance",
51
+ "delete_instance",
52
+ "fork_instance",
53
+ "scale_instance",
54
+ "resize_instance",
55
+ "update_pg_config",
56
+ "create_backup",
57
+ "delete_backup",
58
+ "create_backup_policy",
59
+ "update_backup_policy",
60
+ "delete_backup_policy",
61
+ "delete_snapshot",
62
+ "create_snapshot",
63
+ "create_alert_rule",
64
+ "update_alert_rule",
65
+ "delete_alert_rule",
66
+ "acknowledge_alert",
67
+ "resolve_alert",
68
+ "create_notification_channel",
69
+ "update_notification_channel",
70
+ "delete_notification_channel",
71
+ "test_notification_channel",
72
+ "create_scaling_policy",
73
+ "update_scaling_policy",
74
+ "delete_scaling_policy",
75
+ "create_webhook",
76
+ "update_webhook",
77
+ "delete_webhook",
78
+ "create_agent_token",
79
+ "delete_agent_token",
80
+ "admin_approve_waitlist",
81
+ "admin_revoke_invitation",
82
+ "admin_grant_credits",
83
+ ]);
84
+ export function categorizeOperation(toolName) {
85
+ if (EXEMPT_TOOLS.has(toolName))
86
+ return "exempt";
87
+ if (WRITE_TOOLS.has(toolName))
88
+ return "write";
89
+ return "read";
90
+ }
91
+ //# sourceMappingURL=tiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiers.js","sourceRoot":"","sources":["../../src/types/tiers.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,YAAY,GAAmD;IAC1E,IAAI,EAAE;QACJ,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;QAC3C,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;QAC/C,aAAa,EAAE,CAAC;KACjB;IACD,OAAO,EAAE;QACP,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE;QAC7C,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;QAC/C,aAAa,EAAE,CAAC;KACjB;IACD,GAAG,EAAE;QACH,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;QAC3C,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;QAC5C,aAAa,EAAE,EAAE;KAClB;IACD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE;QAC7C,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;QAC5C,aAAa,EAAE,QAAQ;KACxB;CACF,CAAC;AAIF,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAClC,cAAc;IACd,+BAA+B;IAC/B,oBAAoB;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACjC,sBAAsB;IACtB,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,gBAAgB;IAChB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IACxB,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,uBAAuB;IACvB,uBAAuB;IACvB,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;IAClB,eAAe;IACf,eAAe;IACf,sBAAsB;IACtB,sBAAsB;IACtB,sBAAsB;IACtB,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,eAAe;IACf,6BAA6B;IAC7B,6BAA6B;IAC7B,6BAA6B;IAC7B,2BAA2B;IAC3B,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,oBAAoB;IACpB,oBAAoB;IACpB,wBAAwB;IACxB,yBAAyB;IACzB,qBAAqB;CACtB,CAAC,CAAC;AAEH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAChD,IAAI,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,OAAO,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function stripSensitiveFields(obj: unknown): unknown;
@@ -0,0 +1,28 @@
1
+ const SENSITIVE_KEYS = new Set([
2
+ "init_pg_pass",
3
+ "shdev_admin_pass",
4
+ "repl_admin_pass",
5
+ "credential_data",
6
+ "token_key",
7
+ "secret",
8
+ ]);
9
+ export function stripSensitiveFields(obj) {
10
+ if (obj === null || obj === undefined)
11
+ return obj;
12
+ if (typeof obj !== "object")
13
+ return obj;
14
+ if (Array.isArray(obj)) {
15
+ return obj.map(stripSensitiveFields);
16
+ }
17
+ const result = {};
18
+ for (const [key, value] of Object.entries(obj)) {
19
+ if (SENSITIVE_KEYS.has(key)) {
20
+ result[key] = "[REDACTED]";
21
+ }
22
+ else {
23
+ result[key] = stripSensitiveFields(value);
24
+ }
25
+ }
26
+ return result;
27
+ }
28
+ //# sourceMappingURL=formatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/utils/formatters.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,WAAW;IACX,QAAQ;CACT,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAClD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IAExC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAA8B,CAAC,EAAE,CAAC;QAC1E,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ export declare const pidSchema: z.ZodString;
3
+ export declare const orgPidSchema: z.ZodString;
4
+ export declare const instancePidSchema: z.ZodString;
5
+ export declare const paginationSchema: z.ZodObject<{
6
+ page: z.ZodOptional<z.ZodNumber>;
7
+ items: z.ZodOptional<z.ZodNumber>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ page?: number | undefined;
10
+ items?: number | undefined;
11
+ }, {
12
+ page?: number | undefined;
13
+ items?: number | undefined;
14
+ }>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export const pidSchema = z.string().min(1, "PID is required");
3
+ export const orgPidSchema = z.string().min(1, "Organization PID is required");
4
+ export const instancePidSchema = z.string().min(1, "Instance PID is required");
5
+ export const paginationSchema = z.object({
6
+ page: z.number().int().positive().optional(),
7
+ items: z.number().int().min(1).max(100).optional(),
8
+ });
9
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,8BAA8B,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC5C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CACnD,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@selfhost.dev/mcp-server",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for SelfHost.dev — Manage Database Infrastructure via Natural Language",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "selfhost-mcp": "dist/index.js",
9
+ "@selfhost.dev/mcp-server": "dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "keywords": [
15
+ "mcp",
16
+ "selfhost",
17
+ "database",
18
+ "postgres",
19
+ "aws",
20
+ "claude",
21
+ "cursor",
22
+ "managed databases",
23
+ "cloud databases",
24
+ "cheap managed databases",
25
+ "cost efficient managed databases",
26
+ "SelfHost",
27
+ "cloudSql"
28
+ ],
29
+ "license": "MIT",
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "start": "node dist/index.js",
36
+ "dev": "tsx src/index.ts",
37
+ "typecheck": "tsc --noEmit",
38
+ "prepublishOnly": "npm run build"
39
+ },
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.12.1",
42
+ "dotenv": "^16.5.0",
43
+ "open": "^10.1.0",
44
+ "zod": "^3.24.2"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^25.3.3",
48
+ "tsx": "^4.19.3",
49
+ "typescript": "^5.7.3"
50
+ }
51
+ }