Skip to main content
Glama
vespo92

TrueNAS Core MCP Server

list_datasets

Retrieve a list of all datasets on TrueNAS Core systems using the MCP server, enabling efficient storage management and organization.

Instructions

List all datasets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the core logic of the 'list_datasets' tool. It retrieves datasets from the TrueNAS API endpoint '/pool/dataset', processes and formats the data (including size formatting, property extraction), organizes datasets by pool, and returns a structured response with success flag and metadata statistics.
    @tool_handler
    async def list_datasets(self) -> Dict[str, Any]:
        """
        List all datasets
        
        Returns:
            Dictionary containing list of datasets
        """
        await self.ensure_initialized()
        
        datasets = await self.client.get("/pool/dataset")
        
        dataset_list = []
        for ds in datasets:
            # Calculate usage
            used = ds.get("used", {}).get("parsed") if isinstance(ds.get("used"), dict) else ds.get("used", 0)
            available = ds.get("available", {}).get("parsed") if isinstance(ds.get("available"), dict) else ds.get("available", 0)
            
            dataset_info = {
                "name": ds.get("name"),
                "pool": ds.get("pool"),
                "type": ds.get("type"),
                "mountpoint": ds.get("mountpoint"),
                "compression": ds.get("compression", {}).get("value") if isinstance(ds.get("compression"), dict) else ds.get("compression"),
                "deduplication": ds.get("deduplication", {}).get("value") if isinstance(ds.get("deduplication"), dict) else ds.get("deduplication"),
                "encrypted": ds.get("encrypted"),
                "used": self.format_size(used) if isinstance(used, (int, float)) else str(used),
                "available": self.format_size(available) if isinstance(available, (int, float)) else str(available),
                "quota": ds.get("quota", {}).get("value") if isinstance(ds.get("quota"), dict) else ds.get("quota"),
                "children": ds.get("children", [])
            }
            dataset_list.append(dataset_info)
        
        # Organize by pool
        pools_datasets = {}
        for ds in dataset_list:
            pool = ds["pool"]
            if pool not in pools_datasets:
                pools_datasets[pool] = []
            pools_datasets[pool].append(ds)
        
        return {
            "success": True,
            "datasets": dataset_list,
            "metadata": {
                "total_datasets": len(dataset_list),
                "by_pool": {pool: len(datasets) for pool, datasets in pools_datasets.items()},
                "encrypted_datasets": sum(1 for ds in dataset_list if ds.get("encrypted")),
                "compressed_datasets": sum(1 for ds in dataset_list if ds.get("compression") and ds.get("compression") != "off")
            }
        }
  • The get_tool_definitions method in StorageTools class that registers all storage tools, including 'list_datasets' with description 'List all datasets' and empty input schema ({}). This method is called during server initialization to register tools with the MCP server.
    def get_tool_definitions(self) -> list:
        """Get tool definitions for storage management"""
        return [
            ("list_pools", self.list_pools, "List all storage pools", {}),
            ("get_pool_status", self.get_pool_status, "Get detailed status of a specific pool",
             {"pool_name": {"type": "string", "required": True}}),
            ("list_datasets", self.list_datasets, "List all datasets", {}),
            ("get_dataset", self.get_dataset, "Get detailed information about a dataset",
             {"dataset": {"type": "string", "required": True}}),
            ("create_dataset", self.create_dataset, "Create a new dataset",
             {"pool": {"type": "string", "required": True},
              "name": {"type": "string", "required": True},
              "compression": {"type": "string", "required": False},
              "quota": {"type": "string", "required": False},
              "recordsize": {"type": "string", "required": False}}),
            ("delete_dataset", self.delete_dataset, "Delete a dataset",
             {"dataset": {"type": "string", "required": True},
              "recursive": {"type": "boolean", "required": False}}),
            ("update_dataset", self.update_dataset, "Update dataset properties",
             {"dataset": {"type": "string", "required": True},
              "properties": {"type": "object", "required": True}}),
        ]
  • The _register_tool_methods method in TrueNASMCPServer that iterates over tool definitions from StorageTools (among others) and registers each tool with the MCP server using FastMCP.tool(), effectively registering 'list_datasets'.
    def _register_tool_methods(self, tool_instance):
        """Register individual tool methods from a tool instance"""
        # Get all methods that should be exposed as MCP tools
        tool_methods = tool_instance.get_tool_definitions()
        
        for method_name, method_func, method_description, method_params in tool_methods:
            # Register with MCP
            self.mcp.tool(name=method_name, description=method_description)(method_func)
            logger.debug(f"Registered tool: {method_name}")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'List all datasets' but doesn't reveal if this is a read-only operation, how results are returned (e.g., pagination, format), or any rate limits. This leaves gaps in understanding the tool's behavior beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence ('List all datasets') with zero waste. It's front-loaded and appropriately sized for a simple tool with no parameters, making it easy to scan and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (0 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks context on usage, behavior, or output format. For a list operation, more details on result handling would improve completeness, but it's not entirely incomplete for such a simple case.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so the schema fully documents the absence of inputs. The description adds no parameter details, which is acceptable here since there are no parameters to explain. A baseline of 4 is appropriate as the description doesn't need to compensate for any gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'List all datasets' clearly states the verb ('List') and resource ('datasets'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_pools' or 'list_smb_shares' beyond the resource name, nor does it specify scope (e.g., all datasets in a system vs. filtered).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_dataset_properties' for detailed info or 'list_pools' for related resources. It lacks context about prerequisites, such as whether authentication is needed or if it's for browsing vs. detailed queries.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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