@sendinel/mcp-server 1.0.153 → 1.0.154
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.
|
@@ -23,7 +23,6 @@ export const APPROVAL_EXEMPT = {
|
|
|
23
23
|
approve_approval: "is the approval step itself: only a person-role OAuth connection can decide its own pending request, bound to that token and project, audited; sends nothing",
|
|
24
24
|
approve_data_proposal: "turns a proposal into an AI draft for review; sends nothing",
|
|
25
25
|
approve_draft: "marks a draft ready; sending still requires a gated send or activation",
|
|
26
|
-
cancel_approval: "only moves an unused approval to rejected (never grants anything); reduces what can run",
|
|
27
26
|
cancel_send_queue_rows: "cancels queued mail before it sends; reduces sending",
|
|
28
27
|
clone_campaign: "creates a draft copy of a campaign; nothing sends until activated (gated)",
|
|
29
28
|
clone_sequence_template: "creates a draft campaign from a template; nothing sends until activated (gated)",
|
|
@@ -22,8 +22,10 @@ async function clientName(fallback) {
|
|
|
22
22
|
}
|
|
23
23
|
export async function cancelApproval(approvalId, transportClientName) {
|
|
24
24
|
const actor = requestContext();
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const canCancelProject = actor?.scopes?.some(scope => scope === 'write' || scope === 'admin');
|
|
26
|
+
const ownTokenId = actor?.authKind === 'oauth' && actor.scopes?.includes('read') ? actor.oauthTokenId : null;
|
|
27
|
+
if (!actor || (!canCancelProject && !ownTokenId)) {
|
|
28
|
+
return refuse('approval_forbidden', 'Cancellation requires write scope or the requesting OAuth token.');
|
|
27
29
|
}
|
|
28
30
|
try {
|
|
29
31
|
const projectId = getProjectId();
|
|
@@ -31,13 +33,17 @@ export async function cancelApproval(approvalId, transportClientName) {
|
|
|
31
33
|
const now = new Date().toISOString();
|
|
32
34
|
// A single conditional write arbitrates cancellation versus approval/consumption.
|
|
33
35
|
// Preserve the original decision provenance; cancellation never grants authority.
|
|
34
|
-
const
|
|
36
|
+
const cancellation = store().from('action_approvals')
|
|
35
37
|
.update({ status: 'rejected' })
|
|
36
38
|
.eq('id', approvalId).eq('project_id', projectId)
|
|
37
|
-
.in('status', ['pending', 'approved']).is('used_at', null).gt('expires_at', now)
|
|
38
|
-
|
|
39
|
+
.in('status', ['pending', 'approved']).is('used_at', null).gt('expires_at', now);
|
|
40
|
+
// Ownership is part of the write, so concurrent changes cannot cross tokens.
|
|
41
|
+
const bound = canCancelProject ? cancellation : cancellation.eq('oauth_token_id', ownTokenId);
|
|
42
|
+
const { data, error } = await bound.select('id').maybeSingle();
|
|
39
43
|
if (error)
|
|
40
44
|
return refuse('approval_update_failed', 'Unable to cancel the approval. Check its status before retrying.');
|
|
45
|
+
if (!data && !canCancelProject)
|
|
46
|
+
return refuse('approval_forbidden', 'No cancellable approval for this OAuth token in this project.');
|
|
41
47
|
if (!data)
|
|
42
48
|
return refuse('approval_not_cancellable', 'No unexpired, unused pending or approved approval found in this project.');
|
|
43
49
|
const { error: auditError } = await store().from('audit_log').insert({
|
package/build/server.js
CHANGED
|
@@ -88,7 +88,7 @@ export const ALL_TOOL_GROUPS = Object.keys(GROUP_REGISTRY);
|
|
|
88
88
|
// ── Scope enforcement ─────────────────────────────────────────────────────
|
|
89
89
|
// Maps tool names to required scope. Mirrors dashboard's WRITE_TOOLS/ADMIN_TOOLS.
|
|
90
90
|
const WRITE_TOOLS = new Set([
|
|
91
|
-
'
|
|
91
|
+
'approve_approval',
|
|
92
92
|
'recheck_domain_dns',
|
|
93
93
|
'mark_agent_message', 'draft_agent_reply', 'create_agent_mailbox',
|
|
94
94
|
'add_subscriber', 'identify_subscriber', 'emit_contact_event', 'import_subscribers', 'update_subscriber', 'bulk_update_subscribers',
|
|
@@ -188,7 +188,6 @@ export function testerConnectionAllowsTool(name) {
|
|
|
188
188
|
// Retain the existing campaign activation path. A globally gated tool is not by itself
|
|
189
189
|
// permission for a tester: sends, deletes and access/infrastructure writes stay refused.
|
|
190
190
|
return getRequiredScope(name) === 'read'
|
|
191
|
-
|| name === 'cancel_approval'
|
|
192
191
|
|| TESTER_REQUEST_TOOLS.has(name)
|
|
193
192
|
|| name === 'activate_campaigns'
|
|
194
193
|
|| name === 'update_campaign_status';
|
|
@@ -324,7 +323,7 @@ function createScopeProxy(server, scopes, toolGroup, allowedTools) {
|
|
|
324
323
|
const required = getRequiredScope(name);
|
|
325
324
|
const tester = isTesterConnection(scopes);
|
|
326
325
|
const agent = isAgentConnection(scopes);
|
|
327
|
-
const allowed = () =>
|
|
326
|
+
const allowed = () => agent ? agentConnectionAllowsTool(name) : tester
|
|
328
327
|
? testerConnectionAllowsTool(name)
|
|
329
328
|
: scopeAllows(scopes, required) || (scopeAllows(scopes, 'read') && isHumanRequestableAdminTool(name));
|
|
330
329
|
if (!allowed()) {
|
package/build/tools/approvals.js
CHANGED
|
@@ -11,7 +11,7 @@ const j = (data) => txt(JSON.stringify(data, null, 2));
|
|
|
11
11
|
export function registerApprovalTools(server, options) {
|
|
12
12
|
server.registerTool('cancel_approval', {
|
|
13
13
|
title: 'Cancel Approval',
|
|
14
|
-
description: 'Cancel an unexpired, unused pending or approved action approval in this project.
|
|
14
|
+
description: 'Cancel an unexpired, unused pending or approved action approval in this project. Read-scoped OAuth connections can cancel only their own token’s requests; write/admin credentials can cancel any eligible request in this project. Sets it to rejected; cannot approve or undo cancellation.',
|
|
15
15
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
16
16
|
inputSchema: { approval_id: z.string().uuid() },
|
|
17
17
|
}, async ({ approval_id }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendinel/mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.154",
|
|
4
4
|
"description": "AI-controlled email operations control plane for campaigns, contacts, segments, analytics, and multi-provider sending via MCP.",
|
|
5
5
|
"mcpName": "ai.sendinel/mcp-server",
|
|
6
6
|
"type": "module",
|