Skip to main content
Glama
blitzstermayank

Teradata MCP Server

sec_rolePermissions

Retrieve and analyze role permissions in Teradata databases to manage access control and security settings.

Instructions

Get permissions for a role.

Arguments: role_name - role name to analyze

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
role_nameYes

Implementation Reference

  • The handler function that implements the core logic of the 'sec_rolePermissions' tool. It executes a SQL query to fetch permissions for the given role from DBC.RoleMembers and DBC.AllRoleRights views, maps access rights to human-readable names, formats the results as JSON, and returns a response with metadata.
    def handle_sec_rolePermissions(conn: TeradataConnection, role_name: str, *args, **kwargs):
        """
        Get permissions for a role.
    
        Arguments:
          role_name - role name to analyze
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_sec_rolePermissions: Args: role_name: {role_name}")
    
        with conn.cursor() as cur:
            if role_name == "":
                logger.debug("No role_name argument provided")
                data = rows_to_json(None, [])
            else:
                logger.debug(f"Argument provided: {role_name}")
                rows = cur.execute(f"""
                    SELECT RN.Grantee
                        ,ARR.DatabaseName
                        ,ARR.AccessRight
                        ,CASE
                                WHEN ARR.AccessRight = 'AE' THEN 'ALTER EXTERNAL PROCEDURE'
                                WHEN ARR.AccessRight = 'AF' THEN 'ALTER FUNCTION'
                                WHEN ARR.AccessRight = 'AP' THEN 'ALTER PROCEDURE'
                                WHEN ARR.AccessRight = 'AS' THEN 'ABORT SESSION'
                                WHEN ARR.AccessRight = 'CA' THEN 'CREATE AUTHORIZATION'
                                WHEN ARR.AccessRight = 'CD' THEN 'CREATE DATABASE'
                                WHEN ARR.AccessRight = 'CE' THEN 'CREATE EXTERNAL PROCEDURE'
                                WHEN ARR.AccessRight = 'CF' THEN 'CREATE FUNCTION'
                                WHEN ARR.AccessRight = 'CG' THEN 'CREATE TRIGGER'
                                WHEN ARR.AccessRight = 'CM' THEN 'CREATE MACRO'
                                WHEN ARR.AccessRight = 'CO' THEN 'CREATE PROFILE'
                                WHEN ARR.AccessRight = 'CP' THEN 'CHECKPOINT'
                                WHEN ARR.AccessRight = 'CR' THEN 'CREATE ROLE'
                                WHEN ARR.AccessRight = 'CT' THEN 'CREATE TABLE'
                                WHEN ARR.AccessRight = 'CU' THEN 'CREATE USER'
                                WHEN ARR.AccessRight = 'CV' THEN 'CREATE VIEW'
                                WHEN ARR.AccessRight = 'D'  THEN 'DELETE'
                                WHEN ARR.AccessRight = 'DA' THEN 'DROP AUTHORIZATION'
                                WHEN ARR.AccessRight = 'DD' THEN 'DROP DATABASE'
                                WHEN ARR.AccessRight = 'DF' THEN 'DROP FUNCTION'
                                WHEN ARR.AccessRight = 'DG' THEN 'DROP TRIGGER'
                                WHEN ARR.AccessRight = 'DM' THEN 'DROP MACRO'
                                WHEN ARR.AccessRight = 'DO' THEN 'DROP PROFILE'
                                WHEN ARR.AccessRight = 'DP' THEN 'DUMP'
                                WHEN ARR.AccessRight = 'DR' THEN 'DROP ROLE'
                                WHEN ARR.AccessRight = 'DT' THEN 'DROP TABLE'
                                WHEN ARR.AccessRight = 'DU' THEN 'DROP USER'
                                WHEN ARR.AccessRight = 'DV' THEN 'DROP VIEW'
                                WHEN ARR.AccessRight = 'E'  THEN 'EXECUTE'
                                WHEN ARR.AccessRight = 'EF' THEN 'EXECUTE FUNCTION'
                                WHEN ARR.AccessRight = 'GC' THEN 'CREATE GLOP'
                                WHEN ARR.AccessRight = 'GD' THEN 'DROP GLOP'
                                WHEN ARR.AccessRight = 'GM' THEN 'GLOP MEMBER'
                                WHEN ARR.AccessRight = 'I'  THEN 'INSERT'
                                WHEN ARR.AccessRight = 'IX' THEN 'INDEX'
                                WHEN ARR.AccessRight = 'MR' THEN 'MONITOR RESOURCE'
                                WHEN ARR.AccessRight = 'MS' THEN 'MONITOR SESSION'
                                WHEN ARR.AccessRight = 'NT' THEN 'NONTEMPORAL'
                                WHEN ARR.AccessRight = 'OD' THEN 'OVERRIDE DELETE POLICY'
                                WHEN ARR.AccessRight = 'OI' THEN 'OVERRIDE INSERT POLICY'
                                WHEN ARR.AccessRight = 'OP' THEN 'CREATE OWNER PROCEDURE'
                                WHEN ARR.AccessRight = 'OS' THEN 'OVERRIDE SELECT POLICY'
                                WHEN ARR.AccessRight = 'OU' THEN 'OVERRIDE UPDATE POLICY'
                                WHEN ARR.AccessRight = 'PC' THEN 'CREATE PROCEDURE'
                                WHEN ARR.AccessRight = 'PD' THEN 'DROP PROCEDURE'
                                WHEN ARR.AccessRight = 'PE' THEN 'EXECUTE PROCEDURE'
                                WHEN ARR.AccessRight = 'R'  THEN 'SELECT'
                                WHEN ARR.AccessRight = 'RF' THEN 'REFERENCE'
                                WHEN ARR.AccessRight = 'RO' THEN 'REPLCONTROL'
                                WHEN ARR.AccessRight = 'RS' THEN 'RESTORE'
                                WHEN ARR.AccessRight = 'SA' THEN 'SECURITY CONSTRAINT ASSIGNMENT'
                                WHEN ARR.AccessRight = 'SD' THEN 'SECURITY CONSTRAINT DEFINITION'
                                WHEN ARR.AccessRight = 'SH' THEN 'SHOW'
                                WHEN ARR.AccessRight = 'SR' THEN 'SET RESOURCE RATE'
                                WHEN ARR.AccessRight = 'SS' THEN 'SET SESSION RATE'
                                WHEN ARR.AccessRight = 'ST' THEN 'STATISTICS'
                                WHEN ARR.AccessRight = 'TH' THEN 'CTCONTROL'
                                WHEN ARR.AccessRight = 'U'  THEN 'UPDATE'
                                ELSE 'Unknown'
                            END AS AccesRightText
                    FROM DBC.RoleMembers AS RN
                    INNER JOIN DBC.AllRoleRights AS ARR
                        ON RN.RoleName = ARR.RoleName
                    WHERE RN.Grantee = '{role_name}'
                    GROUP BY 1, 2, 3, 4
                    ORDER BY 1, 2, 3, 4;""")
                data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "sec_rolePermissions",
                "argument": role_name,
                "num_permissions": len(data)
            }
            logger.debug(f"Tool: handle_sec_rolePermissions: metadata: {metadata}")
            return create_response(data, metadata)
  • Dynamic registration code that discovers handle_* functions (including handle_sec_rolePermissions) from loaded tool modules via ModuleLoader and registers them as MCP tools with auto-generated schemas from function signatures.
    module_loader = td.initialize_module_loader(config)
    if module_loader:
        all_functions = module_loader.get_all_functions()
        for name, func in all_functions.items():
            if not (inspect.isfunction(func) and name.startswith("handle_")):
                continue
            tool_name = name[len("handle_"):]
            if not any(re.match(p, tool_name) for p in config.get('tool', [])):
                continue
            wrapped = make_tool_wrapper(func)
            mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped)
            logger.info(f"Created tool: {tool_name}")

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3/5.0
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It indicates a read operation but lacks details on side effects, authorization requirements, or error handling (e.g., missing role). The 'formatted response' mention is vague.

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

Conciseness4/5

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

The description is brief and includes a structured Arguments/Returns section. No superfluous content. However, it could be more informative without sacrificing conciseness.

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?

For a simple tool with one parameter and no output schema, the description covers the basic purpose and argument. It lacks completeness in terms of usage examples, return format details, or edge cases.

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

Parameters2/5

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

With 0% schema description coverage, the description's argument note ('role name to analyze') adds minimal value beyond the schema's parameter name. No format, constraints, or examples are provided for role_name.

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 clearly states 'Get permissions for a role' with a specific verb and resource. However, it does not explicitly distinguish from sibling tools like sec_userDbPermissions or sec_userRoles, though the role focus is implied.

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

Usage Guidelines3/5

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

The description implies use for retrieving role permissions but provides no guidance on when to use this versus alternatives. No context about prerequisites or limitations.

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