Skip to main content

 

Splunk Lantern

Optimizing Splunk MCP with LLM context management

You have recently integrated your LLM Agent with Splunk Cloud Platform. Your environment contains multiple indexes, lookups, and source types, but only a subset is relevant for each interaction. Currently, every time you initiate a new conversation with your LLM agent, you must manually specify which indexes, lookups, and source types to use. Different categories of use cases depend on distinct combinations of these data sources. Repeatedly providing this information for each session quickly becomes tedious and inefficient.

Prerequisites

  • Access to a Splunk Cloud Platform environment in commercial AWS regions.
  • An AI/LLM orchestration or workspace software or service that acts as an MCP client, along with some familiarity with configuring the connection to an MCP server. Many free, open source, and commercial third-party software options are available. The client must support the Streamable HTTP protocol.

Configuration

Follow the guidance in Configure the Splunk MCP server and Connect and use an MCP client to set up your MCP server.

Solution

To streamline context management and reduce repetitive setup, leverage dedicated workspaces with custom instructions. This prevents cold starts and ensures that your LLM agent is pre-configured with knowledge of the relevant context - such as which indexes, source types, fields, and lookups it should interact with. This approach enhances both efficiency and consistency across sessions.

Different LLM providers use distinct terminology for these contextualized workspaces:

A best practice is to create a Splunk Context Document (SCM). This document provides a structured summary of your Splunk environment, tailored to your use case. To generate it, prompt your LLM agent to inspect relevant indexes, lookups, source types, and other configuration details, then output the findings in a structured Markdown (MD) file. This file can be uploaded or referenced within your workspace, providing persistent, session-independent context.

Example prompt

Use the following prompt to generate your SCM:

Give me a quick overview of this Splunk environment:

- List all non-system application indexes (exclude _* and internal indexes)
- Show the top N sourcetypes by event count over the last 30 days,
  excluding system sourcetypes (splunkd*, splunk*, stash, etc.)
- Get 1 sample event from each application index
- List all lookups specific to this environment's applications, organized by category
  (exclude lookups like AWS or geolocation)
- List all available data models (exclude disabled models)
- Report the data time range: oldest to newest event in application indexes

Format as a structured MD file with clear sections. Prioritize
indexes and sourcetypes if length becomes an issue.

The resulting markdown file serves as a ready-to-use context summary for your workspace. When creating or updating your workspace, give it a name that matches or clearly reflects the SCM it references.

Walkthrough: Setting up a Claude project

The following steps use Claude Desktop as an example MCP client.

  1. Follow the instructions to How to create a project in Claude Desktop.
  2. Provide a project name that clearly reflects the context, using a naming convention such as Splunk_SCM_[UseCase] — for example, Splunk_SCM_KYC or Splunk_SCM_AML.
    clipboard_ab77047b-8828-45b7-bb53-dee831c022ca.png
  3. Upload your prepared SCM Markdown file through Upload from device.
    clipboard_5ec73227-bcbc-4cbd-b155-92de101566b9.png
  4. You are now ready to start a new conversation with Claude, with the assurance that it has the right context loaded.
    clipboard_8ece2a87-2887-44c3-a84c-9077139b9ada.png

When you start a new conversation within this Claude Project, the agent will automatically reference the SCM, eliminating the need to repeatedly specify indexes, lookups, or source types.

  • Ensure your SCM is updated whenever your Splunk environment changes.
  • You can create multiple projects for different Splunk use cases or teams.

Next steps

After your AI client is connected to the MCP server and context has been added, you can begin working on the following use cases:

In addition, these resources might help you understand and implement this guidance: