Skip to main content
Glama

mcp_search_comprehensive

Search SQL Server database objects by name and definition using configurable criteria to find tables, views, procedures, and other database elements.

Instructions

Search across database objects by name and definition with configurable criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesSearch pattern or text to find
object_typesNoTypes of objects to search in
search_in_namesNoWhether to search in object names
search_in_definitionsNoWhether to search in object definitions/source code

Implementation Reference

  • Main handler function that implements mcp_search_comprehensive. Orchestrates parallel searches in object names and definitions based on input parameters and combines results.
    export const mcp_search_comprehensive = async (args: {
      pattern: string;
      search_in_names?: boolean;
      search_in_definitions?: boolean;
      object_types?: string[]
    }): Promise<ToolResult<{
      name_matches: any[];
      definition_matches: any[];
      total_matches: number;
    }>> => {
      const { 
        pattern, 
        search_in_names = true, 
        search_in_definitions = true, 
        object_types 
      } = args;
      console.log('Executing mcp_search_comprehensive with:', args);
    
      try {
        const promises = [];
        
        // Search in object names
        if (search_in_names) {
          promises.push(mcp_search_objects_by_name({ pattern, object_types }));
        } else {
          // Return empty result with the expected structure
          promises.push(Promise.resolve({ success: true as const, data: [] }));
        }
        
        // Search in object definitions 
        if (search_in_definitions) {
          promises.push(mcp_search_in_definitions({ pattern, object_types }));
        } else {
          // Return empty result with the expected structure
          promises.push(Promise.resolve({ success: true as const, data: [] }));
        }
        
        const [nameResults, definitionResults] = await Promise.all(promises);
        
        if (!nameResults.success) return nameResults;
        if (!definitionResults.success) return definitionResults;
        
        const nameMatches = nameResults.data;
        const definitionMatches = definitionResults.data;
        
        return {
          success: true,
          data: {
            name_matches: nameMatches,
            definition_matches: definitionMatches,
            total_matches: nameMatches.length + definitionMatches.length
          }
        };
      } catch (error: any) {
        console.error(`Error in mcp_search_comprehensive: ${error.message}`);
        return { success: false, error: error.message };
      }
    };
  • Defines the tool name, description, and input schema for mcp_search_comprehensive in the MCP tools registry.
    {
      name: "mcp_search_comprehensive",
      description: "Search across database objects by name and definition with configurable criteria",
      inputSchema: {
        type: "object",
        properties: {
          pattern: {
            type: "string",
            description: "Search pattern or text to find"
          },
          object_types: {
            type: "array",
            items: {
              type: "string",
              enum: ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "TRIGGER", "DEFAULT", "CHECK", "RULE"]
            },
            description: "Types of objects to search in"
          },
          search_in_names: {
            type: "boolean",
            description: "Whether to search in object names",
            default: true
          },
          search_in_definitions: {
            type: "boolean",
            description: "Whether to search in object definitions/source code",
            default: true
          }
        },
        required: ["pattern"]
      }
    },
  • src/server.ts:64-66 (registration)
    Registers the MCP tools list (MCP_MSQL_TOOLS containing mcp_search_comprehensive) for ListTools requests.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: MCP_MSQL_TOOLS
    }));
  • Re-exports the mcp_search_comprehensive handler from objectSearch.ts for use in tool handlers map.
    export {
      mcp_search_comprehensive, // Comprehensive search
      mcp_get_dependencies,      // Object dependencies
      // Funciones adicionales para compatibilidad con server.ts
      mcp_search_objects_by_name,
      mcp_search_in_definitions,
      mcp_search_objects_by_type,
      mcp_get_object_dependencies
    } from './objectSearch.js';
  • Helper function called by handler to search database objects by name pattern.
    export const mcp_search_objects_by_name = async (args: {
      pattern: string;
      object_types?: string[]
    }): Promise<ToolResult<any[]>> => {
      const { pattern, object_types } = args;
      console.log('Executing mcp_search_objects_by_name with:', args);
    
      try {
        const pool = getPool();
        
        let typeFilter = '';
        if (object_types && object_types.length > 0) {
          const validTypes = object_types.map(type => {
            switch(type.toLowerCase()) {
              case 'table': return "'U'";
              case 'view': return "'V'";
              case 'procedure': return "'P'";
              case 'function': return "'FN', 'IF', 'TF'";
              case 'trigger': return "'TR'";
              default: return null;
            }
          }).filter(Boolean);
          
          if (validTypes.length > 0) {
            typeFilter = `AND o.type IN (${validTypes.join(', ')})`;
          }
        }
        
        const query = `
          SELECT 
              s.name AS schema_name,
              o.name AS object_name,
              o.type_desc AS object_type,
              SCHEMA_NAME(o.schema_id) + '.' + o.name AS full_name,
              o.create_date,
              o.modify_date
          FROM 
              sys.objects o
          JOIN 
              sys.schemas s ON o.schema_id = s.schema_id
          WHERE 
              o.name LIKE @pattern
              ${typeFilter}
          ORDER BY 
              s.name, o.name;
        `;
        
        const result = await pool.request()
          .input('pattern', `%${pattern}%`)
          .query(query);
        
        return { success: true, data: result.recordset };
      } catch (error: any) {
        console.error(`Error in mcp_search_objects_by_name: ${error.message}`);
        return { success: false, error: error.message };
      }
    };
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'search across database objects' but doesn't disclose behavioral traits such as performance implications, result limits, pagination, authentication requirements, or error handling. For a search tool with no annotation coverage, this leaves critical operational context unspecified.

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 front-loads the core purpose ('search across database objects') and adds qualifying details without waste. Every word earns its place, making it easy to parse 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 no annotations and no output schema, the description is incomplete for a search tool with 4 parameters. It lacks details on result format, error cases, or behavioral constraints, which are crucial for effective tool use. The high schema coverage helps, but overall context remains insufficient.

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 schema fully documents all parameters. The description adds minimal value beyond the schema by hinting at 'configurable criteria' and 'by name and definition', which aligns with the schema's parameters but doesn't provide additional syntax or usage details. Baseline 3 is appropriate as the schema does the heavy lifting.

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 verb ('search') and resource ('database objects'), specifying scope ('by name and definition with configurable criteria'). It distinguishes from siblings like mcp_execute_procedure or mcp_preview_data by focusing on search functionality, though it doesn't explicitly differentiate from potential search-related siblings not listed.

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?

No guidance on when to use this tool versus alternatives is provided. The description mentions 'configurable criteria' but doesn't specify scenarios, prerequisites, or exclusions. Given siblings like mcp_quick_data_analysis or mcp_table_analysis that might overlap in use cases, this lack of guidance is a significant gap.

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/hendrickcastro/MCPQL'

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