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

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

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