Skip to main content
Glama
egarcia74

Warp SQL Server MCP

by egarcia74

list_foreign_keys

Discover foreign key relationships in SQL Server schemas to understand table dependencies and maintain data integrity.

Instructions

List all foreign key relationships in a schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name (optional)
schemaNoSchema name (optional, defaults to dbo)

Implementation Reference

  • Core handler function that executes SQL query to list foreign key relationships using SQL Server system views.
    async listForeignKeys(database = null, schema = 'dbo') {
      let query;
    
      if (database) {
        query = `
          SELECT 
            fk.name as foreign_key_name,
            tp.name as parent_table,
            cp.name as parent_column,
            tr.name as referenced_table,
            cr.name as referenced_column
          FROM [${database}].sys.foreign_keys fk
          INNER JOIN [${database}].sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id
          INNER JOIN [${database}].sys.tables tp ON fkc.parent_object_id = tp.object_id
          INNER JOIN [${database}].sys.columns cp ON fkc.parent_object_id = cp.object_id AND fkc.parent_column_id = cp.column_id
          INNER JOIN [${database}].sys.tables tr ON fkc.referenced_object_id = tr.object_id
          INNER JOIN [${database}].sys.columns cr ON fkc.referenced_object_id = cr.object_id AND fkc.referenced_column_id = cr.column_id
          INNER JOIN [${database}].sys.schemas s ON tp.schema_id = s.schema_id
          WHERE s.name = '${schema}'
          ORDER BY tp.name, fk.name
        `;
      } else {
        query = `
          SELECT 
            fk.name as foreign_key_name,
            tp.name as parent_table,
            cp.name as parent_column,
            tr.name as referenced_table,
            cr.name as referenced_column
          FROM sys.foreign_keys fk
          INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id
          INNER JOIN sys.tables tp ON fkc.parent_object_id = tp.object_id
          INNER JOIN sys.columns cp ON fkc.parent_object_id = cp.object_id AND fkc.parent_column_id = cp.column_id
          INNER JOIN sys.tables tr ON fkc.referenced_object_id = tr.object_id
          INNER JOIN sys.columns cr ON fkc.referenced_object_id = cr.object_id AND fkc.referenced_column_id = cr.column_id
          INNER JOIN sys.schemas s ON tp.schema_id = s.schema_id
          WHERE s.name = '${schema}'
          ORDER BY tp.name, fk.name
        `;
      }
    
      const result = await this.executeQuery(query, 'list_foreign_keys');
      return this.formatResults(result);
    }
  • Tool registration including name, description, and input schema definition.
      name: 'list_foreign_keys',
      description: 'List all foreign key relationships in a schema',
      inputSchema: {
        type: 'object',
        properties: {
          database: { type: 'string', description: 'Database name (optional)' },
          schema: { type: 'string', description: 'Schema name (optional, defaults to dbo)' }
        }
      }
    }
  • index.js:275-278 (registration)
    Server dispatch handler that routes list_foreign_keys tool calls to the DatabaseToolsHandler.
    case 'list_foreign_keys':
      return {
        content: await this.databaseTools.listForeignKeys(args.database, args.schema)
      };
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 what the tool does but lacks details on permissions required, output format (e.g., list of relationships, JSON structure), pagination, or error handling. This is inadequate for a tool that likely interacts with a database schema.

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, clear sentence with zero wasted words. It front-loads the core purpose efficiently, making it easy to parse and understand quickly.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., a list of foreign keys with details like table names, columns), potential side effects, or usage context in relation to sibling tools. This leaves significant gaps for an AI agent to use it effectively.

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?

Schema description coverage is 100%, so the input schema fully documents the two optional parameters ('database' and 'schema'). The description adds no additional meaning beyond implying a scope ('in a schema'), which is already covered by the schema's descriptions. This meets the baseline for high schema coverage.

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 action ('List all') and resource ('foreign key relationships in a schema'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'describe_table' or 'list_tables', which might also provide relationship information, so it misses the top score.

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. For example, it doesn't clarify if this is for metadata exploration, performance tuning, or schema validation, nor does it mention sibling tools like 'describe_table' that might overlap in functionality.

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/egarcia74/warp-sql-server-mcp'

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