We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jmagar/homelab-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import type { DockerNetworkInfo, HostConfig } from "../../types.js";
import { narrowToDefaultHost } from "../../utils/host-utils.js";
import type { ClientManager } from "./utils/client-manager.js";
/**
* Service for Docker network operations.
* Handles network listing and management.
*/
export class NetworkService {
constructor(private clientManager: ClientManager) {}
/**
* List Docker networks across multiple hosts in parallel.
*
* @param hosts - List of Docker hosts to query
* @returns Promise resolving to array of network information
*/
async listNetworks(hosts: HostConfig[]): Promise<DockerNetworkInfo[]> {
const targetHosts = narrowToDefaultHost(hosts);
const results = await Promise.allSettled(
targetHosts.map((host) => this.listNetworksOnHost(host))
);
return results
.filter((r): r is PromiseFulfilledResult<DockerNetworkInfo[]> => r.status === "fulfilled")
.flatMap((r) => r.value);
}
/**
* List Docker networks from a single host (internal helper).
*/
private async listNetworksOnHost(host: HostConfig): Promise<DockerNetworkInfo[]> {
const docker = await this.clientManager.getClient(host);
const networks = await docker.listNetworks();
return networks.map((network) => ({
id: network.Id,
name: network.Name,
driver: network.Driver,
scope: network.Scope,
created: network.Created,
internal: network.Internal,
attachable: network.Attachable,
ingress: network.Ingress,
hostName: host.name,
}));
}
}