| Crates.io | mxpnexus-core |
| lib.rs | mxpnexus-core |
| version | 0.1.1 |
| created_at | 2025-11-23 12:36:10.943522+00 |
| updated_at | 2025-11-23 12:51:30.440278+00 |
| description | Shared business logic for MXP Nexus platform |
| homepage | |
| repository | https://github.com/yafatek/mxpnexus-core |
| max_upload_size | |
| id | 1946461 |
| size | 130,595 |
Shared business logic library for the MXP Nexus platform.
This library provides common functionality used by both the CLI tool (mxpnexus-cli) and HTTP API server (mxpnexus-api):
Add to your Cargo.toml:
[dependencies]
mxpnexus-core = "0.1.1"
use mxpnexus_core::{agent, registry, RegistryClient};
use mxpnexus_core::models::{AgentGenerateOptions, AgentBundleOptions, AgentDeployOptions};
use tokio::runtime::Runtime;
fn main() -> mxpnexus_core::Result<()> {
let rt = Runtime::new()?;
rt.block_on(async move {
// Registry queries
let agents = registry::list_agents(None).await?;
println!("Found {} agents", agents.len());
// Agent scaffolding
let project_dir = agent::generate(&AgentGenerateOptions { name: "demo-agent".into() }).await?;
println!("Generated project at {project_dir}");
// Bundle + deploy
agent::bundle(&AgentBundleOptions::default()).await?;
agent::deploy(&AgentDeployOptions::default()).await?;
Ok(())
})
}
use mxpnexus_core::{registry, RegistryClient};
#[tokio::main]
async fn main() -> mxpnexus_core::Result<()> {
// Use the global convenience API (reads MXPNEXUS_REGISTRY_ADDR)
let online = registry::list_agents(Some("agent.*")).await?;
println!("{} agents are online", online.len());
// Or manage your own client with a custom timeout
let client = RegistryClient::new("127.0.0.1:9000", Some(std::time::Duration::from_secs(2)))?;
let agent = client.get_agent("demo-agent")?;
println!("agent '{}' is {}", agent.name, agent.status as u8);
Ok(())
}
agent - Agent lifecycle operations (generate, bundle, deploy, status, logs, delete)agent::kind - Kind-specific helpers (image loading, kubectl invocations, deployment records)registry - Async-friendly MXP discovery client + RegistryClientstack - Stack management operations (start/status/stop local Kind + registry + Redis)models - Shared models used across CLI/API/coreerror - Unified error type + helper constructorsThe registry helpers honour the following environment variables:
| Variable | Default | Description |
|---|---|---|
MXPNEXUS_REGISTRY_ADDR |
127.0.0.1:9000 |
UDP endpoint for the registry MXP listener |
MXPNEXUS_REGISTRY_TIMEOUT_MS |
5000 |
Per-attempt MXP request timeout (in milliseconds) |
MXPNEXUS_REGISTRY_BIN |
mxpnexus-registry in PATH |
Override registry binary path |
MXPNEXUS_REGISTRY_ENABLE_API |
false |
Start the embedded HTTP API alongside the MXP listener |
MXPNEXUS_REDIS_PORT |
6379 |
Redis TCP port (auto-detected if already running) |
MXPNEXUS_REDIS_BIN |
system redis-server |
Override Redis binary path |
MXPNEXUS_SKIP_KIND |
false |
Skip Kind provisioning when running the local stack |
Agent generation/deployment inherits the standard MXP agent variables (MXP_AGENT_NAME, MXP_AGENT_CAPABILITIES, etc.) and persists deployment metadata under ~/.mxp/deployments/kind/.
use mxpnexus_core::{stack, Result};
#[tokio::main]
async fn main() -> Result<()> {
let status = stack::start(None, None, None, true).await?;
println!(
"Registry {}, Redis {}",
status.registry.address, status.redis.address
);
// ... run integration tests ...
stack::stop().await
}
cargo fmt, cargo clippy -p mxpnexus-core --all-targets -- -D warnings, cargo test -p mxpnexus-core).version in Cargo.toml.git tag v0.x.y && git push origin --tags).CARGO_REGISTRY_TOKEN secret) or run cargo publish locally.cargo build
cargo test
cargo clippy --all -- -D warnings
Dual-licensed under MIT OR Apache-2.0.