fix: Checking for capabilities from store
This commit is contained in:
parent
874de71573
commit
c4e2ccdff7
|
|
@ -165,12 +165,12 @@
|
||||||
|
|
||||||
let hasMcpPromptsSupport = $derived.by(() => {
|
let hasMcpPromptsSupport = $derived.by(() => {
|
||||||
const perChatOverrides = conversationsStore.getAllMcpServerOverrides();
|
const perChatOverrides = conversationsStore.getAllMcpServerOverrides();
|
||||||
return mcpStore.hasEnabledServers(perChatOverrides);
|
return mcpStore.hasPromptsCapability(perChatOverrides);
|
||||||
});
|
});
|
||||||
|
|
||||||
let hasMcpResourcesSupport = $derived.by(() => {
|
let hasMcpResourcesSupport = $derived.by(() => {
|
||||||
const perChatOverrides = conversationsStore.getAllMcpServerOverrides();
|
const perChatOverrides = conversationsStore.getAllMcpServerOverrides();
|
||||||
return mcpStore.hasEnabledServers(perChatOverrides) && mcpStore.hasResourcesCapability();
|
return mcpStore.hasResourcesCapability(perChatOverrides);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -588,6 +588,60 @@ class MCPStore {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if any enabled server with successful health check supports prompts.
|
||||||
|
* Uses health check state since servers may not have active connections until
|
||||||
|
* the user actually sends a message or uses prompts.
|
||||||
|
* @param perChatOverrides - Per-chat server overrides to filter by enabled servers.
|
||||||
|
* If provided (even empty array), only checks enabled servers.
|
||||||
|
* If undefined, checks all servers with successful health checks.
|
||||||
|
*/
|
||||||
|
hasPromptsCapability(perChatOverrides?: McpServerOverride[]): boolean {
|
||||||
|
// If perChatOverrides is provided (even empty array), filter by enabled servers
|
||||||
|
if (perChatOverrides !== undefined) {
|
||||||
|
const enabledServerIds = new Set(
|
||||||
|
perChatOverrides.filter((o) => o.enabled).map((o) => o.serverId)
|
||||||
|
);
|
||||||
|
// No enabled servers = no capability
|
||||||
|
if (enabledServerIds.size === 0) return false;
|
||||||
|
|
||||||
|
// Check health check states for enabled servers with prompts capability
|
||||||
|
for (const [serverId, state] of Object.entries(this._healthChecks)) {
|
||||||
|
if (!enabledServerIds.has(serverId)) continue;
|
||||||
|
if (
|
||||||
|
state.status === HealthCheckStatus.SUCCESS &&
|
||||||
|
state.capabilities?.server?.prompts !== undefined
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Also check active connections as fallback
|
||||||
|
for (const [serverName, connection] of this.connections) {
|
||||||
|
if (!enabledServerIds.has(serverName)) continue;
|
||||||
|
if (connection.serverCapabilities?.prompts) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No overrides provided - check all servers (global mode)
|
||||||
|
for (const state of Object.values(this._healthChecks)) {
|
||||||
|
if (
|
||||||
|
state.status === HealthCheckStatus.SUCCESS &&
|
||||||
|
state.capabilities?.server?.prompts !== undefined
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const connection of this.connections.values()) {
|
||||||
|
if (connection.serverCapabilities?.prompts) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
async getAllPrompts(): Promise<MCPPromptInfo[]> {
|
async getAllPrompts(): Promise<MCPPromptInfo[]> {
|
||||||
const results: MCPPromptInfo[] = [];
|
const results: MCPPromptInfo[] = [];
|
||||||
for (const [serverName, connection] of this.connections) {
|
for (const [serverName, connection] of this.connections) {
|
||||||
|
|
@ -953,9 +1007,40 @@ class MCPStore {
|
||||||
* Check if any enabled server with successful health check supports resources.
|
* Check if any enabled server with successful health check supports resources.
|
||||||
* Uses health check state since servers may not have active connections until
|
* Uses health check state since servers may not have active connections until
|
||||||
* the user actually sends a message or uses prompts.
|
* the user actually sends a message or uses prompts.
|
||||||
|
* @param perChatOverrides - Per-chat server overrides to filter by enabled servers.
|
||||||
|
* If provided (even empty array), only checks enabled servers.
|
||||||
|
* If undefined, checks all servers with successful health checks.
|
||||||
*/
|
*/
|
||||||
hasResourcesCapability(): boolean {
|
hasResourcesCapability(perChatOverrides?: McpServerOverride[]): boolean {
|
||||||
// Check health check states for servers with resources capability
|
// If perChatOverrides is provided (even empty array), filter by enabled servers
|
||||||
|
if (perChatOverrides !== undefined) {
|
||||||
|
const enabledServerIds = new Set(
|
||||||
|
perChatOverrides.filter((o) => o.enabled).map((o) => o.serverId)
|
||||||
|
);
|
||||||
|
// No enabled servers = no capability
|
||||||
|
if (enabledServerIds.size === 0) return false;
|
||||||
|
|
||||||
|
// Check health check states for enabled servers with resources capability
|
||||||
|
for (const [serverId, state] of Object.entries(this._healthChecks)) {
|
||||||
|
if (!enabledServerIds.has(serverId)) continue;
|
||||||
|
if (
|
||||||
|
state.status === HealthCheckStatus.SUCCESS &&
|
||||||
|
state.capabilities?.server?.resources !== undefined
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Also check active connections as fallback
|
||||||
|
for (const [serverName, connection] of this.connections) {
|
||||||
|
if (!enabledServerIds.has(serverName)) continue;
|
||||||
|
if (MCPService.supportsResources(connection)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No overrides provided - check all servers (global mode)
|
||||||
for (const state of Object.values(this._healthChecks)) {
|
for (const state of Object.values(this._healthChecks)) {
|
||||||
if (
|
if (
|
||||||
state.status === HealthCheckStatus.SUCCESS &&
|
state.status === HealthCheckStatus.SUCCESS &&
|
||||||
|
|
@ -964,7 +1049,6 @@ class MCPStore {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Also check active connections as fallback
|
|
||||||
for (const connection of this.connections.values()) {
|
for (const connection of this.connections.values()) {
|
||||||
if (MCPService.supportsResources(connection)) {
|
if (MCPService.supportsResources(connection)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue