Skip to main content

Crate mcp_execution_core

Crate mcp_execution_core 

Source
Expand description

Core types, traits, and errors for MCP Code Execution.

This crate provides the foundational types and abstractions used across all other crates in the MCP execution workspace.

§Architecture

The core consists of:

  • Strong domain types (ServerId, ToolName)
  • Error hierarchy with contextual information
  • Server configuration with security validation
  • Command validation utilities

§Examples

use mcp_execution_core::{ServerConfig, ServerId};

// Create a server configuration
let config = ServerConfig::builder()
    .command("docker".to_string())
    .arg("run".to_string())
    .env("LOG_LEVEL".to_string(), "debug".to_string())
    .build()
    .unwrap();

// Server ID
let server_id = ServerId::new("github").unwrap();

Modules§

cli
CLI-specific types and utilities.
metadata
Structured sidecar metadata describing a server’s generated tools.
untrusted
Helpers for safely embedding untrusted MCP-server-supplied metadata into Markdown documents and LLM-facing prompts.

Structs§

RedactedItems
Debug-formats a list of strings, replacing every entry wholesale with REDACTED_PLACEHOLDER.
RedactedMapValues
Debug-formats a String-valued map with keys visible and every value replaced by REDACTED_PLACEHOLDER.
RedactedUrl
Debug-formats a URL with userinfo credentials and query string hidden, keeping the scheme, host, and path readable.
ServerConfig
MCP server configuration with command, arguments, and environment.
ServerConfigBuilder
Builder for constructing ServerConfig instances.
ServerId
Server identifier (newtype over String).
ToolName
Tool name identifier (newtype over String).

Enums§

Error
Main error type for MCP Code Execution.
ResourceKind
Identifies which bounded resource a Error::ResourceLimitExceeded rejection concerns.
ServerIdError
Error returned when a candidate string fails the invariant ServerId::new enforces.
ToolNameError
Error returned when a candidate string fails the invariant ToolName::new enforces.
Transport
Transport-specific configuration for connecting to an MCP server.

Constants§

MAX_ARG_COUNT
Maximum number of positional arguments accepted in a ServerConfig (denial-of-service protection, CWE-400).
MAX_ARG_LEN
Maximum byte length for a single command string, argument, or environment variable name.
MAX_ENV_COUNT
Maximum number of environment variables accepted in a ServerConfig.
MAX_ENV_VALUE_LEN
Maximum byte length for a single environment variable value.
MAX_HEADER_COUNT
Maximum number of HTTP headers accepted for Http/Sse transport.
MAX_HEADER_VALUE_LEN
Maximum byte length for a single HTTP header value.
MAX_URL_LEN
Maximum byte length for the HTTP/Sse transport url.
REDACTED_PLACEHOLDER
Fixed placeholder substituted for every redacted value.

Functions§

contains_parent_dir
Returns true if path contains a .. (parent-directory) component.
forbidden_chars
Returns the shell metacharacters considered forbidden in a command or argument string.
forbidden_env_names
Returns the exact-match forbidden environment variable names.
forbidden_env_prefix
Returns the environment-variable-name prefix rejected regardless of exact match (currently DYLD_, macOS’s dynamic-linker variable family).
redact_urls_in_text
Finds every URL-shaped token in text and redacts each one.
sanitize_path_for_error
Sanitizes a file path for inclusion in an error message, to prevent information disclosure.
validate_path_segment
Validates that segment is a single plain path component: non-empty, and with no .., path separator, or root/prefix component.
validate_server_config
Validates a ServerConfig for safe execution, dispatching on transport type.
validate_url_scheme
Validates that a URL uses the http:// or https:// scheme.

Type Aliases§

Result
Result type alias for MCP operations.