Skip to content

privsim/rust-repl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Rust MCP REPL Server

A REPL (Read-Eval-Print Loop) server implementation in Rust that provides an interactive shell environment with variable management capabilities.

Features

  • TCP-based REPL server
  • Variable storage and retrieval
  • Extensible command system
  • Async/await support with Tokio
  • Thread-safe state management

Prerequisites

  • Rust (latest stable version)
  • Cargo (Rust's package manager)

Installation

  1. Clone the repository
  2. Navigate to the project directory
  3. Build the project:
cargo build

Running the Server

Start the server using cargo:

cargo run

The server will start listening on 127.0.0.1:8080.

Connecting to the Server

You can connect to the server using any TCP client. For example, using netcat:

nc localhost 8080

Available Commands

The REPL supports the following commands:

set <key> <value>

Store a variable with the specified key and value.

Example:

mcp> set name John
Variable name set to John

get <key>

Retrieve the value of a stored variable.

Example:

mcp> get name
John

execute <args...>

Execute a model with the specified arguments.

Example:

mcp> execute model1 param1 param2
Executing model with args: ["model1", "param1", "param2"]

Architecture

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 connections
  • ReplState: Thread-safe state management using Arc and RwLock
  • Shell: Command processing and execution

Configuration

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.

Error Handling

The server provides informative error messages for:

  • Invalid command syntax
  • Uninitialized shell
  • Connection issues
  • Command execution failures

Development

To run tests:

cargo test

To run with debug logging:

RUST_LOG=debug cargo run

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages