Skip to content

Commit bdb2280

Browse files
author
Lasim
committed
feat(frontend): integrate team selection for client activity fetching
1 parent 7ab668c commit bdb2280

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

services/frontend/src/components/mcp-server/McpClientConnectionsCard.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<script setup lang="ts">
22
import { ref, onMounted, onUnmounted } from 'vue'
33
import { useI18n } from 'vue-i18n'
4+
import { useEventBus } from '@/composables/useEventBus'
45
import Card from '@/components/ui/card/Card.vue'
56
import { Item } from '@/components/ui/item'
67
import { McpClientActivityService } from '@/services/mcpClientActivityService'
78
import type { McpClientActivity } from '@/services/mcpClientActivityService'
89
910
const { t } = useI18n()
11+
const eventBus = useEventBus()
1012
1113
const activities = ref<McpClientActivity[]>([])
1214
const isLoading = ref(false)
@@ -33,11 +35,20 @@ function getRelativeTime(isoString: string): string {
3335
}
3436
3537
async function fetchClientActivity() {
38+
// Get teamId from storage (selected team)
39+
const teamId = eventBus.getState<string>('selected_team_id')
40+
41+
if (!teamId) {
42+
error.value = 'No team selected'
43+
console.warn('No team selected - please select a team first')
44+
return
45+
}
46+
3647
try {
3748
isLoading.value = true
3849
error.value = null
3950
40-
const response = await McpClientActivityService.getMyClientActivity({
51+
const response = await McpClientActivityService.getMyClientActivity(teamId, {
4152
limit: 20,
4253
active_within_minutes: 30
4354
})
@@ -67,6 +78,11 @@ function stopPolling() {
6778
onMounted(async () => {
6879
await fetchClientActivity()
6980
startPolling()
81+
82+
// Listen for team selection changes and refresh activity
83+
eventBus.on('team-selected', async () => {
84+
await fetchClientActivity()
85+
})
7086
})
7187
7288
onUnmounted(() => {

services/frontend/src/services/mcpClientActivityService.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,35 @@ export class McpClientActivityService {
3737
private static baseUrl = getEnv('VITE_DEPLOYSTACK_BACKEND_URL')
3838

3939
/**
40-
* Get current user's active MCP client connections
40+
* Get current user's active MCP client connections for a specific team
41+
*
42+
* @param teamId - Team ID to filter activity by (must be a string)
43+
* @param params - Optional query parameters
44+
* @returns MCP client activity response
4145
*/
4246
static async getMyClientActivity(
47+
teamId: string,
4348
params: GetClientActivityParams = {}
4449
): Promise<McpClientActivityResponse> {
50+
// Runtime validation to catch common mistake of passing team object instead of team ID
51+
if (typeof teamId !== 'string' || !teamId) {
52+
throw new Error(
53+
'teamId must be a non-empty string. Did you pass the team object instead of team.id?'
54+
)
55+
}
56+
4557
const queryParams = new URLSearchParams()
4658

59+
// Required parameter
60+
queryParams.append('team_id', teamId)
61+
4762
if (params.limit) queryParams.append('limit', params.limit.toString())
4863
if (params.offset) queryParams.append('offset', params.offset.toString())
4964
if (params.active_within_minutes) {
5065
queryParams.append('active_within_minutes', params.active_within_minutes.toString())
5166
}
5267

53-
const url = `${this.baseUrl}/api/users/me/mcp/client-activity${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
68+
const url = `${this.baseUrl}/api/users/me/mcp/client-activity?${queryParams.toString()}`
5469

5570
const response = await fetch(url, {
5671
method: 'GET',

0 commit comments

Comments
 (0)