| Crates.io | qudag-mcp |
| lib.rs | qudag-mcp |
| version | 0.5.0 |
| created_at | 2025-06-21 23:42:06.058777+00 |
| updated_at | 2025-06-23 20:57:34.783479+00 |
| description | Model Context Protocol (MCP) server for QuDAG - Integrates vault, exchange, and quantum-resistant operations |
| homepage | |
| repository | https://github.com/ruvnet/QuDAG |
| max_upload_size | |
| id | 1721179 |
| size | 1,109,481 |
QuDAG MCP Server is a Model Context Protocol (MCP) server implementation that provides secure, quantum-resistant access to QuDAG's distributed system capabilities.
Add this to your Cargo.toml:
[dependencies]
qudag-mcp = "1.0.0"
Or install via cargo:
cargo add qudag-mcp
use qudag_mcp::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create server configuration
let config = ServerConfig::new()
.with_server_info("My QuDAG MCP Server", "1.0.0")
.with_transport(transport::TransportFactory::stdio());
// Create and run the server
let mut server = QuDAGMCPServer::new(config).await?;
server.run().await?;
Ok(())
}
use qudag_mcp::*;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client configuration
let config = ClientConfig::new()
.with_client_info("My QuDAG MCP Client", "1.0.0")
.with_transport(transport::TransportFactory::stdio())
.with_timeout(Duration::from_secs(30));
// Create and connect the client
let mut client = QuDAGMCPClient::new(config).await?;
client.connect().await?;
// List available tools
let tools = client.list_tools().await?;
println!("Available tools: {}", tools.len());
// Execute a tool
let result = client.call_tool("dag_get_tips", None).await?;
println!("DAG tips: {:?}", result);
Ok(())
}
QuDAG MCP Server exposes QuDAG's capabilities through the standardized MCP protocol:
βββββββββββββββββββββββββββββββββββββββ
β MCP Clients β
β (Claude, IDEs, Applications) β
βββββββββββββββββββββββββββββββββββββββ€
β MCP Protocol Layer β
β (JSON-RPC 2.0 over stdio/ β
β HTTP/WebSocket) β
βββββββββββββββββββββββββββββββββββββββ€
β QuDAG MCP Server β
β β
β βββββββββββ βββββββββββ ββββββββββββ
β β DAG β β Crypto β β Network ββ
β β Tools β β Tools β β Tools ββ
β βββββββββββ βββββββββββ ββββββββββββ
β βββββββββββ βββββββββββ ββββββββββββ
β β DAG β β Crypto β β Vault ββ
β βResourcesβ βResourcesβ βResourcesββ
β βββββββββββ βββββββββββ ββββββββββββ
βββββββββββββββββββββββββββββββββββββββ€
β QuDAG Core System β
β (Consensus, Storage, Network) β
βββββββββββββββββββββββββββββββββββββββ
DAG Operations:
dag_add_vertex - Add new vertex to the DAGdag_get_vertex - Retrieve vertex informationdag_get_tips - Get current DAG tipsdag_get_order - Get total order of verticesdag_get_confidence - Get vertex confidence levelCryptographic Operations:
crypto_generate_keypair - Generate quantum-resistant key pairscrypto_sign - Digital signature creationcrypto_verify - Signature verificationcrypto_encrypt - Data encryption with ML-KEMcrypto_decrypt - Data decryptionNetwork Operations:
network_connect_peer - Connect to network peersnetwork_register_dark - Register dark addressesnetwork_resolve - Resolve network addressesnetwork_create_shadow - Create temporary shadow addressesVault Operations:
vault_add_secret - Store encrypted secretsvault_get_secret - Retrieve secretsvault_list_secrets - List available secretsvault_generate_password - Generate secure passwordsDAG Resources:
dag://vertices/all - All DAG verticesdag://tips/current - Current tip verticesdag://consensus/status - Consensus statusdag://order/global - Global vertex orderingdag://stats/summary - DAG statisticsCrypto Resources:
crypto://algorithms/supported - Supported algorithmscrypto://keys/public - Public key informationcrypto://stats/performance - Performance metricsVault Resources:
vault://entries/count - Entry count statisticsvault://categories/list - Available categoriesvault://stats/usage - Usage statisticsvault://health/status - System healthNetwork Resources:
network://peers/connected - Connected peersnetwork://stats/traffic - Network trafficnetwork://routes/active - Active routesnetwork://dark/addresses - Dark addressesQuDAG MCP Server supports multiple transport mechanisms:
let config = ServerConfig::new()
.with_transport(transport::TransportFactory::stdio());
let config = ServerConfig::new()
.with_transport(transport::TransportFactory::http("http://localhost:8080"));
let config = ServerConfig::new()
.with_transport(transport::TransportFactory::websocket("ws://localhost:8080/mcp"));
# Basic server example
cargo run --example basic_server
# Vault integration example
cargo run --example with_vault
use qudag_mcp::*;
// Add a new vertex to the DAG
let args = serde_json::json!({
"id": "vertex_123",
"payload": "Important data",
"parents": ["parent_vertex_1", "parent_vertex_2"]
});
let result = client.call_tool("dag_add_vertex", Some(args)).await?;
// Generate quantum-resistant key pair
let args = serde_json::json!({
"algorithm": "ml-kem",
"security_level": 3
});
let keypair = client.call_tool("crypto_generate_keypair", Some(args)).await?;
// Sign data
let sign_args = serde_json::json!({
"data": base64::encode("Hello, QuDAG!"),
"private_key": keypair_result["private_key"]
});
let signature = client.call_tool("crypto_sign", Some(sign_args)).await?;
// Read DAG statistics
let dag_stats = client.read_resource("dag://stats/summary").await?;
// Read crypto algorithms
let algorithms = client.read_resource("crypto://algorithms/supported").await?;
// Read vault health
let vault_health = client.read_resource("vault://health/status").await?;
let config = ServerConfig::new()
.with_server_info("Production QuDAG Server", "1.0.0")
.with_transport(transport::TransportFactory::websocket("ws://0.0.0.0:8080/mcp"))
.with_log_level("info");
let config = ClientConfig::new()
.with_client_info("Production Client", "1.0.0")
.with_transport(transport::TransportFactory::websocket("ws://server:8080/mcp"))
.with_timeout(Duration::from_secs(60))
.with_capability("authentication", serde_json::json!({
"required": true,
"methods": ["oauth2", "api_key"]
}));
# Server configuration
QUDAG_MCP_LOG_LEVEL=info
QUDAG_MCP_SERVER_PORT=8080
QUDAG_MCP_TRANSPORT=websocket
# Client configuration
QUDAG_MCP_CLIENT_TIMEOUT=30
QUDAG_MCP_SERVER_URL=ws://localhost:8080/mcp
QuDAG MCP Server uses post-quantum cryptographic algorithms:
// Configure authentication
let mut capabilities = HashMap::new();
capabilities.insert("authentication".to_string(), serde_json::json!({
"required": true,
"methods": ["oauth2", "vault_token"],
"secure_channels_only": true
}));
let config = ClientConfig::new()
.with_capability("authentication", capabilities["authentication"].clone());
Always use secure transports in production:
// Use WSS for WebSocket
let config = ServerConfig::new()
.with_transport(transport::TransportFactory::websocket("wss://secure-server:443/mcp"));
// Use HTTPS for HTTP transport
let config = ServerConfig::new()
.with_transport(transport::TransportFactory::http("https://secure-server:443"));
Run performance benchmarks:
cargo bench
Typical performance characteristics:
Run the complete test suite:
# Unit and integration tests
cargo test
# Protocol compliance tests
cargo test --test protocol_tests
# Security tests
cargo test --test auth_tests
# Performance benchmarks
cargo bench
The library includes comprehensive tests:
git clone https://github.com/qudag/qudag.git
cd qudag/qudag-mcp
cargo build --release
# All tests
cargo test
# Specific test suites
cargo test --test integration_tests
cargo test --test protocol_tests
cargo test --test auth_tests
# With logging
RUST_LOG=debug cargo test
We welcome contributions! Please read our Contributing Guide for details on:
Connection Failures:
# Check if server is running
netstat -tlnp | grep 8080
# Test with telnet
telnet localhost 8080
Authentication Errors:
// Verify client capabilities
let capabilities = client.server_capabilities().await?;
println!("Server auth: {:?}", capabilities.experimental);
Performance Issues:
# Enable debug logging
RUST_LOG=qudag_mcp=debug cargo run
# Check system resources
htop
iostat -x 1
This project is licensed under either of
at your option.
Built with β€οΈ for the quantum-resistant future
π Star us on GitHub | π Read the Docs | π¬ Join Discussions