Skip to main content
Glama
itshare4u

Agent Knowledge MCP

delete_index_metadata

Remove metadata documentation for Elasticsearch indexes to manage and organize search data effectively.

Instructions

Delete metadata documentation for an Elasticsearch index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
index_nameYesName of the index to remove metadata for

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'delete_index_metadata' tool. It uses @app.tool decorator for registration in FastMCP, includes input schema via Annotated Field, searches for existing metadata in 'index_metadata' index, deletes the document if found, and provides detailed success/error messages.
    @app.tool(
        description="Delete metadata documentation for an Elasticsearch index",
        tags={"elasticsearch", "metadata", "delete", "cleanup"}
    )
    async def delete_index_metadata(
            index_name: Annotated[str, Field(description="Name of the index to remove metadata for")]
    ) -> str:
        """Delete metadata documentation for an Elasticsearch index."""
        try:
            es = get_es_client()
            metadata_index = "index_metadata"
    
            # Search for existing metadata
            search_body = {
                "query": {
                    "term": {
                        "index_name.keyword": index_name
                    }
                },
                "size": 1
            }
    
            existing_result = es.search(index=metadata_index, body=search_body)
    
            if existing_result['hits']['total']['value'] == 0:
                return (f"⚠️ No metadata found for index '{index_name}'!\n\n" +
                        f"📋 **Status**: Index metadata does not exist\n" +
                        f"   ✅ **Good**: No cleanup required for metadata\n" +
                        f"   🔧 **Safe**: You can proceed with 'delete_index' if needed\n" +
                        f"   🔍 **Check**: Use 'list_indices' to see all documented indices\n\n" +
                        f"💡 **This is Normal If**:\n" +
                        f"   • Index was created before metadata system was implemented\n" +
                        f"   • Index was created without using 'create_index_metadata' first\n" +
                        f"   • Metadata was already deleted in a previous cleanup")
    
            # Get existing document details before deletion
            existing_doc = existing_result['hits']['hits'][0]
            existing_id = existing_doc['_id']
            existing_data = existing_doc['_source']
    
            # Delete the metadata document
            result = es.delete(index=metadata_index, id=existing_id)
    
            return (f"✅ Index metadata deleted successfully!\n\n" +
                    f"🗑️ **Deleted Metadata for '{index_name}'**:\n" +
                    f"   📋 Document ID: {existing_id}\n" +
                    f"   📝 Description: {existing_data.get('description', 'No description')}\n" +
                    f"   🎯 Purpose: {existing_data.get('purpose', 'No purpose')}\n" +
                    f"   📂 Data Types: {', '.join(existing_data.get('data_types', [])) if existing_data.get('data_types') else 'None'}\n" +
                    f"   👤 Created By: {existing_data.get('created_by', 'Unknown')}\n" +
                    f"   📅 Created: {existing_data.get('created_date', 'Unknown')}\n\n" +
                    f"✅ **Cleanup Complete**:\n" +
                    f"   🗑️ Metadata documentation removed from registry\n" +
                    f"   🔧 You can now safely use 'delete_index' to remove the actual index\n" +
                    f"   📊 Use 'list_indices' to verify metadata removal\n\n" +
                    f"🎯 **Next Steps**:\n" +
                    f"   1. Proceed with 'delete_index {index_name}' to remove the actual index\n" +
                    f"   2. Or use 'create_index_metadata' if you want to re-document this index\n" +
                    f"   3. Clean up any related indices mentioned in metadata\n\n" +
                    f"⚠️ **Important**: This only deleted the documentation, not the actual index")
    
        except Exception as e:
            error_message = "❌ Failed to delete index metadata:\n\n"
    
            error_str = str(e).lower()
            if "connection" in error_str or "refused" in error_str:
                error_message += "🔌 **Connection Error**: Cannot connect to Elasticsearch server\n"
                error_message += f"📍 Check if Elasticsearch is running at the configured address\n"
                error_message += f"💡 Try: Use 'setup_elasticsearch' tool to start Elasticsearch\n\n"
            elif ("not_found" in error_str or "not found" in error_str) and "index" in error_str:
                error_message += f"📁 **Index Error**: Metadata index 'index_metadata' does not exist\n"
                error_message += f"📍 The metadata system has not been initialized\n"
                error_message += f"💡 This means no metadata exists to delete - you can proceed safely\n\n"
            else:
                error_message += f"⚠️ **Unknown Error**: {str(e)}\n\n"
    
            error_message += f"🔍 **Technical Details**: {str(e)}"
            return error_message
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Delete' implies a destructive operation, the description doesn't clarify whether this is reversible, what permissions are required, what happens to the index itself (just metadata), or any rate limits/constraints. This is inadequate for a destructive tool with zero annotation coverage.

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 with zero wasted words. It's appropriately sized and front-loaded with the essential information.

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

Completeness3/5

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

Given this is a destructive operation with no annotations but has an output schema (which handles return values), the description is minimally adequate. However, for a delete operation that could have significant consequences, more context about what 'metadata documentation' entails and how this differs from deleting the index itself would be valuable.

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 already fully documents the single parameter 'index_name'. The description adds no additional meaning about parameter usage, constraints, or examples beyond what's in the schema. With high schema coverage, baseline 3 is appropriate.

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 ('Delete') and target ('metadata documentation for an Elasticsearch index'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this from sibling tools like 'delete_index' or 'update_index_metadata', which would require more specific differentiation.

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. With sibling tools like 'delete_index' (deletes the entire index) and 'update_index_metadata' (modifies metadata), there's clear potential for confusion, but the description offers no comparison or context for choosing between them.

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/itshare4u/AgentKnowledgeMCP'

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