pub struct Config {
pub mcp_servers: HashMap<String, ServerConfig>,
}
Expand description
Main configuration for the MCP Runner.
This structure holds configurations for multiple MCP servers that can be managed by the runner. Each server has a unique name and its own configuration.
§JSON Schema
The configuration follows this JSON schema:
{
"mcpServers": {
"server1": {
"command": "node",
"args": ["server.js"],
"env": {
"PORT": "3000",
"DEBUG": "true"
}
},
"server2": {
"command": "python",
"args": ["-m", "mcp_server"],
"env": {}
}
}
}
§Examples
Loading a configuration from a file:
use mcp_runner::config::Config;
let config = Config::from_file("config.json").unwrap();
Accessing a server configuration:
use mcp_runner::config::{Config, ServerConfig};
if let Some(server_config) = config.mcp_servers.get("fetch") {
println!("Command: {}", server_config.command);
}
Fields§
§mcp_servers: HashMap<String, ServerConfig>
Map of server names to their configurations. The key is a unique identifier for each server.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Loads a configuration from a file path.
This method reads the file at the specified path and parses its contents as a JSON configuration.
§Arguments
path
- The path to the configuration file
§Returns
A Result<Config>
that contains the parsed configuration or an error
§Errors
Returns an error if:
- The file cannot be read
- The file contents are not valid JSON
- The JSON does not conform to the expected schema
Sourcepub fn parse_from_str(content: &str) -> Result<Self>
pub fn parse_from_str(content: &str) -> Result<Self>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more