Skip to main content
Glama
vespo92

TrueNAS Core MCP Server

create_nfs_export

Create an NFS export on TrueNAS Core for Kubernetes persistent volumes, specifying dataset, allowed networks, read-only access, and root user/group mapping.

Instructions

Create an NFS export for Kubernetes persistent volumes

Args:
    dataset: Dataset path to export (e.g., "tank/k8s-volumes")
    allowed_networks: List of allowed networks (e.g., ["10.0.0.0/24"])
    read_only: Whether the export is read-only
    maproot_user: User to map root to
    maproot_group: Group to map root to

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allowed_networksNo
datasetYes
maproot_groupNowheel
maproot_userNoroot
read_onlyNo

Implementation Reference

  • The @tool_handler decorated method that implements the core logic of the create_nfs_export tool. It normalizes the path, sets up export data with API calls to TrueNAS /sharing/nfs endpoint, handles defaults for networks/hosts, and returns structured response with mount example.
    @tool_handler
    async def create_nfs_export(
        self,
        path: str,
        allowed_networks: Optional[List[str]] = None,
        allowed_hosts: Optional[List[str]] = None,
        read_only: bool = False,
        maproot_user: str = "root",
        maproot_group: str = "wheel",
        alldirs: bool = False,
        comment: str = ""
    ) -> Dict[str, Any]:
        """
        Create an NFS export
        
        Args:
            path: Path to export (must exist)
            allowed_networks: List of allowed networks (e.g., ["10.0.0.0/24"])
            allowed_hosts: List of allowed hosts
            read_only: Whether export is read-only
            maproot_user: User to map root to
            maproot_group: Group to map root to
            alldirs: Allow mounting of subdirectories
            comment: Optional comment
            
        Returns:
            Dictionary containing created export information
        """
        await self.ensure_initialized()
        
        # Ensure path starts with /mnt/
        if not path.startswith("/mnt/"):
            path = f"/mnt/{path}"
        
        # Default to allow all if no restrictions specified
        if not allowed_networks and not allowed_hosts:
            allowed_networks = ["0.0.0.0/0"]
        
        export_data = {
            "path": path,
            "comment": comment,
            "ro": read_only,
            "maproot_user": maproot_user,
            "maproot_group": maproot_group,
            "alldirs": alldirs,
            "enabled": True
        }
        
        if allowed_networks:
            export_data["networks"] = allowed_networks
        if allowed_hosts:
            export_data["hosts"] = allowed_hosts
        
        created = await self.client.post("/sharing/nfs", export_data)
        
        # Generate example mount command
        server_ip = str(self.settings.truenas_url).replace("https://", "").replace("http://", "").split(":")[0]
        mount_example = f"mount -t nfs {server_ip}:{path} /local/mount/point"
        
        return {
            "success": True,
            "message": f"NFS export created for path '{path}'",
            "export": {
                "id": created.get("id"),
                "path": created.get("path"),
                "networks": created.get("networks", []),
                "enabled": created.get("enabled")
            },
            "mount_example": mount_example
        }
  • Registration of the create_nfs_export tool within SharingTools.get_tool_definitions() method, including the tool name, handler reference, description, and input schema.
    ("create_nfs_export", self.create_nfs_export, "Create an NFS export",
     {"path": {"type": "string", "required": True},
      "allowed_networks": {"type": "array", "required": False},
      "read_only": {"type": "boolean", "required": False},
      "maproot_user": {"type": "string", "required": False},
      "maproot_group": {"type": "string", "required": False}}),
  • Input schema definition for the create_nfs_export tool, specifying parameter types and requirements as part of the tool registration.
    {"path": {"type": "string", "required": True},
     "allowed_networks": {"type": "array", "required": False},
     "read_only": {"type": "boolean", "required": False},
     "maproot_user": {"type": "string", "required": False},
     "maproot_group": {"type": "string", "required": False}}),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vespo92/TrueNasCoreMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server