@burdenoff/mcp-libs 2026.511.1
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 +76 -0
- package/dist/chunk-4GBVJ4OY.js +847 -0
- package/dist/chunk-4GBVJ4OY.js.map +1 -0
- package/dist/chunk-H2OYWLOA.js +919 -0
- package/dist/chunk-H2OYWLOA.js.map +1 -0
- package/dist/chunk-JFEQYSWM.js +174 -0
- package/dist/chunk-JFEQYSWM.js.map +1 -0
- package/dist/chunk-WWFVD7BO.js +273 -0
- package/dist/chunk-WWFVD7BO.js.map +1 -0
- package/dist/context-1jV4NsLv.d.cts +138 -0
- package/dist/context-1jV4NsLv.d.ts +138 -0
- package/dist/core/index.cjs +953 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +59 -0
- package/dist/core/index.d.ts +59 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/http-BP4c721D.d.cts +22 -0
- package/dist/http-DXTeCD5r.d.ts +22 -0
- package/dist/index.cjs +1013 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/module-DBcfA-i3.d.ts +67 -0
- package/dist/module-DFQBZNK6.d.cts +67 -0
- package/dist/modules/auth/index.cjs +533 -0
- package/dist/modules/auth/index.cjs.map +1 -0
- package/dist/modules/auth/index.d.cts +51 -0
- package/dist/modules/auth/index.d.ts +51 -0
- package/dist/modules/auth/index.js +159 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/billing/index.cjs +655 -0
- package/dist/modules/billing/index.cjs.map +1 -0
- package/dist/modules/billing/index.d.cts +8 -0
- package/dist/modules/billing/index.d.ts +8 -0
- package/dist/modules/billing/index.js +606 -0
- package/dist/modules/billing/index.js.map +1 -0
- package/dist/modules/channels/index.cjs +443 -0
- package/dist/modules/channels/index.cjs.map +1 -0
- package/dist/modules/channels/index.d.cts +8 -0
- package/dist/modules/channels/index.d.ts +8 -0
- package/dist/modules/channels/index.js +394 -0
- package/dist/modules/channels/index.js.map +1 -0
- package/dist/modules/conversations/index.cjs +288 -0
- package/dist/modules/conversations/index.cjs.map +1 -0
- package/dist/modules/conversations/index.d.cts +8 -0
- package/dist/modules/conversations/index.d.ts +8 -0
- package/dist/modules/conversations/index.js +239 -0
- package/dist/modules/conversations/index.js.map +1 -0
- package/dist/modules/devportal/index.cjs +796 -0
- package/dist/modules/devportal/index.cjs.map +1 -0
- package/dist/modules/devportal/index.d.cts +8 -0
- package/dist/modules/devportal/index.d.ts +8 -0
- package/dist/modules/devportal/index.js +747 -0
- package/dist/modules/devportal/index.js.map +1 -0
- package/dist/modules/export/index.cjs +333 -0
- package/dist/modules/export/index.cjs.map +1 -0
- package/dist/modules/export/index.d.cts +8 -0
- package/dist/modules/export/index.d.ts +8 -0
- package/dist/modules/export/index.js +284 -0
- package/dist/modules/export/index.js.map +1 -0
- package/dist/modules/files/index.cjs +278 -0
- package/dist/modules/files/index.cjs.map +1 -0
- package/dist/modules/files/index.d.cts +8 -0
- package/dist/modules/files/index.d.ts +8 -0
- package/dist/modules/files/index.js +229 -0
- package/dist/modules/files/index.js.map +1 -0
- package/dist/modules/groups/index.cjs +451 -0
- package/dist/modules/groups/index.cjs.map +1 -0
- package/dist/modules/groups/index.d.cts +8 -0
- package/dist/modules/groups/index.d.ts +8 -0
- package/dist/modules/groups/index.js +402 -0
- package/dist/modules/groups/index.js.map +1 -0
- package/dist/modules/health/index.cjs +159 -0
- package/dist/modules/health/index.cjs.map +1 -0
- package/dist/modules/health/index.d.cts +8 -0
- package/dist/modules/health/index.d.ts +8 -0
- package/dist/modules/health/index.js +36 -0
- package/dist/modules/health/index.js.map +1 -0
- package/dist/modules/integrations/index.cjs +316 -0
- package/dist/modules/integrations/index.cjs.map +1 -0
- package/dist/modules/integrations/index.d.cts +8 -0
- package/dist/modules/integrations/index.d.ts +8 -0
- package/dist/modules/integrations/index.js +267 -0
- package/dist/modules/integrations/index.js.map +1 -0
- package/dist/modules/notifications/index.cjs +222 -0
- package/dist/modules/notifications/index.cjs.map +1 -0
- package/dist/modules/notifications/index.d.cts +8 -0
- package/dist/modules/notifications/index.d.ts +8 -0
- package/dist/modules/notifications/index.js +173 -0
- package/dist/modules/notifications/index.js.map +1 -0
- package/dist/modules/organizations/index.cjs +267 -0
- package/dist/modules/organizations/index.cjs.map +1 -0
- package/dist/modules/organizations/index.d.cts +8 -0
- package/dist/modules/organizations/index.d.ts +8 -0
- package/dist/modules/organizations/index.js +218 -0
- package/dist/modules/organizations/index.js.map +1 -0
- package/dist/modules/products/index.cjs +736 -0
- package/dist/modules/products/index.cjs.map +1 -0
- package/dist/modules/products/index.d.cts +8 -0
- package/dist/modules/products/index.d.ts +8 -0
- package/dist/modules/products/index.js +687 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/rbac/index.cjs +378 -0
- package/dist/modules/rbac/index.cjs.map +1 -0
- package/dist/modules/rbac/index.d.cts +8 -0
- package/dist/modules/rbac/index.d.ts +8 -0
- package/dist/modules/rbac/index.js +329 -0
- package/dist/modules/rbac/index.js.map +1 -0
- package/dist/modules/sandbox/index.cjs +318 -0
- package/dist/modules/sandbox/index.cjs.map +1 -0
- package/dist/modules/sandbox/index.d.cts +8 -0
- package/dist/modules/sandbox/index.d.ts +8 -0
- package/dist/modules/sandbox/index.js +225 -0
- package/dist/modules/sandbox/index.js.map +1 -0
- package/dist/modules/scheduler/index.cjs +267 -0
- package/dist/modules/scheduler/index.cjs.map +1 -0
- package/dist/modules/scheduler/index.d.cts +8 -0
- package/dist/modules/scheduler/index.d.ts +8 -0
- package/dist/modules/scheduler/index.js +218 -0
- package/dist/modules/scheduler/index.js.map +1 -0
- package/dist/modules/security/index.cjs +529 -0
- package/dist/modules/security/index.cjs.map +1 -0
- package/dist/modules/security/index.d.cts +8 -0
- package/dist/modules/security/index.d.ts +8 -0
- package/dist/modules/security/index.js +480 -0
- package/dist/modules/security/index.js.map +1 -0
- package/dist/modules/store/index.cjs +450 -0
- package/dist/modules/store/index.cjs.map +1 -0
- package/dist/modules/store/index.d.cts +8 -0
- package/dist/modules/store/index.d.ts +8 -0
- package/dist/modules/store/index.js +401 -0
- package/dist/modules/store/index.js.map +1 -0
- package/dist/modules/support/index.cjs +285 -0
- package/dist/modules/support/index.cjs.map +1 -0
- package/dist/modules/support/index.d.cts +8 -0
- package/dist/modules/support/index.d.ts +8 -0
- package/dist/modules/support/index.js +236 -0
- package/dist/modules/support/index.js.map +1 -0
- package/dist/modules/tags/index.cjs +421 -0
- package/dist/modules/tags/index.cjs.map +1 -0
- package/dist/modules/tags/index.d.cts +8 -0
- package/dist/modules/tags/index.d.ts +8 -0
- package/dist/modules/tags/index.js +372 -0
- package/dist/modules/tags/index.js.map +1 -0
- package/dist/modules/tours/index.cjs +225 -0
- package/dist/modules/tours/index.cjs.map +1 -0
- package/dist/modules/tours/index.d.cts +8 -0
- package/dist/modules/tours/index.d.ts +8 -0
- package/dist/modules/tours/index.js +176 -0
- package/dist/modules/tours/index.js.map +1 -0
- package/dist/modules/vibecontrols/index.cjs +5551 -0
- package/dist/modules/vibecontrols/index.cjs.map +1 -0
- package/dist/modules/vibecontrols/index.d.cts +8 -0
- package/dist/modules/vibecontrols/index.d.ts +8 -0
- package/dist/modules/vibecontrols/index.js +4380 -0
- package/dist/modules/vibecontrols/index.js.map +1 -0
- package/dist/modules/workspaces/index.cjs +552 -0
- package/dist/modules/workspaces/index.cjs.map +1 -0
- package/dist/modules/workspaces/index.d.cts +8 -0
- package/dist/modules/workspaces/index.d.ts +8 -0
- package/dist/modules/workspaces/index.js +503 -0
- package/dist/modules/workspaces/index.js.map +1 -0
- package/dist/tool-name-CQf_IqAj.d.cts +47 -0
- package/dist/tool-name-DlnrBsZ6.d.ts +47 -0
- package/dist/transports/index.cjs +183 -0
- package/dist/transports/index.cjs.map +1 -0
- package/dist/transports/index.d.cts +13 -0
- package/dist/transports/index.d.ts +13 -0
- package/dist/transports/index.js +3 -0
- package/dist/transports/index.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
require('graphql-request');
|
|
5
|
+
require('cross-fetch');
|
|
6
|
+
require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
7
|
+
require('@modelcontextprotocol/sdk/types.js');
|
|
8
|
+
|
|
9
|
+
// src/modules/security/tools.ts
|
|
10
|
+
|
|
11
|
+
// src/core/errors.ts
|
|
12
|
+
var McpInternalError = class extends Error {
|
|
13
|
+
cause;
|
|
14
|
+
constructor(message, cause) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "McpInternalError";
|
|
17
|
+
this.cause = cause;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/core/result.ts
|
|
22
|
+
function jsonResult(data, structured) {
|
|
23
|
+
const result = {
|
|
24
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
25
|
+
};
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
function errorResult(message, hint) {
|
|
29
|
+
const text = hint ? `${message}
|
|
30
|
+
|
|
31
|
+
Hint: ${hint}` : message;
|
|
32
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/core/tool-name.ts
|
|
36
|
+
var MAX_TOOL_NAME_LENGTH = 63;
|
|
37
|
+
function assertSafeName(name, kind) {
|
|
38
|
+
if (name.length > MAX_TOOL_NAME_LENGTH) {
|
|
39
|
+
throw new McpInternalError(
|
|
40
|
+
`Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
function mcpToolName(productName, ...parts) {
|
|
46
|
+
if (!productName) {
|
|
47
|
+
throw new McpInternalError("mcpToolName: productName is required");
|
|
48
|
+
}
|
|
49
|
+
const name = [productName, ...parts].filter(Boolean).join("_");
|
|
50
|
+
return assertSafeName(name);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/modules/security/operations.ts
|
|
54
|
+
var GET_VAULTS = `
|
|
55
|
+
query GetVaults($filter: VaultFilterInput, $pagination: SecurityPaginationInput) {
|
|
56
|
+
getVaults(filter: $filter, pagination: $pagination) {
|
|
57
|
+
items { id name description scope status createdAt }
|
|
58
|
+
total hasMore
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
var GET_VAULT = `
|
|
63
|
+
query GetVault($id: ID!) {
|
|
64
|
+
getVault(id: $id) {
|
|
65
|
+
id name description scope scopeId status lockAfterMinutes createdAt updatedAt
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
var CREATE_VAULT = `
|
|
70
|
+
mutation CreateVault($input: CreateVaultInput!) {
|
|
71
|
+
createVault(input: $input) {
|
|
72
|
+
id name scope scopeId status
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
var DELETE_VAULT = `
|
|
77
|
+
mutation DeleteVault($id: ID!) {
|
|
78
|
+
deleteVault(id: $id)
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
var ARCHIVE_VAULT = `
|
|
82
|
+
mutation ArchiveVault($id: ID!) {
|
|
83
|
+
archiveVault(id: $id) { id status }
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
var GET_SECRETS = `
|
|
87
|
+
query GetSecrets($vaultId: ID!, $filter: SecretFilterInput, $pagination: SecurityPaginationInput) {
|
|
88
|
+
getSecrets(vaultId: $vaultId, filter: $filter, pagination: $pagination) {
|
|
89
|
+
items { id key name description type status isEphemeral createdAt }
|
|
90
|
+
total hasMore
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
var GET_SECRET = `
|
|
95
|
+
query GetSecret($id: ID!) {
|
|
96
|
+
getSecret(id: $id) {
|
|
97
|
+
id key name description type status isEphemeral expiresAt createdAt updatedAt
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
var DECRYPT_SECRET = `
|
|
102
|
+
query DecryptSecret($id: ID!) {
|
|
103
|
+
decryptSecret(id: $id) {
|
|
104
|
+
id key value
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
var CREATE_SECRET = `
|
|
109
|
+
mutation CreateSecret($input: CreateSecretInput!) {
|
|
110
|
+
createSecret(input: $input) {
|
|
111
|
+
id key name type status
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
var UPDATE_SECRET = `
|
|
116
|
+
mutation UpdateSecret($id: ID!, $input: UpdateSecretInput!) {
|
|
117
|
+
updateSecret(id: $id, input: $input) {
|
|
118
|
+
id key name status updatedAt
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
var DELETE_SECRET = `
|
|
123
|
+
mutation DeleteSecret($id: ID!) {
|
|
124
|
+
deleteSecret(id: $id)
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
var ROTATE_SECRET = `
|
|
128
|
+
mutation RotateSecret($id: ID!, $newValue: String!) {
|
|
129
|
+
rotateSecret(id: $id, newValue: $newValue) {
|
|
130
|
+
id key updatedAt
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
// src/modules/security/tools.ts
|
|
136
|
+
var VaultScopeEnum = zod.z.enum(["WORKSPACE", "GLOBAL", "VIBE"]);
|
|
137
|
+
var VaultStatusEnum = zod.z.enum(["ACTIVE", "LOCKED", "ARCHIVED"]);
|
|
138
|
+
var SecretTypeEnum = zod.z.enum(["API_KEY", "PASSWORD", "CERTIFICATE", "TOKEN", "OTHER"]);
|
|
139
|
+
var SecretStatusEnum = zod.z.enum(["ACTIVE", "EXPIRED", "REVOKED"]);
|
|
140
|
+
function readWorkspaceContext(ctx) {
|
|
141
|
+
const auth = ctx.auth.read();
|
|
142
|
+
if (!auth?.workspaceId) return null;
|
|
143
|
+
return { workspaceId: auth.workspaceId };
|
|
144
|
+
}
|
|
145
|
+
function registerSecurityTools(server, ctx, track) {
|
|
146
|
+
server.registerTool(
|
|
147
|
+
track(mcpToolName(ctx.productName, "security_vaults_list")),
|
|
148
|
+
{
|
|
149
|
+
title: "List Vaults",
|
|
150
|
+
description: "List vaults in the current workspace with optional filters and pagination.",
|
|
151
|
+
inputSchema: {
|
|
152
|
+
scope: VaultScopeEnum.optional().describe("Filter by vault scope"),
|
|
153
|
+
status: VaultStatusEnum.optional().describe("Filter by status"),
|
|
154
|
+
search: zod.z.string().optional().describe("Free-text search"),
|
|
155
|
+
limit: zod.z.number().optional().describe("Page size (default 50)"),
|
|
156
|
+
offset: zod.z.number().optional().describe("Skip results")
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async ({ scope, status, search, limit, offset }) => {
|
|
160
|
+
try {
|
|
161
|
+
const workspaceCtx = readWorkspaceContext(ctx);
|
|
162
|
+
if (!workspaceCtx) {
|
|
163
|
+
return errorResult(
|
|
164
|
+
"No active workspace. Bind a workspace via the auth login flow first."
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const filter = { context: workspaceCtx };
|
|
168
|
+
if (scope !== void 0) filter.scope = scope;
|
|
169
|
+
if (status !== void 0) filter.status = status;
|
|
170
|
+
if (search !== void 0) filter.search = search;
|
|
171
|
+
const pagination = {};
|
|
172
|
+
if (limit !== void 0) pagination.limit = limit;
|
|
173
|
+
if (offset !== void 0) pagination.offset = offset;
|
|
174
|
+
const data = await ctx.gql.workspace.request(GET_VAULTS, {
|
|
175
|
+
filter,
|
|
176
|
+
pagination: Object.keys(pagination).length > 0 ? pagination : void 0
|
|
177
|
+
});
|
|
178
|
+
return jsonResult(data.getVaults);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
ctx.logger.error("security_vaults_list failed", { error });
|
|
181
|
+
return errorResult(
|
|
182
|
+
`Failed to list vaults: ${error instanceof Error ? error.message : String(error)}`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
server.registerTool(
|
|
188
|
+
track(mcpToolName(ctx.productName, "security_vaults_get")),
|
|
189
|
+
{
|
|
190
|
+
title: "Get Vault",
|
|
191
|
+
description: "Get a vault by ID.",
|
|
192
|
+
inputSchema: {
|
|
193
|
+
id: zod.z.string().describe("Vault ID")
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
async ({ id }) => {
|
|
197
|
+
try {
|
|
198
|
+
const data = await ctx.gql.workspace.request(GET_VAULT, {
|
|
199
|
+
id
|
|
200
|
+
});
|
|
201
|
+
if (!data.getVault) {
|
|
202
|
+
return errorResult(`Vault ${id} not found`);
|
|
203
|
+
}
|
|
204
|
+
return jsonResult(data.getVault);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
ctx.logger.error("security_vaults_get failed", { error });
|
|
207
|
+
return errorResult(
|
|
208
|
+
`Failed to get vault: ${error instanceof Error ? error.message : String(error)}`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
server.registerTool(
|
|
214
|
+
track(mcpToolName(ctx.productName, "security_vaults_create")),
|
|
215
|
+
{
|
|
216
|
+
title: "Create Vault",
|
|
217
|
+
description: "Create a new vault scoped to the current workspace.",
|
|
218
|
+
inputSchema: {
|
|
219
|
+
name: zod.z.string().describe("Vault name"),
|
|
220
|
+
description: zod.z.string().optional().describe("Vault description"),
|
|
221
|
+
scope: VaultScopeEnum.optional().describe("Vault scope (default: WORKSPACE)"),
|
|
222
|
+
scopeId: zod.z.string().optional().describe("Scope ID (defaults to current workspace ID when scope is WORKSPACE)"),
|
|
223
|
+
lockAfterMinutes: zod.z.number().optional().describe("Auto-lock after N minutes of inactivity")
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
async ({ name, description, scope, scopeId, lockAfterMinutes }) => {
|
|
227
|
+
try {
|
|
228
|
+
const workspaceCtx = readWorkspaceContext(ctx);
|
|
229
|
+
if (!workspaceCtx) {
|
|
230
|
+
return errorResult(
|
|
231
|
+
"No active workspace. Bind a workspace via the auth login flow first."
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
const resolvedScope = scope ?? "WORKSPACE";
|
|
235
|
+
const input = {
|
|
236
|
+
context: workspaceCtx,
|
|
237
|
+
name,
|
|
238
|
+
scope: resolvedScope,
|
|
239
|
+
scopeId: scopeId ?? workspaceCtx.workspaceId
|
|
240
|
+
};
|
|
241
|
+
if (description !== void 0) input.description = description;
|
|
242
|
+
if (lockAfterMinutes !== void 0) input.lockAfterMinutes = lockAfterMinutes;
|
|
243
|
+
const data = await ctx.gql.workspace.request(CREATE_VAULT, {
|
|
244
|
+
input
|
|
245
|
+
});
|
|
246
|
+
return jsonResult(data.createVault);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
ctx.logger.error("security_vaults_create failed", { error });
|
|
249
|
+
return errorResult(
|
|
250
|
+
`Failed to create vault: ${error instanceof Error ? error.message : String(error)}`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
server.registerTool(
|
|
256
|
+
track(mcpToolName(ctx.productName, "security_vaults_delete")),
|
|
257
|
+
{
|
|
258
|
+
title: "Delete Vault",
|
|
259
|
+
description: "Delete a vault. Set archive=true to soft-archive instead of permanently deleting.",
|
|
260
|
+
inputSchema: {
|
|
261
|
+
id: zod.z.string().describe("Vault ID"),
|
|
262
|
+
archive: zod.z.boolean().optional().describe("Archive instead of hard delete")
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
async ({ id, archive }) => {
|
|
266
|
+
try {
|
|
267
|
+
if (archive === true) {
|
|
268
|
+
const data2 = await ctx.gql.workspace.request(ARCHIVE_VAULT, { id });
|
|
269
|
+
return jsonResult({ archived: true, vault: data2.archiveVault });
|
|
270
|
+
}
|
|
271
|
+
const data = await ctx.gql.workspace.request(DELETE_VAULT, {
|
|
272
|
+
id
|
|
273
|
+
});
|
|
274
|
+
return jsonResult({ deleted: data.deleteVault, vaultId: id });
|
|
275
|
+
} catch (error) {
|
|
276
|
+
ctx.logger.error("security_vaults_delete failed", { error });
|
|
277
|
+
return errorResult(
|
|
278
|
+
`Failed to delete vault: ${error instanceof Error ? error.message : String(error)}`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
server.registerTool(
|
|
284
|
+
track(mcpToolName(ctx.productName, "security_secrets_list")),
|
|
285
|
+
{
|
|
286
|
+
title: "List Secrets",
|
|
287
|
+
description: "List secrets in a vault with optional filters and pagination.",
|
|
288
|
+
inputSchema: {
|
|
289
|
+
vaultId: zod.z.string().describe("Vault ID"),
|
|
290
|
+
type: SecretTypeEnum.optional().describe("Filter by secret type"),
|
|
291
|
+
search: zod.z.string().optional().describe("Free-text search"),
|
|
292
|
+
limit: zod.z.number().optional().describe("Page size (default 100)"),
|
|
293
|
+
offset: zod.z.number().optional().describe("Skip results")
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
async ({ vaultId, type, search, limit, offset }) => {
|
|
297
|
+
try {
|
|
298
|
+
const workspaceCtx = readWorkspaceContext(ctx);
|
|
299
|
+
if (!workspaceCtx) {
|
|
300
|
+
return errorResult(
|
|
301
|
+
"No active workspace. Bind a workspace via the auth login flow first."
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
const filter = { context: workspaceCtx };
|
|
305
|
+
if (type !== void 0) filter.type = type;
|
|
306
|
+
if (search !== void 0) filter.search = search;
|
|
307
|
+
const pagination = {};
|
|
308
|
+
if (limit !== void 0) pagination.limit = limit;
|
|
309
|
+
if (offset !== void 0) pagination.offset = offset;
|
|
310
|
+
const data = await ctx.gql.workspace.request(GET_SECRETS, {
|
|
311
|
+
vaultId,
|
|
312
|
+
filter,
|
|
313
|
+
pagination: Object.keys(pagination).length > 0 ? pagination : void 0
|
|
314
|
+
});
|
|
315
|
+
return jsonResult(data.getSecrets);
|
|
316
|
+
} catch (error) {
|
|
317
|
+
ctx.logger.error("security_secrets_list failed", { error });
|
|
318
|
+
return errorResult(
|
|
319
|
+
`Failed to list secrets: ${error instanceof Error ? error.message : String(error)}`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
server.registerTool(
|
|
325
|
+
track(mcpToolName(ctx.productName, "security_secrets_get")),
|
|
326
|
+
{
|
|
327
|
+
title: "Get Secret Metadata",
|
|
328
|
+
description: "Get a secret's metadata. Does NOT decrypt the value \u2014 use security_secrets_reveal for that.",
|
|
329
|
+
inputSchema: {
|
|
330
|
+
id: zod.z.string().describe("Secret ID")
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
async ({ id }) => {
|
|
334
|
+
try {
|
|
335
|
+
const data = await ctx.gql.workspace.request(GET_SECRET, {
|
|
336
|
+
id
|
|
337
|
+
});
|
|
338
|
+
if (!data.getSecret) {
|
|
339
|
+
return errorResult(`Secret ${id} not found`);
|
|
340
|
+
}
|
|
341
|
+
return jsonResult(data.getSecret);
|
|
342
|
+
} catch (error) {
|
|
343
|
+
ctx.logger.error("security_secrets_get failed", { error });
|
|
344
|
+
return errorResult(
|
|
345
|
+
`Failed to get secret: ${error instanceof Error ? error.message : String(error)}`
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
server.registerTool(
|
|
351
|
+
track(mcpToolName(ctx.productName, "security_secrets_reveal")),
|
|
352
|
+
{
|
|
353
|
+
title: "Reveal Secret Value",
|
|
354
|
+
description: "Decrypt and return the secret value. This action is audited server-side. Treat the result as sensitive and avoid persisting it.",
|
|
355
|
+
inputSchema: {
|
|
356
|
+
id: zod.z.string().describe("Secret ID")
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
async ({ id }) => {
|
|
360
|
+
try {
|
|
361
|
+
const data = await ctx.gql.workspace.request(DECRYPT_SECRET, { id });
|
|
362
|
+
return jsonResult(data.decryptSecret);
|
|
363
|
+
} catch (error) {
|
|
364
|
+
ctx.logger.error("security_secrets_reveal failed", { error });
|
|
365
|
+
return errorResult(
|
|
366
|
+
`Failed to reveal secret: ${error instanceof Error ? error.message : String(error)}`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
server.registerTool(
|
|
372
|
+
track(mcpToolName(ctx.productName, "security_secrets_set")),
|
|
373
|
+
{
|
|
374
|
+
title: "Create Secret",
|
|
375
|
+
description: "Create a new secret in a vault. The value is encrypted server-side.",
|
|
376
|
+
inputSchema: {
|
|
377
|
+
vaultId: zod.z.string().describe("Vault ID"),
|
|
378
|
+
key: zod.z.string().describe("Secret key (unique within the vault)"),
|
|
379
|
+
name: zod.z.string().describe("Human-readable secret name"),
|
|
380
|
+
value: zod.z.string().describe("Secret value (will be encrypted server-side)"),
|
|
381
|
+
description: zod.z.string().optional().describe("Secret description"),
|
|
382
|
+
type: SecretTypeEnum.optional().describe("Secret type (default: OTHER)"),
|
|
383
|
+
isEphemeral: zod.z.boolean().optional().describe("Mark as ephemeral"),
|
|
384
|
+
expiresAt: zod.z.string().optional().describe("Expiry timestamp in ISO 8601")
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
async ({ vaultId, key, name, value, description, type, isEphemeral, expiresAt }) => {
|
|
388
|
+
try {
|
|
389
|
+
const workspaceCtx = readWorkspaceContext(ctx);
|
|
390
|
+
if (!workspaceCtx) {
|
|
391
|
+
return errorResult(
|
|
392
|
+
"No active workspace. Bind a workspace via the auth login flow first."
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
const input = {
|
|
396
|
+
context: workspaceCtx,
|
|
397
|
+
vaultId,
|
|
398
|
+
key,
|
|
399
|
+
name,
|
|
400
|
+
value,
|
|
401
|
+
type: type ?? "OTHER",
|
|
402
|
+
isEphemeral: isEphemeral === true
|
|
403
|
+
};
|
|
404
|
+
if (description !== void 0) input.description = description;
|
|
405
|
+
if (expiresAt !== void 0) input.expiresAt = expiresAt;
|
|
406
|
+
const data = await ctx.gql.workspace.request(CREATE_SECRET, {
|
|
407
|
+
input
|
|
408
|
+
});
|
|
409
|
+
return jsonResult(data.createSecret);
|
|
410
|
+
} catch (error) {
|
|
411
|
+
ctx.logger.error("security_secrets_set failed", { error });
|
|
412
|
+
return errorResult(
|
|
413
|
+
`Failed to create secret: ${error instanceof Error ? error.message : String(error)}`
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
);
|
|
418
|
+
server.registerTool(
|
|
419
|
+
track(mcpToolName(ctx.productName, "security_secrets_update")),
|
|
420
|
+
{
|
|
421
|
+
title: "Update Secret Metadata",
|
|
422
|
+
description: "Update secret metadata (name, description, status). To rotate the value, use security_secrets_rotate.",
|
|
423
|
+
inputSchema: {
|
|
424
|
+
id: zod.z.string().describe("Secret ID"),
|
|
425
|
+
name: zod.z.string().optional().describe("Updated name"),
|
|
426
|
+
description: zod.z.string().optional().describe("Updated description"),
|
|
427
|
+
status: SecretStatusEnum.optional().describe("Updated status")
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
async ({ id, name, description, status }) => {
|
|
431
|
+
try {
|
|
432
|
+
const workspaceCtx = readWorkspaceContext(ctx);
|
|
433
|
+
if (!workspaceCtx) {
|
|
434
|
+
return errorResult(
|
|
435
|
+
"No active workspace. Bind a workspace via the auth login flow first."
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
const input = { context: workspaceCtx };
|
|
439
|
+
if (name !== void 0) input.name = name;
|
|
440
|
+
if (description !== void 0) input.description = description;
|
|
441
|
+
if (status !== void 0) input.status = status;
|
|
442
|
+
if (Object.keys(input).length === 1) {
|
|
443
|
+
return errorResult("No updates specified");
|
|
444
|
+
}
|
|
445
|
+
const data = await ctx.gql.workspace.request(UPDATE_SECRET, {
|
|
446
|
+
id,
|
|
447
|
+
input
|
|
448
|
+
});
|
|
449
|
+
return jsonResult(data.updateSecret);
|
|
450
|
+
} catch (error) {
|
|
451
|
+
ctx.logger.error("security_secrets_update failed", { error });
|
|
452
|
+
return errorResult(
|
|
453
|
+
`Failed to update secret: ${error instanceof Error ? error.message : String(error)}`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
server.registerTool(
|
|
459
|
+
track(mcpToolName(ctx.productName, "security_secrets_rotate")),
|
|
460
|
+
{
|
|
461
|
+
title: "Rotate Secret Value",
|
|
462
|
+
description: "Replace a secret's encrypted value with a new one.",
|
|
463
|
+
inputSchema: {
|
|
464
|
+
id: zod.z.string().describe("Secret ID"),
|
|
465
|
+
newValue: zod.z.string().describe("New secret value")
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
async ({ id, newValue }) => {
|
|
469
|
+
try {
|
|
470
|
+
const data = await ctx.gql.workspace.request(ROTATE_SECRET, {
|
|
471
|
+
id,
|
|
472
|
+
newValue
|
|
473
|
+
});
|
|
474
|
+
return jsonResult(data.rotateSecret);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
ctx.logger.error("security_secrets_rotate failed", { error });
|
|
477
|
+
return errorResult(
|
|
478
|
+
`Failed to rotate secret: ${error instanceof Error ? error.message : String(error)}`
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
server.registerTool(
|
|
484
|
+
track(mcpToolName(ctx.productName, "security_secrets_delete")),
|
|
485
|
+
{
|
|
486
|
+
title: "Delete Secret",
|
|
487
|
+
description: "Delete a secret by ID.",
|
|
488
|
+
inputSchema: {
|
|
489
|
+
id: zod.z.string().describe("Secret ID")
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
async ({ id }) => {
|
|
493
|
+
try {
|
|
494
|
+
const data = await ctx.gql.workspace.request(DELETE_SECRET, {
|
|
495
|
+
id
|
|
496
|
+
});
|
|
497
|
+
return jsonResult({ deleted: data.deleteSecret, secretId: id });
|
|
498
|
+
} catch (error) {
|
|
499
|
+
ctx.logger.error("security_secrets_delete failed", { error });
|
|
500
|
+
return errorResult(
|
|
501
|
+
`Failed to delete secret: ${error instanceof Error ? error.message : String(error)}`
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/modules/security/index.ts
|
|
509
|
+
var securityModule = {
|
|
510
|
+
id: "security",
|
|
511
|
+
version: "0.0.1",
|
|
512
|
+
displayName: "Security",
|
|
513
|
+
dependsOn: ["auth"],
|
|
514
|
+
capabilities: { tools: {} },
|
|
515
|
+
register(server, ctx) {
|
|
516
|
+
const tools = [];
|
|
517
|
+
const track = (n) => {
|
|
518
|
+
tools.push(n);
|
|
519
|
+
return n;
|
|
520
|
+
};
|
|
521
|
+
registerSecurityTools(server, ctx, track);
|
|
522
|
+
return { tools, resources: [], prompts: [] };
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
var security_default = securityModule;
|
|
526
|
+
|
|
527
|
+
module.exports = security_default;
|
|
528
|
+
//# sourceMappingURL=index.cjs.map
|
|
529
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/security/operations.ts","../../../src/modules/security/tools.ts","../../../src/modules/security/index.ts"],"names":["z","data"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ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EAAE;AAAA,EAE1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,qBAAA,CAAsB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAExC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,gBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const GET_VAULTS = `\n query GetVaults($filter: VaultFilterInput, $pagination: SecurityPaginationInput) {\n getVaults(filter: $filter, pagination: $pagination) {\n items { id name description scope status createdAt }\n total hasMore\n }\n }\n`;\n\nexport const GET_VAULT = `\n query GetVault($id: ID!) {\n getVault(id: $id) {\n id name description scope scopeId status lockAfterMinutes createdAt updatedAt\n }\n }\n`;\n\nexport const CREATE_VAULT = `\n mutation CreateVault($input: CreateVaultInput!) {\n createVault(input: $input) {\n id name scope scopeId status\n }\n }\n`;\n\nexport const DELETE_VAULT = `\n mutation DeleteVault($id: ID!) {\n deleteVault(id: $id)\n }\n`;\n\nexport const ARCHIVE_VAULT = `\n mutation ArchiveVault($id: ID!) {\n archiveVault(id: $id) { id status }\n }\n`;\n\nexport const GET_SECRETS = `\n query GetSecrets($vaultId: ID!, $filter: SecretFilterInput, $pagination: SecurityPaginationInput) {\n getSecrets(vaultId: $vaultId, filter: $filter, pagination: $pagination) {\n items { id key name description type status isEphemeral createdAt }\n total hasMore\n }\n }\n`;\n\nexport const GET_SECRET = `\n query GetSecret($id: ID!) {\n getSecret(id: $id) {\n id key name description type status isEphemeral expiresAt createdAt updatedAt\n }\n }\n`;\n\nexport const DECRYPT_SECRET = `\n query DecryptSecret($id: ID!) {\n decryptSecret(id: $id) {\n id key value\n }\n }\n`;\n\nexport const CREATE_SECRET = `\n mutation CreateSecret($input: CreateSecretInput!) {\n createSecret(input: $input) {\n id key name type status\n }\n }\n`;\n\nexport const UPDATE_SECRET = `\n mutation UpdateSecret($id: ID!, $input: UpdateSecretInput!) {\n updateSecret(id: $id, input: $input) {\n id key name status updatedAt\n }\n }\n`;\n\nexport const DELETE_SECRET = `\n mutation DeleteSecret($id: ID!) {\n deleteSecret(id: $id)\n }\n`;\n\nexport const ROTATE_SECRET = `\n mutation RotateSecret($id: ID!, $newValue: String!) {\n rotateSecret(id: $id, newValue: $newValue) {\n id key updatedAt\n }\n }\n`;\n","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport {\n GET_VAULTS,\n GET_VAULT,\n CREATE_VAULT,\n DELETE_VAULT,\n ARCHIVE_VAULT,\n GET_SECRETS,\n GET_SECRET,\n DECRYPT_SECRET,\n CREATE_SECRET,\n UPDATE_SECRET,\n DELETE_SECRET,\n ROTATE_SECRET,\n} from './operations.js';\n\nconst VaultScopeEnum = z.enum(['WORKSPACE', 'GLOBAL', 'VIBE']);\nconst VaultStatusEnum = z.enum(['ACTIVE', 'LOCKED', 'ARCHIVED']);\nconst SecretTypeEnum = z.enum(['API_KEY', 'PASSWORD', 'CERTIFICATE', 'TOKEN', 'OTHER']);\nconst SecretStatusEnum = z.enum(['ACTIVE', 'EXPIRED', 'REVOKED']);\n\ninterface VaultRow {\n id: string;\n name: string;\n description?: string | null;\n scope?: string;\n scopeId?: string;\n status?: string;\n createdAt?: string;\n updatedAt?: string;\n lockAfterMinutes?: number;\n}\n\ninterface SecretRow {\n id: string;\n key: string;\n name: string;\n description?: string | null;\n type?: string;\n status?: string;\n isEphemeral?: boolean;\n expiresAt?: string;\n createdAt?: string;\n updatedAt?: string;\n}\n\nfunction readWorkspaceContext(ctx: McpContext): { workspaceId: string } | null {\n const auth = ctx.auth.read();\n if (!auth?.workspaceId) return null;\n return { workspaceId: auth.workspaceId };\n}\n\nexport function registerSecurityTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Vaults ─────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_vaults_list')),\n {\n title: 'List Vaults',\n description: 'List vaults in the current workspace with optional filters and pagination.',\n inputSchema: {\n scope: VaultScopeEnum.optional().describe('Filter by vault scope'),\n status: VaultStatusEnum.optional().describe('Filter by status'),\n search: z.string().optional().describe('Free-text search'),\n limit: z.number().optional().describe('Page size (default 50)'),\n offset: z.number().optional().describe('Skip results'),\n },\n },\n async ({ scope, status, search, limit, offset }) => {\n try {\n const workspaceCtx = readWorkspaceContext(ctx);\n if (!workspaceCtx) {\n return errorResult(\n 'No active workspace. Bind a workspace via the auth login flow first.',\n );\n }\n const filter: Record<string, unknown> = { context: workspaceCtx };\n if (scope !== undefined) filter.scope = scope;\n if (status !== undefined) filter.status = status;\n if (search !== undefined) filter.search = search;\n\n const pagination: Record<string, unknown> = {};\n if (limit !== undefined) pagination.limit = limit;\n if (offset !== undefined) pagination.offset = offset;\n\n const data = await ctx.gql.workspace.request<{\n getVaults: { items: VaultRow[]; total: number; hasMore: boolean };\n }>(GET_VAULTS, {\n filter,\n pagination: Object.keys(pagination).length > 0 ? pagination : undefined,\n });\n return jsonResult(data.getVaults);\n } catch (error) {\n ctx.logger.error('security_vaults_list failed', { error });\n return errorResult(\n `Failed to list vaults: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_vaults_get')),\n {\n title: 'Get Vault',\n description: 'Get a vault by ID.',\n inputSchema: {\n id: z.string().describe('Vault ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getVault: VaultRow | null }>(GET_VAULT, {\n id,\n });\n if (!data.getVault) {\n return errorResult(`Vault ${id} not found`);\n }\n return jsonResult(data.getVault);\n } catch (error) {\n ctx.logger.error('security_vaults_get failed', { error });\n return errorResult(\n `Failed to get vault: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_vaults_create')),\n {\n title: 'Create Vault',\n description: 'Create a new vault scoped to the current workspace.',\n inputSchema: {\n name: z.string().describe('Vault name'),\n description: z.string().optional().describe('Vault description'),\n scope: VaultScopeEnum.optional().describe('Vault scope (default: WORKSPACE)'),\n scopeId: z\n .string()\n .optional()\n .describe('Scope ID (defaults to current workspace ID when scope is WORKSPACE)'),\n lockAfterMinutes: z.number().optional().describe('Auto-lock after N minutes of inactivity'),\n },\n },\n async ({ name, description, scope, scopeId, lockAfterMinutes }) => {\n try {\n const workspaceCtx = readWorkspaceContext(ctx);\n if (!workspaceCtx) {\n return errorResult(\n 'No active workspace. Bind a workspace via the auth login flow first.',\n );\n }\n const resolvedScope = scope ?? 'WORKSPACE';\n const input: Record<string, unknown> = {\n context: workspaceCtx,\n name,\n scope: resolvedScope,\n scopeId: scopeId ?? workspaceCtx.workspaceId,\n };\n if (description !== undefined) input.description = description;\n if (lockAfterMinutes !== undefined) input.lockAfterMinutes = lockAfterMinutes;\n\n const data = await ctx.gql.workspace.request<{ createVault: VaultRow }>(CREATE_VAULT, {\n input,\n });\n return jsonResult(data.createVault);\n } catch (error) {\n ctx.logger.error('security_vaults_create failed', { error });\n return errorResult(\n `Failed to create vault: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_vaults_delete')),\n {\n title: 'Delete Vault',\n description:\n 'Delete a vault. Set archive=true to soft-archive instead of permanently deleting.',\n inputSchema: {\n id: z.string().describe('Vault ID'),\n archive: z.boolean().optional().describe('Archive instead of hard delete'),\n },\n },\n async ({ id, archive }) => {\n try {\n if (archive === true) {\n const data = await ctx.gql.workspace.request<{\n archiveVault: { id: string; status: string };\n }>(ARCHIVE_VAULT, { id });\n return jsonResult({ archived: true, vault: data.archiveVault });\n }\n const data = await ctx.gql.workspace.request<{ deleteVault: boolean }>(DELETE_VAULT, {\n id,\n });\n return jsonResult({ deleted: data.deleteVault, vaultId: id });\n } catch (error) {\n ctx.logger.error('security_vaults_delete failed', { error });\n return errorResult(\n `Failed to delete vault: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Secrets ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_secrets_list')),\n {\n title: 'List Secrets',\n description: 'List secrets in a vault with optional filters and pagination.',\n inputSchema: {\n vaultId: z.string().describe('Vault ID'),\n type: SecretTypeEnum.optional().describe('Filter by secret type'),\n search: z.string().optional().describe('Free-text search'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Skip results'),\n },\n },\n async ({ vaultId, type, search, limit, offset }) => {\n try {\n const workspaceCtx = readWorkspaceContext(ctx);\n if (!workspaceCtx) {\n return errorResult(\n 'No active workspace. Bind a workspace via the auth login flow first.',\n );\n }\n const filter: Record<string, unknown> = { context: workspaceCtx };\n if (type !== undefined) filter.type = type;\n if (search !== undefined) filter.search = search;\n\n const pagination: Record<string, unknown> = {};\n if (limit !== undefined) pagination.limit = limit;\n if (offset !== undefined) pagination.offset = offset;\n\n const data = await ctx.gql.workspace.request<{\n getSecrets: { items: SecretRow[]; total: number; hasMore: boolean };\n }>(GET_SECRETS, {\n vaultId,\n filter,\n pagination: Object.keys(pagination).length > 0 ? pagination : undefined,\n });\n return jsonResult(data.getSecrets);\n } catch (error) {\n ctx.logger.error('security_secrets_list failed', { error });\n return errorResult(\n `Failed to list secrets: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_secrets_get')),\n {\n title: 'Get Secret Metadata',\n description:\n \"Get a secret's metadata. Does NOT decrypt the value — use security_secrets_reveal for that.\",\n inputSchema: {\n id: z.string().describe('Secret ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getSecret: SecretRow | null }>(GET_SECRET, {\n id,\n });\n if (!data.getSecret) {\n return errorResult(`Secret ${id} not found`);\n }\n return jsonResult(data.getSecret);\n } catch (error) {\n ctx.logger.error('security_secrets_get failed', { error });\n return errorResult(\n `Failed to get secret: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_secrets_reveal')),\n {\n title: 'Reveal Secret Value',\n description:\n 'Decrypt and return the secret value. This action is audited server-side. Treat the result as sensitive and avoid persisting it.',\n inputSchema: {\n id: z.string().describe('Secret ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n decryptSecret: { id: string; key: string; value: string };\n }>(DECRYPT_SECRET, { id });\n return jsonResult(data.decryptSecret);\n } catch (error) {\n ctx.logger.error('security_secrets_reveal failed', { error });\n return errorResult(\n `Failed to reveal secret: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_secrets_set')),\n {\n title: 'Create Secret',\n description: 'Create a new secret in a vault. The value is encrypted server-side.',\n inputSchema: {\n vaultId: z.string().describe('Vault ID'),\n key: z.string().describe('Secret key (unique within the vault)'),\n name: z.string().describe('Human-readable secret name'),\n value: z.string().describe('Secret value (will be encrypted server-side)'),\n description: z.string().optional().describe('Secret description'),\n type: SecretTypeEnum.optional().describe('Secret type (default: OTHER)'),\n isEphemeral: z.boolean().optional().describe('Mark as ephemeral'),\n expiresAt: z.string().optional().describe('Expiry timestamp in ISO 8601'),\n },\n },\n async ({ vaultId, key, name, value, description, type, isEphemeral, expiresAt }) => {\n try {\n const workspaceCtx = readWorkspaceContext(ctx);\n if (!workspaceCtx) {\n return errorResult(\n 'No active workspace. Bind a workspace via the auth login flow first.',\n );\n }\n const input: Record<string, unknown> = {\n context: workspaceCtx,\n vaultId,\n key,\n name,\n value,\n type: type ?? 'OTHER',\n isEphemeral: isEphemeral === true,\n };\n if (description !== undefined) input.description = description;\n if (expiresAt !== undefined) input.expiresAt = expiresAt;\n\n const data = await ctx.gql.workspace.request<{ createSecret: SecretRow }>(CREATE_SECRET, {\n input,\n });\n return jsonResult(data.createSecret);\n } catch (error) {\n ctx.logger.error('security_secrets_set failed', { error });\n return errorResult(\n `Failed to create secret: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_secrets_update')),\n {\n title: 'Update Secret Metadata',\n description:\n 'Update secret metadata (name, description, status). To rotate the value, use security_secrets_rotate.',\n inputSchema: {\n id: z.string().describe('Secret ID'),\n name: z.string().optional().describe('Updated name'),\n description: z.string().optional().describe('Updated description'),\n status: SecretStatusEnum.optional().describe('Updated status'),\n },\n },\n async ({ id, name, description, status }) => {\n try {\n const workspaceCtx = readWorkspaceContext(ctx);\n if (!workspaceCtx) {\n return errorResult(\n 'No active workspace. Bind a workspace via the auth login flow first.',\n );\n }\n const input: Record<string, unknown> = { context: workspaceCtx };\n if (name !== undefined) input.name = name;\n if (description !== undefined) input.description = description;\n if (status !== undefined) input.status = status;\n if (Object.keys(input).length === 1) {\n return errorResult('No updates specified');\n }\n const data = await ctx.gql.workspace.request<{ updateSecret: SecretRow }>(UPDATE_SECRET, {\n id,\n input,\n });\n return jsonResult(data.updateSecret);\n } catch (error) {\n ctx.logger.error('security_secrets_update failed', { error });\n return errorResult(\n `Failed to update secret: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_secrets_rotate')),\n {\n title: 'Rotate Secret Value',\n description: \"Replace a secret's encrypted value with a new one.\",\n inputSchema: {\n id: z.string().describe('Secret ID'),\n newValue: z.string().describe('New secret value'),\n },\n },\n async ({ id, newValue }) => {\n try {\n const data = await ctx.gql.workspace.request<{ rotateSecret: SecretRow }>(ROTATE_SECRET, {\n id,\n newValue,\n });\n return jsonResult(data.rotateSecret);\n } catch (error) {\n ctx.logger.error('security_secrets_rotate failed', { error });\n return errorResult(\n `Failed to rotate secret: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'security_secrets_delete')),\n {\n title: 'Delete Secret',\n description: 'Delete a secret by ID.',\n inputSchema: {\n id: z.string().describe('Secret ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteSecret: boolean }>(DELETE_SECRET, {\n id,\n });\n return jsonResult({ deleted: data.deleteSecret, secretId: id });\n } catch (error) {\n ctx.logger.error('security_secrets_delete failed', { error });\n return errorResult(\n `Failed to delete secret: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Security module — workspace vaults & secrets\n * (<product>_security_vaults_{list,get,create,delete},\n * <product>_security_secrets_{list,get,reveal,set,update,rotate,delete}).\n *\n * Backend: ~/products/wspace/security/wspace-security-svc/.\n * Ported from cli-sdk/src/modules/security/. The CLI reads secret values from\n * stdin; in MCP they come in as the `value` / `newValue` tool arguments.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerSecurityTools } from './tools.js';\n\nconst securityModule: McpModule = {\n id: 'security',\n version: '0.0.1',\n displayName: 'Security',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerSecurityTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default securityModule;\n"]}
|