Skip to main content
Glama
vespo92

TrueNAS Core MCP Server

get_user

Retrieve detailed user information, such as account settings and permissions, by specifying a username in the TrueNAS Core MCP Server environment.

Instructions

Get detailed information about a specific user

Args:
    username: Username to look up

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • Main execution logic for the 'get_user' tool: fetches all users from TrueNAS API, finds the matching user by username, formats detailed user information, and returns it in a standardized response.
    @tool_handler
    async def get_user(self, username: str) -> Dict[str, Any]:
        """
        Get detailed information about a specific user
        
        Args:
            username: Username to look up
            
        Returns:
            Dictionary containing user details
        """
        await self.ensure_initialized()
        
        # Get all users and find the specific one
        users = await self.client.get("/user")
        
        target_user = None
        for user in users:
            if user.get("username") == username:
                target_user = user
                break
        
        if not target_user:
            return {
                "success": False,
                "error": f"User '{username}' not found"
            }
        
        # Get additional user details if available
        user_details = {
            "id": target_user.get("id"),
            "username": target_user.get("username"),
            "full_name": target_user.get("full_name"),
            "email": target_user.get("email"),
            "uid": target_user.get("uid"),
            "gid": target_user.get("group", {}).get("gid") if isinstance(target_user.get("group"), dict) else None,
            "groups": target_user.get("groups", []),
            "shell": target_user.get("shell"),
            "home": target_user.get("home"),
            "locked": target_user.get("locked", False),
            "sudo": target_user.get("sudo", False),
            "builtin": target_user.get("builtin", False),
            "microsoft_account": target_user.get("microsoft_account", False),
            "attributes": target_user.get("attributes", {}),
            "sshpubkey": target_user.get("sshpubkey"),
            "created": target_user.get("created"),
            "modified": target_user.get("modified")
        }
        
        return {
            "success": True,
            "user": user_details
        }
  • Registers the 'get_user' tool in UserTools.get_tool_definitions(), including name, handler reference, description, and input schema.
    def get_tool_definitions(self) -> list:
        """Get tool definitions for user management"""
        return [
            ("list_users", self.list_users, "List all users in TrueNAS", {}),
            ("get_user", self.get_user, "Get detailed information about a specific user", 
             {"username": {"type": "string", "required": True}}),
            ("create_user", self.create_user, "Create a new user",
             {"username": {"type": "string", "required": True},
              "full_name": {"type": "string", "required": False},
              "email": {"type": "string", "required": False},
              "password": {"type": "string", "required": True},
              "shell": {"type": "string", "required": False},
              "home": {"type": "string", "required": False},
              "groups": {"type": "array", "required": False}}),
            ("update_user", self.update_user, "Update an existing user",
             {"username": {"type": "string", "required": True},
              "updates": {"type": "object", "required": True}}),
            ("delete_user", self.delete_user, "Delete a user",
             {"username": {"type": "string", "required": True}}),
        ]
  • Input schema definition for 'get_user' tool: requires 'username' as string.
    ("get_user", self.get_user, "Get detailed information about a specific user", 
     {"username": {"type": "string", "required": True}}),
  • Registers all tools from tool instances (including UserTools) by calling get_tool_definitions() and using FastMCP.tool() for each, including 'get_user'.
    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}")
  • Includes UserTools in the list of tool classes to instantiate and register.
    tool_classes = [
        UserTools,
        StorageTools,
        SharingTools,
        SnapshotTools
    ]

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