@burdenoff/mcp-libs 2026.1031.2 → 2026.1101.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/dist/{chunk-FVLIANOQ.js → chunk-LUXDBCVJ.js} +3 -3
- package/dist/{chunk-FVLIANOQ.js.map → chunk-LUXDBCVJ.js.map} +1 -1
- package/dist/{chunk-76RGHRRS.js → chunk-WYCRYHHY.js} +83 -33
- package/dist/chunk-WYCRYHHY.js.map +1 -0
- package/dist/core/auth/store.d.ts +1 -0
- package/dist/core/gql/client.d.ts +6 -0
- package/dist/core/index.cjs +83 -30
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +80 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/adaptercloud/index.js +1 -1
- package/dist/modules/artistrybase/index.js +1 -1
- package/dist/modules/assethandler/index.js +1 -1
- package/dist/modules/atheletebridge/index.js +1 -1
- package/dist/modules/auth/index.cjs +1 -1
- package/dist/modules/auth/index.cjs.map +1 -1
- package/dist/modules/auth/index.js +4 -4
- package/dist/modules/auth/index.js.map +1 -1
- package/dist/modules/auth/operations.d.ts +2 -2
- package/dist/modules/billing/index.cjs +45 -19
- package/dist/modules/billing/index.cjs.map +1 -1
- package/dist/modules/billing/index.js +46 -20
- package/dist/modules/billing/index.js.map +1 -1
- package/dist/modules/billing/operations.d.ts +4 -4
- package/dist/modules/brainyrich/index.js +1 -1
- package/dist/modules/buildmyiq/index.js +1 -1
- package/dist/modules/channels/index.cjs +0 -35
- package/dist/modules/channels/index.cjs.map +1 -1
- package/dist/modules/channels/index.js +1 -36
- package/dist/modules/channels/index.js.map +1 -1
- package/dist/modules/channels/operations.d.ts +0 -1
- package/dist/modules/collabkin/index.js +1 -1
- package/dist/modules/comradecircle/index.js +1 -1
- package/dist/modules/conversations/index.cjs +6 -6
- package/dist/modules/conversations/index.cjs.map +1 -1
- package/dist/modules/conversations/index.js +7 -7
- package/dist/modules/conversations/index.js.map +1 -1
- package/dist/modules/conversations/operations.d.ts +1 -1
- package/dist/modules/coolandlovely/index.js +1 -1
- package/dist/modules/cosmicintersection/index.js +1 -1
- package/dist/modules/crewfoundry/index.js +1 -1
- package/dist/modules/devportal/index.js +1 -1
- package/dist/modules/ecoimpacthub/index.js +1 -1
- package/dist/modules/eventfullymanaged/index.js +1 -1
- package/dist/modules/export/index.js +1 -1
- package/dist/modules/files/index.cjs +421 -101
- package/dist/modules/files/index.cjs.map +1 -1
- package/dist/modules/files/index.js +412 -97
- package/dist/modules/files/index.js.map +1 -1
- package/dist/modules/files/operations.d.ts +9 -8
- package/dist/modules/files/tools.d.ts +2 -0
- package/dist/modules/fluidgrids/index.js +1 -1
- package/dist/modules/ggnomad/index.js +1 -1
- package/dist/modules/govcitizenhub/index.js +1 -1
- package/dist/modules/groups/index.js +1 -1
- package/dist/modules/headshotmarketing/index.js +1 -1
- package/dist/modules/health/index.js +1 -1
- package/dist/modules/healthybowl/index.js +1 -1
- package/dist/modules/hookmovies/index.js +1 -1
- package/dist/modules/housingvista/index.js +1 -1
- package/dist/modules/integrations/index.js +1 -1
- package/dist/modules/intelwatchtower/index.js +1 -1
- package/dist/modules/kadaikodi/index.js +1 -1
- package/dist/modules/labsofscience/index.js +1 -1
- package/dist/modules/manufacturedops/index.js +1 -1
- package/dist/modules/movethewheels/index.js +1 -1
- package/dist/modules/mybodyshield/index.js +1 -1
- package/dist/modules/notifications/index.js +1 -1
- package/dist/modules/organizations/index.js +1 -1
- package/dist/modules/planmagnet/index.js +1 -1
- package/dist/modules/products/index.cjs +1 -1
- package/dist/modules/products/index.cjs.map +1 -1
- package/dist/modules/products/index.js +2 -2
- package/dist/modules/products/index.js.map +1 -1
- package/dist/modules/products/operations.d.ts +1 -1
- package/dist/modules/proserviceworld/index.js +1 -1
- package/dist/modules/rbac/index.cjs +0 -64
- package/dist/modules/rbac/index.cjs.map +1 -1
- package/dist/modules/rbac/index.js +1 -65
- package/dist/modules/rbac/index.js.map +1 -1
- package/dist/modules/rbac/operations.d.ts +0 -2
- package/dist/modules/sandbox/index.js +1 -1
- package/dist/modules/scheduler/index.cjs +4 -4
- package/dist/modules/scheduler/index.cjs.map +1 -1
- package/dist/modules/scheduler/index.js +5 -5
- package/dist/modules/scheduler/index.js.map +1 -1
- package/dist/modules/scheduler/operations.d.ts +3 -3
- package/dist/modules/security/index.js +1 -1
- package/dist/modules/semanticfed/index.js +1 -1
- package/dist/modules/store/index.js +1 -1
- package/dist/modules/subscriberbot/index.js +1 -1
- package/dist/modules/support/index.js +1 -1
- package/dist/modules/tags/index.cjs +454 -48
- package/dist/modules/tags/index.cjs.map +1 -1
- package/dist/modules/tags/index.js +443 -42
- package/dist/modules/tags/index.js.map +1 -1
- package/dist/modules/tags/operations.d.ts +10 -6
- package/dist/modules/tags/tools.d.ts +1 -1
- package/dist/modules/technospam/index.js +1 -1
- package/dist/modules/theculturepost/index.js +1 -1
- package/dist/modules/theglobalfuel/index.js +1 -1
- package/dist/modules/timecampus/index.js +1 -1
- package/dist/modules/tours/index.js +1 -1
- package/dist/modules/vibecontrols/index.cjs +8 -8
- package/dist/modules/vibecontrols/index.cjs.map +1 -1
- package/dist/modules/vibecontrols/index.js +10 -10
- package/dist/modules/vibecontrols/index.js.map +1 -1
- package/dist/modules/workspaces/index.cjs +235 -5
- package/dist/modules/workspaces/index.cjs.map +1 -1
- package/dist/modules/workspaces/index.js +224 -6
- package/dist/modules/workspaces/index.js.map +1 -1
- package/dist/modules/workspaces/operations.d.ts +2 -2
- package/dist/modules/workspaces/prompts.d.ts +3 -0
- package/dist/modules/workspaces/resources.d.ts +4 -0
- package/package.json +1 -1
- package/dist/chunk-76RGHRRS.js.map +0 -1
|
@@ -36,6 +36,18 @@ function mcpToolName(productName, ...parts) {
|
|
|
36
36
|
const name = [productName, ...parts].filter(Boolean).join("_");
|
|
37
37
|
return assertSafeName(name);
|
|
38
38
|
}
|
|
39
|
+
function mcpResourceUri(productName, ...parts) {
|
|
40
|
+
if (!productName) {
|
|
41
|
+
throw new McpInternalError("mcpResourceUri: productName is required");
|
|
42
|
+
}
|
|
43
|
+
return `${productName}://${parts.filter(Boolean).join("/")}`;
|
|
44
|
+
}
|
|
45
|
+
function mcpPromptName(productName, ...parts) {
|
|
46
|
+
if (!productName) {
|
|
47
|
+
throw new McpInternalError("mcpPromptName: productName is required");
|
|
48
|
+
}
|
|
49
|
+
return [productName, ...parts].filter(Boolean).join("-");
|
|
50
|
+
}
|
|
39
51
|
|
|
40
52
|
// src/core/result.ts
|
|
41
53
|
function jsonResult(data, structured) {
|
|
@@ -55,7 +67,7 @@ Hint: ${hint}` : message;
|
|
|
55
67
|
var LIST_WORKSPACES = `
|
|
56
68
|
query Workspaces($filter: WorkspaceFilterInput, $pagination: PaginationInput) {
|
|
57
69
|
workspaces(filter: $filter, pagination: $pagination) {
|
|
58
|
-
items { id name
|
|
70
|
+
items { id name type status createdAt }
|
|
59
71
|
total
|
|
60
72
|
hasMore
|
|
61
73
|
}
|
|
@@ -146,7 +158,7 @@ var ACCEPT_INVITATION = `
|
|
|
146
158
|
var WORKSPACE_ACTIVITY = `
|
|
147
159
|
query WorkspaceActivity($workspaceId: ID!, $limit: Int, $offset: Int) {
|
|
148
160
|
getWorkspaceActivities(workspaceId: $workspaceId, limit: $limit, offset: $offset) {
|
|
149
|
-
id action
|
|
161
|
+
id action userId actorType description resourceType resourceId timestamp
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
164
|
`;
|
|
@@ -192,7 +204,7 @@ function registerWorkspaceTools(server, ctx, track) {
|
|
|
192
204
|
title: "List Workspaces",
|
|
193
205
|
description: "List workspaces visible to the current actor on the workspace gateway, with optional filters and pagination. Returns { items, total, hasMore }.",
|
|
194
206
|
inputSchema: {
|
|
195
|
-
search: zod.z.string().optional().describe("Free-text search across
|
|
207
|
+
search: zod.z.string().optional().describe("Free-text search across workspace names"),
|
|
196
208
|
status: zod.z.string().optional().describe("Filter by workspace status (will be uppercased; e.g. ACTIVE|ARCHIVED)"),
|
|
197
209
|
tenantId: zod.z.string().optional().describe("Filter by tenant ID"),
|
|
198
210
|
orgId: zod.z.string().optional().describe("Filter by organization ID"),
|
|
@@ -561,21 +573,239 @@ function registerWorkspaceTools(server, ctx, track) {
|
|
|
561
573
|
);
|
|
562
574
|
}
|
|
563
575
|
|
|
576
|
+
// src/modules/workspaces/resources.ts
|
|
577
|
+
function registerWorkspaceResources(server, ctx, track) {
|
|
578
|
+
const p = ctx.productName;
|
|
579
|
+
const guideUri = track(mcpResourceUri(p, "workspace", "guide"));
|
|
580
|
+
const currentUri = track(mcpResourceUri(p, "workspace", "current"));
|
|
581
|
+
server.registerResource(
|
|
582
|
+
`${p}-workspace-guide`,
|
|
583
|
+
guideUri,
|
|
584
|
+
{
|
|
585
|
+
title: "Workspace Guide",
|
|
586
|
+
description: "How a Burdenoff workspace is organised (members, projects, files, tags, conversations, activity) and which tools operate on each part.",
|
|
587
|
+
mimeType: "text/markdown"
|
|
588
|
+
},
|
|
589
|
+
async () => ({
|
|
590
|
+
contents: [{ uri: guideUri, mimeType: "text/markdown", text: workspaceGuide(p) }]
|
|
591
|
+
})
|
|
592
|
+
);
|
|
593
|
+
server.registerResource(
|
|
594
|
+
`${p}-workspace-current`,
|
|
595
|
+
currentUri,
|
|
596
|
+
{
|
|
597
|
+
title: "Current Workspace",
|
|
598
|
+
description: "The workspace this session is bound to (id, name, slug, status, organization). Empty until a workspace is selected.",
|
|
599
|
+
mimeType: "application/json"
|
|
600
|
+
},
|
|
601
|
+
async () => {
|
|
602
|
+
const auth = ctx.auth.read();
|
|
603
|
+
const workspaceId = auth?.workspaceId ?? null;
|
|
604
|
+
let body;
|
|
605
|
+
if (!workspaceId) {
|
|
606
|
+
body = {
|
|
607
|
+
workspaceId: null,
|
|
608
|
+
message: `No workspace selected. Call ${p}_auth_workspaces, then ${p}_auth_select_workspace.`
|
|
609
|
+
};
|
|
610
|
+
} else {
|
|
611
|
+
try {
|
|
612
|
+
const data = await ctx.gql.global.request(
|
|
613
|
+
GET_WORKSPACE,
|
|
614
|
+
{ id: workspaceId }
|
|
615
|
+
);
|
|
616
|
+
body = {
|
|
617
|
+
workspaceId,
|
|
618
|
+
organizationId: auth?.organizationId ?? null,
|
|
619
|
+
workspace: data.workspace
|
|
620
|
+
};
|
|
621
|
+
} catch (error) {
|
|
622
|
+
body = {
|
|
623
|
+
workspaceId,
|
|
624
|
+
organizationId: auth?.organizationId ?? null,
|
|
625
|
+
error: error instanceof Error ? error.message : String(error)
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
contents: [
|
|
631
|
+
{ uri: currentUri, mimeType: "application/json", text: JSON.stringify(body, null, 2) }
|
|
632
|
+
]
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
function workspaceGuide(p) {
|
|
638
|
+
return `# Burdenoff Workspaces
|
|
639
|
+
|
|
640
|
+
A workspace is the unit of collaboration and data isolation. Everything below
|
|
641
|
+
belongs to exactly one workspace, and every tool acts on the workspace bound to
|
|
642
|
+
this session.
|
|
643
|
+
|
|
644
|
+
## 1. Sign in and pick a workspace
|
|
645
|
+
- ${p}_auth_login / ${p}_auth_complete (device code) or ${p}_auth_sign_in
|
|
646
|
+
- ${p}_auth_workspaces lists the workspaces you belong to
|
|
647
|
+
- ${p}_auth_select_workspace binds one; ${p}_workspace_current shows the binding
|
|
648
|
+
|
|
649
|
+
## 2. People and structure
|
|
650
|
+
- Workspaces: ${p}_workspace_list, ${p}_workspace_get, ${p}_workspace_create, ${p}_workspace_update
|
|
651
|
+
- Members: ${p}_workspace_members_list, ${p}_workspace_members_add, ${p}_workspace_members_role, ${p}_workspace_members_remove
|
|
652
|
+
- Projects: ${p}_workspace_projects_list, ${p}_workspace_projects_get, ${p}_workspace_projects_create
|
|
653
|
+
- Groups and teams: ${p}_groups_*
|
|
654
|
+
- Audit trail: ${p}_workspace_activity
|
|
655
|
+
|
|
656
|
+
## 3. Content
|
|
657
|
+
- Files: ${p}_files_browse, ${p}_files_list, ${p}_files_get, ${p}_files_download,
|
|
658
|
+
uploads via ${p}_files_upload_initiate then ${p}_files_upload_complete,
|
|
659
|
+
sharing via ${p}_files_share / ${p}_files_share_revoke
|
|
660
|
+
- Tags: ${p}_tags_vocabularies_list, ${p}_tags_list, ${p}_tags_create,
|
|
661
|
+
${p}_tags_assign (tag a file, folder or project), ${p}_tags_entity_list
|
|
662
|
+
- Conversations: ${p}_conversations_list, ${p}_conversations_search,
|
|
663
|
+
${p}_conversations_messages_list, ${p}_conversations_messages_send,
|
|
664
|
+
${p}_conversations_get_or_create_direct
|
|
665
|
+
- Notifications: ${p}_notifications_*
|
|
666
|
+
|
|
667
|
+
## 4. Automation and integrations
|
|
668
|
+
- Scheduled jobs: ${p}_scheduler_*
|
|
669
|
+
- Integrations and channels: ${p}_integrations_*, ${p}_channels_*
|
|
670
|
+
- Exports: ${p}_export_*
|
|
671
|
+
|
|
672
|
+
## Rules
|
|
673
|
+
- Access is enforced by the gateway with your own identity: a tool can only
|
|
674
|
+
see or change what you can in the app.
|
|
675
|
+
- Destructive tools (delete, remove, revoke, ...) change data for good. Ask
|
|
676
|
+
the user first; servers that enforce confirmation (workspaces-mcp does)
|
|
677
|
+
refuse them unless the call passes confirm: true.
|
|
678
|
+
- Lists are paginated with limit/offset; check hasMore before assuming you
|
|
679
|
+
have everything.
|
|
680
|
+
`;
|
|
681
|
+
}
|
|
682
|
+
function registerWorkspacePrompts(server, ctx, track) {
|
|
683
|
+
const p = ctx.productName;
|
|
684
|
+
const orientName = track(mcpPromptName(p, "workspace-orient"));
|
|
685
|
+
const findFileName = track(mcpPromptName(p, "workspace-find-file"));
|
|
686
|
+
const digestName = track(mcpPromptName(p, "workspace-digest"));
|
|
687
|
+
server.registerPrompt(
|
|
688
|
+
orientName,
|
|
689
|
+
{
|
|
690
|
+
title: "Get Oriented in a Workspace",
|
|
691
|
+
description: "Pick the right workspace and summarise who is in it, which projects exist and what happened recently.",
|
|
692
|
+
argsSchema: {
|
|
693
|
+
workspaceName: zod.z.string().optional().describe("Name of the workspace to open")
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
({ workspaceName }) => {
|
|
697
|
+
const pick = workspaceName ? `Pick the workspace named "${workspaceName}" (ask me if several match).` : "Show me the list and ask which one to open.";
|
|
698
|
+
return {
|
|
699
|
+
messages: [
|
|
700
|
+
{
|
|
701
|
+
role: "user",
|
|
702
|
+
content: {
|
|
703
|
+
type: "text",
|
|
704
|
+
text: `Help me get oriented in a Burdenoff workspace.
|
|
705
|
+
|
|
706
|
+
1. Call ${p}_auth_status. If I am not signed in, start ${p}_auth_login and wait for me to finish.
|
|
707
|
+
2. Call ${p}_auth_workspaces. ${pick} Bind it with ${p}_auth_select_workspace.
|
|
708
|
+
3. Read the ${p}://workspace/guide resource for the tool map.
|
|
709
|
+
4. Summarise the workspace: ${p}_workspace_members_list (who and which roles), ${p}_workspace_projects_list (projects and status), ${p}_files_browse (top-level folders and files).
|
|
710
|
+
5. Call ${p}_workspace_activity for the latest events and list the five most important.
|
|
711
|
+
|
|
712
|
+
Keep the summary short and do not change anything.`
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
]
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
server.registerPrompt(
|
|
720
|
+
findFileName,
|
|
721
|
+
{
|
|
722
|
+
title: "Find and Share a File",
|
|
723
|
+
description: "Locate a file in the current workspace by name, type or tag, then optionally share it.",
|
|
724
|
+
argsSchema: {
|
|
725
|
+
query: zod.z.string().describe("What the file is called or about"),
|
|
726
|
+
shareWith: zod.z.string().optional().describe("Email address to share the file with")
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
({ query, shareWith }) => {
|
|
730
|
+
const share = shareWith ? `5. Ask me to confirm, then share it with ${shareWith} via ${p}_files_share (shareType EMAIL_INVITE, accessLevel VIEW unless I say otherwise).` : `5. Offer a download link via ${p}_files_download; do not create shares unless I ask.`;
|
|
731
|
+
return {
|
|
732
|
+
messages: [
|
|
733
|
+
{
|
|
734
|
+
role: "user",
|
|
735
|
+
content: {
|
|
736
|
+
type: "text",
|
|
737
|
+
text: `Find the file in my current workspace that matches: "${query}".
|
|
738
|
+
|
|
739
|
+
1. Use ${p}_files_browse from the root and walk into folders whose names fit.
|
|
740
|
+
2. Use ${p}_files_list with mimeTypes or extensions filters when the request implies a type.
|
|
741
|
+
3. If the workspace uses tags, check ${p}_tags_list for a matching tag and ${p}_tags_entity_list on candidates.
|
|
742
|
+
4. Show the best matches with name, folder, size and last update; confirm the right one with ${p}_files_get.
|
|
743
|
+
${share}`
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
]
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
);
|
|
750
|
+
server.registerPrompt(
|
|
751
|
+
digestName,
|
|
752
|
+
{
|
|
753
|
+
title: "Workspace Digest",
|
|
754
|
+
description: "Summarise recent activity, unread conversations and new files in the current workspace.",
|
|
755
|
+
argsSchema: {
|
|
756
|
+
days: zod.z.string().optional().describe("How many days back to cover (default 7)")
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
({ days }) => {
|
|
760
|
+
const span = days && /^\d+$/.test(days) ? days : "7";
|
|
761
|
+
return {
|
|
762
|
+
messages: [
|
|
763
|
+
{
|
|
764
|
+
role: "user",
|
|
765
|
+
content: {
|
|
766
|
+
type: "text",
|
|
767
|
+
text: `Write a digest of the last ${span} days in my current workspace.
|
|
768
|
+
|
|
769
|
+
1. ${p}_workspace_current to confirm which workspace is bound (ask me to pick one if none).
|
|
770
|
+
2. ${p}_workspace_activity: group the events by person and by kind.
|
|
771
|
+
3. ${p}_conversations_list and ${p}_conversations_messages_unread: list conversations that need my reply.
|
|
772
|
+
4. ${p}_files_list: note files created or updated in the period.
|
|
773
|
+
5. Finish with up to three suggested follow-ups. Do not send messages or change data.`
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
]
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
|
|
564
782
|
// src/modules/workspaces/index.ts
|
|
565
783
|
var workspacesModule = {
|
|
566
784
|
id: "workspaces",
|
|
567
785
|
version: "0.0.1",
|
|
568
786
|
displayName: "Workspaces",
|
|
569
787
|
dependsOn: ["auth"],
|
|
570
|
-
capabilities: { tools: {} },
|
|
788
|
+
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
571
789
|
register(server, ctx) {
|
|
572
790
|
const tools = [];
|
|
791
|
+
const resources = [];
|
|
792
|
+
const prompts = [];
|
|
573
793
|
const track = (n) => {
|
|
574
794
|
tools.push(n);
|
|
575
795
|
return n;
|
|
576
796
|
};
|
|
797
|
+
const trackResource = (uri) => {
|
|
798
|
+
resources.push(uri);
|
|
799
|
+
return uri;
|
|
800
|
+
};
|
|
801
|
+
const trackPrompt = (n) => {
|
|
802
|
+
prompts.push(n);
|
|
803
|
+
return n;
|
|
804
|
+
};
|
|
577
805
|
registerWorkspaceTools(server, ctx, track);
|
|
578
|
-
|
|
806
|
+
registerWorkspaceResources(server, ctx, trackResource);
|
|
807
|
+
registerWorkspacePrompts(server, ctx, trackPrompt);
|
|
808
|
+
return { tools, resources, prompts };
|
|
579
809
|
}
|
|
580
810
|
};
|
|
581
811
|
var workspaces_default = workspacesModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/workspaces/operations.ts","../../../src/modules/workspaces/tools.ts","../../../src/modules/workspaces/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OA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GAAA;AAAA,UAChB,QAAQ,MAAA,IAAU;AAAA,SACnB,CAAA;AACD,QAAA,OAAO,UAAA,CAAW,KAAK,sBAAsB,CAAA;AAAA,MAC/C,SAAS,KAAA,EAAO;AACd,QAAA,GAAA,CAAI,MAAA,CAAO,MAAM,2BAAA,EAA6B,EAAE,OAAO,MAAA,CAAO,KAAK,GAAG,CAAA;AACtE,QAAA,OAAO,WAAA;AAAA,UACL,uCAAuC,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,SAC/F;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;;;ACpjBA,IAAM,gBAAA,GAA8B;AAAA,EAClC,EAAA,EAAI,YAAA;AAAA,EACJ,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,YAAA;AAAA,EACb,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,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,sBAAA,CAAuB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAEzC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,kBAAA,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 * 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\n/**\n * Name-based hint heuristics for MCP `annotations` (readOnlyHint /\n * destructiveHint). Used by tool-governance.ts to auto-fill annotations for\n * the fleet of product modules that call `server.registerTool` directly\n * (bypassing the `registerTool()` core helper) and so never set them\n * explicitly today (BOFF-3903). Deliberately conservative — matched against\n * whole `_`-delimited segments so e.g. `timeentries_delete` and\n * `pomodoro_delete_goal` match, but a hypothetical `undeletable_check`\n * would not.\n *\n * The destructive verb set covers more than `delete`: stopping, killing or\n * terminating a running process, revoking or rotating a credential/share,\n * resetting settings and removing/purging/uninstalling are all actions an\n * MCP client must not auto-run without the user's intent (VC/FG parity G57 —\n * e.g. `vibecontrols_sessions_kill`, `vibecontrols_tunnels_rotate_credentials`\n * were previously reported as non-destructive).\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()` — do\n * that for the rare verb match that is harmless (e.g. a typing indicator's\n * `typing_stop`).\n */\nexport const DESTRUCTIVE_NAME_VERBS = [\n 'delete',\n 'destroy',\n 'erase',\n 'kill',\n 'purge',\n 'remove',\n 'reset',\n 'revoke',\n 'rotate',\n 'stop',\n 'terminate',\n 'uninstall',\n 'wipe',\n] as const;\nconst DESTRUCTIVE_NAME_SEGMENT = new RegExp(\n `(?:^|_)(?:${DESTRUCTIVE_NAME_VERBS.join('|')})(?:_|$)`,\n 'i',\n);\nconst READ_ONLY_NAME_SEGMENT = /(?:^|_)(?:list|get|search|check|read|count|stats|by_date)(?:_|$)/i;\n\n/** True when a tool name looks destructive (irreversibly deletes data) by naming convention. */\nexport function inferDestructiveHint(toolName: string): boolean {\n return DESTRUCTIVE_NAME_SEGMENT.test(toolName);\n}\n\n/**\n * True when a tool name looks read-only by naming convention. Never true for\n * a name that also looks destructive (a tool can't be both).\n */\nexport function inferReadOnlyHint(toolName: string): boolean {\n return !inferDestructiveHint(toolName) && READ_ONLY_NAME_SEGMENT.test(toolName);\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';\nimport type { ToolAnnotations } from './tool-governance.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 * Explicit MCP annotations (readOnlyHint / destructiveHint / ...). Optional\n * — when omitted, `wrapServerWithToolGovernance` (applied centrally in\n * `createMcpServer`) infers them from the tool name. Set this to override\n * the inference for a tool whose name doesn't match the naming convention.\n */\n annotations?: ToolAnnotations;\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 ...(metadata.annotations ? { annotations: metadata.annotations } : {}),\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 } } | 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 * Workspaces module GraphQL operations — full CRUD + members + projects +\n * activity + invitations.\n *\n * Ported verbatim from cli-sdk/src/modules/workspaces/extra-operations.ts\n * (the Phase 3 expansion of the Phase 2 thin context-only commands).\n */\n\nexport const LIST_WORKSPACES = `\n query Workspaces($filter: WorkspaceFilterInput, $pagination: PaginationInput) {\n workspaces(filter: $filter, pagination: $pagination) {\n items { id name slug description status createdAt }\n total\n hasMore\n }\n }\n`;\n\n// BOFF-8181 + BOFF-8203: live `Workspace` no longer exposes\n// `description`, `tenantId`, or `organizationId` — selecting them\n// returns \"Cannot query field\" errors. The MCP tool can still read the\n// minimum surface (id / name / slug / status / createdAt / updatedAt).\nexport const GET_WORKSPACE = `\n query GetWorkspace($id: ID!) {\n workspace(id: $id) {\n id name slug status createdAt updatedAt\n }\n }\n`;\n\n// BOFF-8181: `createWorkspace` on alpha requires `organizationId` inside\n// `CreateWorkspaceInput` — `tenantId` is the legacy alias and the\n// gateway no longer accepts it. Tool auto-fills `organizationId` from\n// the actor's auth context (decoded from the access token) so callers\n// don't need to pass it.\nexport const CREATE_WORKSPACE = `\n mutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n id name slug status createdAt\n }\n }\n`;\n\n// BOFF-8203: same — `description` is gone from `Workspace`. The mutation\n// still accepts a description in the input (the field IS valid on\n// `CreateWorkspaceInput`) but the returned object doesn't echo it.\nexport const UPDATE_WORKSPACE = `\n mutation UpdateWorkspace($id: ID!, $input: UpdateWorkspaceInput!) {\n updateWorkspace(id: $id, input: $input) {\n id name status updatedAt\n }\n }\n`;\n\n// BOFF-8203: `deleteWorkspace` was removed from the alpha supergraph\n// (the gateway now suggests `archiveWorkspace` / `suspendWorkspace`).\n// The closest user-visible action is `archiveWorkspace(id)` — but it\n// doesn't exist as a real mutation either. We expose this as a stub\n// in the tool itself (see tools.ts) rather than ship a query that\n// fails every call.\nexport const DELETE_WORKSPACE = `\n mutation DeleteWorkspace($id: ID!) {\n deleteWorkspace(id: $id)\n }\n`;\n\n// BOFF-8203: `WorkspaceMember` on alpha exposes only `id / userId /\n// role / joinedAt` — `email` and `status` are gone. The connection\n// itself is unchanged (items + total + hasMore).\nexport const LIST_WORKSPACE_MEMBERS = `\n query ListWorkspaceMembers($workspaceId: ID!, $pagination: PaginationInput) {\n workspaceMembers(workspaceId: $workspaceId, pagination: $pagination) {\n items { id userId role createdAt }\n total hasMore\n }\n }\n`;\n\n// Live `addWorkspaceMember` on the workspaces endpoint takes ONLY\n// `AddWorkspaceMemberInput!` (which is `{ userId: ID! }` on alpha).\n// Workspace context is taken from `x-workspace-id` (no `workspaceId` arg\n// anywhere — neither top-level nor inside the input). The original MCP\n// module sent `{ workspaceId, userId, role }` which the gateway\n// rejected with \"workspaceId is not defined by type AddWorkspaceMemberInput\"\n// (PR #23 regression catch).\nexport const ADD_WORKSPACE_MEMBER = `\n mutation AddWorkspaceMember($input: AddWorkspaceMemberInput!) {\n addWorkspaceMember(input: $input) {\n id userId\n }\n }\n`;\n\n// BOFF-8203: `removeWorkspaceMember` on alpha takes `workspaceId: String!`\n// and `userId: String!` (NOT `id`). The legacy `id` arg was a holdover\n// from the original MCP module before the workspaces gateway refactor.\n// Live `removeWorkspaceMember` on the workspaces endpoint takes the\n// MEMBERSHIP id (`id: ID!`) — NOT `(workspaceId, userId)`. The global\n// endpoint has the alternate shape `(workspaceId, userId: String!)`;\n// the MCP tool calls the workspaces endpoint via `ctx.gql.workspace`,\n// so we use the workspaces shape here. The user-facing tool takes\n// `membershipId` (sourced from the `workspaceMembers.list` response,\n// which exposes `id` per member).\nexport const REMOVE_WORKSPACE_MEMBER = `\n mutation RemoveWorkspaceMember($id: ID!) {\n removeWorkspaceMember(id: $id)\n }\n`;\n\n// Live `updateWorkspaceMemberRoles` on the workspaces endpoint takes\n// a `UpdateWorkspaceMemberRolesInput!` input. The input shape on alpha\n// is `{ userId: ID!, roleIds: [ID!]! }` (NOT a single `role` enum\n// string — the live service uses role-id lookups, not enum coercion).\n// The legacy `(workspaceId, userId, input.role)` shape on the global\n// endpoint no longer exists.\nexport const UPDATE_WORKSPACE_MEMBER_ROLES = `\n mutation UpdateWorkspaceMemberRoles($input: UpdateWorkspaceMemberRolesInput!) {\n updateWorkspaceMemberRoles(input: $input) {\n id userId\n }\n }\n`;\n\n// BOFF-8203: `projects(...)` was removed from the alpha `Query`. There\n// is no surviving field — the project workspace sub-resource appears to\n// have been moved to its own service. The tool is registered as a stub\n// in tools.ts (see `stubbedTool`).\n// (LIST_PROJECTS / GET_PROJECT / CREATE_PROJECT — un-stubbed in #28; shapes\n// pinned to wspace-workspace-svc origin/main, BOFF-9289 for CREATE_PROJECT.)\nexport const LIST_PROJECTS = `\n query ListProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items { id name workspaceId status createdAt }\n total hasMore\n }\n }\n`;\n\nexport const GET_PROJECT = `\n query GetProject($id: ID!) {\n project(id: $id) {\n id name description workspaceId status createdAt updatedAt\n }\n }\n`;\n\nexport const CREATE_PROJECT = `\n mutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n id name workspaceId status\n }\n }\n`;\n\nexport const ACCEPT_INVITATION = `\n mutation AcceptInvitation($id: ID!) {\n acceptInvitation(id: $id) {\n id status workspaceId\n }\n }\n`;\n\n// BOFF-8193 + BOFF-8203: `getWorkspaceActivities` and\n// `workspaceActivities` were both removed from the alpha `Query`.\n// The tool is registered as a stub in tools.ts. The selection shape\n// here is left in place to match the legacy expectation — it never\n// reaches the wire.\nexport const WORKSPACE_ACTIVITY = `\n query WorkspaceActivity($workspaceId: ID!, $limit: Int, $offset: Int) {\n getWorkspaceActivities(workspaceId: $workspaceId, limit: $limit, offset: $offset) {\n id action actorId summary createdAt\n }\n }\n`;\n","/**\n * Workspaces MCP tools — full CRUD + members + projects + activity + invitations.\n *\n * Note: workspace SELECTION (set/list/info) lives in the auth module\n * (auth_workspaces / auth_select_workspace) since it mutates the auth store.\n * This module covers the GraphQL data plane only, plus a lightweight\n * `workspace_current` for inspecting the bound workspace context.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface WorkspaceRow {\n id: string;\n name: string;\n slug?: string;\n status?: string;\n createdAt?: string;\n}\n\ninterface MemberRow {\n id: string;\n userId: string;\n email?: string;\n role?: string;\n status?: string;\n joinedAt?: string;\n}\n\ninterface ProjectRow {\n id: string;\n name: string;\n workspaceId: string;\n description?: string;\n status?: string;\n createdAt?: string;\n updatedAt?: string;\n}\n\ninterface ActivityRow {\n id: string;\n action?: string;\n actorId?: string;\n summary?: string;\n createdAt?: string;\n}\n\nconst RoleEnum = z.enum(['MEMBER', 'ADMIN', 'OWNER']);\n\nexport function registerWorkspaceTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Current workspace context ───────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_current')),\n {\n title: 'Current Workspace',\n description:\n 'Inspect the workspace currently bound to this MCP session (workspace ID, organization ID, and whether a workspace token is held).',\n inputSchema: {},\n },\n async () => {\n try {\n const auth = ctx.auth.read();\n const wid = auth?.workspaceId ?? null;\n if (!wid) {\n return jsonResult({\n workspaceId: null,\n organizationId: null,\n hasWorkspaceToken: false,\n message:\n 'No workspace selected. Call <product>_auth_workspaces to list and <product>_auth_select_workspace to bind one.',\n });\n }\n return jsonResult({\n workspaceId: wid,\n organizationId: auth?.organizationId ?? null,\n hasWorkspaceToken: Boolean(auth?.workspaceToken),\n });\n } catch (error) {\n ctx.logger.error('workspace_current failed', { error: String(error) });\n return errorResult(\n `Failed to read workspace context: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── CRUD ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_list')),\n {\n title: 'List Workspaces',\n description:\n 'List workspaces visible to the current actor on the workspace gateway, with optional filters and pagination. Returns { items, total, hasMore }.',\n inputSchema: {\n search: z.string().optional().describe('Free-text search across name/slug/description'),\n status: z\n .string()\n .optional()\n .describe('Filter by workspace status (will be uppercased; e.g. ACTIVE|ARCHIVED)'),\n tenantId: z.string().optional().describe('Filter by tenant ID'),\n orgId: z.string().optional().describe('Filter by organization ID'),\n limit: z.number().int().optional().describe('Page size (default 100)'),\n offset: z.number().int().optional().describe('Pagination offset (default 0)'),\n },\n },\n async ({ search, status, tenantId, orgId, limit, offset }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (search !== undefined) filter.search = search;\n if (status !== undefined) filter.status = status.toUpperCase();\n if (tenantId !== undefined) filter.tenantId = tenantId;\n if (orgId !== undefined) filter.orgId = orgId;\n const data = await ctx.gql.workspace.request<{\n workspaces: { items: WorkspaceRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_WORKSPACES, {\n filter: Object.keys(filter).length ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.workspaces);\n } catch (error) {\n ctx.logger.error('workspace_list failed', { error: String(error) });\n return errorResult(\n `Failed to list workspaces: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_get')),\n {\n title: 'Get Workspace',\n description: 'Get a workspace by its ID (global layer).',\n inputSchema: { id: z.string().describe('Workspace ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ workspace: WorkspaceRow | null }>(\n ops.GET_WORKSPACE,\n { id },\n );\n if (!data.workspace) {\n return errorResult(`Workspace ${id} not found`);\n }\n return jsonResult(data.workspace);\n } catch (error) {\n ctx.logger.error('workspace_get failed', { error: String(error) });\n return errorResult(\n `Failed to get workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_create')),\n {\n title: 'Create Workspace',\n description:\n \"Create a workspace (global layer). BOFF-8181: live alpha requires `slug` (auto-derived from name as kebab-case when omitted) and a valid `organizationId` (the legacy `tenantId` alias is gone). The MCP tool auto-fills `organizationId` from the actor's auth context — call without it unless you have a specific override.\",\n inputSchema: {\n name: z.string().describe('Workspace name'),\n slug: z\n .string()\n .optional()\n .describe('URL slug (auto-derived from name as kebab-case when omitted)'),\n description: z.string().optional().describe('Workspace description'),\n organizationId: z\n .string()\n .optional()\n .describe(\n \"Owning organization id (defaults to the actor's organization from the access token)\",\n ),\n },\n },\n async ({ name, description, organizationId, slug }) => {\n try {\n const input: Record<string, unknown> = { name };\n if (description !== undefined) input.description = description;\n const orgId = organizationId ?? ctx.auth.read()?.organizationId;\n if (orgId) input.organizationId = orgId;\n if (slug !== undefined) input.slug = slug;\n\n const data = await ctx.gql.global.request<{ createWorkspace: WorkspaceRow }>(\n ops.CREATE_WORKSPACE,\n { input },\n );\n return jsonResult(data.createWorkspace);\n } catch (error) {\n ctx.logger.error('workspace_create failed', { error: String(error) });\n return errorResult(\n `Failed to create workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_update')),\n {\n title: 'Update Workspace',\n description:\n \"Update a workspace (global layer). BOFF-8203: live alpha removed `description` from the `Workspace` return type; the field IS still accepted in the `UpdateWorkspaceInput` body but the response won't echo it. At least one field must be provided.\",\n inputSchema: {\n id: z.string().describe('Workspace ID'),\n name: z.string().optional().describe('Updated name'),\n description: z\n .string()\n .optional()\n .describe(\"Updated description (live alpha won't echo this on the response)\"),\n status: z.string().optional().describe('Updated status (will be uppercased)'),\n },\n },\n async ({ id, name, description, status }) => {\n try {\n const input: Record<string, unknown> = {};\n if (name !== undefined) input.name = name;\n if (description !== undefined) input.description = description;\n if (status !== undefined) input.status = status.toUpperCase();\n if (Object.keys(input).length === 0) {\n return errorResult(\n 'No updates specified — provide at least one of name/description/status',\n );\n }\n const data = await ctx.gql.global.request<{ updateWorkspace: WorkspaceRow }>(\n ops.UPDATE_WORKSPACE,\n { id, input },\n );\n return jsonResult(data.updateWorkspace);\n } catch (error) {\n ctx.logger.error('workspace_update failed', { error: String(error) });\n return errorResult(\n `Failed to update workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // BOFF-8203: `deleteWorkspace` was removed from the alpha supergraph\n // (the gateway now suggests `archiveWorkspace` / `suspendWorkspace`,\n // neither of which are real mutations on alpha). The mutation is\n // restored here on the un-stub pass; today the gateway returns a real\n // \"Cannot query field deleteWorkspace\" / \"Field X is not defined\"\n // error, which is clearer than the old [stubbed] note. The mutation is\n // queued behind workspaces service work; once re-exposed, the tool\n // starts working without further MCP changes.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_delete')),\n {\n title: 'Delete Workspace',\n description: 'Delete a workspace by its ID (global layer).',\n inputSchema: { id: z.string().describe('Workspace ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteWorkspace: boolean }>(\n ops.DELETE_WORKSPACE,\n { id },\n );\n return jsonResult({ deleted: data.deleteWorkspace, workspaceId: id });\n } catch (error) {\n ctx.logger.error('workspace_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Members ─────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_list')),\n {\n title: 'List Workspace Members',\n description:\n 'List members of a workspace. BOFF-8203: live `WorkspaceMember` only exposes `id / userId / role / joinedAt` — `email` and `status` are gone from the selection set.',\n inputSchema: {\n workspaceId: z.string().describe('Workspace ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ workspaceId, limit, offset }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n workspaceMembers: { items: MemberRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_WORKSPACE_MEMBERS, {\n workspaceId,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.workspaceMembers);\n } catch (error) {\n ctx.logger.error('workspace_members_list failed', { error: String(error) });\n return errorResult(\n `Failed to list workspace members: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // BOFF-8203 follow-up: live `addWorkspaceMember` on the workspaces\n // endpoint takes ONLY `AddWorkspaceMemberInput! = { userId: ID! }`.\n // Workspace context comes from `x-workspace-id`. The original MCP\n // module sent `{ workspaceId, userId, role }` (PR #23) which the\n // gateway rejected with \"workspaceId is not defined by type\n // AddWorkspaceMemberInput\" and \"Field role is not defined\". The\n // role is assigned at the default tier server-side; if a future\n // alpha release exposes `roleIds`, this tool can be extended without\n // an input-shape break.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_add')),\n {\n title: 'Add Workspace Member',\n description:\n 'Add a member to the active workspace. Live `addWorkspaceMember(input: { userId })` (workspaces endpoint). Workspace context is taken from the active workspace selection — pass `select_workspace` first if no workspace is active.',\n inputSchema: {\n userId: z.string().describe('User ID to add to the active workspace'),\n },\n },\n async ({ userId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ addWorkspaceMember: MemberRow }>(\n ops.ADD_WORKSPACE_MEMBER,\n { input: { userId } },\n );\n return jsonResult(data.addWorkspaceMember);\n } catch (error) {\n ctx.logger.error('workspace_members_add failed', { error: String(error) });\n return errorResult(\n `Failed to add workspace member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // BOFF-8203: `removeWorkspaceMember` on the workspaces endpoint takes\n // the MEMBERSHIP id (`id: ID!`). The user-facing tool takes\n // `membershipId` — sourced from the `workspaceMembers.list` response,\n // which exposes `id` per member. (The global endpoint has the\n // alternate `(workspaceId, userId)` shape; the MCP tool is wired to\n // the workspaces endpoint via `ctx.gql.workspace`, so we use the\n // workspaces shape here.)\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_remove')),\n {\n title: 'Remove Workspace Member',\n description:\n 'Remove a workspace member. Live alpha: `removeWorkspaceMember(id: ID!)` (workspaces endpoint, membership id). Get the id from `workspace_members_list` first.',\n inputSchema: {\n membershipId: z\n .string()\n .describe('Membership ID to remove (from `workspace_members_list`)'),\n },\n },\n async ({ membershipId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ removeWorkspaceMember: boolean }>(\n ops.REMOVE_WORKSPACE_MEMBER,\n { id: membershipId },\n );\n return jsonResult({ removed: data.removeWorkspaceMember, membershipId });\n } catch (error) {\n ctx.logger.error('workspace_members_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove workspace member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // BOFF-8203: `updateWorkspaceMemberRoles` on the workspaces endpoint\n // takes a `UpdateWorkspaceMemberRolesInput!` input. The live alpha\n // input shape is `{ userId: ID!, roleIds: [ID!]! }` — alpha does NOT\n // take a single `role` string (it uses role-id lookups, not enum\n // coercion). The user-facing tool takes `membershipId` (the\n // workspace-member id) and `role` (an enum); we look up the role\n // id by enum name via the `me` field's role list, then call the\n // mutation. To keep the tool surface simple, we use the role ENUM\n // NAME as the role id (the alpha backend resolves it). If the role\n // id resolution fails, the tool returns a clear error.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_role')),\n {\n title: 'Update Workspace Member Role',\n description:\n \"Update a workspace member's role. Live alpha: `updateWorkspaceMemberRoles(input: UpdateWorkspaceMemberRolesInput!)` where the input is `{ userId, roleIds }`. Pass the membershipId (from `workspace_members_list`) and the new role enum.\",\n inputSchema: {\n membershipId: z\n .string()\n .describe('Membership ID to update (from `workspace_members_list`)'),\n role: RoleEnum.describe('New role'),\n },\n },\n async ({ membershipId, role }) => {\n try {\n // The alpha input requires `userId: ID!` and `roleIds: [ID!]!`.\n // We need to map the membershipId → userId. The simplest path\n // is to call `updateWorkspaceMemberRoles` with the role ENUM\n // NAME as the roleId (the alpha role-id resolution accepts\n // role names like 'WORKSPACE_ADMIN' directly — see the roleIds\n // input above). If the gateway rejects the enum name as a role\n // id, we'll need a follow-up to look up role ids via a roles\n // query.\n const data = await ctx.gql.workspace.request<{\n updateWorkspaceMemberRoles: { id: string; userId: string };\n }>(ops.UPDATE_WORKSPACE_MEMBER_ROLES, { input: { userId: membershipId, roleIds: [role] } });\n return jsonResult(data.updateWorkspaceMemberRoles);\n } catch (error) {\n ctx.logger.error('workspace_members_role failed', { error: String(error) });\n return errorResult(\n `Failed to update workspace member role: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Projects (BOFF-8193 + BOFF-8203: `Query.projects` removed from alpha) ──\n // Un-stub pass: restore the GraphQL calls; today the gateway returns a\n // real \"Cannot query field projects\" / \"Field X is not defined\" error\n // (clearer than [stubbed]). Tracked behind workspaces service work to\n // re-expose the project surface.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_projects_list')),\n {\n title: 'List Projects',\n description:\n 'List projects, optionally filtered by workspace. Returns { items, total, hasMore }.',\n inputSchema: {\n workspaceId: z.string().optional().describe('Filter by workspace ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ workspaceId, limit, offset }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (workspaceId !== undefined) filter.workspaceId = workspaceId;\n const data = await ctx.gql.workspace.request<{\n projects: { items: ProjectRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_PROJECTS, {\n filter: Object.keys(filter).length ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.projects);\n } catch (error) {\n ctx.logger.error('workspace_projects_list failed', { error: String(error) });\n return errorResult(\n `Failed to list projects: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_projects_get')),\n {\n title: 'Get Project',\n description: 'Get a project by its ID.',\n inputSchema: { id: z.string().describe('Project ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ project: ProjectRow | null }>(\n ops.GET_PROJECT,\n { id },\n );\n if (!data.project) {\n return errorResult(`Project ${id} not found`);\n }\n return jsonResult(data.project);\n } catch (error) {\n ctx.logger.error('workspace_projects_get failed', { error: String(error) });\n return errorResult(\n `Failed to get project: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_projects_create')),\n {\n title: 'Create Project',\n description:\n 'Create a project in the current workspace (workspace comes from the session context).',\n inputSchema: {\n name: z.string().describe('Project name'),\n description: z.string().optional().describe('Project description'),\n },\n },\n async ({ name, description }) => {\n try {\n // CreateProjectInput has no workspaceId — the workspace is injected\n // by the gateway from the session context (BOFF-9289).\n const input: Record<string, unknown> = { name };\n if (description !== undefined) input.description = description;\n const data = await ctx.gql.workspace.request<{ createProject: ProjectRow }>(\n ops.CREATE_PROJECT,\n { input },\n );\n return jsonResult(data.createProject);\n } catch (error) {\n ctx.logger.error('workspace_projects_create failed', { error: String(error) });\n return errorResult(\n `Failed to create project: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Invitations (BOFF-8203: `acceptInvitation` removed from alpha) ─────\n // Un-stub pass: restore the GraphQL call; today the gateway returns a\n // real \"Cannot query field acceptInvitation\" / \"Field X is not defined\"\n // error. Tracked behind workspaces service work to re-expose the invite\n // acceptance path.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_invites_accept')),\n {\n title: 'Accept Workspace Invitation',\n description:\n 'Accept a workspace invitation by invitation ID. Returns { id, status, workspaceId } of the accepted invite.',\n inputSchema: { invitationId: z.string().describe('Invitation ID') },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n acceptInvitation: { id: string; status: string; workspaceId: string };\n }>(ops.ACCEPT_INVITATION, { id: invitationId });\n return jsonResult(data.acceptInvitation);\n } catch (error) {\n ctx.logger.error('workspace_invites_accept failed', { error: String(error) });\n return errorResult(\n `Failed to accept invitation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Activity (BOFF-8193 + BOFF-8203: `getWorkspaceActivities` removed) ──\n // Un-stub pass: restore the GraphQL call; today the gateway returns a\n // real \"Cannot query field getWorkspaceActivities\" / \"workspaceActivities\"\n // not-defined. Tracked behind workspaces service work to re-expose the audit\n // path; the global `complianceAuditLog` field is unrelated domain.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_activity')),\n {\n title: 'Workspace Activity Log',\n description: 'Workspace activity log (audit events) for a given workspace.',\n inputSchema: {\n workspaceId: z.string().describe('Workspace ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ workspaceId, limit, offset }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getWorkspaceActivities: ActivityRow[];\n }>(ops.WORKSPACE_ACTIVITY, {\n workspaceId,\n limit: limit ?? 100,\n offset: offset ?? 0,\n });\n return jsonResult(data.getWorkspaceActivities);\n } catch (error) {\n ctx.logger.error('workspace_activity failed', { error: String(error) });\n return errorResult(\n `Failed to fetch workspace activity: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Workspaces module — full CRUD + members + projects + activity + invitations.\n *\n * Surface mirrors cli-sdk/src/modules/workspaces/extra-commands.ts.\n *\n * Workspace SELECTION (set/list bound workspace) is handled by the auth module\n * (auth_workspaces / auth_select_workspace) since it mutates the auth store.\n * This module covers the GraphQL data plane plus a read-only `workspace_current`.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerWorkspaceTools } from './tools.js';\n\nconst workspacesModule: McpModule = {\n id: 'workspaces',\n version: '0.0.1',\n displayName: 'Workspaces',\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 registerWorkspaceTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default workspacesModule;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/workspaces/operations.ts","../../../src/modules/workspaces/tools.ts","../../../src/modules/workspaces/resources.ts","../../../src/modules/workspaces/prompts.ts","../../../src/modules/workspaces/index.ts"],"names":["z"],"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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,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AACA,IAAA,MAAM,aAAA,GAAgB,CAAC,GAAA,KAAwB;AAC7C,MAAA,SAAA,CAAU,KAAK,GAAG,CAAA;AAClB,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AACA,IAAA,MAAM,WAAA,GAAc,CAAC,CAAA,KAAsB;AACzC,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACd,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,sBAAA,CAAuB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACzC,IAAA,0BAAA,CAA2B,MAAA,EAAQ,KAAK,aAAa,CAAA;AACrD,IAAA,wBAAA,CAAyB,MAAA,EAAQ,KAAK,WAAW,CAAA;AAEjD,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,OAAA,EAAQ;AAAA,EACrC;AACF,CAAA;AAEA,IAAO,kBAAA,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 * 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\n/**\n * Name-based hint heuristics for MCP `annotations` (readOnlyHint /\n * destructiveHint). Used by tool-governance.ts to auto-fill annotations for\n * the fleet of product modules that call `server.registerTool` directly\n * (bypassing the `registerTool()` core helper) and so never set them\n * explicitly today (BOFF-3903). Deliberately conservative — matched against\n * whole `_`-delimited segments so e.g. `timeentries_delete` and\n * `pomodoro_delete_goal` match, but a hypothetical `undeletable_check`\n * would not.\n *\n * The destructive verb set covers more than `delete`: stopping, killing or\n * terminating a running process, revoking or rotating a credential/share,\n * resetting settings and removing/purging/uninstalling are all actions an\n * MCP client must not auto-run without the user's intent (VC/FG parity G57 —\n * e.g. `vibecontrols_sessions_kill`, `vibecontrols_tunnels_rotate_credentials`\n * were previously reported as non-destructive).\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()` — do\n * that for the rare verb match that is harmless (e.g. a typing indicator's\n * `typing_stop`).\n */\nexport const DESTRUCTIVE_NAME_VERBS = [\n 'delete',\n 'destroy',\n 'erase',\n 'kill',\n 'purge',\n 'remove',\n 'reset',\n 'revoke',\n 'rotate',\n 'stop',\n 'terminate',\n 'uninstall',\n 'wipe',\n] as const;\nconst DESTRUCTIVE_NAME_SEGMENT = new RegExp(\n `(?:^|_)(?:${DESTRUCTIVE_NAME_VERBS.join('|')})(?:_|$)`,\n 'i',\n);\nconst READ_ONLY_NAME_SEGMENT = /(?:^|_)(?:list|get|search|check|read|count|stats|by_date)(?:_|$)/i;\n\n/** True when a tool name looks destructive (irreversibly deletes data) by naming convention. */\nexport function inferDestructiveHint(toolName: string): boolean {\n return DESTRUCTIVE_NAME_SEGMENT.test(toolName);\n}\n\n/**\n * True when a tool name looks read-only by naming convention. Never true for\n * a name that also looks destructive (a tool can't be both).\n */\nexport function inferReadOnlyHint(toolName: string): boolean {\n return !inferDestructiveHint(toolName) && READ_ONLY_NAME_SEGMENT.test(toolName);\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';\nimport type { ToolAnnotations } from './tool-governance.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 * Explicit MCP annotations (readOnlyHint / destructiveHint / ...). Optional\n * — when omitted, `wrapServerWithToolGovernance` (applied centrally in\n * `createMcpServer`) infers them from the tool name. Set this to override\n * the inference for a tool whose name doesn't match the naming convention.\n */\n annotations?: ToolAnnotations;\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 ...(metadata.annotations ? { annotations: metadata.annotations } : {}),\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 } } | 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 * Workspaces module GraphQL operations — full CRUD + members + projects +\n * activity + invitations.\n *\n * Ported verbatim from cli-sdk/src/modules/workspaces/extra-operations.ts\n * (the Phase 3 expansion of the Phase 2 thin context-only commands).\n */\n\n// The workspace-layer `Workspace` type has no `slug` or `description`\n// (those live on the global-layer type), so the list selects only the\n// fields the wspace-workspaces subgraph exposes (BOFF-4413).\nexport const LIST_WORKSPACES = `\n query Workspaces($filter: WorkspaceFilterInput, $pagination: PaginationInput) {\n workspaces(filter: $filter, pagination: $pagination) {\n items { id name type status createdAt }\n total\n hasMore\n }\n }\n`;\n\n// BOFF-8181 + BOFF-8203: live `Workspace` no longer exposes\n// `description`, `tenantId`, or `organizationId` — selecting them\n// returns \"Cannot query field\" errors. The MCP tool can still read the\n// minimum surface (id / name / slug / status / createdAt / updatedAt).\nexport const GET_WORKSPACE = `\n query GetWorkspace($id: ID!) {\n workspace(id: $id) {\n id name slug status createdAt updatedAt\n }\n }\n`;\n\n// BOFF-8181: `createWorkspace` on alpha requires `organizationId` inside\n// `CreateWorkspaceInput` — `tenantId` is the legacy alias and the\n// gateway no longer accepts it. Tool auto-fills `organizationId` from\n// the actor's auth context (decoded from the access token) so callers\n// don't need to pass it.\nexport const CREATE_WORKSPACE = `\n mutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n id name slug status createdAt\n }\n }\n`;\n\n// BOFF-8203: same — `description` is gone from `Workspace`. The mutation\n// still accepts a description in the input (the field IS valid on\n// `CreateWorkspaceInput`) but the returned object doesn't echo it.\nexport const UPDATE_WORKSPACE = `\n mutation UpdateWorkspace($id: ID!, $input: UpdateWorkspaceInput!) {\n updateWorkspace(id: $id, input: $input) {\n id name status updatedAt\n }\n }\n`;\n\n// `deleteWorkspace(id): Boolean` on the workspace gateway (wspace-workspaces-svc).\nexport const DELETE_WORKSPACE = `\n mutation DeleteWorkspace($id: ID!) {\n deleteWorkspace(id: $id)\n }\n`;\n\n// BOFF-8203: `WorkspaceMember` on alpha exposes only `id / userId /\n// role / joinedAt` — `email` and `status` are gone. The connection\n// itself is unchanged (items + total + hasMore).\nexport const LIST_WORKSPACE_MEMBERS = `\n query ListWorkspaceMembers($workspaceId: ID!, $pagination: PaginationInput) {\n workspaceMembers(workspaceId: $workspaceId, pagination: $pagination) {\n items { id userId role createdAt }\n total hasMore\n }\n }\n`;\n\n// Live `addWorkspaceMember` on the workspaces endpoint takes ONLY\n// `AddWorkspaceMemberInput!` (which is `{ userId: ID! }` on alpha).\n// Workspace context is taken from `x-workspace-id` (no `workspaceId` arg\n// anywhere — neither top-level nor inside the input). The original MCP\n// module sent `{ workspaceId, userId, role }` which the gateway\n// rejected with \"workspaceId is not defined by type AddWorkspaceMemberInput\"\n// (PR #23 regression catch).\nexport const ADD_WORKSPACE_MEMBER = `\n mutation AddWorkspaceMember($input: AddWorkspaceMemberInput!) {\n addWorkspaceMember(input: $input) {\n id userId\n }\n }\n`;\n\n// BOFF-8203: `removeWorkspaceMember` on alpha takes `workspaceId: String!`\n// and `userId: String!` (NOT `id`). The legacy `id` arg was a holdover\n// from the original MCP module before the workspaces gateway refactor.\n// Live `removeWorkspaceMember` on the workspaces endpoint takes the\n// MEMBERSHIP id (`id: ID!`) — NOT `(workspaceId, userId)`. The global\n// endpoint has the alternate shape `(workspaceId, userId: String!)`;\n// the MCP tool calls the workspaces endpoint via `ctx.gql.workspace`,\n// so we use the workspaces shape here. The user-facing tool takes\n// `membershipId` (sourced from the `workspaceMembers.list` response,\n// which exposes `id` per member).\nexport const REMOVE_WORKSPACE_MEMBER = `\n mutation RemoveWorkspaceMember($id: ID!) {\n removeWorkspaceMember(id: $id)\n }\n`;\n\n// Live `updateWorkspaceMemberRoles` on the workspaces endpoint takes\n// a `UpdateWorkspaceMemberRolesInput!` input. The input shape on alpha\n// is `{ userId: ID!, roleIds: [ID!]! }` (NOT a single `role` enum\n// string — the live service uses role-id lookups, not enum coercion).\n// The legacy `(workspaceId, userId, input.role)` shape on the global\n// endpoint no longer exists.\nexport const UPDATE_WORKSPACE_MEMBER_ROLES = `\n mutation UpdateWorkspaceMemberRoles($input: UpdateWorkspaceMemberRolesInput!) {\n updateWorkspaceMemberRoles(input: $input) {\n id userId\n }\n }\n`;\n\n// Projects live on wspace-workspaces-svc (BOFF-9289 for CREATE_PROJECT).\nexport const LIST_PROJECTS = `\n query ListProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items { id name workspaceId status createdAt }\n total hasMore\n }\n }\n`;\n\nexport const GET_PROJECT = `\n query GetProject($id: ID!) {\n project(id: $id) {\n id name description workspaceId status createdAt updatedAt\n }\n }\n`;\n\nexport const CREATE_PROJECT = `\n mutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n id name workspaceId status\n }\n }\n`;\n\nexport const ACCEPT_INVITATION = `\n mutation AcceptInvitation($id: ID!) {\n acceptInvitation(id: $id) {\n id status workspaceId\n }\n }\n`;\n\n// `getWorkspaceActivities` returns ActivityLog rows: who (`userId`,\n// `actorType`), what (`action`, `description`, `resourceType`/`resourceId`)\n// and when (`timestamp`). BOFF-4413 fixed the selection, which asked for\n// `actorId` / `summary` / `createdAt` (not on the type) and failed every call.\nexport const WORKSPACE_ACTIVITY = `\n query WorkspaceActivity($workspaceId: ID!, $limit: Int, $offset: Int) {\n getWorkspaceActivities(workspaceId: $workspaceId, limit: $limit, offset: $offset) {\n id action userId actorType description resourceType resourceId timestamp\n }\n }\n`;\n","/**\n * Workspaces MCP tools — full CRUD + members + projects + activity + invitations.\n *\n * Note: workspace SELECTION (set/list/info) lives in the auth module\n * (auth_workspaces / auth_select_workspace) since it mutates the auth store.\n * This module covers the GraphQL data plane only, plus a lightweight\n * `workspace_current` for inspecting the bound workspace context.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface WorkspaceRow {\n id: string;\n name: string;\n type?: string;\n slug?: string;\n status?: string;\n createdAt?: string;\n}\n\ninterface MemberRow {\n id: string;\n userId: string;\n email?: string;\n role?: string;\n status?: string;\n joinedAt?: string;\n}\n\ninterface ProjectRow {\n id: string;\n name: string;\n workspaceId: string;\n description?: string;\n status?: string;\n createdAt?: string;\n updatedAt?: string;\n}\n\ninterface ActivityRow {\n id: string;\n action?: string;\n userId?: string;\n actorType?: string | null;\n description?: string | null;\n resourceType?: string | null;\n resourceId?: string | null;\n timestamp?: string;\n}\n\nconst RoleEnum = z.enum(['MEMBER', 'ADMIN', 'OWNER']);\n\nexport function registerWorkspaceTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Current workspace context ───────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_current')),\n {\n title: 'Current Workspace',\n description:\n 'Inspect the workspace currently bound to this MCP session (workspace ID, organization ID, and whether a workspace token is held).',\n inputSchema: {},\n },\n async () => {\n try {\n const auth = ctx.auth.read();\n const wid = auth?.workspaceId ?? null;\n if (!wid) {\n return jsonResult({\n workspaceId: null,\n organizationId: null,\n hasWorkspaceToken: false,\n message:\n 'No workspace selected. Call <product>_auth_workspaces to list and <product>_auth_select_workspace to bind one.',\n });\n }\n return jsonResult({\n workspaceId: wid,\n organizationId: auth?.organizationId ?? null,\n hasWorkspaceToken: Boolean(auth?.workspaceToken),\n });\n } catch (error) {\n ctx.logger.error('workspace_current failed', { error: String(error) });\n return errorResult(\n `Failed to read workspace context: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── CRUD ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_list')),\n {\n title: 'List Workspaces',\n description:\n 'List workspaces visible to the current actor on the workspace gateway, with optional filters and pagination. Returns { items, total, hasMore }.',\n inputSchema: {\n search: z.string().optional().describe('Free-text search across workspace names'),\n status: z\n .string()\n .optional()\n .describe('Filter by workspace status (will be uppercased; e.g. ACTIVE|ARCHIVED)'),\n tenantId: z.string().optional().describe('Filter by tenant ID'),\n orgId: z.string().optional().describe('Filter by organization ID'),\n limit: z.number().int().optional().describe('Page size (default 100)'),\n offset: z.number().int().optional().describe('Pagination offset (default 0)'),\n },\n },\n async ({ search, status, tenantId, orgId, limit, offset }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (search !== undefined) filter.search = search;\n if (status !== undefined) filter.status = status.toUpperCase();\n if (tenantId !== undefined) filter.tenantId = tenantId;\n if (orgId !== undefined) filter.orgId = orgId;\n const data = await ctx.gql.workspace.request<{\n workspaces: { items: WorkspaceRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_WORKSPACES, {\n filter: Object.keys(filter).length ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.workspaces);\n } catch (error) {\n ctx.logger.error('workspace_list failed', { error: String(error) });\n return errorResult(\n `Failed to list workspaces: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_get')),\n {\n title: 'Get Workspace',\n description: 'Get a workspace by its ID (global layer).',\n inputSchema: { id: z.string().describe('Workspace ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ workspace: WorkspaceRow | null }>(\n ops.GET_WORKSPACE,\n { id },\n );\n if (!data.workspace) {\n return errorResult(`Workspace ${id} not found`);\n }\n return jsonResult(data.workspace);\n } catch (error) {\n ctx.logger.error('workspace_get failed', { error: String(error) });\n return errorResult(\n `Failed to get workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_create')),\n {\n title: 'Create Workspace',\n description:\n \"Create a workspace (global layer). BOFF-8181: live alpha requires `slug` (auto-derived from name as kebab-case when omitted) and a valid `organizationId` (the legacy `tenantId` alias is gone). The MCP tool auto-fills `organizationId` from the actor's auth context — call without it unless you have a specific override.\",\n inputSchema: {\n name: z.string().describe('Workspace name'),\n slug: z\n .string()\n .optional()\n .describe('URL slug (auto-derived from name as kebab-case when omitted)'),\n description: z.string().optional().describe('Workspace description'),\n organizationId: z\n .string()\n .optional()\n .describe(\n \"Owning organization id (defaults to the actor's organization from the access token)\",\n ),\n },\n },\n async ({ name, description, organizationId, slug }) => {\n try {\n const input: Record<string, unknown> = { name };\n if (description !== undefined) input.description = description;\n const orgId = organizationId ?? ctx.auth.read()?.organizationId;\n if (orgId) input.organizationId = orgId;\n if (slug !== undefined) input.slug = slug;\n\n const data = await ctx.gql.global.request<{ createWorkspace: WorkspaceRow }>(\n ops.CREATE_WORKSPACE,\n { input },\n );\n return jsonResult(data.createWorkspace);\n } catch (error) {\n ctx.logger.error('workspace_create failed', { error: String(error) });\n return errorResult(\n `Failed to create workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_update')),\n {\n title: 'Update Workspace',\n description:\n \"Update a workspace (global layer). BOFF-8203: live alpha removed `description` from the `Workspace` return type; the field IS still accepted in the `UpdateWorkspaceInput` body but the response won't echo it. At least one field must be provided.\",\n inputSchema: {\n id: z.string().describe('Workspace ID'),\n name: z.string().optional().describe('Updated name'),\n description: z\n .string()\n .optional()\n .describe(\"Updated description (live alpha won't echo this on the response)\"),\n status: z.string().optional().describe('Updated status (will be uppercased)'),\n },\n },\n async ({ id, name, description, status }) => {\n try {\n const input: Record<string, unknown> = {};\n if (name !== undefined) input.name = name;\n if (description !== undefined) input.description = description;\n if (status !== undefined) input.status = status.toUpperCase();\n if (Object.keys(input).length === 0) {\n return errorResult(\n 'No updates specified — provide at least one of name/description/status',\n );\n }\n const data = await ctx.gql.global.request<{ updateWorkspace: WorkspaceRow }>(\n ops.UPDATE_WORKSPACE,\n { id, input },\n );\n return jsonResult(data.updateWorkspace);\n } catch (error) {\n ctx.logger.error('workspace_update failed', { error: String(error) });\n return errorResult(\n `Failed to update workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // `deleteWorkspace(id)` is served by wspace-workspaces-svc on the workspace\n // gateway; the document is validated against the supergraph by\n // platform-supergraph-contract.test.ts (BOFF-4413).\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_delete')),\n {\n title: 'Delete Workspace',\n description: 'Delete a workspace by its ID (global layer).',\n inputSchema: { id: z.string().describe('Workspace ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteWorkspace: boolean }>(\n ops.DELETE_WORKSPACE,\n { id },\n );\n return jsonResult({ deleted: data.deleteWorkspace, workspaceId: id });\n } catch (error) {\n ctx.logger.error('workspace_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete workspace: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Members ─────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_list')),\n {\n title: 'List Workspace Members',\n description:\n 'List members of a workspace. BOFF-8203: live `WorkspaceMember` only exposes `id / userId / role / joinedAt` — `email` and `status` are gone from the selection set.',\n inputSchema: {\n workspaceId: z.string().describe('Workspace ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ workspaceId, limit, offset }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n workspaceMembers: { items: MemberRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_WORKSPACE_MEMBERS, {\n workspaceId,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.workspaceMembers);\n } catch (error) {\n ctx.logger.error('workspace_members_list failed', { error: String(error) });\n return errorResult(\n `Failed to list workspace members: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // BOFF-8203 follow-up: live `addWorkspaceMember` on the workspaces\n // endpoint takes ONLY `AddWorkspaceMemberInput! = { userId: ID! }`.\n // Workspace context comes from `x-workspace-id`. The original MCP\n // module sent `{ workspaceId, userId, role }` (PR #23) which the\n // gateway rejected with \"workspaceId is not defined by type\n // AddWorkspaceMemberInput\" and \"Field role is not defined\". The\n // role is assigned at the default tier server-side; if a future\n // alpha release exposes `roleIds`, this tool can be extended without\n // an input-shape break.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_add')),\n {\n title: 'Add Workspace Member',\n description:\n 'Add a member to the active workspace. Live `addWorkspaceMember(input: { userId })` (workspaces endpoint). Workspace context is taken from the active workspace selection — pass `select_workspace` first if no workspace is active.',\n inputSchema: {\n userId: z.string().describe('User ID to add to the active workspace'),\n },\n },\n async ({ userId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ addWorkspaceMember: MemberRow }>(\n ops.ADD_WORKSPACE_MEMBER,\n { input: { userId } },\n );\n return jsonResult(data.addWorkspaceMember);\n } catch (error) {\n ctx.logger.error('workspace_members_add failed', { error: String(error) });\n return errorResult(\n `Failed to add workspace member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // BOFF-8203: `removeWorkspaceMember` on the workspaces endpoint takes\n // the MEMBERSHIP id (`id: ID!`). The user-facing tool takes\n // `membershipId` — sourced from the `workspaceMembers.list` response,\n // which exposes `id` per member. (The global endpoint has the\n // alternate `(workspaceId, userId)` shape; the MCP tool is wired to\n // the workspaces endpoint via `ctx.gql.workspace`, so we use the\n // workspaces shape here.)\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_remove')),\n {\n title: 'Remove Workspace Member',\n description:\n 'Remove a workspace member. Live alpha: `removeWorkspaceMember(id: ID!)` (workspaces endpoint, membership id). Get the id from `workspace_members_list` first.',\n inputSchema: {\n membershipId: z\n .string()\n .describe('Membership ID to remove (from `workspace_members_list`)'),\n },\n },\n async ({ membershipId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ removeWorkspaceMember: boolean }>(\n ops.REMOVE_WORKSPACE_MEMBER,\n { id: membershipId },\n );\n return jsonResult({ removed: data.removeWorkspaceMember, membershipId });\n } catch (error) {\n ctx.logger.error('workspace_members_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove workspace member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // BOFF-8203: `updateWorkspaceMemberRoles` on the workspaces endpoint\n // takes a `UpdateWorkspaceMemberRolesInput!` input. The live alpha\n // input shape is `{ userId: ID!, roleIds: [ID!]! }` — alpha does NOT\n // take a single `role` string (it uses role-id lookups, not enum\n // coercion). The user-facing tool takes `membershipId` (the\n // workspace-member id) and `role` (an enum); we look up the role\n // id by enum name via the `me` field's role list, then call the\n // mutation. To keep the tool surface simple, we use the role ENUM\n // NAME as the role id (the alpha backend resolves it). If the role\n // id resolution fails, the tool returns a clear error.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_members_role')),\n {\n title: 'Update Workspace Member Role',\n description:\n \"Update a workspace member's role. Live alpha: `updateWorkspaceMemberRoles(input: UpdateWorkspaceMemberRolesInput!)` where the input is `{ userId, roleIds }`. Pass the membershipId (from `workspace_members_list`) and the new role enum.\",\n inputSchema: {\n membershipId: z\n .string()\n .describe('Membership ID to update (from `workspace_members_list`)'),\n role: RoleEnum.describe('New role'),\n },\n },\n async ({ membershipId, role }) => {\n try {\n // The alpha input requires `userId: ID!` and `roleIds: [ID!]!`.\n // We need to map the membershipId → userId. The simplest path\n // is to call `updateWorkspaceMemberRoles` with the role ENUM\n // NAME as the roleId (the alpha role-id resolution accepts\n // role names like 'WORKSPACE_ADMIN' directly — see the roleIds\n // input above). If the gateway rejects the enum name as a role\n // id, we'll need a follow-up to look up role ids via a roles\n // query.\n const data = await ctx.gql.workspace.request<{\n updateWorkspaceMemberRoles: { id: string; userId: string };\n }>(ops.UPDATE_WORKSPACE_MEMBER_ROLES, { input: { userId: membershipId, roleIds: [role] } });\n return jsonResult(data.updateWorkspaceMemberRoles);\n } catch (error) {\n ctx.logger.error('workspace_members_role failed', { error: String(error) });\n return errorResult(\n `Failed to update workspace member role: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Projects ──────────────────────────────────────────────────────────\n // `projects`, `project` and `createProject` are live on the workspace\n // gateway (validated by platform-supergraph-contract.test.ts, BOFF-4413).\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_projects_list')),\n {\n title: 'List Projects',\n description:\n 'List projects, optionally filtered by workspace. Returns { items, total, hasMore }.',\n inputSchema: {\n workspaceId: z.string().optional().describe('Filter by workspace ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ workspaceId, limit, offset }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (workspaceId !== undefined) filter.workspaceId = workspaceId;\n const data = await ctx.gql.workspace.request<{\n projects: { items: ProjectRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_PROJECTS, {\n filter: Object.keys(filter).length ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.projects);\n } catch (error) {\n ctx.logger.error('workspace_projects_list failed', { error: String(error) });\n return errorResult(\n `Failed to list projects: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_projects_get')),\n {\n title: 'Get Project',\n description: 'Get a project by its ID.',\n inputSchema: { id: z.string().describe('Project ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ project: ProjectRow | null }>(\n ops.GET_PROJECT,\n { id },\n );\n if (!data.project) {\n return errorResult(`Project ${id} not found`);\n }\n return jsonResult(data.project);\n } catch (error) {\n ctx.logger.error('workspace_projects_get failed', { error: String(error) });\n return errorResult(\n `Failed to get project: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_projects_create')),\n {\n title: 'Create Project',\n description:\n 'Create a project in the current workspace (workspace comes from the session context).',\n inputSchema: {\n name: z.string().describe('Project name'),\n description: z.string().optional().describe('Project description'),\n },\n },\n async ({ name, description }) => {\n try {\n // CreateProjectInput has no workspaceId — the workspace is injected\n // by the gateway from the session context (BOFF-9289).\n const input: Record<string, unknown> = { name };\n if (description !== undefined) input.description = description;\n const data = await ctx.gql.workspace.request<{ createProject: ProjectRow }>(\n ops.CREATE_PROJECT,\n { input },\n );\n return jsonResult(data.createProject);\n } catch (error) {\n ctx.logger.error('workspace_projects_create failed', { error: String(error) });\n return errorResult(\n `Failed to create project: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Invitations (BOFF-8203: `acceptInvitation` removed from alpha) ─────\n // Un-stub pass: restore the GraphQL call; today the gateway returns a\n // real \"Cannot query field acceptInvitation\" / \"Field X is not defined\"\n // error. Tracked behind workspaces service work to re-expose the invite\n // acceptance path.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_invites_accept')),\n {\n title: 'Accept Workspace Invitation',\n description:\n 'Accept a workspace invitation by invitation ID. Returns { id, status, workspaceId } of the accepted invite.',\n inputSchema: { invitationId: z.string().describe('Invitation ID') },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n acceptInvitation: { id: string; status: string; workspaceId: string };\n }>(ops.ACCEPT_INVITATION, { id: invitationId });\n return jsonResult(data.acceptInvitation);\n } catch (error) {\n ctx.logger.error('workspace_invites_accept failed', { error: String(error) });\n return errorResult(\n `Failed to accept invitation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Activity (BOFF-8193 + BOFF-8203: `getWorkspaceActivities` removed) ──\n // Un-stub pass: restore the GraphQL call; today the gateway returns a\n // real \"Cannot query field getWorkspaceActivities\" / \"workspaceActivities\"\n // not-defined. Tracked behind workspaces service work to re-expose the audit\n // path; the global `complianceAuditLog` field is unrelated domain.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'workspace_activity')),\n {\n title: 'Workspace Activity Log',\n description: 'Workspace activity log (audit events) for a given workspace.',\n inputSchema: {\n workspaceId: z.string().describe('Workspace ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ workspaceId, limit, offset }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getWorkspaceActivities: ActivityRow[];\n }>(ops.WORKSPACE_ACTIVITY, {\n workspaceId,\n limit: limit ?? 100,\n offset: offset ?? 0,\n });\n return jsonResult(data.getWorkspaceActivities);\n } catch (error) {\n ctx.logger.error('workspace_activity failed', { error: String(error) });\n return errorResult(\n `Failed to fetch workspace activity: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResourceUri, type McpContext } from '../../core/index.js';\nimport { GET_WORKSPACE } from './operations.js';\n\n/**\n * Read-only Workspaces resources (BOFF-4413):\n *\n * - <product>://workspace/guide — how the workspace surface fits together\n * and which tools to reach for, so an agent can orient itself without\n * listing ~300 tools first;\n * - <product>://workspace/current — the workspace bound to this session,\n * resolved live from the global gateway.\n */\nexport function registerWorkspaceResources(\n server: McpServer,\n ctx: McpContext,\n track: (uri: string) => string,\n): void {\n const p = ctx.productName;\n const guideUri = track(mcpResourceUri(p, 'workspace', 'guide'));\n const currentUri = track(mcpResourceUri(p, 'workspace', 'current'));\n\n server.registerResource(\n `${p}-workspace-guide`,\n guideUri,\n {\n title: 'Workspace Guide',\n description:\n 'How a Burdenoff workspace is organised (members, projects, files, tags, conversations, activity) and which tools operate on each part.',\n mimeType: 'text/markdown',\n },\n async () => ({\n contents: [{ uri: guideUri, mimeType: 'text/markdown', text: workspaceGuide(p) }],\n }),\n );\n\n server.registerResource(\n `${p}-workspace-current`,\n currentUri,\n {\n title: 'Current Workspace',\n description:\n 'The workspace this session is bound to (id, name, slug, status, organization). Empty until a workspace is selected.',\n mimeType: 'application/json',\n },\n async () => {\n const auth = ctx.auth.read();\n const workspaceId = auth?.workspaceId ?? null;\n let body: Record<string, unknown>;\n if (!workspaceId) {\n body = {\n workspaceId: null,\n message: `No workspace selected. Call ${p}_auth_workspaces, then ${p}_auth_select_workspace.`,\n };\n } else {\n try {\n const data = await ctx.gql.global.request<{ workspace: Record<string, unknown> | null }>(\n GET_WORKSPACE,\n { id: workspaceId },\n );\n body = {\n workspaceId,\n organizationId: auth?.organizationId ?? null,\n workspace: data.workspace,\n };\n } catch (error) {\n body = {\n workspaceId,\n organizationId: auth?.organizationId ?? null,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n return {\n contents: [\n { uri: currentUri, mimeType: 'application/json', text: JSON.stringify(body, null, 2) },\n ],\n };\n },\n );\n}\n\nexport function workspaceGuide(p: string): string {\n return `# Burdenoff Workspaces\n\nA workspace is the unit of collaboration and data isolation. Everything below\nbelongs to exactly one workspace, and every tool acts on the workspace bound to\nthis session.\n\n## 1. Sign in and pick a workspace\n- ${p}_auth_login / ${p}_auth_complete (device code) or ${p}_auth_sign_in\n- ${p}_auth_workspaces lists the workspaces you belong to\n- ${p}_auth_select_workspace binds one; ${p}_workspace_current shows the binding\n\n## 2. People and structure\n- Workspaces: ${p}_workspace_list, ${p}_workspace_get, ${p}_workspace_create, ${p}_workspace_update\n- Members: ${p}_workspace_members_list, ${p}_workspace_members_add, ${p}_workspace_members_role, ${p}_workspace_members_remove\n- Projects: ${p}_workspace_projects_list, ${p}_workspace_projects_get, ${p}_workspace_projects_create\n- Groups and teams: ${p}_groups_*\n- Audit trail: ${p}_workspace_activity\n\n## 3. Content\n- Files: ${p}_files_browse, ${p}_files_list, ${p}_files_get, ${p}_files_download,\n uploads via ${p}_files_upload_initiate then ${p}_files_upload_complete,\n sharing via ${p}_files_share / ${p}_files_share_revoke\n- Tags: ${p}_tags_vocabularies_list, ${p}_tags_list, ${p}_tags_create,\n ${p}_tags_assign (tag a file, folder or project), ${p}_tags_entity_list\n- Conversations: ${p}_conversations_list, ${p}_conversations_search,\n ${p}_conversations_messages_list, ${p}_conversations_messages_send,\n ${p}_conversations_get_or_create_direct\n- Notifications: ${p}_notifications_*\n\n## 4. Automation and integrations\n- Scheduled jobs: ${p}_scheduler_*\n- Integrations and channels: ${p}_integrations_*, ${p}_channels_*\n- Exports: ${p}_export_*\n\n## Rules\n- Access is enforced by the gateway with your own identity: a tool can only\n see or change what you can in the app.\n- Destructive tools (delete, remove, revoke, ...) change data for good. Ask\n the user first; servers that enforce confirmation (workspaces-mcp does)\n refuse them unless the call passes confirm: true.\n- Lists are paginated with limit/offset; check hasMore before assuming you\n have everything.\n`;\n}\n","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpPromptName, type McpContext } from '../../core/index.js';\n\n/**\n * Guided Workspaces workflows (BOFF-4413). Each prompt only names tools the\n * auth, workspaces, files, tags and conversations modules register, so it\n * works in any product shell that mounts them.\n */\nexport function registerWorkspacePrompts(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n const p = ctx.productName;\n const orientName = track(mcpPromptName(p, 'workspace-orient'));\n const findFileName = track(mcpPromptName(p, 'workspace-find-file'));\n const digestName = track(mcpPromptName(p, 'workspace-digest'));\n\n server.registerPrompt(\n orientName,\n {\n title: 'Get Oriented in a Workspace',\n description:\n 'Pick the right workspace and summarise who is in it, which projects exist and what happened recently.',\n argsSchema: {\n workspaceName: z.string().optional().describe('Name of the workspace to open'),\n },\n },\n ({ workspaceName }) => {\n const pick = workspaceName\n ? `Pick the workspace named \"${workspaceName}\" (ask me if several match).`\n : 'Show me the list and ask which one to open.';\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `Help me get oriented in a Burdenoff workspace.\n\n1. Call ${p}_auth_status. If I am not signed in, start ${p}_auth_login and wait for me to finish.\n2. Call ${p}_auth_workspaces. ${pick} Bind it with ${p}_auth_select_workspace.\n3. Read the ${p}://workspace/guide resource for the tool map.\n4. Summarise the workspace: ${p}_workspace_members_list (who and which roles), ${p}_workspace_projects_list (projects and status), ${p}_files_browse (top-level folders and files).\n5. Call ${p}_workspace_activity for the latest events and list the five most important.\n\nKeep the summary short and do not change anything.`,\n },\n },\n ],\n };\n },\n );\n\n server.registerPrompt(\n findFileName,\n {\n title: 'Find and Share a File',\n description:\n 'Locate a file in the current workspace by name, type or tag, then optionally share it.',\n argsSchema: {\n query: z.string().describe('What the file is called or about'),\n shareWith: z.string().optional().describe('Email address to share the file with'),\n },\n },\n ({ query, shareWith }) => {\n const share = shareWith\n ? `5. Ask me to confirm, then share it with ${shareWith} via ${p}_files_share (shareType EMAIL_INVITE, accessLevel VIEW unless I say otherwise).`\n : `5. Offer a download link via ${p}_files_download; do not create shares unless I ask.`;\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `Find the file in my current workspace that matches: \"${query}\".\n\n1. Use ${p}_files_browse from the root and walk into folders whose names fit.\n2. Use ${p}_files_list with mimeTypes or extensions filters when the request implies a type.\n3. If the workspace uses tags, check ${p}_tags_list for a matching tag and ${p}_tags_entity_list on candidates.\n4. Show the best matches with name, folder, size and last update; confirm the right one with ${p}_files_get.\n${share}`,\n },\n },\n ],\n };\n },\n );\n\n server.registerPrompt(\n digestName,\n {\n title: 'Workspace Digest',\n description:\n 'Summarise recent activity, unread conversations and new files in the current workspace.',\n argsSchema: {\n days: z.string().optional().describe('How many days back to cover (default 7)'),\n },\n },\n ({ days }) => {\n const span = days && /^\\d+$/.test(days) ? days : '7';\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `Write a digest of the last ${span} days in my current workspace.\n\n1. ${p}_workspace_current to confirm which workspace is bound (ask me to pick one if none).\n2. ${p}_workspace_activity: group the events by person and by kind.\n3. ${p}_conversations_list and ${p}_conversations_messages_unread: list conversations that need my reply.\n4. ${p}_files_list: note files created or updated in the period.\n5. Finish with up to three suggested follow-ups. Do not send messages or change data.`,\n },\n },\n ],\n };\n },\n );\n}\n","/**\n * Workspaces module — full CRUD + members + projects + activity + invitations.\n *\n * Surface mirrors cli-sdk/src/modules/workspaces/extra-commands.ts.\n *\n * Workspace SELECTION (set/list bound workspace) is handled by the auth module\n * (auth_workspaces / auth_select_workspace) since it mutates the auth store.\n * This module covers the GraphQL data plane plus a read-only `workspace_current`,\n * the <product>://workspace/{guide,current} resources and the\n * <product>-workspace-{orient,find-file,digest} prompts.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerWorkspaceTools } from './tools.js';\nimport { registerWorkspaceResources } from './resources.js';\nimport { registerWorkspacePrompts } from './prompts.js';\n\nconst workspacesModule: McpModule = {\n id: 'workspaces',\n version: '0.0.1',\n displayName: 'Workspaces',\n dependsOn: ['auth'],\n capabilities: { tools: {}, resources: {}, prompts: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const resources: string[] = [];\n const prompts: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n const trackResource = (uri: string): string => {\n resources.push(uri);\n return uri;\n };\n const trackPrompt = (n: string): string => {\n prompts.push(n);\n return n;\n };\n\n registerWorkspaceTools(server, ctx, track);\n registerWorkspaceResources(server, ctx, trackResource);\n registerWorkspacePrompts(server, ctx, trackPrompt);\n\n return { tools, resources, prompts };\n },\n};\n\nexport default workspacesModule;\n"]}
|