Skip to main content
Glama
vic3custodio

Trade Surveillance Support MCP Server

by vic3custodio

rebuild_metadata_index

Manually rebuilds the metadata index by scanning SQL configs and Java files after adding new files or updating annotations to ensure accurate search results.

Instructions

Rebuild the metadata index by scanning all SQL configs and Java files.

Use this tool when you've added new files or updated metadata annotations.
The index is automatically built on first search, but you can manually rebuild
it with this tool.

Args:
    config_directory: Path to the directory containing SQL config files
    code_directory: Path to the directory containing Java source files
    
Returns:
    A summary of the indexing operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
config_directoryNo./configs
code_directoryNo./src

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main asynchronous handler function for the 'rebuild_metadata_index' tool. It is decorated with @mcp.tool(), which registers it with the MCP server. The function rebuilds the metadata index by calling scan methods on the MetadataIndex instance and returns a summary dictionary.
    @mcp.tool()
    async def rebuild_metadata_index(
        config_directory: str = "./configs",
        code_directory: str = "./src"
    ) -> dict[str, Any]:
        """
        Rebuild the metadata index by scanning all SQL configs and Java files.
        
        Use this tool when you've added new files or updated metadata annotations.
        The index is automatically built on first search, but you can manually rebuild
        it with this tool.
        
        Args:
            config_directory: Path to the directory containing SQL config files
            code_directory: Path to the directory containing Java source files
            
        Returns:
            A summary of the indexing operation
        """
        logger.info("Rebuilding metadata index...")
        
        sql_count = len(metadata_index.scan_sql_configs(config_directory))
        java_count = len(metadata_index.scan_java_classes(code_directory))
        
        result = {
            "status": "success",
            "sql_configs_indexed": sql_count,
            "java_classes_indexed": java_count,
            "total_files_indexed": sql_count + java_count,
            "index_file": str(metadata_index.index_file.absolute())
        }
        
        logger.info(f"Index rebuilt: {sql_count} SQL configs, {java_count} Java classes")
        return result
  • Helper method in MetadataIndex class that scans SQL configuration files, extracts metadata from comments, updates the index, and saves it to JSON. Called by the tool handler.
    def scan_sql_configs(self, config_dir: str) -> dict[str, Any]:
        """
        Scan SQL config files and extract metadata from comments.
        
        Looks for annotations like:
        -- @keywords: trade, transaction, daily_report
        -- @type: compliance_check
        -- @description: Daily trade reconciliation report
        """
        config_path = Path(config_dir)
        if not config_path.exists():
            return {}
        
        configs = {}
        for sql_file in config_path.rglob("*.sql"):
            metadata = self._extract_sql_metadata(sql_file)
            if metadata:
                configs[str(sql_file.relative_to(config_path))] = metadata
        
        self.index["sql_configs"] = configs
        self._save_index()
        return configs
  • Helper method in MetadataIndex class that scans Java source files, extracts metadata from Javadoc comments, updates the index, and saves it to JSON. Called by the tool handler.
    def scan_java_classes(self, code_dir: str) -> dict[str, Any]:
        """
        Scan Java files and extract metadata from javadoc comments.
        
        Looks for annotations like:
        /**
         * @keywords trade, settlement, report_generator
         * @type report_engine
         * @description Generates daily settlement reports
         */
        """
        code_path = Path(code_dir)
        if not code_path.exists():
            return {}
        
        classes = {}
        for java_file in code_path.rglob("*.java"):
            metadata = self._extract_java_metadata(java_file)
            if metadata:
                classes[str(java_file.relative_to(code_path))] = metadata
        
        self.index["java_classes"] = classes
        self._save_index()
        return classes
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by explaining the tool's purpose, triggering conditions, and automatic vs manual behavior. It doesn't mention performance implications, error handling, or permissions, but provides solid operational context.

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?

Perfectly structured with purpose statement, usage guidelines, and parameter explanations in separate logical sections. Every sentence earns its place with no wasted words, and key information is front-loaded.

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

Completeness5/5

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

Given the tool's complexity (rebuilding indexes across file systems), no annotations, and the presence of an output schema (handling return values), the description provides complete operational context including purpose, when to use, parameter meanings, and return value summary.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by clearly explaining both parameters (config_directory for SQL config files, code_directory for Java source files) and their purposes, adding essential meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('rebuild the metadata index') and resources involved ('scanning all SQL configs and Java files'), distinguishing it from sibling tools like search_java_code or search_sql_configs which only search rather than rebuild indexes.

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

Usage Guidelines5/5

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

Explicit guidance is provided on when to use this tool ('when you've added new files or updated metadata annotations') and when not to use it ('automatically built on first search'), with clear context about manual vs automatic rebuilding.

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/vic3custodio/mcp_test_2'

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