@daileyos/mcp-server 1.17.0 → 1.19.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buddy.js","sourceRoot":"","sources":["../../src/tools/buddy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,gFAAgF;AAChF,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAybxB,CAAC,IAAI,EAAE,CAAC;AAET,gFAAgF;AAEhF,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,4EAA4E;IAC5E,yDAAyD;IACzD,qCAAqC;IACrC,+BAA+B;IAC/B,8EAA8E;IAC9E,0DAA0D;IAC1D,MAAM,CAAC,MAAM,CACX,WAAW,EACX,iJAAiJ,EACjJ,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAA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BACnC,OAAO;gBACP,EAAE;gBACF,0CAA0C;gBAC1C,2DAA2D;gBAC3D,uFAAuF;gBACvF,EAAE;gBACF,mEAAmE;aACpE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChB,CAAC;QAED,uEAAuE;QACvE,OAAO,UAAU,CAAC;YAChB,kDAAkD;YAClD,EAAE;YACF,oBAAoB,KAAK,EAAE;YAC3B,EAAE;YACF,wEAAwE;YACxE,uEAAuE;YACvE,6DAA6D;YAC7D,kDAAkD;SACnD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerPaymentsTools(server: McpServer): void;
3
+ //# sourceMappingURL=payments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../../src/tools/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAgCpE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAwHtD"}
@@ -0,0 +1,96 @@
1
+ import { z } from 'zod';
2
+ import { apiRequest, formatError, textResult } from '../api.js';
3
+ export function registerPaymentsTools(server) {
4
+ server.tool('dailey_payments_status', 'Check Stripe Connect payments status for the authenticated account. Reports whether a connected Stripe account exists and whether it is ready to take payments (charges enabled, payouts enabled, onboarding details submitted). If not connected, run dailey_payments_connect first.', {}, async () => {
5
+ const res = await apiRequest('GET', '/stripe/connect/status');
6
+ if (!res.ok)
7
+ return textResult(formatError(res));
8
+ const s = res.data;
9
+ if (!s.connected) {
10
+ return textResult([
11
+ 'Payments status',
12
+ '─'.repeat(40),
13
+ 'Connected: no',
14
+ '',
15
+ 'No Stripe account yet. Run dailey_payments_connect to start onboarding.',
16
+ ].join('\n'));
17
+ }
18
+ const ready = Boolean(s.charges_enabled && s.details_submitted);
19
+ const lines = [
20
+ 'Payments status',
21
+ '─'.repeat(40),
22
+ 'Connected: yes',
23
+ `Account: ${s.account_id || '-'}`,
24
+ `Ready (charges): ${s.charges_enabled ? 'yes' : 'no'}`,
25
+ `Payouts enabled: ${s.payouts_enabled ? 'yes' : 'no'}`,
26
+ `Details submitted:${s.details_submitted ? ' yes' : ' no'}`,
27
+ '',
28
+ ready
29
+ ? 'Ready to take payments.'
30
+ : 'Onboarding incomplete — run dailey_payments_connect to finish.',
31
+ ];
32
+ return textResult(lines.join('\n'));
33
+ });
34
+ server.tool('dailey_payments_connect', 'Start (or resume) Stripe Connect onboarding for the authenticated account. Returns a hosted Stripe onboarding URL for the user to open in a browser and complete. Safe to call repeatedly — it reuses the existing connected account and just mints a fresh onboarding link. After the user finishes, call dailey_payments_status to confirm the account is ready.', {}, async () => {
35
+ const res = await apiRequest('POST', '/stripe/connect/onboard');
36
+ if (!res.ok)
37
+ return textResult(formatError(res));
38
+ const lines = [
39
+ 'Stripe onboarding link',
40
+ '─'.repeat(40),
41
+ `Open this URL to connect/finish Stripe: ${res.data.url}`,
42
+ '',
43
+ 'After completing onboarding, call dailey_payments_status to confirm the account is ready.',
44
+ ];
45
+ return textResult(lines.join('\n'));
46
+ });
47
+ server.tool('dailey_payments_create_key', 'Mint a per-project payment key (a `dospay_` token) for a project. This is the credential the app uses to call the payments checkout endpoint. The raw key is returned ONCE here and is NEVER recoverable afterward — copy it now and store it securely (e.g. as an app env var). Listing keys later shows only a masked prefix.', {
48
+ project_id: z.string().describe('The project ID (or name) to mint the payment key for'),
49
+ }, async ({ project_id }) => {
50
+ const res = await apiRequest('POST', `/projects/${project_id}/payment-keys`);
51
+ if (!res.ok)
52
+ return textResult(formatError(res));
53
+ const d = res.data;
54
+ const lines = [
55
+ 'Payment key created',
56
+ '─'.repeat(40),
57
+ `Name: ${d.name}`,
58
+ `Prefix: ${d.token_prefix}`,
59
+ '',
60
+ '⚠ Shown ONCE — not recoverable. Copy it now:',
61
+ d.token,
62
+ '',
63
+ 'Store it as an app secret (env var). To rotate, mint a new key and revoke the old one in the dashboard.',
64
+ ];
65
+ return textResult(lines.join('\n'));
66
+ });
67
+ server.tool('dailey_payments_create_product', 'Create a product with a price in the seller\'s connected Stripe account. Returns the Stripe product_id and price_id. Use the price_id in checkout line items. For a subscription, pass recurring_interval (e.g. "month" or "year"); omit it for a one-time price. Requires a connected Stripe account (run dailey_payments_status / dailey_payments_connect first).', {
68
+ name: z.string().describe('Product name'),
69
+ amount: z.number().int().min(0).describe('Price in the smallest currency unit (integer cents, e.g. 1999 = $19.99)'),
70
+ currency: z.string().optional().describe('ISO currency code (default "usd")'),
71
+ recurring_interval: z
72
+ .string()
73
+ .optional()
74
+ .describe('For subscriptions, the billing interval (e.g. "month", "year"). Omit for a one-time price.'),
75
+ }, async ({ name, amount, currency, recurring_interval }) => {
76
+ const body = { name, amount };
77
+ if (currency !== undefined)
78
+ body.currency = currency;
79
+ if (recurring_interval !== undefined)
80
+ body.recurring_interval = recurring_interval;
81
+ const res = await apiRequest('POST', '/payments/products', body);
82
+ if (!res.ok)
83
+ return textResult(formatError(res));
84
+ const d = res.data;
85
+ const lines = [
86
+ 'Product created',
87
+ '─'.repeat(40),
88
+ `Product ID: ${d.product_id}`,
89
+ `Price ID: ${d.price_id}`,
90
+ '',
91
+ 'Use the Price ID in checkout line items (e.g. { price: "' + d.price_id + '", quantity: 1 }).',
92
+ ];
93
+ return textResult(lines.join('\n'));
94
+ });
95
+ }
96
+ //# sourceMappingURL=payments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/tools/payments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA8BhE,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,CAAC,IAAI,CACT,wBAAwB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AAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daileyos/mcp-server",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "description": "Dailey OS MCP server for Claude Code and AI assistants",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/api.ts CHANGED
@@ -31,13 +31,44 @@ function readCliStoredToken(): string | undefined {
31
31
  }
