Skip to main content
Glama
git-scarrow

Oracle MCP Server

by git-scarrow

get_table_constraints

Retrieve primary keys, foreign keys, unique, and check constraints for Oracle database tables to understand table relationships and enforce data integrity.

Instructions

Get constraints (primary keys, foreign keys, unique, check) for a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesTable name
schemaNoSchema name (optional, searches all accessible schemas if not specified)

Implementation Reference

  • The handler function for 'get_table_constraints' tool. Executes a SQL query against Oracle's data dictionary views (all_constraints, all_cons_columns) to retrieve table constraints (PK, UQ, FK, CHECK) including details like columns involved and referenced tables.
    async handleGetTableConstraints(args) {
      const query = `
        SELECT 
          c.owner AS schema_name,
          c.constraint_name,
          c.constraint_type,
          c.status,
          c.validated,
          CASE 
            WHEN c.constraint_type = 'C' THEN 'CHECK CONSTRAINT' 
            ELSE NULL 
          END as search_condition,
          LISTAGG(cc.column_name, ', ') WITHIN GROUP (ORDER BY cc.position) AS columns,
          r.table_name AS referenced_table,
          r.constraint_name AS referenced_constraint
        FROM all_constraints c
        LEFT JOIN all_cons_columns cc ON c.constraint_name = cc.constraint_name AND c.owner = cc.owner
        LEFT JOIN all_constraints r ON c.r_constraint_name = r.constraint_name AND c.r_owner = r.owner
        WHERE c.table_name = :1
          ${args.schema ? 'AND c.owner = :2' : ''}
        GROUP BY c.owner, c.constraint_name, c.constraint_type, c.status, c.validated, 
                 r.table_name, r.constraint_name
        ORDER BY 
          c.owner,
          CASE c.constraint_type 
            WHEN 'P' THEN 1 
            WHEN 'U' THEN 2 
            WHEN 'R' THEN 3 
            WHEN 'C' THEN 4 
            ELSE 5 
          END,
          c.constraint_name
      `;
      
      const params = [args.table_name.toUpperCase()];
      if (args.schema) {
        params.push(args.schema.toUpperCase());
      }
      
      const result = await this.executeQuery(query, params);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result.rows, null, 2)
          }
        ]
      };
    }
  • src/index.js:247-264 (registration)
    Tool registration in listTools response, including name, description, and input schema definition.
    {
      name: 'get_table_constraints',
      description: 'Get constraints (primary keys, foreign keys, unique, check) for a table',
      inputSchema: {
        type: 'object',
        properties: {
          table_name: {
            type: 'string',
            description: 'Table name'
          },
          schema: {
            type: 'string',
            description: 'Schema name (optional, searches all accessible schemas if not specified)'
          }
        },
        required: ['table_name']
      }
    },
  • src/index.js:294-295 (registration)
    Dispatch case in CallToolRequest handler that routes to the tool handler.
    case 'get_table_constraints':
      return await this.handleGetTableConstraints(args);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves constraints but doesn't describe the return format, pagination, error handling, or any limitations (e.g., access permissions, rate limits). For a read operation with no annotation coverage, this is a significant gap, as the agent lacks essential context for safe and effective use.

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 that directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded, with every word contributing to clarity. This is an example of optimal conciseness for a simple tool.

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

Completeness2/5

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

Given the tool's complexity (a read operation with 2 parameters) and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., format of constraints), potential errors, or how it relates to sibling tools. For a tool that retrieves database metadata, more context is needed to ensure the agent can use it correctly.

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

Parameters3/5

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

The schema description coverage is 100%, meaning the input schema fully documents the parameters ('table_name' and 'schema'). The description doesn't add any semantic details beyond what the schema provides (e.g., it doesn't explain constraint types further or parameter interactions). With high schema coverage, the baseline is 3, as the description doesn't compensate but also doesn't detract.

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 the tool's purpose: 'Get constraints (primary keys, foreign keys, unique, check) for a table'. It specifies the verb ('Get') and resource ('constraints for a table'), including the types of constraints. However, it doesn't explicitly differentiate from sibling tools like 'describe_table' or 'get_table_indexes', which might also provide constraint information, so it doesn't reach a perfect 5.

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. It doesn't mention sibling tools like 'describe_table' (which might include constraints) or 'get_table_indexes', nor does it specify prerequisites or exclusions. This lack of context leaves the agent to infer usage, which is minimal guidance.

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

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/git-scarrow/oracle-mcp-server'

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