| Crates.io | solana_ai_registries |
| lib.rs | solana_ai_registries |
| version | 0.1.0 |
| created_at | 2025-06-26 17:14:02.246959+00 |
| updated_at | 2025-06-26 17:14:02.246959+00 |
| description | Rust SDK for Solana AI Registries - Agent and MCP Server registries |
| homepage | https://github.com/openSVM/aeamcp |
| repository | https://github.com/openSVM/aeamcp |
| max_upload_size | |
| id | 1727574 |
| size | 382,908 |
A comprehensive Rust SDK for interacting with the Solana AI Registries, providing type-safe access to Agent Registry and MCP Server Registry protocols.
Add this to your Cargo.toml:
[dependencies]
solana_ai_registries = "0.1.0"
# Enable specific payment features as needed
[features]
default = []
pyg = ["solana_ai_registries/pyg"] # Pay-as-you-go payments
prepay = ["solana_ai_registries/prepay"] # Prepaid account management
stream = ["solana_ai_registries/stream"] # Streaming payments
use solana_ai_registries::{SolanaAiRegistriesClient, AgentBuilder};
use solana_sdk::signer::keypair::Keypair;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client
let client = SolanaAiRegistriesClient::new("https://api.devnet.solana.com");
let keypair = Keypair::new();
// Build agent configuration
let agent = AgentBuilder::new("my-agent-id", "My AI Agent")
.description("An AI agent that provides helpful services")
.version("1.0.0")
.add_service_endpoint("http", "https://my-agent.com/api", true)?
.add_skill("coding", "Code Generation", vec!["rust", "python"])?
.tags(vec!["ai", "assistant"])
.build()?;
// Register agent
let signature = client.register_agent(&keypair, agent).await?;
println!("Agent registered: {}", signature);
Ok(())
}
use solana_ai_registries::{SolanaAiRegistriesClient, mcp::McpServerBuilder};
use solana_sdk::signer::keypair::Keypair;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = SolanaAiRegistriesClient::new("https://api.devnet.solana.com");
let keypair = Keypair::new();
// Build MCP server configuration
let server = McpServerBuilder::new(
"my-mcp-server",
"My MCP Server",
"https://my-server.com/mcp"
)
.version("1.0.0")
.supports_tools(true)
.supports_resources(true)
.add_tool("search", vec!["query", "web"])?
.add_resource("documents/*", vec!["pdf", "text"])?
.tags(vec!["search", "documents"])
.build()?;
// Register MCP server
let signature = client.register_mcp_server(&keypair, server).await?;
println!("MCP server registered: {}", signature);
Ok(())
}
pyg feature)#[cfg(feature = "pyg")]
use solana_ai_registries::payments::pyg::{PygPaymentClient, estimate_pyg_cost};
#[cfg(feature = "pyg")]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = PygPaymentClient::new("https://api.devnet.solana.com");
let payer = Keypair::new();
let service_provider = Pubkey::new_unique();
let token_mint = get_token_mint_for_network(false)?; // devnet
// Estimate cost for agent service with priority fee
let estimate = estimate_pyg_cost(
convert_a2ampl_to_base_units(2.0), // 2 A2AMPL base fee
Some(150), // 1.5x priority multiplier
Some(10000), // 10K compute units
Some(100) // 100 lamports per CU
)?;
println!("Estimated cost: {:.4} A2AMPL", estimate.to_a2ampl().total_cost);
// Make payment
let result = client.pay_agent_service(
&payer,
&service_provider,
&token_mint,
estimate.total_cost,
Some(10000)
).await?;
println!("Payment successful: {}", result.signature);
Ok(())
}
The SDK uses feature flags to enable different payment systems:
pyg: Pay-as-you-go payments with compute unit budgetsprepay: Prepaid account management with balance trackingstream: Streaming payments over timeThe SDK provides comprehensive error handling that mirrors the on-chain program errors:
use solana_ai_registries::{AgentBuilder, SdkError};
let result = AgentBuilder::new("", "Valid Name").build();
match result {
Ok(agent) => println!("Agent created successfully"),
Err(SdkError::InvalidAgentIdLength) => println!("Agent ID cannot be empty"),
Err(e) => println!("Other error: {}", e),
}
Run tests with different feature combinations:
# Test core functionality only
cargo test --no-default-features
# Test with specific payment features
cargo test --features pyg
cargo test --features prepay
cargo test --features stream
# Test all features
cargo test --all-features
The test suite includes:
SolanaAiRegistriesClient: Main RPC client for interacting with registriesAgentBuilder: Type-safe agent configuration builderMcpServerBuilder: Type-safe MCP server configuration builderThe SDK integrates with on-chain Solana programs:
All interactions are fully typed with compile-time validation:
The SDK enforces all on-chain program limits:
use solana_ai_registries::agent::*;
const MAX_AGENT_ID_LEN: usize = 64;
const MAX_AGENT_NAME_LEN: usize = 128;
const MAX_SERVICE_ENDPOINTS: usize = 3;
const MAX_SKILLS: usize = 10;
// ... and many more
See the tests/ directory for comprehensive examples:
agent_flow.rs: 26 test cases covering all agent operationspayment_pyg.rs: Payment system examples with compute unit budgetsThis SDK follows the requirements specified in the SDK Roadmap. When contributing:
This project includes automated GitHub Actions workflows for publishing to crates.io:
The SDK is automatically published to crates.io when:
sdk/rust/v* is pushed (e.g., sdk/rust/v0.1.0, sdk/rust/v1.2.0)To enable automatic publishing, repository maintainers need to:
Create a crates.io API token:
solana_ai_registries crateAdd the token as a GitHub secret:
CARGO_API_KEYFor manual publishing during development:
# Navigate to the rust directory
cd rust
# Test the package
cargo test --all-features
# Build and package
cargo package
# Publish to crates.io (requires CARGO_API_KEY environment variable)
cargo publish
The project includes two workflows:
rust-ci.yml: Runs on PRs and pushes to test the SDKpublish-rust-sdk.yml: Publishes to crates.io on releases/tagsBoth workflows test all feature flag combinations to ensure reliability.
This project is licensed under the MIT OR Apache-2.0 license.