A Model Context Protocol (MCP) server that provides seamless integration with Ubuntu MAAS (Metal as a Service) for zero-touch provisioning of machines and virtual hosts. This server enables AI-powered automation of infrastructure management through comprehensive tools for machines, VM hosts, networking, and templated deployments.
- Machine Management: Commission, deploy, test, and manage physical machines in your MAAS environment
- VM Host Operations: List VM hosts, query details, and compose new virtual machines with custom specifications
- Power Management: Query and control machine power states
- Template-Based Deployments: Create and manage Cloud-Init deployment templates (K3s, K8s, nginx, and custom)
- Network Infrastructure: Manage fabrics, VLANs, subnets, and IP address ranges
- Machine Tagging: Create, update, and query machine tags for organization and filtering
- OAuth 1.0 Authentication: Secure communication with MAAS API using OAuth 1.0 with PLAINTEXT signature
- Multiple Transport Modes: Support for stdio, HTTP, and SSE transport protocols
- Structured Logging: Comprehensive logging with Zap logger for monitoring and debugging
- Multi-Platform Support: Pre-built binaries for Windows, Linux, and macOS (both amd64 and ARM64)
- Docker Support: Official Docker images for containerized deployments
- Go 1.23.3 or later
- Ubuntu MAAS instance with API access
- Valid MAAS API credentials
- Clone the repository:
git clone https://github.com/JarcauCristian/ztp-mcp.git
cd ztp-mcp- Install dependencies:
go mod tidy- Build the project:
go build -o ztp-mcp cmd/main.goSet the following environment variables:
# Required: MAAS configuration
export MAAS_BASE_URL="https://your-maas-server.com"
export MAAS_API_KEY="consumer_key:token:secret"
# Optional: MCP server configuration
export MCP_TRANSPORT="stdio" # Options: stdio, http, sse
export MCP_ADDRESS=":8080" # Required for http/sse modesThe MAAS_API_KEY must be in the format: consumer_key:token:secret
You can obtain your MAAS API key from your MAAS web interface under your user preferences.
./ztp-mcpexport MCP_TRANSPORT=http
export MCP_ADDRESS=":8080"
./ztp-mcpexport MCP_TRANSPORT=sse
export MCP_ADDRESS=":8080"
./ztp-mcpList all available machines in the MAAS environment, with optional filtering by status.
Parameters:
status(optional): Filter machines by status. Options:new,commissioning,failed_commissioning,readydeploying,deployed,releasing,failed_deploymentallocated,retired,broken,recommissioningtesting,failed_testing,rescuing,disk_erasing,failed_disk_erasing
Returns: JSON array of machine objects (protected machines are automatically filtered out)
Get detailed information about a specific machine by its ID.
Parameters:
id(required): The machine system ID (6 alphanumeric characters, e.g., "abc123")
Returns: Detailed machine object or empty if protected
Start the commissioning process on a machine to prepare it for deployment.
Parameters:
id(required): The machine system ID
Returns: Updated machine object with commissioning status
Deploy a machine using a specified Cloud-Init template with custom parameters.
Parameters:
machineId(required): The machine system IDtemplateId(required): The ID of the deployment template (e.g., "cpu_k3s_deployment", "cpu_k8s_deployment", "nginx_server")templateParameters(required): JSON object with template-specific parameters. Use{}for templates with no parameters
Returns: Deployment result with machine configuration
Run testing scripts on a machine to validate hardware and software.
Parameters:
system_id(required): The machine system IDenable_ssh(optional): Enable SSH for testing environment (true/false)parameters(optional): Custom parameters for test scriptstesting_scripts(optional): Comma-separated list of test script names/tags to run
Returns: Testing result and status
Query the current power state of a machine.
Parameters:
id(required): The machine system ID
Returns: Current power state (on/off)
Change the power state of a machine.
Parameters:
id(required): The machine system IDstate(required): Boolean - true to power on, false to power off
Returns: Updated power state
Retrieve all VM hosts available in the MAAS environment.
Returns: JSON array of all VM host objects with capabilities and utilization
Get detailed information about a specific VM host.
Parameters:
id(required): The numeric ID of the VM host
Returns: Detailed VM host object
Create a new virtual machine on a specified VM host.
Parameters:
id(required): ID of the VM hostcores(required): Number of CPU cores for the VMmemory(required): RAM allocation in MiBstorage(required): Storage allocation in GBhostname(required): Name for the new VM (alphanumeric, dots, and hyphens allowed)
Returns: New VM object with configuration details
List all available deployment templates.
Parameters:
only_ids(optional): If true, return only template IDs; if false, return full descriptions
Returns: Array of template IDs or template descriptions with metadata
Get detailed information about a specific template.
Parameters:
id(required): The template ID
Returns: Template description including parameters and requirements
Get the full content (Cloud-Init configuration) of a template.
Parameters:
id(required): The template ID
Returns: Template file content (YAML/Cloud-Init format)
Create a new deployment template with custom Cloud-Init configuration.
Parameters:
- Input schema:
GenericTemplateobject with:id(required): Unique template identifierdescription(required): Template description and use casetemplate_yaml(required): Cloud-Init YAML template content- Additional metadata fields
Returns: Confirmation of template creation
Delete an existing deployment template.
Parameters:
id(required): The template ID to delete
Returns: Confirmation of deletion
List all available machine tags.
Returns: Array of all tag objects with names and descriptions
Create a new machine tag for organizing and filtering machines.
Parameters:
name(required): Tag name (unique identifier)comment(required): Description of the tag's purposedefinition(optional): XPATH query for automatic tag assignment based on hardware detailskernel_opts(optional): Kernel options to apply to machines with this tag
Returns: Created tag object
Get detailed information about a specific tag.
Parameters:
name(required): The tag name
Returns: Tag object with definition and associated machines
Modify an existing tag's properties.
Parameters:
name(required): The current tag namenew_name(optional): New tag namecomment(optional): Updated descriptiondefinition(optional): Updated XPATH definition
Returns: Updated tag object
Delete a machine tag.
Parameters:
name(required): The tag name to delete
Returns: Deletion confirmation
List all machines/resources of a specific type that have a given tag.
Parameters:
name(required): The tag nametype(required): Resource type -nodes,devices,machines,rack_controllers, orregion_controllers
Returns: Array of resources with the specified tag
List all subnets in the MAAS environment.
Returns: Array of all subnet objects with configuration
Create a new subnet for network provisioning.
Parameters:
cidr(required): Network CIDR notation (e.g., "192.168.1.0/24")name(optional): Human-readable subnet namedescription(optional): Subnet descriptionvlan(optional): VLAN this subnet belongs tofabric(optional): Fabric for the subnetvid(optional): VLAN IDspace(optional): Address spacegateway_ip(optional): Gateway IP addressdns_servers(optional): Comma-separated DNS serversmanaged(optional): Whether MAAS manages DHCP/DNS (default: true)
Returns: Created subnet object
Get detailed information about a specific subnet.
Parameters:
id(required): The subnet ID
Returns: Subnet object with full configuration
Modify subnet configuration.
Parameters:
id(required): The subnet IDcidr,name,description,gateway_ip,dns_servers, etc. (optional): Fields to updatemanaged,allow_dns,allow_proxy(optional): Boolean configuration optionsrdns_mode(optional): Reverse DNS mode (0=Disabled, 1=Enabled, 2=RFC2317)
Returns: Updated subnet object
Delete a subnet.
Parameters:
id(required): The subnet ID
Returns: Deletion confirmation
Get summary of IP addresses assigned to a subnet.
Parameters:
id(required): The subnet IDwith_username(optional): Include associated usernames (default: true)with_summary(optional): Include node/BMC/DNS summaries (default: true)
Returns: IP address usage summary
Get detailed statistics about subnet IP usage.
Parameters:
id(required): The subnet IDinclude_ranges(optional): Include detailed range information (default: false)include_suggestions(optional): Include suggested gateway and ranges (default: false)
Returns: Subnet statistics with usage information
List IP ranges currently reserved in a subnet.
Parameters:
id(required): The subnet ID
Returns: Array of reserved IP ranges
List IP ranges currently unreserved in a subnet.
Parameters:
id(required): The subnet ID
Returns: Array of unreserved IP ranges
List all network fabrics in the MAAS environment.
Returns: Array of all fabric objects
Create a new network fabric.
Parameters:
name(optional): Fabric namedescription(optional): Fabric descriptionclass_type(optional): Fabric class type
Returns: Created fabric object
List all VLANs in a specific fabric.
Parameters:
fabric_id(required): The fabric ID to list VLANs from
Returns: Array of VLAN objects for the fabric
Create a new VLAN on a fabric.
Parameters:
fabric_id(required): The fabric IDvid(required): VLAN ID (numeric)name(optional): VLAN namedescription(optional): VLAN description
Returns: Created VLAN object
ztp-mcp/
βββ .github/
β βββ workflows/
β βββ go.yaml # CI/CD pipeline configuration
βββ cmd/
β βββ main.go # Application entry point
βββ internal/
β βββ server/
β βββ maas_client/
β β βββ maas-client.go # MAAS API client with OAuth 1.0 support
β βββ middleware/
β β βββ middleware.go # HTTP middleware (logging, auth)
β βββ parser/
β β βββ parse.go # URI parsing utilities
β βββ registry/
β β βββ registry.go # Registry pattern for tool registration
β βββ templates/
β β βββ cpu_k3s_deployment/
β β β βββ description.json
β β β βββ template.yaml
β β βββ cpu_k8s_deployment/
β β β βββ description.json
β β β βββ template.yaml
β β βββ nginx_server/
β β β βββ description.json
β β β βββ template.yaml
β β βββ template/ # Template scaffolding
β β βββ executor.go # Template execution engine
β β βββ template.go # Single template operations
β β βββ templates.go # Template management
β βββ tools/
β βββ fabrics/ # Fabric management tools
β βββ node_scripts/ # Node script management tools
β βββ subnets/ # Subnet management tools
β βββ tags/ # Machine tag tools
β βββ vlans/ # VLAN management tools
β βββ tool.go # MCP tool interface definition
β βββ machines.go # Machine management tools
β βββ power.go # Power state management tools
β βββ templates.go # Template deployment tools
β βββ vm-hosts.go # VM host management tools
βββ go.mod # Go module definition
βββ go.sum # Go module checksums
βββ LICENSE # MIT License
βββ README.md # This file
βββ AGENTS.md # Development guidelines for AI agents
- Uses OAuth 1.0 with PLAINTEXT signature method for MAAS API authentication
- Secure credential management through environment variables
- Request timeouts and proper error handling
- No sensitive data stored in code or logs
- Security scanning with Trivy in CI/CD pipeline
- Vulnerability detection for high and critical severity issues
Build the project for your local system:
go build -o ztp-mcp ./cmd/main.goFor optimized release builds:
CGO_ENABLED=0 go build -ldflags="-s -w" -o ztp-mcp ./cmd/main.goThe CI/CD pipeline automatically builds releases for multiple platforms when you push a version tag (e.g., v1.0.0):
- Windows: amd64, arm64
- Linux: amd64, arm64
- macOS: amd64 (Intel), arm64 (Apple Silicon)
Pre-built binaries are available in GitHub Releases.
# Download from releases
# Example for Linux x64
wget https://github.com/JarcauCristian/ztp-mcp/releases/download/v1.0.0/ztp-mcp-v1.0.0-linux-amd64.tar.gz
tar xzf ztp-mcp-v1.0.0-linux-amd64.tar.gz
chmod +x ztp-mcp-linux-amd64
./ztp-mcp-linux-amd64Run the server in a Docker container:
docker run -e MAAS_BASE_URL="https://your-maas-server.com" \
-e MAAS_API_KEY="consumer_key:token:secret" \
-e MCP_TRANSPORT="stdio" \
ghcr.io/JarcauCristian/ztp-mcp:latestCreate a docker-compose.yml:
version: '3.8'
services:
ztp-mcp:
image: ghcr.io/JarcauCristian/ztp-mcp:latest
environment:
- MAAS_BASE_URL=https://your-maas-server.com
- MAAS_API_KEY=consumer_key:token:secret
- MCP_TRANSPORT=http
- MCP_ADDRESS=:8080
ports:
- "8080:8080"
restart: unless-stoppedThen start the service:
docker-compose up -dBuild a Docker image from the source:
docker build -t ztp-mcp:latest .
docker run -e MAAS_BASE_URL="https://your-maas-server.com" \
-e MAAS_API_KEY="consumer_key:token:secret" \
ztp-mcp:latestOfficial container images are published to GitHub Container Registry (GHCR):
ghcr.io/JarcauCristian/ztp-mcp:latest # Latest version
ghcr.io/JarcauCristian/ztp-mcp:v1.0.0 # Specific version
ghcr.io/JarcauCristian/ztp-mcp:1.0 # Latest patch for minor version
ghcr.io/JarcauCristian/ztp-mcp:1 # Latest patch for major version
Supports multi-platform images for:
linux/amd64linux/arm64
All tools return responses in the following JSON structure:
{
"Body": "response_content",
"StatusCode": 200,
"Headers": {
"Content-Type": ["application/json"],
"..."
}
}Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Follow the code style guidelines in AGENTS.md
- Ensure all tests pass and code is properly formatted
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For development guidelines, testing commands, and code style requirements, please refer to AGENTS.md.
This project is licensed under the MIT License - see the LICENSE file for details.
- Authentication Errors: Verify your
MAAS_API_KEYformat and credentials - Connection Issues: Check your
MAAS_BASE_URLand network connectivity - Permission Errors: Ensure your MAAS user has appropriate permissions for the operations you're trying to perform
The server uses structured logging with different log levels. Set the log level using:
export LOG_LEVEL=debug # Options: debug, info, warn, errorFor issues and questions:
- Create an issue in this repository
- Check existing issues for similar problems
- Provide logs and configuration details when reporting bugs