32
32
  }
33
33
 
34
- let currentToken = process.env.DAILEY_API_TOKEN || readCliStoredToken() || '';
34
+ // An explicit env token (headless/CI) takes precedence and is fixed for the
35
+ // process lifetime. Otherwise the token is resolved DYNAMICALLY on every request
36
+ // (resolveToken below): the email/password refresh token if present, else the
37
+ // active CLI login — re-read from disk each call so a `dailey login` account
38
+ // switch is picked up live, without restarting the MCP server. This is what
39
+ // keeps multi-account users in sync (no token is baked into the client config).
40
+ const ENV_TOKEN = process.env.DAILEY_API_TOKEN || '';
41
+ let refreshedToken = '';
42
+
43
+ export function resolveToken(): string {
44
+ if (ENV_TOKEN) return ENV_TOKEN;
45
+ if (refreshedToken) return refreshedToken;
46
+ return readCliStoredToken() || '';
47
+ }
48
+
49
+ // Active managed-account context for the "manager / managed-accounts" capability.
50
+ // A manager (a Dailey account) can operate inside other accounts that granted
51
+ // them a consent-based grant by sending header `X-Dailey-Account: <slug|id>`;
52
+ // the server verifies a LIVE grant and scopes the request to that account (no
53
+ // re-login). This is SESSION-SCOPED: it persists for the MCP server process
54
+ // lifetime, which is what we want — an agent calls `dailey_use_account` once and
55
+ // every subsequent tool call operates within that account until it clears or
56
+ // switches. When unset, no header is sent (normal self-scoped behavior).
57
+ let activeAccount: string | undefined;
58
+
59
+ export function setActiveAccount(slugOrId: string | undefined): void {
60
+ activeAccount = slugOrId && slugOrId.trim() ? slugOrId.trim() : undefined;
61
+ }
62
+
63
+ export function getActiveAccount(): string | undefined {
64
+ return activeAccount;
65
+ }
35
66
 
36
67
  // Credential preflight lives in index.ts so it can distinguish TTY vs
37
68
  // MCP-stdio invocation and emit a JSON-RPC-shaped error instead of just
