Download crates/forge_domain/src/mcp_servers.rs from SaylorTwift/forgecode: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_domain/src/mcp_servers.rs
- Command line
-
hf download hf://SaylorTwift/forgecode/crates/forge_domain/src/mcp_servers.rs
-
curl -L -o mcp_servers.rs https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_domain/src/mcp_servers.rs
1.54 kB
| use std::collections::{HashMap, hash_map}; | |
| use serde::{Deserialize, Serialize}; | |
| use crate::{ServerName, ToolDefinition}; | |
| /// Cache for MCP tool definitions | |
| /// | |
| /// Simplified cache structure that stores only the essential data. | |
| /// Validation and TTL checking are handled by the infrastructure layer | |
| /// using cacache's built-in metadata capabilities. | |
| pub struct McpServers { | |
| /// Successfully loaded MCP servers with their tools | |
| servers: HashMap<ServerName, Vec<ToolDefinition>>, | |
| /// Failed MCP servers with their error messages | |
| failures: HashMap<ServerName, String>, | |
| } | |
| impl McpServers { | |
| /// Create a new cache entry with servers and failures | |
| pub fn new( | |
| servers: HashMap<ServerName, Vec<ToolDefinition>>, | |
| failures: HashMap<ServerName, String>, | |
| ) -> Self { | |
| Self { servers, failures } | |
| } | |
| /// Get the successful servers | |
| pub fn get_servers(&self) -> &HashMap<ServerName, Vec<ToolDefinition>> { | |
| &self.servers | |
| } | |
| /// Get the failed servers | |
| pub fn get_failures(&self) -> &HashMap<ServerName, String> { | |
| &self.failures | |
| } | |
| } | |
| impl IntoIterator for McpServers { | |
| type Item = (ServerName, Vec<ToolDefinition>); | |
| type IntoIter = hash_map::IntoIter<ServerName, Vec<ToolDefinition>>; | |
| fn into_iter(self) -> Self::IntoIter { | |
| self.servers.into_iter() | |
| } | |
| } | |