@selfhost.dev/mcp-server 0.4.0 → 0.5.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 +91 -51
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -3
- package/dist/client.js +1 -1
- package/dist/config.js +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/rate-limiter.js +9 -11
- package/dist/rate-limiter.js.map +1 -1
- package/dist/session.d.ts +0 -1
- package/dist/session.js +3 -12
- package/dist/session.js.map +1 -1
- package/dist/tools/alerts.js +5 -3
- package/dist/tools/alerts.js.map +1 -1
- package/dist/tools/auth.js +0 -1
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/billing.js +68 -72
- package/dist/tools/billing.js.map +1 -1
- package/dist/tools/credentials.js +1 -1
- package/dist/tools/database-users.js +15 -11
- package/dist/tools/database-users.js.map +1 -1
- package/dist/tools/hetzner.js +13 -13
- package/dist/tools/instances.js +22 -16
- package/dist/tools/instances.js.map +1 -1
- package/dist/tools/mysql-config.d.ts +2 -0
- package/dist/tools/mysql-config.js +43 -0
- package/dist/tools/mysql-config.js.map +1 -0
- package/dist/tools/organizations.js +0 -1
- package/dist/tools/organizations.js.map +1 -1
- package/dist/tools/pgbouncer.js +7 -6
- package/dist/tools/pgbouncer.js.map +1 -1
- package/dist/tools/pitr.js +22 -20
- package/dist/tools/pitr.js.map +1 -1
- package/dist/tools/project-databases.js +4 -4
- package/dist/tools/project-databases.js.map +1 -1
- package/dist/tools/project-services.js +3 -4
- package/dist/tools/project-services.js.map +1 -1
- package/dist/tools/proxysql.d.ts +15 -0
- package/dist/tools/proxysql.js +141 -0
- package/dist/tools/proxysql.js.map +1 -0
- package/dist/tools/scaling.js +13 -13
- package/dist/types/models.d.ts +1 -1
- package/dist/types/models.js +1 -1
- package/dist/types/tiers.d.ts +1 -1
- package/dist/types/tiers.js +8 -26
- package/dist/types/tiers.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# SelfHost MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[SelfHost](https://selfhost.dev) is the managed home for your whole backend, databases and apps, on servers you control and run for you. This [Model Context Protocol](https://modelcontextprotocol.io/) server puts all of it one sentence away inside your AI coding assistant: spin up production databases, ship apps straight from GitHub, wire up domains and environment variables, and watch builds stream live, all in plain English without ever leaving your editor.
|
|
4
|
+
|
|
5
|
+
The power of your own server. The simplicity of a PaaS. Driven by AI.
|
|
6
|
+
|
|
7
|
+
**One platform, two capabilities:**
|
|
8
|
+
|
|
9
|
+
- **Projects** - your apps, shipped. Connect a GitHub repo, click deploy, and it's live: auto-detected builds (Nixpacks, Dockerfile, Docker Compose, or static), auto-deploy on every push, live streaming build logs, environment variables, custom domains, pause and resume to scale to zero, and databases right inside the project. The ease of Railway, Render, and Vercel, with a server you actually control.
|
|
10
|
+
- **Managed Databases** - production-grade database hosting, your way. Managed PostgreSQL, MySQL, and Redis on AWS, in our cloud or your own AWS account (BYOC). Automated backups, snapshots, replicas, and metrics across engines; PITR, connection pooling, and parameter tuning on PostgreSQL and MySQL.
|
|
11
|
+
|
|
12
|
+
One account, one bill, one AI control plane. Pay only for what you run: prepaid credits from $5, no plans or tiers.
|
|
4
13
|
|
|
5
14
|
Works with **Claude Code**, **Cursor**, **Windsurf**, **Cline**, and any MCP-compatible client.
|
|
6
15
|
|
|
@@ -70,11 +79,34 @@ Claude: Authenticates → fetches your orgs → selects org → lists instances
|
|
|
70
79
|
|
|
71
80
|
## What Can You Do?
|
|
72
81
|
|
|
73
|
-
|
|
82
|
+
Talk to the whole platform in plain English.
|
|
83
|
+
|
|
84
|
+
### Ship and run apps with Projects
|
|
85
|
+
|
|
86
|
+
Connect a repo, deploy, and it's live - SelfHost takes your code from GitHub to a running app.
|
|
87
|
+
|
|
88
|
+
| You say | What happens |
|
|
89
|
+
|---------|-------------|
|
|
90
|
+
| *"Create a project and deploy my GitHub repo into it"* | Provisions the project, waits until it's ready, auto-detects the build, and deploys the repo |
|
|
91
|
+
| *"Deploy the main branch of my-org/api"* | Creates the deployment, triggers the build, and streams live logs until it's running |
|
|
92
|
+
| *"Turn on auto-deploy so every push ships"* | Enables auto-deploy; future pushes to the branch redeploy automatically |
|
|
93
|
+
| *"Add a private Postgres database to my project"* | Provisions a Postgres database inside the project, with the credentials and visibility you choose |
|
|
94
|
+
| *"Spin up Supabase in this project"* | Deploys the Supabase template alongside your app |
|
|
95
|
+
| *"Set DATABASE_URL on my app and redeploy"* | Updates the env var (without wiping the others) and rolls out the change |
|
|
96
|
+
| *"Point app.example.com at my deployment"* | Attaches the custom domain and returns the exact DNS records to add, then verifies them |
|
|
97
|
+
| *"Show me the build logs for the last deploy"* | Streams the build and container logs for that run |
|
|
98
|
+
| *"Pause my staging app so I stop paying for it"* | Pauses the deployment (scales to zero); resume instantly when you need it |
|
|
99
|
+
| *"Roll back to the last working deploy"* | Re-deploys the commit from the previous successful run |
|
|
100
|
+
| *"Notify my team channel when a deploy fails"* | Binds a notification channel to the app's deploy outcomes |
|
|
101
|
+
|
|
102
|
+
### Manage database infrastructure with Managed Databases
|
|
103
|
+
|
|
104
|
+
Production-grade, standalone database hosting.
|
|
74
105
|
|
|
75
106
|
| You say | What happens |
|
|
76
107
|
|---------|-------------|
|
|
77
108
|
| *"Spin up a Postgres 18 instance in us-east-1"* | Walks you through config, shows cost estimate, provisions it |
|
|
109
|
+
| *"Spin up a Redis 7.2 instance for caching in us-east-1"* | Provisions a managed Redis instance with a cost estimate (backups, replicas, and metrics; no SQL tuning or pooling) |
|
|
78
110
|
| *"Stop my staging database"* | Finds the instance, confirms with you, stops it |
|
|
79
111
|
| *"Set up a CPU alert at 80% on my prod DB"* | Creates an alert rule with email notification |
|
|
80
112
|
| *"Show me the backups for my main instance"* | Lists all backups with sizes and timestamps |
|
|
@@ -82,19 +114,13 @@ Claude: Authenticates → fetches your orgs → selects org → lists instances
|
|
|
82
114
|
| *"What's my estimated monthly cost for an r6i.xlarge with 500GB gp3?"* | Calculates itemized cost breakdown |
|
|
83
115
|
| *"Tune shared_buffers on my instance"* | Previews defaults, applies the override, syncs to replicas |
|
|
84
116
|
| *"Enable PgBouncer on my prod DB with 200 max clients"* | Configures connection pooling, clients connect on port 6432 |
|
|
117
|
+
| *"Enable ProxySQL pooling on my MySQL database"* | Configures MySQL connection pooling; clients connect on port 6033 |
|
|
118
|
+
| *"Tune innodb_buffer_pool_size on my MySQL instance"* | Reads the current MySQL config and applies the override |
|
|
85
119
|
| *"Add a read-only database user for the reporting app"* | Creates a DBMS-level credential with the right grants |
|
|
86
120
|
| *"Restore my prod database to 14:30 yesterday into a new instance"* | Sets up a point-in-time recovery from WAL + base backups |
|
|
87
121
|
| *"Scale my instance to r6i.2xlarge and 1TB"* | Issues a manual scale, polls the resize event |
|
|
88
122
|
| *"Auto-stop my staging DB at 7pm weekdays"* | Creates a scheduled scaling policy with start/stop times |
|
|
89
|
-
| *"
|
|
90
|
-
| *"Spin up a Postgres instance on Hetzner in Helsinki"* | Confirms provider, walks through Hetzner location + server type, provisions on Hetzner Cloud |
|
|
91
|
-
| *"What cloud providers can I use?"* | Lists AWS and Hetzner with their capabilities so you can pick |
|
|
92
|
-
| *"Create a project and deploy my GitHub repo into it"* | Provisions a project, waits for it to be ready, detects the build config, and deploys the repo |
|
|
93
|
-
| *"Deploy the main branch of my-org/api"* | Creates a deployment, triggers the build, and streams build logs until it's live |
|
|
94
|
-
| *"Set DATABASE_URL on my app and redeploy"* | Updates the env var (without wiping the others) and rolls out the change |
|
|
95
|
-
| *"Add a Postgres database to my project"* | Provisions a Postgres database inside the project with the credentials you choose |
|
|
96
|
-
| *"Point app.example.com at my deployment"* | Attaches the custom domain and returns the exact DNS records to add, then verifies them |
|
|
97
|
-
| *"Roll back my app to the last working deploy"* | Re-deploys the commit from the previous successful run |
|
|
123
|
+
| *"Top up my wallet with $25"* | Checks the balance, returns a Razorpay payment link to add credit |
|
|
98
124
|
|
|
99
125
|
### Safety Built In
|
|
100
126
|
|
|
@@ -104,7 +130,7 @@ Destructive operations (delete, stop, reboot) require explicit confirmation. The
|
|
|
104
130
|
|
|
105
131
|
## Features
|
|
106
132
|
|
|
107
|
-
###
|
|
133
|
+
### 150 tools across 23 modules
|
|
108
134
|
|
|
109
135
|
Every tool maps to a real API endpoint. No mock data, no shortcuts.
|
|
110
136
|
|
|
@@ -116,7 +142,7 @@ Automatic browser-based sign-in with Firebase. Tokens refresh transparently.
|
|
|
116
142
|
| `create_or_login_user` | Create account or sign in |
|
|
117
143
|
| `get_current_user` | Your profile, admin status, org membership |
|
|
118
144
|
| `get_my_memberships` | List your orgs and pending invitations |
|
|
119
|
-
| `select_organization` | Switch
|
|
145
|
+
| `select_organization` | Switch the active org for subsequent calls |
|
|
120
146
|
| `get_invite_credits` | Check remaining platform invite credits |
|
|
121
147
|
| `send_platform_invite` | Invite someone to join SelfHost |
|
|
122
148
|
| `list_my_platform_invites` | See invitations you've sent |
|
|
@@ -129,7 +155,7 @@ Multi-tenant - everything is scoped to your org.
|
|
|
129
155
|
|------|-------------|
|
|
130
156
|
| `list_organizations` | All orgs you belong to |
|
|
131
157
|
| `create_organization` | Create a new org (you become owner, get 5 invite credits) |
|
|
132
|
-
| `get_organization` | Org details
|
|
158
|
+
| `get_organization` | Org details (name, members, payment-channel state) |
|
|
133
159
|
| `update_organization` | Change name, description, or IAM role |
|
|
134
160
|
| `delete_organization` | Soft-delete org and all related resources |
|
|
135
161
|
| `list_members` | See team members and their roles |
|
|
@@ -167,7 +193,7 @@ VPCs, subnets, and security groups. Optional - auto-created during provisioning
|
|
|
167
193
|
| `update_security_group` | Replace inbound rules on a security group |
|
|
168
194
|
|
|
169
195
|
#### Database Instances
|
|
170
|
-
The core feature. Full lifecycle management for PostgreSQL, MySQL, and
|
|
196
|
+
The core feature. Full lifecycle management for PostgreSQL, MySQL, and Redis.
|
|
171
197
|
|
|
172
198
|
| Tool | Description |
|
|
173
199
|
|------|-------------|
|
|
@@ -195,6 +221,14 @@ Tune database parameters with calculated defaults per instance type.
|
|
|
195
221
|
| `get_pg_config` | Current config with defaults, overrides, and effective values |
|
|
196
222
|
| `update_pg_config` | Apply overrides (auto-syncs to replicas, set null to revert) |
|
|
197
223
|
|
|
224
|
+
#### MySQL Configuration
|
|
225
|
+
Tune MySQL server parameters on a managed instance. No preview step - read the current config, then apply overrides.
|
|
226
|
+
|
|
227
|
+
| Tool | Description |
|
|
228
|
+
|------|-------------|
|
|
229
|
+
| `get_mysql_config` | Current config with defaults, overrides, and effective values |
|
|
230
|
+
| `update_mysql_config` | Apply overrides for `max_connections`, `innodb_buffer_pool_size`, `tmp_table_size`, and `wait_timeout` |
|
|
231
|
+
|
|
198
232
|
#### Backups & Snapshots
|
|
199
233
|
Automated backups with DLM policies and manual EBS snapshots.
|
|
200
234
|
|
|
@@ -232,15 +266,19 @@ Monitor your databases and get notified when things go wrong.
|
|
|
232
266
|
| `delete_notification_channel` | Remove channel (with confirmation) |
|
|
233
267
|
| `test_notification_channel` | Send test notification |
|
|
234
268
|
|
|
235
|
-
#### Connection Pooling (PgBouncer)
|
|
236
|
-
|
|
269
|
+
#### Connection Pooling (PgBouncer + ProxySQL)
|
|
270
|
+
Reduces connection overhead for high-concurrency workloads. PgBouncer pools PostgreSQL (clients connect on port 6432); ProxySQL pools MySQL (clients connect on port 6033, admin on port 6032). Enable the one that matches your engine.
|
|
237
271
|
|
|
238
272
|
| Tool | Description |
|
|
239
273
|
|------|-------------|
|
|
240
|
-
| `get_pgbouncer` | Get current pooling config (or null if never configured) |
|
|
241
|
-
| `enable_pgbouncer` | Enable pooling with pool mode, max client conn, pool sizes |
|
|
242
|
-
| `reconfigure_pgbouncer` | Apply new settings on an enabled instance (PATCH-style) |
|
|
243
|
-
| `disable_pgbouncer` | Drain pool and disable (with confirmation) |
|
|
274
|
+
| `get_pgbouncer` | Get current PgBouncer (Postgres) pooling config (or null if never configured) |
|
|
275
|
+
| `enable_pgbouncer` | Enable Postgres pooling with pool mode, max client conn, pool sizes |
|
|
276
|
+
| `reconfigure_pgbouncer` | Apply new PgBouncer settings on an enabled instance (PATCH-style) |
|
|
277
|
+
| `disable_pgbouncer` | Drain the PgBouncer pool and disable (with confirmation) |
|
|
278
|
+
| `get_proxysql` | Get current ProxySQL (MySQL) pooling config (or null if never configured) |
|
|
279
|
+
| `enable_proxysql` | Enable MySQL pooling (clients on port 6033, admin on port 6032) |
|
|
280
|
+
| `reconfigure_proxysql` | Apply new ProxySQL settings on an enabled instance (PATCH-style) |
|
|
281
|
+
| `disable_proxysql` | Drain the ProxySQL pool and disable (with confirmation) |
|
|
244
282
|
|
|
245
283
|
#### Database Users
|
|
246
284
|
DBMS-level credentials - distinct from the SelfHost platform login. Use for apps and people that need their own DB user.
|
|
@@ -265,43 +303,32 @@ Manual one-off resize plus auto-scaling policies (reactive metric-based, schedul
|
|
|
265
303
|
| `delete_scaling_policy` | Remove a policy (with confirmation) |
|
|
266
304
|
|
|
267
305
|
#### Point-in-Time Recovery (PITR)
|
|
268
|
-
PostgreSQL
|
|
306
|
+
PostgreSQL and MySQL (Redis excluded). Continuous transaction-log archiving to S3 + restore to any second within the retention window. Restore creates a brand-new instance - the source is untouched.
|
|
269
307
|
|
|
270
308
|
| Tool | Description |
|
|
271
309
|
|------|-------------|
|
|
272
310
|
| `get_pitr` | Current config + restore window (oldest / latest restorable moments) |
|
|
273
|
-
| `enable_pitr` | Set up
|
|
311
|
+
| `enable_pitr` | Set up transaction-log archiving to an S3 bucket with retention days |
|
|
274
312
|
| `configure_pitr` | Toggle between `enabled` (resume) and `disabled` (pause) |
|
|
275
313
|
| `retry_pitr` | Retry after an `error` state (e.g. fix IAM, then retry) |
|
|
276
314
|
| `trigger_pitr_base_backup` | Run a one-off base backup now |
|
|
277
315
|
| `list_pitr_base_backups` | List historical base backups with status + timestamps |
|
|
278
316
|
| `restore_pitr` | Restore to a target time into a new instance (with confirmation) |
|
|
279
317
|
|
|
280
|
-
#### Billing &
|
|
281
|
-
|
|
318
|
+
#### Billing & Wallet (PAYG)
|
|
319
|
+
Prepaid **credit wallet** + payment-method linking. No plans or tiers. Credit is
|
|
320
|
+
consumed per usage and gated by wallet balance. All endpoints scoped to the active org.
|
|
282
321
|
|
|
283
322
|
| Tool | Description |
|
|
284
323
|
|------|-------------|
|
|
285
|
-
| `
|
|
286
|
-
| `
|
|
287
|
-
| `
|
|
288
|
-
| `
|
|
289
|
-
| `
|
|
324
|
+
| `get_wallet_balance` | Wallet balance, currency, payment state, hourly burn rate + runway |
|
|
325
|
+
| `list_skus` | Priced resource catalog (hourly rates); estimate how long a top-up lasts |
|
|
326
|
+
| `list_credit_ledger` | Credit lots: `topup` / `free_credit` (welcome grant, has expiry) / `usage_charge` |
|
|
327
|
+
| `list_wallet_transactions` | Per-resource hourly charges (`applied` / `skipped`) |
|
|
328
|
+
| `create_topup` | Buy credit; returns a hosted Razorpay `payment_url` to open in a browser |
|
|
329
|
+
| `link_billing_payment_method` | Initiate Razorpay card link; returns short URL to open in browser |
|
|
290
330
|
| `update_billing_contact` | Update billing phone / tax ID / country / state for invoices |
|
|
291
331
|
|
|
292
|
-
#### Hetzner Cloud (Postgres-only)
|
|
293
|
-
Provisioning on Hetzner Cloud as an alternative to AWS. Currently provision / get / status / delete only - no start / stop / reboot / update / scaling / PITR / pooling yet. Call `list_cloud_providers` at the start of any create-database intent to surface both options to the user.
|
|
294
|
-
|
|
295
|
-
| Tool | Description |
|
|
296
|
-
|------|-------------|
|
|
297
|
-
| `list_cloud_providers` | List available cloud providers (AWS, Hetzner) with capabilities + the create tool to use for each |
|
|
298
|
-
| `list_hetzner_locations` | Hetzner datacenter locations (fsn1, nbg1, hel1, ash, sin) with country + continent |
|
|
299
|
-
| `list_hetzner_server_types` | Hetzner server types (cpx11-cpx51) with vCPU / RAM / local disk |
|
|
300
|
-
| `create_hetzner_instance` | Provision a Postgres instance on Hetzner Cloud (region, server type, storage size, HA toggle, CIDR allowlist) |
|
|
301
|
-
| `get_hetzner_instance` | Fetch a Hetzner instance's full details by PID |
|
|
302
|
-
| `get_hetzner_instance_status` | Poll provisioning progress (per-step status: network → firewall → ssh_key → server → volume → load_balancer → ansible → finalize) |
|
|
303
|
-
| `delete_hetzner_instance` | Tear down a Hetzner instance and all associated resources (with confirmation) |
|
|
304
|
-
|
|
305
332
|
---
|
|
306
333
|
|
|
307
334
|
### PaaS - Projects (app containers)
|
|
@@ -360,7 +387,7 @@ A **deployment** is an app built from a GitHub repo, living inside an `active` p
|
|
|
360
387
|
| `get_github_connect_url` | Get a browser URL to connect GitHub (interactive; then re-list installations) |
|
|
361
388
|
|
|
362
389
|
### PaaS - Project Databases
|
|
363
|
-
Postgres/Redis/MySQL/MongoDB provisioned inside a project (distinct from
|
|
390
|
+
Postgres/Redis/MySQL/MongoDB provisioned inside a project (distinct from the managed AWS instances).
|
|
364
391
|
|
|
365
392
|
| Tool | Description |
|
|
366
393
|
|------|-------------|
|
|
@@ -386,6 +413,20 @@ Postgres/Redis/MySQL/MongoDB provisioned inside a project (distinct from AWS/Het
|
|
|
386
413
|
|
|
387
414
|
## Common Workflows
|
|
388
415
|
|
|
416
|
+
### Deploy an app from GitHub (Projects)
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
You: "Deploy my-org/web to a new project"
|
|
420
|
+
|
|
421
|
+
Claude: Creates a project → polls until it's provisioned and active
|
|
422
|
+
→ detects the build config from the repo (build pack, port)
|
|
423
|
+
→ creates the deployment and triggers the first build
|
|
424
|
+
→ streams the build logs until the app is live
|
|
425
|
+
→ hands you the deploy URL
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Then: *"add a private Postgres to it"*, *"set my env vars"*, *"point app.example.com at it"*, or *"turn on auto-deploy"* to round out the app.
|
|
429
|
+
|
|
389
430
|
### Switch AWS Account (BYOC vs Platform-Managed)
|
|
390
431
|
|
|
391
432
|
```
|
|
@@ -434,14 +475,13 @@ Claude: Lists snapshots → you pick one
|
|
|
434
475
|
|
|
435
476
|
## Rate Limiting
|
|
436
477
|
|
|
437
|
-
|
|
478
|
+
A single flat **fair-use** limit applies to all authenticated users (there are
|
|
479
|
+
no plans/tiers); `ADMIN` is unlimited:
|
|
438
480
|
|
|
439
|
-
|
|
|
481
|
+
| | Reads/min | Writes/min | Concurrent |
|
|
440
482
|
|------|-----------|------------|------------|
|
|
441
|
-
|
|
|
442
|
-
|
|
|
443
|
-
| Pro | ~300 | ~120 | 10 |
|
|
444
|
-
| Enterprise | ~600 | ~300 | Unlimited |
|
|
483
|
+
| Fair-use (default) | ~300 | ~120 | 10 |
|
|
484
|
+
| Admin | Unlimited | Unlimited | Unlimited |
|
|
445
485
|
|
|
446
486
|
Reference data lookups (regions, instance types, storage types) are unlimited.
|
|
447
487
|
|
|
@@ -455,7 +495,7 @@ Reference data lookups (regions, instance types, storage types) are unlimited.
|
|
|
455
495
|
|----------|---------|-------------|
|
|
456
496
|
| `API_URL` | `https://api.selfhost.dev` | SelfHost API endpoint |
|
|
457
497
|
| `CONSOLE_URL` | `https://console.selfhost.dev` | SelfHost Console URL (for browser auth) |
|
|
458
|
-
| `TIER` |
|
|
498
|
+
| `TIER` | `DEFAULT` | Override rate limit tier for testing (`DEFAULT`, `ADMIN`) |
|
|
459
499
|
| `FIREBASE_API_KEY` | - | Skip browser auth (CI/headless) |
|
|
460
500
|
| `FIREBASE_REFRESH_TOKEN` | - | Skip browser auth (CI/headless) |
|
|
461
501
|
|
package/dist/auth.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare function wasAuthPrompted(): Promise<boolean>;
|
|
|
2
2
|
export declare function markAuthPrompted(): Promise<void>;
|
|
3
3
|
/**
|
|
4
4
|
* Returns true if credentials are available (env vars or stored file).
|
|
5
|
-
* No network calls
|
|
5
|
+
* No network calls - just a fast file existence check.
|
|
6
6
|
*/
|
|
7
7
|
export declare function hasCredentials(): Promise<boolean>;
|
|
8
8
|
/**
|
package/dist/auth.js
CHANGED
|
@@ -130,7 +130,7 @@ async function resolveCredentials() {
|
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Returns true if credentials are available (env vars or stored file).
|
|
133
|
-
* No network calls
|
|
133
|
+
* No network calls - just a fast file existence check.
|
|
134
134
|
*/
|
|
135
135
|
export async function hasCredentials() {
|
|
136
136
|
if (config.firebaseApiKey && config.firebaseRefreshToken)
|
|
@@ -169,7 +169,7 @@ async function _getValidTokenImpl() {
|
|
|
169
169
|
return jwt;
|
|
170
170
|
}
|
|
171
171
|
catch {
|
|
172
|
-
// Refresh token expired
|
|
172
|
+
// Refresh token expired - re-authenticate via browser
|
|
173
173
|
cachedJwt = null;
|
|
174
174
|
jwtExpiresAt = 0;
|
|
175
175
|
const newCreds = await browserLogin();
|
|
@@ -192,7 +192,7 @@ export async function forceReauth() {
|
|
|
192
192
|
await unlink(config.credentialsPath);
|
|
193
193
|
}
|
|
194
194
|
catch {
|
|
195
|
-
// File may not exist
|
|
195
|
+
// File may not exist - that's fine
|
|
196
196
|
}
|
|
197
197
|
const creds = await browserLogin();
|
|
198
198
|
await saveCredentials(creds.apiKey, creds.refreshToken);
|
package/dist/client.js
CHANGED
|
@@ -63,7 +63,7 @@ export async function apiRequest(path, options = {}) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
|
-
// Rate limit errors are thrown before fetch
|
|
66
|
+
// Rate limit errors are thrown before fetch - re-throw as-is
|
|
67
67
|
if (error instanceof Error && error.message.includes("Rate limit")) {
|
|
68
68
|
throw error;
|
|
69
69
|
}
|
package/dist/config.js
CHANGED
|
@@ -5,7 +5,7 @@ function log(message) {
|
|
|
5
5
|
const API_URL = process.env.API_URL || "https://api.selfhost.dev";
|
|
6
6
|
const CONSOLE_URL = process.env.CONSOLE_URL || "https://console.selfhost.dev";
|
|
7
7
|
const TIER_OVERRIDE = process.env.TIER;
|
|
8
|
-
// Headless/CI fallback
|
|
8
|
+
// Headless/CI fallback - skip browser login if these are set
|
|
9
9
|
const FIREBASE_API_KEY = process.env.FIREBASE_API_KEY;
|
|
10
10
|
const FIREBASE_REFRESH_TOKEN = process.env.FIREBASE_REFRESH_TOKEN;
|
|
11
11
|
export const config = {
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,6 @@ import { registerDatabaseUserTools } from "./tools/database-users.js";
|
|
|
17
17
|
import { registerScalingTools } from "./tools/scaling.js";
|
|
18
18
|
import { registerPitrTools } from "./tools/pitr.js";
|
|
19
19
|
import { registerBillingTools } from "./tools/billing.js";
|
|
20
|
-
import { registerHetznerTools } from "./tools/hetzner.js";
|
|
21
20
|
import { registerProjectTools } from "./tools/projects.js";
|
|
22
21
|
import { registerDeploymentTools } from "./tools/deployments.js";
|
|
23
22
|
import { registerDeploymentDomainTools } from "./tools/deployment-domains.js";
|
|
@@ -26,6 +25,8 @@ import { registerGithubTools } from "./tools/github.js";
|
|
|
26
25
|
import { registerProjectDatabaseTools } from "./tools/project-databases.js";
|
|
27
26
|
import { registerProjectServiceTools } from "./tools/project-services.js";
|
|
28
27
|
import { registerDeploymentNotificationTools } from "./tools/deployment-notifications.js";
|
|
28
|
+
import { registerProxySqlTools } from "./tools/proxysql.js";
|
|
29
|
+
import { registerMysqlConfigTools } from "./tools/mysql-config.js";
|
|
29
30
|
const server = new McpServer({
|
|
30
31
|
name: "selfhost",
|
|
31
32
|
version: "0.1.0",
|
|
@@ -40,24 +41,22 @@ registerCredentialTools(server);
|
|
|
40
41
|
registerNetworkingTools(server);
|
|
41
42
|
// Module 5: Instance Lifecycle
|
|
42
43
|
registerInstanceTools(server);
|
|
43
|
-
// Module 6: PostgreSQL Config
|
|
44
|
+
// Module 6: PostgreSQL Config - MySQL sibling is MySQL Config (Module 24)
|
|
44
45
|
registerPgConfigTools(server);
|
|
45
46
|
// Module 7: Backups & Snapshots
|
|
46
47
|
registerBackupTools(server);
|
|
47
48
|
// Module 8: Alerts & Notifications
|
|
48
49
|
registerAlertTools(server);
|
|
49
|
-
// Module 9: PgBouncer connection pooling (Postgres
|
|
50
|
+
// Module 9: PgBouncer connection pooling (Postgres) - MySQL sibling is ProxySQL (Module 23)
|
|
50
51
|
registerPgBouncerTools(server);
|
|
51
52
|
// Module 10: Database users (DBMS-level credentials)
|
|
52
53
|
registerDatabaseUserTools(server);
|
|
53
54
|
// Module 11: Scaling - manual + auto-scaling policies + auto start/stop
|
|
54
55
|
registerScalingTools(server);
|
|
55
|
-
// Module 12: Point-in-Time Recovery (Postgres
|
|
56
|
+
// Module 12: Point-in-Time Recovery (Postgres + MySQL)
|
|
56
57
|
registerPitrTools(server);
|
|
57
|
-
// Module 13: Billing -
|
|
58
|
+
// Module 13: Billing - credit wallet (balance / top-up / ledger) + card linking
|
|
58
59
|
registerBillingTools(server);
|
|
59
|
-
// Module 14: Hetzner Cloud - Postgres-only provision/get/status/delete + provider discovery
|
|
60
|
-
registerHetznerTools(server);
|
|
61
60
|
// ─── PaaS / Apps surface (/api/v1/platform/...) ──────────────────────────────
|
|
62
61
|
// Module 15: Projects - CoolifyProject app-container lifecycle + metrics
|
|
63
62
|
registerProjectTools(server);
|
|
@@ -75,6 +74,11 @@ registerProjectDatabaseTools(server);
|
|
|
75
74
|
registerProjectServiceTools(server);
|
|
76
75
|
// Module 22: Deployment notifications - bind/unbind org channels to deploy outcomes
|
|
77
76
|
registerDeploymentNotificationTools(server);
|
|
77
|
+
// ─── MySQL parity tools (AWS surface, /aws/v1/...) ───────────────────────────
|
|
78
|
+
// Module 23: ProxySQL connection pooling (MySQL) - MySQL sibling of PgBouncer (Module 9)
|
|
79
|
+
registerProxySqlTools(server);
|
|
80
|
+
// Module 24: MySQL parameter tuning - MySQL sibling of PostgreSQL Config (Module 6)
|
|
81
|
+
registerMysqlConfigTools(server);
|
|
78
82
|
// Server utility tools
|
|
79
83
|
server.tool("reauthenticate", "Clear stored credentials and sign in again (use to switch accounts or fix auth issues)", {}, async () => {
|
|
80
84
|
try {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE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AAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,iGAAiG;IACjG,IAAI,CAAC,CAAC,MAAM,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,eAAe,EAAE,CAAC,EAAE,CAAC;QAC5D,gBAAgB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YACzB,sDAAsD;QACxD,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,MAAM,CAAC,GAAG,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/rate-limiter.js
CHANGED
|
@@ -26,7 +26,7 @@ function tryConsume(bucket) {
|
|
|
26
26
|
return { ok: false, retryAfterSeconds };
|
|
27
27
|
}
|
|
28
28
|
class RateLimiter {
|
|
29
|
-
tier = "
|
|
29
|
+
tier = "DEFAULT";
|
|
30
30
|
isAdmin = false;
|
|
31
31
|
readBucket;
|
|
32
32
|
writeBucket;
|
|
@@ -34,7 +34,7 @@ class RateLimiter {
|
|
|
34
34
|
activeRequests = 0;
|
|
35
35
|
bootstrapRemaining = 5;
|
|
36
36
|
constructor() {
|
|
37
|
-
const tierConfig = TIER_CONFIGS.
|
|
37
|
+
const tierConfig = TIER_CONFIGS.DEFAULT;
|
|
38
38
|
this.readBucket = createBucket(tierConfig.readBucket.burst, tierConfig.readBucket.ratePerSecond);
|
|
39
39
|
this.writeBucket = createBucket(tierConfig.writeBucket.burst, tierConfig.writeBucket.ratePerSecond);
|
|
40
40
|
this.maxConcurrent = tierConfig.maxConcurrent;
|
|
@@ -43,7 +43,7 @@ class RateLimiter {
|
|
|
43
43
|
this.tier = tier;
|
|
44
44
|
this.isAdmin = tier === "ADMIN";
|
|
45
45
|
if (this.isAdmin) {
|
|
46
|
-
config.log("Admin tier set
|
|
46
|
+
config.log("Admin tier set - rate limits disabled.");
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
const tierConfig = TIER_CONFIGS[tier];
|
|
@@ -83,7 +83,7 @@ class RateLimiter {
|
|
|
83
83
|
}
|
|
84
84
|
// Concurrency check
|
|
85
85
|
if (this.activeRequests >= this.maxConcurrent) {
|
|
86
|
-
throw new Error(`Too many concurrent requests
|
|
86
|
+
throw new Error(`Too many concurrent requests (fair-use limit: ${this.maxConcurrent} at once).\n` +
|
|
87
87
|
`Please wait for a current request to complete.`);
|
|
88
88
|
}
|
|
89
89
|
// Token bucket check
|
|
@@ -94,10 +94,8 @@ class RateLimiter {
|
|
|
94
94
|
const tierConfig = TIER_CONFIGS[this.tier];
|
|
95
95
|
const readRate = Math.round(tierConfig.readBucket.ratePerSecond * 60);
|
|
96
96
|
const writeRate = Math.round(tierConfig.writeBucket.ratePerSecond * 60);
|
|
97
|
-
throw new Error(`
|
|
98
|
-
`
|
|
99
|
-
`Current plan: ${this.tier} (${readRate} reads/min, ${writeRate} writes/min)\n` +
|
|
100
|
-
`To increase limits, upgrade at https://console.selfhost.dev/billing`);
|
|
97
|
+
throw new Error(`Fair-use ${bucketType} limit reached. You can retry in ${result.retryAfterSeconds} second(s).\n` +
|
|
98
|
+
`Fair-use limits: ${readRate} reads/min, ${writeRate} writes/min (reference lookups are unlimited).`);
|
|
101
99
|
}
|
|
102
100
|
this.activeRequests++;
|
|
103
101
|
}
|
|
@@ -108,14 +106,14 @@ class RateLimiter {
|
|
|
108
106
|
}
|
|
109
107
|
getWelcomeMessage(orgName) {
|
|
110
108
|
if (this.isAdmin) {
|
|
111
|
-
return `Welcome to ${orgName}
|
|
109
|
+
return `Welcome to ${orgName} (ADMIN).\nRate limits: unlimited. No concurrency restrictions.`;
|
|
112
110
|
}
|
|
113
111
|
const tierConfig = TIER_CONFIGS[this.tier];
|
|
114
112
|
const readRate = Math.round(tierConfig.readBucket.ratePerSecond * 60);
|
|
115
113
|
const writeRate = Math.round(tierConfig.writeBucket.ratePerSecond * 60);
|
|
116
114
|
const concurrent = tierConfig.maxConcurrent === Infinity ? "unlimited" : String(tierConfig.maxConcurrent);
|
|
117
|
-
return (`Welcome to ${orgName}
|
|
118
|
-
`
|
|
115
|
+
return (`Welcome to ${orgName}.\n` +
|
|
116
|
+
`Fair-use limits: ${readRate} reads/min, ${writeRate} writes/min (reference lookups are unlimited).\n` +
|
|
119
117
|
`Up to ${concurrent} concurrent requests.`);
|
|
120
118
|
}
|
|
121
119
|
}
|
package/dist/rate-limiter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../src/rate-limiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,SAAS,YAAY,CAAC,SAAiB,EAAE,aAAqB;IAC5D,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,SAAS;QACT,aAAa;QACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;KACvB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,MAAmB;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACjD,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAC3F,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC;AAC1B,CAA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E,CAAC;QAChG,CAAC;QAED,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,IAAkC,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,aAAa,GAAG,EAAE,CAAC,CAAC;QACtE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,aAAa,GAAG,EAAE,CAAC,CAAC;QACxE,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAE1G,OAAO,CACL,cAAc,OAAO,KAAK;YAC1B,oBAAoB,QAAQ,eAAe,SAAS,kDAAkD;YACtG,SAAS,UAAU,uBAAuB,CAC3C,CAAC;IACJ,CAAC;CACF;AAED,YAAY;AACZ,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
|
package/dist/session.d.ts
CHANGED
package/dist/session.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { rateLimiter } from "./rate-limiter.js";
|
|
2
2
|
import { config } from "./config.js";
|
|
3
|
-
const BILLING_PLAN_TO_TIER = {
|
|
4
|
-
free: "FREE",
|
|
5
|
-
starter: "STARTER",
|
|
6
|
-
pro: "PRO",
|
|
7
|
-
enterprise: "ENTERPRISE",
|
|
8
|
-
};
|
|
9
3
|
class Session {
|
|
10
4
|
_user = null;
|
|
11
5
|
_activeOrg = null;
|
|
@@ -23,12 +17,9 @@ class Session {
|
|
|
23
17
|
}
|
|
24
18
|
setActiveOrg(org) {
|
|
25
19
|
this._activeOrg = org;
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
rateLimiter.setTier(tier);
|
|
30
|
-
}
|
|
31
|
-
config.log(`Active org: ${org.name} (${org.id}), billing_plan: ${org.billingPlan}`);
|
|
20
|
+
// No plans/tiers: all non-admin users share the flat fair-use limit set in
|
|
21
|
+
// the constructor; ADMIN (set in setUser) stays unlimited.
|
|
22
|
+
config.log(`Active org: ${org.name} (${org.id})`);
|
|
32
23
|
}
|
|
33
24
|
getActiveOrg() {
|
|
34
25
|
return this._activeOrg;
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAcrC,MAAM,OAAO;IACH,KAAK,GAAuB,IAAI,CAAC;IACjC,UAAU,GAA8B,IAAI,CAAC;IAErD,OAAO,CAAC,IAAiB;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,KAAK,CAAC;IACtC,CAAC;IAED,YAAY,CAAC,GAAuB;QAClC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,2EAA2E;QAC3E,2DAA2D;QAC3D,MAAM,CAAC,GAAG,CAAC,eAAe,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,IAAI,CAAC;IACrC,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC;IAClC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/tools/alerts.js
CHANGED
|
@@ -7,7 +7,7 @@ function resolveOrgId(organization_id) {
|
|
|
7
7
|
const noOrgMessage = "No organization selected. Call `select_organization` first or pass an organization_id.";
|
|
8
8
|
const alertRuleSchema = {
|
|
9
9
|
name: z.string().min(1, "Rule name is required"),
|
|
10
|
-
metric_type: z.enum(["system", "network", "storage", "postgresql.database"]).describe("Metric category"),
|
|
10
|
+
metric_type: z.enum(["system", "network", "storage", "postgresql.database", "mysql.database", "redis.database"]).describe("Metric category"),
|
|
11
11
|
metric_name: z.string().min(1, "Metric name is required (e.g. cpu_percent, memory_percent, disk_used_percent)"),
|
|
12
12
|
operator: z.enum([">", "<", ">=", "<=", "=="]).describe("Comparison operator"),
|
|
13
13
|
threshold: z.number().describe("Threshold value to trigger alert"),
|
|
@@ -47,7 +47,9 @@ Valid metric combinations:
|
|
|
47
47
|
- system: cpu_percent, cpu_io_wait_percent, memory_percent, swap_usage_percent, disk_usage_percent, load_avg_1/5/15
|
|
48
48
|
- network: recv_bytes_per_sec, sent_bytes_per_sec
|
|
49
49
|
- storage: disk_free_bytes, disk_free_percent, disk_used_percent, inodes_used_percent, read/write_io_per_second (requires mount_point)
|
|
50
|
-
- postgresql.database: cache_hit_ratio, connections_total, max_connections, replication_lag_seconds, transactions_per_second
|
|
50
|
+
- postgresql.database: cache_hit_ratio, connections_total, max_connections, replication_lag_seconds, transactions_per_second
|
|
51
|
+
- mysql.database: connections_total, max_connections, connections_aborted, threads_running, queries_per_second, slow_queries_per_second, replication_lag_seconds, innodb_buffer_pool_hit_ratio, innodb_row_lock_waits_per_second, tmp_disk_tables_per_second, select_full_scans_per_second
|
|
52
|
+
- redis.database: used_memory, connected_clients, evicted_keys, expired_keys, keyspace_hits, keyspace_misses, instantaneous_ops_per_sec, rdb_changes_since_last_save, rdb_last_save_time, replication_lag_seconds, connected_slaves, blocked_clients`, {
|
|
51
53
|
organization_id: z.string().optional().describe("Organization PID (defaults to active org)"),
|
|
52
54
|
...alertRuleSchema,
|
|
53
55
|
}, async ({ organization_id, ...ruleParams }) => {
|
|
@@ -95,7 +97,7 @@ Valid metric combinations:
|
|
|
95
97
|
organization_id: z.string().optional().describe("Organization PID (defaults to active org)"),
|
|
96
98
|
rule_id: z.string().min(1, "Alert rule PID is required"),
|
|
97
99
|
name: z.string().optional(),
|
|
98
|
-
metric_type: z.enum(["system", "network", "storage", "postgresql.database"]).optional(),
|
|
100
|
+
metric_type: z.enum(["system", "network", "storage", "postgresql.database", "mysql.database", "redis.database"]).optional(),
|
|
99
101
|
metric_name: z.string().optional(),
|
|
100
102
|
operator: z.enum([">", "<", ">=", "<=", "=="]).optional(),
|
|
101
103
|
threshold: z.number().optional(),
|