38
69
  // dying with a stderr line that Claude Code doesn't surface.
39
70
  export function hasCredentials(): boolean {
40
- return Boolean(currentToken || DAILEY_EMAIL);
71
+ return Boolean(resolveToken() || DAILEY_EMAIL);
41
72
  }
42
73
 
43
74
  async function refreshToken(): Promise<string> {
@@ -56,8 +87,8 @@ async function refreshToken(): Promise<string> {
56
87
  if (!data.access_token) {
57
88
  throw new Error('Token refresh: no access_token in response');
58
89
  }
59
- currentToken = data.access_token;
60
- return currentToken;
90
+ refreshedToken = data.access_token;
91
+ return refreshedToken;
61
92
  }
62
93
 
63
94
  interface ApiResponse<T = unknown> {
@@ -80,6 +111,11 @@ export async function apiRequest<T = unknown>(
80
111
  // first successful MCP connection (onboarding progress).
81
112
  'X-Dailey-Source': 'mcp',
82
113
  };
114
+ // Manager / managed-accounts: when an active account is set, scope every
115
+ // request to it. The server verifies a live consent grant; absent header =
116
+ // normal self-scoped behavior.
117
+ const acct = getActiveAccount();
118
+ if (acct) headers['X-Dailey-Account'] = acct;
83
119
  const options: RequestInit = { method, headers };
84
120
  if (body && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
85
121
  options.body = JSON.stringify(body);
@@ -87,13 +123,13 @@ export async function apiRequest<T = unknown>(
87
123
  return fetch(url, options);
88
124
  };
89
125
 
90
- let res = await makeRequest(currentToken);
126
+ let res = await makeRequest(resolveToken());
91
127
 
92
128
  // Auto-refresh on 401 if credentials are configured
93
129
  if (res.status === 401 && DAILEY_EMAIL) {
94
130
  try {
95
131
  await refreshToken();
96
- res = await makeRequest(currentToken);
132
+ res = await makeRequest(resolveToken());
97
133
  } catch {
98
134
  // refresh failed, return the original 401
99
135
  }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
5
5
 
6
6
  import { hasCredentials } from './api.js';
7
7
  import { registerAuthTools } from './tools/auth.js';
8
+ import { registerAccountTools } from './tools/accounts.js';
8
9
  import { registerProjectTools } from './tools/projects.js';
9
10
  import { registerDeployTools } from './tools/deploy.js';
10
11
  import { registerDeployStatusTools } from './tools/deploy-status.js';
@@ -111,6 +112,7 @@ const server = new McpServer({
111
112
 
112
113
  // Core + identity
113
114
  registerAuthTools(server);
115
+ registerAccountTools(server);
114
116
  registerPlatformTools(server);
115
117
  registerUsageTools(server);
116
118
  registerBillingTools(server);
@@ -0,0 +1,111 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod';
3
+ import {
4
+ apiRequest,
5
+ formatError,
6
+ jsonResult,
7
+ getActiveAccount,
8
+ setActiveAccount,
9
+ } from '../api.js';
10
+
11
+ interface ManagedAccount {
12
+ managed_customer_id: string;
13
+ slug: string;
14
+ name: string;
15
+ }
16
+
17
+ const AUTH_REQUIRED_ERROR = {
18
+ error_code: 'DAILEY_AUTH_REQUIRED',
19
+ message: 'Not authenticated',
20
+ remediation: 'Run `dailey auth setup` in your terminal',
21
+ help_url: 'https://docs.dailey.cloud/auth',
22
+ };
23
+
24
+ export function registerAccountTools(server: McpServer) {
25
+ server.tool(
26
+ 'dailey_accounts',
27
+ 'List the managed accounts (the "fleet") this user manages — other Dailey accounts that have granted you a consent-based access grant. Returns each account\'s managed_customer_id, slug, and name, plus which account is currently active for this session. Empty fleet means you manage no other accounts. Use `dailey_use_account` to switch into one of these accounts; after switching, all other dailey tools operate inside that account until you clear or switch.',
28
+ {},
29
+ async () => {
30
+ const res = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
31
+ if (!res.ok) {
32
+ if (res.status === 401 || res.status === 403) {
33
+ return jsonResult(AUTH_REQUIRED_ERROR);
34
+ }
35
+ return jsonResult({ error: formatError(res) });
36
+ }
37
+ const fleet = Array.isArray(res.data) ? res.data : [];
38
+ return jsonResult({
39
+ active_account: getActiveAccount() ?? null,
40
+ operating_as: getActiveAccount() ? 'managed_account' : 'self',
41
+ count: fleet.length,
42
+ accounts: fleet,
43
+ });
44
+ },
45
+ );
46
+
47
+ server.tool(
48
+ 'dailey_use_account',
49
+ 'Switch the active managed-account context for this MCP session. Pass `account` (a slug or id from `dailey_accounts`) to operate INSIDE that managed account; after calling this, ALL other dailey tools act inside that managed account until you clear or switch. Pass `clear: true` to stop and operate as yourself again. The target account must be in your fleet (`dailey_accounts`) — an invalid account is rejected. This context is session-scoped: it persists for the life of this MCP server.',
50
+ {
51
+ account: z
52
+ .string()
53
+ .optional()
54
+ .describe('The slug or id of a managed account to operate within (must be in your fleet from dailey_accounts)'),
55
+ clear: z
56
+ .boolean()
57
+ .optional()
58
+ .describe('If true, clear the active managed account and operate as yourself again'),
59
+ },
60
+ async ({ account, clear }) => {
61
+ if (clear) {
62
+ setActiveAccount(undefined);
63
+ return jsonResult({
64
+ ok: true,
65
+ active_account: null,
66
+ operating_as: 'self',
67
+ message: 'Cleared managed-account context — now operating as yourself.',
68
+ });
69
+ }
70
+
71
+ if (!account || !account.trim()) {
72
+ return jsonResult({
73
+ ok: false,
74
+ message: 'Provide `account` (a slug or id from dailey_accounts) to switch into, or `clear: true` to operate as yourself.',
75
+ });
76
+ }
77
+
78
+ const res = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
79
+ if (!res.ok) {
80
+ if (res.status === 401 || res.status === 403) {
81
+ return jsonResult(AUTH_REQUIRED_ERROR);
82
+ }
83
+ return jsonResult({ ok: false, error: formatError(res) });
84
+ }
85
+ const fleet = Array.isArray(res.data) ? res.data : [];
86
+ const target = account.trim();
87
+ const match = fleet.find(
88
+ (a) => a.slug === target || a.managed_customer_id === target,
89
+ );
90
+ if (!match) {
91
+ return jsonResult({
92
+ ok: false,
93
+ message: `Account "${target}" is not in your managed-accounts fleet. Call dailey_accounts to list the accounts you manage.`,
94
+ available: fleet.map((a) => ({ slug: a.slug, name: a.name })),
95
+ });
96
+ }
97
+
98
+ // Use the slug as the header value when available (matches the dashboard/CLI
99
+ // convention); the server accepts either slug or id.
100
+ const activeValue = match.slug || match.managed_customer_id;
101
+ setActiveAccount(activeValue);
102
+ return jsonResult({
103
+ ok: true,
104
+ active_account: activeValue,
105
+ operating_as: 'managed_account',
106
+ account: match,
107
+ message: `Now operating within "${match.name}" (${match.slug}). All subsequent dailey tool calls run inside this account until you clear or switch.`,
108
+ });
109
+ },
110
+ );
111
+ }
package/src/tools/auth.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { z } from 'zod';
3
- import { apiRequest, formatError, textResult, jsonResult } from '../api.js';
3
+ import { apiRequest, formatError, textResult, jsonResult, getActiveAccount } from '../api.js';
4
+
5
+ interface ManagedAccount {
6
+ managed_customer_id: string;
7
+ slug: string;
8
+ name: string;
9
+ }
4
10
 
5
11
  interface AuthEnableResponse {
6
12
  ok: boolean;
@@ -100,12 +106,32 @@ export function registerAuthTools(server: McpServer) {
100
106
  source = 'session';
101
107
  }
102
108
 
109
+ // Manager / managed-accounts: report whether this user manages any other
110
+ // accounts (the fleet) and which one — if any — is the active context for
111
+ // this session. A non-empty fleet means they can `dailey_use_account` to
112
+ // operate inside one of these accounts. Best-effort: a failure here must
113
+ // not break auth-status, so we swallow errors and report manager: null.
114
+ let fleet: ManagedAccount[] = [];
115
+ try {
116
+ const mres = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
117
+ if (mres.ok && Array.isArray(mres.data)) fleet = mres.data;
118
+ } catch {
119
+ // ignore — leave fleet empty
120
+ }
121
+ const active = getActiveAccount() ?? null;
122
+
103
123
  return jsonResult({
104
124
  authenticated: true,
105
125
  source,
106
126
  account: u.name,
107
127
  email: u.email,
108
128
  recommended_action: null,
129
+ manager: {
130
+ is_manager: fleet.length > 0,
131
+ managed_accounts: fleet,
132
+ active_account: active,
133
+ operating_as: active ? 'managed_account' : 'self',
134
+ },
109
135
  });
110
136
  },
111
137
  );