MCP cover image
See in Github
2025-03-04

Eine einfache Blockchain-Implementierung in Rust mit SHA-256-Hashing, CLI-Schnittstelle und MCP-Server-Integration. Demonstriert Kernblockchain -Konzepte durch Blockerstellung und Kettenvalidierung, während Blockchain -Funktionen über einem Netzwerk freigesetzt werden.

1

Github Watches

1

Github Forks

0

Github Stars

Blockchain CLI in Rust

This repository contains a simple blockchain demonstration implemented in Rust. The project illustrates core Rust principles through a minimal command-line application and integrates an MCP server to expose blockchain functionalities over a network.

Overview

The application implements a basic blockchain where each block includes:

  • Index: The block's position in the chain.
  • Timestamp: The creation time in ISO 8601 format.
  • Data: User-supplied content.
  • Previous Hash: The SHA-256 hash of the previous block.
  • Current Hash: The SHA-256 hash computed from the block's contents.

A menu-driven CLI lets you:

  • Add a new block.
  • Print the current blockchain.
  • Validate the blockchain's integrity.

Technologies

  • Rust: A systems programming language focused on safety and performance.
  • sha2: For computing SHA-256 hashes.
  • chrono: For accurate timestamping using UTC time.
  • serde & serde_json: For JSON serialization (used in MCP communication).

Getting Started

Prerequisites

Build and Run

To create and run the project using Cargo, execute in your terminal:

cargo new blockchain_app
cd blockchain_app && cargo run

Note: If you cloned this repository, simply navigate into the project folder and run cargo run.

Usage

When you run the application, the CLI displays the following options:

  1. Add Block: Input data to create a new block.
  2. Print Blockchain: Display all blocks in the blockchain.
  3. Validate Blockchain: Verify that each block is properly linked.
  4. Exit: Close the application.

MCP Server Integration

The project includes an MCP server that runs concurrently with the CLI. It listens on 127.0.0.1:7878 and allows external clients to interact with the blockchain using JSON commands.

Available MCP Commands

  • latest_block: Retrieves the latest block in the blockchain.

    • Example:
      echo '{"command": "latest_block"}' | nc 127.0.0.1 7878
      
    • Sample Output:
      {"status":"ok","message":"Latest block retrieved","block":{"index":0,"timestamp":"2025-02-26T10:06:59.931506+00:00","data":"Genesis Block","previous_hash":"0","hash":"f465878acf7be88a124fd7ebc9a3640793612023828d9af8ad237eefd4a1a22e"}}
      
  • add_block: Adds a new block with the provided data.

    • Example:
      echo '{"command": "add_block", "data": "sample transaction"}' | nc 127.0.0.1 7878
      
    • Sample Output:
      {"status":"ok","message":"Block added","block":null}
      

Testing the MCP Server

  1. Run the Application:
    Open a terminal, navigate to the project directory (blockchain_app), and run:

    cargo run
    

    You will see the CLI menu and a message indicating that the MCP server is listening on 127.0.0.1:7878.

  2. Query from a Separate Terminal:
    Open a new terminal window and test the MCP commands using netcat (nc). For example:

    • To retrieve the latest block:
      echo '{"command": "latest_block"}' | nc 127.0.0.1 7878
      
    • To add a new block:
      echo '{"command": "add_block", "data": "sample transaction"}' | nc 127.0.0.1 7878
      

Note: The MCP server runs in a separate thread alongside the CLI, so ensure you use a different terminal window for these tests.

Summary

This project demonstrates how to combine blockchain logic with an externally accessible MCP server in Rust. It serves as a practical example for networked tool integration.

相关推荐

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Contraband Interactive
  • Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • rustassistant.com
  • Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • https://jgadvisorycpa.com
  • This GPT assists in finding a top-rated business CPA - local or virtual. We account for their qualifications, experience, testimonials and reviews. Business operators provide a short description of your business, services wanted, and city or state.

  • apappascs
  • Entdecken Sie die umfassendste und aktuellste Sammlung von MCP-Servern auf dem Markt. Dieses Repository dient als zentraler Hub und bietet einen umfangreichen Katalog von Open-Source- und Proprietary MCP-Servern mit Funktionen, Dokumentationslinks und Mitwirkenden.

  • Mintplex-Labs
  • Die All-in-One-Desktop & Docker-AI-Anwendung mit integriertem Lappen, AI-Agenten, No-Code-Agent Builder, MCP-Kompatibilität und vielem mehr.

  • modelcontextprotocol
  • Modellkontext -Protokollserver

  • n8n-io
  • Fair-Code-Workflow-Automatisierungsplattform mit nativen KI-Funktionen. Kombinieren Sie visuelles Gebäude mit benutzerdefiniertem Code, SelbstHost oder Cloud, 400+ Integrationen.

  • OffchainLabs
  • GO -Umsetzung des Ethereum -Beweises des Anteils

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llm 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Zusammenfassung der weltbesten LLM -Ressourcen.

  • wong2
  • Eine kuratierte Liste von Servern des Modellkontextprotokolls (MCP)

    Reviews

    3 (1)
    Avatar
    user_bweNrX59
    2025-04-16

    Mini-Blockchain by FaustoS88 is an outstanding blockchain implementation for educational purposes. It simplifies complex blockchain concepts and is perfect for those looking to grasp the basics. The detailed documentation and well-structured codebase make it accessible even to beginners. Highly recommend checking it out on GitHub!