Skip to main content
Glama
deslicer

MCP Server for Splunk

get_kvstore_data

Retrieve documents from a Splunk KV Store collection, optionally filtering by field values using a MongoDB-style query.

Instructions

Get documents from a KV Store collection with optional MongoDB-style query filtering. Use this to fetch lookup/configuration data or narrow results by field values.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
appNoApp where the collection resides (defaults to current/app context)
queryNoMongoDB-style filter object (e.g., {"status": "active"})

Implementation Reference

  • The GetKvstoreData class (extends BaseTool) with the execute() method that retrieves documents from a Splunk KV Store collection using optional MongoDB-style query filtering. Handles Splunk availability check, optional app context, query execution, error handling, and returns documents with count.
    class GetKvstoreData(BaseTool):
        """
        Retrieve data from a specific KV Store collection.
        """
    
        METADATA = ToolMetadata(
            name="get_kvstore_data",
            description=(
                "Get documents from a KV Store collection with optional MongoDB-style query filtering. Use this "
                "to fetch lookup/configuration data or narrow results by field values.\n\n"
                "Args:\n"
                "    collection (str): Collection name\n"
                "    app (str, optional): App where the collection resides (defaults to current/app context)\n"
                '    query (object, optional): MongoDB-style filter object (e.g., {"status": "active"})\n\n'
                "Outputs: 'documents' array and 'count'.\n"
                "Security: access and results are constrained by the authenticated user's permissions."
            ),
            category="kvstore",
            tags=["kvstore", "data", "query", "storage"],
            requires_connection=True,
        )
    
        async def execute(
            self, ctx: Context, collection: str, app: str | None = None, query: dict | None = None
        ) -> dict[str, Any]:
            """
            Retrieve data from a KV Store collection.
    
            Args:
                collection: Name of the collection to retrieve data from
                app: Optional app name where the collection resides
                query: Optional MongoDB-style query filter
    
            Returns:
                Dict containing retrieved documents
            """
            log_tool_execution("get_kvstore_data", collection=collection, app=app, query=query)
    
            is_available, service, error_msg = self.check_splunk_available(ctx)
    
            if not is_available:
                return self.format_error_response(error_msg)
    
            self.logger.info(f"Retrieving data from KV Store collection: {collection}")
            await ctx.info(f"Retrieving data from KV Store collection: {collection}")
    
            try:
                # Get the collection from the appropriate app context
                if app:
                    kvstore = service.kvstore[app]
                else:
                    kvstore = service.kvstore
    
                collection_obj = kvstore[collection]
    
                # Retrieve data with optional query filter
                if query:
                    documents = collection_obj.data.query(**query)
                else:
                    documents = collection_obj.data.query()
    
                # Convert to list for response
                doc_list = list(documents)
    
                await ctx.info(f"Retrieved {len(doc_list)} documents from collection {collection}")
                return self.format_success_response({"count": len(doc_list), "documents": doc_list})
    
            except Exception as e:
                self.logger.error(f"Failed to retrieve KV Store data: {str(e)}")
                await ctx.error(f"Failed to retrieve KV Store data: {str(e)}")
                return self.format_error_response(str(e))
  • ToolMetadata definition for get_kvstore_data: name, description (with args for collection, app, query), category='kvstore', tags, and requires_connection=True.
    METADATA = ToolMetadata(
        name="get_kvstore_data",
        description=(
            "Get documents from a KV Store collection with optional MongoDB-style query filtering. Use this "
            "to fetch lookup/configuration data or narrow results by field values.\n\n"
            "Args:\n"
            "    collection (str): Collection name\n"
            "    app (str, optional): App where the collection resides (defaults to current/app context)\n"
            '    query (object, optional): MongoDB-style filter object (e.g., {"status": "active"})\n\n'
            "Outputs: 'documents' array and 'count'.\n"
            "Security: access and results are constrained by the authenticated user's permissions."
        ),
        category="kvstore",
        tags=["kvstore", "data", "query", "storage"],
        requires_connection=True,
    )
  • GetKvstoreData is imported from .data and listed in __all__ for the kvstore tools package.
    from .data import GetKvstoreData
    
    __all__ = ["ListKvstoreCollections", "GetKvstoreData", "CreateKvstoreCollection"]
  • GetKvstoreData is re-exported in the top-level src/tools/__init__.py via wildcard import from .kvstore and listed in __all__.
    "GetKvstoreData",
    "CreateKvstoreCollection",
  • get_kvstore_data listed as a tool reference in workflow requirements with description 'Retrieve data from KV Store collections'.
    "get_kvstore_data": "Retrieve data from KV Store collections",
    "list_kvstore_collections": "List all KV Store collections",
    "create_kvstore_collection": "Create new KV Store collections",
    # Workflow Tools
    "list_workflows": "List available workflows",
    "workflow_runner": "Execute workflows by ID",
    # Utility Tools
Behavior2/5

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

With no annotations provided, the description must disclose behavioral traits. It implies a read-only operation via 'Get', but does not mention permissions, error handling, pagination, or any side effects. This is insufficient for full transparency.

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 two sentences, front-loads the core action, and contains no fluff. Every word adds value.

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?

For a simple read tool with 3 parameters and no output schema, the description covers the basic purpose and use case. However, it lacks details on return format, error conditions, and pagination, which are important for a complete understanding.

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 coverage is 100%, so the schema already documents all parameters. The description adds context like 'MongoDB-style query filtering' for the query parameter, but does not add significant meaning beyond the schema's existing descriptions.

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 'Get documents from a KV Store collection' and mentions optional MongoDB-style filtering. It identifies the resource (KV Store collection) and action (get), but does not explicitly differentiate from sibling tools like get_configurations or get_metadata.

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

Usage Guidelines3/5

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

The description provides a use case: 'fetch lookup/configuration data or narrow results by field values.' However, it does not specify when not to use this tool or mention alternatives, leaving the agent without exclusion criteria.

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/deslicer/mcp-for-splunk'

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