Run long-running searches with Splunk MCP Server

Splunk MCP Server version 2.2 introduces three tools for running searches asynchronously. Use splunk_submit_query to start a search and receive a search ID (sid) without waiting for the search to complete. Use splunk_get_query_results to check the search status and retrieve results in pages. To stop a search that is no longer needed, use splunk_cancel_query.

For quick searches with smaller result sets, continue to use splunk_run_query, which returns results in a single call.

Before you begin

Before using the long-running search tools in Splunk MCP Server version 2.2, make sure the tools are enabled.

  • New installations: The splunk_submit_query, splunk_get_query_results, and splunk_cancel_query tools are enabled by default.

  • Upgraded installations: The three tools are disabled by default. An administrator must enable them before they can be used.

Submit a long running search

Use the splunk_submit_query tool to start a Splunk search without waiting for it to finish. The tool submits the search asynchronously and returns a search ID (sid) that you can use to check its progress and retrieve results.

Follow these steps to submit a long-running search:

  1. In your MCP client, invoke the splunk_submit_query tool.

  2. Provide the SPL search query you want to run.

  3. Submit the request.

  4. Note the returned search ID (sid). Use this ID to check the search status and retrieve results with splunk_get_query_results.

The search continues running independently of the initial request.

Check search status and retrieve results

Use splunk_get_query_results to check the progress of a submitted search and retrieve its results. The tool uses the search ID (sid) returned by splunk_submit_query.

Follow these steps to check a search and retrieve its results:

  1. In your MCP client, invoke splunk_get_query_results.

  2. Provide the search ID (sid) returned when you submitted the search.

  3. Check the search status to determine whether the search has completed.

  4. If the search is still running, wait and check its status again.

  5. When results are available, retrieve them in pages. Continue requesting additional pages until you've retrieved the results you need.

You can retrieve additional pages without rerunning the original search.

Search result retention and limitations

Results from searches submitted using splunk_submit_query remain available for 30 minutes after the search finishes. You can use the keep_results_minutes parameter to request a longer retention period.

During the retention period, use splunk_get_query_results with the search ID (sid) to retrieve additional pages without rerunning the search.

If the results expire or the search is canceled, the search ID can no longer be used to retrieve results. Submit the search again to obtain a new search ID.

The number of results available for retrieval is subject to the Maximum row limit configured by the administrator. If the search exceeds this limit, narrow the search or ask an administrator whether the limit can be increased.

Note: If the MCP Server Maximum row limit is higher than the Splunk [restapi] maxresultrows setting in limits.conf, a search might return fewer rows than requested and still appear complete. For larger queries, keep the MCP Server limit at or below maxresultrows, which is 50,000 by default.

The new pagination behavior does not apply to custom tools or splunk_run_saved_search.

Cancel a long-running search

Use splunk_cancel_query to cancel a submitted search that is still running or is no longer needed. Canceling a search also deletes its results.

Follow these steps to cancel a long-running search:

  1. In your MCP client, invoke splunk_cancel_query.

  2. Provide the search ID (sid) returned by splunk_submit_query.

  3. Submit the cancellation request.

  4. Check the response to confirm whether the search was canceled.

After cancellation, the search results are no longer available for retrieval using splunk_get_query_results.