mcp_execution_core/lib.rs
1//! Core types, traits, and errors for MCP Code Execution.
2//!
3//! This crate provides the foundational types and abstractions used across
4//! all other crates in the MCP execution workspace.
5//!
6//! # Architecture
7//!
8//! The core consists of:
9//! - Strong domain types (`ServerId`, `ToolName`)
10//! - Error hierarchy with contextual information
11//! - Server configuration with security validation
12//! - Command validation utilities
13//!
14//! # Examples
15//!
16//! ```
17//! use mcp_execution_core::{ServerConfig, ServerId};
18//!
19//! // Create a server configuration
20//! let config = ServerConfig::builder()
21//! .command("docker".to_string())
22//! .arg("run".to_string())
23//! .env("LOG_LEVEL".to_string(), "debug".to_string())
24//! .build()
25//! .unwrap();
26//!
27//! // Server ID
28//! let server_id = ServerId::new("github").unwrap();
29//! ```
30
31#![deny(unsafe_code)]
32#![warn(missing_docs, missing_debug_implementations)]
33
34mod command;
35mod error;
36mod path;
37mod redact;
38mod server_config;
39mod types;
40
41pub mod cli;
42pub mod metadata;
43pub mod untrusted;
44
45// Re-export error types
46pub use error::{Error, ResourceKind, Result};
47
48// Re-export domain types
49pub use types::{ServerId, ServerIdError, ToolName, ToolNameError};
50
51// Re-export server configuration types
52pub use server_config::{ServerConfig, ServerConfigBuilder, Transport};
53
54// Re-export command validation
55pub use command::{
56 MAX_ARG_COUNT, MAX_ARG_LEN, MAX_ENV_COUNT, MAX_ENV_VALUE_LEN, MAX_HEADER_COUNT,
57 MAX_HEADER_VALUE_LEN, MAX_URL_LEN, forbidden_chars, forbidden_env_names, forbidden_env_prefix,
58 validate_server_config, validate_url_scheme,
59};
60
61// Re-export path helpers shared by confinement checks
62pub use path::{contains_parent_dir, sanitize_path_for_error, validate_path_segment};
63
64// Re-export Debug-redaction helpers shared by secret-shaped fields
65pub use redact::{
66 REDACTED_PLACEHOLDER, RedactedItems, RedactedMapValues, RedactedUrl, redact_urls_in_text,
67};