A REPL (Read-Eval-Print Loop) server implementation in Rust that provides an interactive shell environment with variable management capabilities.
- TCP-based REPL server
- Variable storage and retrieval
- Extensible command system
- Async/await support with Tokio
- Thread-safe state management
- Rust (latest stable version)
- Cargo (Rust's package manager)
- Clone the repository
- Navigate to the project directory
- Build the project:
cargo buildStart the server using cargo:
cargo runThe server will start listening on 127.0.0.1:8080.
You can connect to the server using any TCP client. For example, using netcat:
nc localhost 8080The REPL supports the following commands:
Store a variable with the specified key and value.
Example:
mcp> set name John
Variable name set to John
Retrieve the value of a stored variable.
Example:
mcp> get name
John
Execute a model with the specified arguments.
Example:
mcp> execute model1 param1 param2
Executing model with args: ["model1", "param1", "param2"]
The server is built with a multi-threaded architecture using Tokio for async I/O operations. Key components include:
McpServer: Core server implementation handling TCP connectionsReplState: Thread-safe state management usingArcandRwLockShell: Command processing and execution
The server listens on 127.0.0.1:8080 by default. To modify this or other settings, update the corresponding values in src/server.rs.
The server provides informative error messages for:
- Invalid command syntax
- Uninitialized shell
- Connection issues
- Command execution failures
To run tests:
cargo testTo run with debug logging:
RUST_LOG=debug cargo run