run402-mcp
Version:
MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.
843 lines • 26.9 kB
JavaScript
class ScopedProjectStripeAccount {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
connect(input) {
return this.parent.projects.stripe.account.connect(this.projectId, input);
}
get() {
return this.parent.projects.stripe.account.get(this.projectId);
}
disconnect() {
return this.parent.projects.stripe.account.disconnect(this.projectId);
}
}
class ScopedProjectStripeOnboardingLinks {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(input) {
return this.parent.projects.stripe.onboardingLinks.create(this.projectId, input);
}
}
class ScopedProjectStripeCheckoutSessions {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(input) {
return this.parent.projects.stripe.checkoutSessions.create(this.projectId, input);
}
get(checkoutSessionId) {
return this.parent.projects.stripe.checkoutSessions.get(this.projectId, checkoutSessionId);
}
}
class ScopedProjectStripePortalSessions {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(input) {
return this.parent.projects.stripe.portalSessions.create(this.projectId, input);
}
}
/** `r.project(id).stripe` — the organization's Stripe account and sessions, project pre-bound. */
class ScopedProjectStripe {
account;
onboardingLinks;
checkoutSessions;
portalSessions;
constructor(parent, projectId) {
this.account = new ScopedProjectStripeAccount(parent, projectId);
this.onboardingLinks = new ScopedProjectStripeOnboardingLinks(parent, projectId);
this.checkoutSessions = new ScopedProjectStripeCheckoutSessions(parent, projectId);
this.portalSessions = new ScopedProjectStripePortalSessions(parent, projectId);
}
}
class ScopedProjects {
parent;
projectId;
stripe;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
this.stripe = new ScopedProjectStripe(parent, projectId);
}
delete() {
return this.parent.projects.delete(this.projectId);
}
getUsage() {
return this.parent.projects.getUsage(this.projectId);
}
getSchema() {
return this.parent.projects.getSchema(this.projectId);
}
sql(sql, params, opts) {
return this.parent.projects.sql(this.projectId, sql, params, opts);
}
sqlBatch(statements, opts) {
return this.parent.projects.sqlBatch(this.projectId, statements, opts);
}
rest(table, options) {
return this.parent.projects.rest(this.projectId, table, options);
}
restResponse(table, options) {
return this.parent.projects.restResponse(this.projectId, table, options);
}
applyExpose(manifest) {
return this.parent.projects.applyExpose(this.projectId, manifest);
}
validateExpose(manifest, opts = {}) {
if (opts.project !== undefined || opts.project_id !== undefined) {
return this.parent.projects.validateExpose(manifest, opts);
}
return this.parent.projects.validateExpose(manifest, { ...opts, project: this.projectId });
}
getExpose() {
return this.parent.projects.getExpose(this.projectId);
}
rename(name) {
return this.parent.projects.rename(this.projectId, name);
}
setRepoName(name) {
return this.parent.projects.setRepoName(this.projectId, name);
}
listTenantPayments(opts) {
return this.parent.projects.listTenantPayments(this.projectId, opts);
}
promoteUser(email) {
return this.parent.projects.promoteUser(this.projectId, email);
}
demoteUser(email) {
return this.parent.projects.demoteUser(this.projectId, email);
}
get() {
return this.parent.projects.get(this.projectId);
}
info() {
return this.parent.projects.info(this.projectId);
}
keys() {
return this.parent.projects.keys(this.projectId);
}
// Pass-through for non-id-bearing methods.
list(opts) {
return this.parent.projects.list(opts);
}
getQuote() {
return this.parent.projects.getQuote();
}
active() {
return this.parent.projects.active();
}
}
class ScopedApps {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
publish(opts) {
return this.parent.apps.publish(this.projectId, opts);
}
listVersions() {
return this.parent.apps.listVersions(this.projectId);
}
updateVersion(versionId, opts) {
return this.parent.apps.updateVersion(this.projectId, versionId, opts);
}
deleteVersion(versionId) {
return this.parent.apps.deleteVersion(this.projectId, versionId);
}
// Pass-through.
browse(tags) {
return this.parent.apps.browse(tags);
}
fork(opts) {
return this.parent.apps.fork(opts);
}
getApp(versionId) {
return this.parent.apps.getApp(versionId);
}
upsertInstallState(input) {
return this.parent.apps.upsertInstallState({ ...input, project_id: input.project_id ?? this.projectId });
}
getInstallState(appKey) {
return this.parent.apps.getInstallState(this.projectId, appKey);
}
}
class ScopedAi {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
translate(opts) {
return this.parent.ai.translate(this.projectId, opts);
}
moderate(text) {
return this.parent.ai.moderate(this.projectId, text);
}
usage() {
return this.parent.ai.usage(this.projectId);
}
// Pass-through.
generateImage(opts) {
return this.parent.ai.generateImage(opts);
}
}
class ScopedGrants {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(input) {
return this.parent.grants.create(this.projectId, input);
}
list() {
return this.parent.grants.list(this.projectId);
}
revoke(grantId) {
return this.parent.grants.revoke(this.projectId, grantId);
}
createKey(grantId, input) {
return this.parent.grants.createKey(this.projectId, grantId, input);
}
revokeKey(keyId) {
return this.parent.grants.revokeKey(this.projectId, keyId);
}
rotateKey(keyId) {
return this.parent.grants.rotateKey(this.projectId, keyId);
}
}
class ScopedEvents {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
/** Read a page of this project's events feed (cursor is opaque — store and echo). */
list(opts) {
return this.parent.events.list(this.projectId, opts);
}
}
class ScopedLive {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
/** Hints since `cursor`, or hold up to `wait` seconds for the first one. */
changes(opts) {
return this.parent.live.changes(this.projectId, opts);
}
/** Reconnecting SSE subscription; handle `resync` by refetching. */
subscribe(opts, onEvent) {
return this.parent.live.subscribe(this.projectId, opts, onEvent);
}
}
class ScopedErrors {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
/** Read a verdict-first page of this project's grouped error fingerprints. */
list(opts) {
return this.parent.errors.list(this.projectId, opts);
}
/** Read one fingerprint's full detail (all samples + per-sample drill-downs). */
get(fingerprintId) {
return this.parent.errors.get(this.projectId, fingerprintId);
}
/** Run the promote-gate poll loop against a release (`{ newIn }` required). */
watch(opts) {
return this.parent.errors.watch(this.projectId, opts);
}
}
class ScopedArchives {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(opts) {
return this.parent.archives.create(this.projectId, opts);
}
get(archiveId) {
return this.parent.archives.get(this.projectId, archiveId);
}
wait(archiveId, opts) {
return this.parent.archives.wait(this.projectId, archiveId, opts);
}
download(archiveId) {
return this.parent.archives.download(this.projectId, archiveId);
}
export(opts) {
return this.parent.archives.export(this.projectId, opts);
}
}
class ScopedSnapshots {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(opts) {
return this.parent.snapshots.create(this.projectId, opts);
}
list(opts) {
return this.parent.snapshots.list(this.projectId, opts);
}
get(snapshotId) {
return this.parent.snapshots.get(this.projectId, snapshotId);
}
delete(snapshotId) {
return this.parent.snapshots.delete(this.projectId, snapshotId);
}
restorePlan(snapshotId, opts) {
return this.parent.snapshots.restorePlan(this.projectId, snapshotId, opts);
}
restore(snapshotId, confirm, opts) {
return this.parent.snapshots.restore(this.projectId, snapshotId, confirm, opts);
}
getRestore(snapshotId, restoreId) {
return this.parent.snapshots.getRestore(this.projectId, snapshotId, restoreId);
}
}
class ScopedBranches {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(opts) {
return this.parent.branches.create(this.projectId, opts);
}
list() {
return this.parent.branches.list(this.projectId);
}
renew(branchProjectId, opts) {
return this.parent.branches.renew(this.projectId, branchProjectId, opts);
}
delete(branchProjectId) {
return this.parent.branches.delete(this.projectId, branchProjectId);
}
}
class ScopedAuth {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
requestMagicLink(opts) {
return this.parent.auth.requestMagicLink(this.projectId, opts);
}
verifyMagicLink(token) {
return this.parent.auth.verifyMagicLink(this.projectId, token);
}
verifyEmailCode(opts) {
return this.parent.auth.verifyEmailCode(this.projectId, opts);
}
createUser(opts) {
return this.parent.auth.createUser(this.projectId, opts);
}
inviteUser(opts) {
return this.parent.auth.inviteUser(this.projectId, opts);
}
setUserPassword(opts) {
return this.parent.auth.setUserPassword(this.projectId, opts);
}
settings(settings) {
return this.parent.auth.settings(this.projectId, settings);
}
createPasskeyRegistrationOptions(opts) {
return this.parent.auth.createPasskeyRegistrationOptions(this.projectId, opts);
}
verifyPasskeyRegistration(opts) {
return this.parent.auth.verifyPasskeyRegistration(this.projectId, opts);
}
createPasskeyLoginOptions(opts) {
return this.parent.auth.createPasskeyLoginOptions(this.projectId, opts);
}
verifyPasskeyLogin(opts) {
return this.parent.auth.verifyPasskeyLogin(this.projectId, opts);
}
listPasskeys(opts) {
return this.parent.auth.listPasskeys(this.projectId, opts);
}
deletePasskey(opts) {
return this.parent.auth.deletePasskey(this.projectId, opts);
}
providers() {
return this.parent.auth.providers(this.projectId);
}
promote(email) {
return this.parent.auth.promote(this.projectId, email);
}
demote(email) {
return this.parent.auth.demote(this.projectId, email);
}
}
class ScopedAssets {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
put(key, source, opts) {
return this.parent.assets.put(this.projectId, key, source, opts);
}
diagnoseUrl(url) {
return this.parent.assets.diagnoseUrl(this.projectId, url);
}
waitFresh(opts) {
return this.parent.assets.waitFresh(this.projectId, opts);
}
get(key) {
return this.parent.assets.get(this.projectId, key);
}
ls(opts) {
return this.parent.assets.ls(this.projectId, opts);
}
rm(key) {
return this.parent.assets.rm(this.projectId, key);
}
sign(key, opts) {
return this.parent.assets.sign(this.projectId, key, opts);
}
}
class ScopedContracts {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
provisionSigner(opts) {
return this.parent.contracts.provisionSigner(this.projectId, opts);
}
getSigner(signerId) {
return this.parent.contracts.getSigner(this.projectId, signerId);
}
listSigners() {
return this.parent.contracts.listSigners(this.projectId);
}
setRecovery(signerId, recoveryAddress) {
return this.parent.contracts.setRecovery(this.projectId, signerId, recoveryAddress);
}
setLowBalanceAlert(signerId, thresholdWei) {
return this.parent.contracts.setLowBalanceAlert(this.projectId, signerId, thresholdWei);
}
call(opts) {
return this.parent.contracts.call(this.projectId, opts);
}
deploy(opts) {
return this.parent.contracts.deploy(this.projectId, opts);
}
callStatus(callId) {
return this.parent.contracts.callStatus(this.projectId, callId);
}
transfer(opts) {
return this.parent.contracts.transfer(this.projectId, opts);
}
transferStatus(signerId, transferId) {
return this.parent.contracts.transferStatus(this.projectId, signerId, transferId);
}
listTransfers(signerId) {
return this.parent.contracts.listTransfers(this.projectId, signerId);
}
drain(signerId, destinationAddress) {
return this.parent.contracts.drain(this.projectId, signerId, destinationAddress);
}
deleteSigner(signerId) {
return this.parent.contracts.deleteSigner(this.projectId, signerId);
}
// `read` is not project-scoped — pass through.
read(opts) {
return this.parent.contracts.read(opts);
}
}
function createScopedApplyHero(parent, projectId) {
const bindProject = (spec) => ({ ...spec, project_id: spec.project_id ?? projectId });
const hero = ((spec, opts) => parent._applyEngine.apply(bindProject(spec), opts));
hero.plan = (spec, opts) => parent._applyEngine.plan(bindProject(spec), opts);
hero.start = (spec, opts) => parent._applyEngine.start(bindProject(spec), opts);
hero.resume = (operationId, opts = {}) => parent._applyEngine.resume(operationId, {
...opts,
project: opts.project ?? projectId,
});
hero.promote = (releaseId, opts = {}) => parent._applyEngine.promote(projectId, releaseId, opts);
hero.upload = (plan, opts) => parent._applyEngine.upload(plan, {
...opts,
project: opts.project ?? projectId,
});
hero.commit = (planId, opts = {}) => parent._applyEngine.commit(planId, {
...opts,
project: opts.project ?? projectId,
});
hero.rehearse = (planId, opts = {}) => parent._applyEngine.rehearse(planId, {
...opts,
project: opts.project ?? projectId,
});
hero.status = (operationId, opts = {}) => parent._applyEngine.status(operationId, {
...opts,
project: opts.project ?? projectId,
});
hero.list = (opts = {}) => parent._applyEngine.list({
project: opts.project ?? projectId,
limit: opts.limit,
cursor: opts.cursor,
});
hero.events = (operationId, opts = {}) => parent._applyEngine.events(operationId, {
project: opts.project ?? projectId,
});
hero.edgeCoherence = (operationId, opts = {}) => parent._applyEngine.edgeCoherence(operationId, {
project: opts.project ?? projectId,
});
hero.waitEdgeCoherent = (operationId, opts = {}) => parent._applyEngine.waitEdgeCoherent(operationId, {
...opts,
project: opts.project ?? projectId,
});
hero.getRelease = (releaseId, opts = {}) => parent._applyEngine.getRelease({
project: opts.project ?? projectId,
releaseId,
siteLimit: opts.siteLimit,
});
hero.getActiveRelease = (opts = {}) => parent._applyEngine.getActiveRelease({
project: opts.project ?? projectId,
siteLimit: opts.siteLimit,
});
hero.diff = (opts) => parent._applyEngine.diff({
...opts,
project: opts.project ?? projectId,
});
hero.resolve = (opts) => parent._applyEngine.resolve({
...opts,
project: opts.project ?? projectId,
});
return hero;
}
class ScopedDomains {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
connect(input) {
return this.parent.domains.connect(this.projectId, input);
}
get(domain) {
return this.parent.domains.get(this.projectId, domain);
}
list() {
return this.parent.domains.list(this.projectId);
}
check(domain) {
return this.parent.domains.check(this.projectId, domain);
}
apply(domain) {
return this.parent.domains.apply(this.projectId, domain);
}
repair(domain) {
return this.parent.domains.repair(this.projectId, domain);
}
testReceive(domain, to) {
return this.parent.domains.testReceive(this.projectId, domain, to);
}
activate(domain) {
return this.parent.domains.activate(this.projectId, domain);
}
disconnect(domain) {
return this.parent.domains.disconnect(this.projectId, domain);
}
wait(domain, opts) {
return this.parent.domains.wait(this.projectId, domain, opts);
}
}
class ScopedEmailWebhooks {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
register(opts) {
return this.parent.email.webhooks.register(this.projectId, opts);
}
list() {
return this.parent.email.webhooks.list(this.projectId);
}
get(webhookId) {
return this.parent.email.webhooks.get(this.projectId, webhookId);
}
update(webhookId, opts) {
return this.parent.email.webhooks.update(this.projectId, webhookId, opts);
}
delete(webhookId) {
return this.parent.email.webhooks.delete(this.projectId, webhookId);
}
listDeliveries(opts) {
return this.parent.email.webhooks.listDeliveries(this.projectId, opts);
}
redriveDelivery(deliveryId) {
return this.parent.email.webhooks.redriveDelivery(this.projectId, deliveryId);
}
}
class ScopedEmail {
parent;
projectId;
webhooks;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
this.webhooks = new ScopedEmailWebhooks(parent, projectId);
}
createMailbox(slug) {
return this.parent.email.createMailbox(this.projectId, slug);
}
listMailboxes() {
return this.parent.email.listMailboxes(this.projectId);
}
setMailboxDefaults(opts) {
return this.parent.email.setMailboxDefaults(this.projectId, opts);
}
updateMailbox(opts) {
return this.parent.email.updateMailbox(this.projectId, opts);
}
send(opts) {
return this.parent.email.send(this.projectId, opts);
}
list(opts) {
return this.parent.email.list(this.projectId, opts);
}
get(messageId) {
return this.parent.email.get(this.projectId, messageId);
}
getRaw(messageId) {
return this.parent.email.getRaw(this.projectId, messageId);
}
getMailbox() {
return this.parent.email.getMailbox(this.projectId);
}
deleteMailbox(mailboxId) {
return this.parent.email.deleteMailbox(this.projectId, mailboxId);
}
}
class ScopedFunctionRuns {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
create(name, opts) {
return this.parent.functions.runs.create(this.projectId, name, opts);
}
list(name, opts) {
return this.parent.functions.runs.list(this.projectId, name, opts);
}
get(runId) {
return this.parent.functions.runs.get(this.projectId, runId);
}
logs(runId, opts) {
return this.parent.functions.runs.logs(this.projectId, runId, opts);
}
cancel(runId) {
return this.parent.functions.runs.cancel(this.projectId, runId);
}
redrive(runId, opts) {
return this.parent.functions.runs.redrive(this.projectId, runId, opts);
}
wait(runId, opts) {
return this.parent.functions.runs.wait(this.projectId, runId, opts);
}
}
class ScopedFunctions {
parent;
projectId;
runs;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
this.runs = new ScopedFunctionRuns(parent, projectId);
}
deploy(opts) {
return this.parent.functions.deploy(this.projectId, opts);
}
invoke(name, opts) {
return this.parent.functions.invoke(this.projectId, name, opts);
}
logs(name, opts) {
return this.parent.functions.logs(this.projectId, name, opts);
}
logsByRequestId(requestId, opts) {
return this.parent.functions.logsByRequestId(this.projectId, requestId, opts);
}
list() {
return this.parent.functions.list(this.projectId);
}
delete(name) {
return this.parent.functions.delete(this.projectId, name);
}
update(name, opts) {
return this.parent.functions.update(this.projectId, name, opts);
}
rebuild(name) {
return this.parent.functions.rebuild(this.projectId, name);
}
rebuildAll() {
return this.parent.functions.rebuildAll(this.projectId);
}
}
class ScopedSecrets {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
set(key, opts) {
return this.parent.secrets.set(this.projectId, key, opts);
}
list() {
return this.parent.secrets.list(this.projectId);
}
delete(key) {
return this.parent.secrets.delete(this.projectId, key);
}
}
class ScopedJobs {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
submit(request) {
return this.parent.jobs.submit(this.projectId, request);
}
get(jobId) {
return this.parent.jobs.get(this.projectId, jobId);
}
logs(jobId, opts) {
return this.parent.jobs.logs(this.projectId, jobId, opts);
}
cancel(jobId) {
return this.parent.jobs.cancel(this.projectId, jobId);
}
purge() {
return this.parent.jobs.purge(this.projectId);
}
downloadArtifact(jobId, filename) {
return this.parent.jobs.downloadArtifact(this.projectId, jobId, filename);
}
}
class ScopedSubdomains {
parent;
projectId;
constructor(parent, projectId) {
this.parent = parent;
this.projectId = projectId;
}
list() {
return this.parent.subdomains.list(this.projectId);
}
add(input) {
return this.parent.subdomains.add({
...input,
projectId: input.projectId ?? this.projectId,
});
}
delete(name, opts = {}) {
return this.parent.subdomains.delete(name, {
...opts,
projectId: opts.projectId ?? this.projectId,
});
}
}
export class ScopedRun402 {
/** Resolved project id this client is bound to. Read-only. */
projectId;
projects;
apps;
ai;
auth;
assets;
contracts;
/**
* Hero apply surface: `r.project(id).apply(spec)`
* is the documented happy path for both release-only and mixed apply.
* Callable directly, with `.plan(spec)` / `.start(spec)` / `.resume(opId)`
* sub-methods for advanced plan-upload-commit pipelines.
*/
apply;
/**
* No `deploy` namespace: `apply` owns both writes and lifecycle reads.
* Use `p.apply(...)`, `p.apply.plan(...)`, `p.apply.status(...)`,
* `p.apply.getRelease(...)`, and `p.apply.resolve(...)`.
*/
domains;
email;
functions;
jobs;
secrets;
subdomains;
/** Per-project capability grants and their grant keys, project-id pre-bound. */
grants;
/** Cursored project events feed, project-id pre-bound. */
events;
live;
/** Release-error-rollup query surface (list / get / watch), project-id pre-bound. */
errors;
archives;
snapshots;
branches;
constructor(parent, _client, projectId) {
this.projectId = projectId;
this.projects = new ScopedProjects(parent, projectId);
this.apps = new ScopedApps(parent, projectId);
this.ai = new ScopedAi(parent, projectId);
this.auth = new ScopedAuth(parent, projectId);
this.assets = new ScopedAssets(parent, projectId);
this.contracts = new ScopedContracts(parent, projectId);
this.apply = createScopedApplyHero(parent, projectId);
this.domains = new ScopedDomains(parent, projectId);
this.email = new ScopedEmail(parent, projectId);
this.functions = new ScopedFunctions(parent, projectId);
this.jobs = new ScopedJobs(parent, projectId);
this.secrets = new ScopedSecrets(parent, projectId);
this.subdomains = new ScopedSubdomains(parent, projectId);
this.grants = new ScopedGrants(parent, projectId);
this.events = new ScopedEvents(parent, projectId);
this.live = new ScopedLive(parent, projectId);
this.errors = new ScopedErrors(parent, projectId);
this.archives = new ScopedArchives(parent, projectId);
this.snapshots = new ScopedSnapshots(parent, projectId);
this.branches = new ScopedBranches(parent, projectId);
}
}
//# sourceMappingURL=scoped.js.map