Repository navigation
Add MCP tools to search, read and list API Explorer operations - #4886
Merged
Merged
Conversation
Agents could reach API operations only through page-shaped search, so they could not ask for an endpoint by route or operation id, or get its fields. The new tools read the api.* fields the docs search index already holds and reuse the query behind the API Explorer search box. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4886/ Sample changed pages: |
Route parsing repeated ApiEndpointPath.NormalizeQuery, and both gateways formatted endpoints the same way by hand. The test stub now owns its client. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The journeys suite keeps its own copy of the handshake response, which still listed only the original tools. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mpdreamz
approved these changes
Nov 17, 2026
Every tool repeated the same span, logging and error handling, and only some turned transient backend failures into a retryable McpException. The API gateway also missed routes made only of parameters, listed only the versions of the visible landing page, and reported overloads as permanent errors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server instructions now send API lookups to the API tools, so the parameter description pointed agents two ways. The filter value still works. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A typed route like GET /_bulk with the wrong method, or a typo such as
/_clusterr, matched GET /{index} and came back as the index operation.
Index names cannot start with an underscore, so such a segment never fills
a route made only of parameters.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
_all is an index expression, so it fills a route made only of parameters
such as /{index} even though it starts with an underscore.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The docs MCP server gains three tools for the REST API reference:
search_api_operations,get_api_operationandlist_api_operations. An agent can now ask for an operation by route, such asGET /_cluster/health, or by operation id, and get its parameters and request and response fields as structured data.Affects: MCP, Search
Prompt summary: Add MCP tools dedicated to API Explorer content, as filed in elastic/docs-eng-team#1203. Ship searching, reading and listing operations together in one PR.
Why
API operations reach an agent only through
search_docswithsectionFilter: apiand throughget_document_by_url. Both return page-shaped results. An agent cannot look up an endpoint by route or operation id, narrow to one API and version, or read the fields of a request body. The docs search index already holds all of this inapi.*on every API Explorer page, so the gap is only in the MCP server.What
Searching operations
search_api_operationsruns the same query as the API Explorer search box (ApiLookupQueryBuilder), so the MCP server and the site rank operations the same way. It understands typed routes, operation words and field paths, and a trailing dot such asretriever.lists child fields. Each hit carries the fields the query matched. Results can be narrowed to one API key and version, and deprecated operations stay out unless the caller asks for them.Reading one operation
get_api_operationtakes either an operation id or an endpoint. A concrete endpoint such asGET /my-index/_searchresolves to the route it fills: the index returns every candidate template, andApiRouteMatchpicks the route with the most literal segments that also serves the typed method. A route made only of parameters, such asPUT /{index}, has no endpoint key, so the lookup also matches it by path. Index names cannot start with_, so a typed system route such asGET /_bulknever falls through to it. The reply lists the operation's routes, version trees and every documented field with its location (path,query,header,request,response). The page body comes back only on request. Operations that match equally well, such as the same operation id in another API, are listed asotherMatches.Browsing APIs
list_api_operationswithout arguments lists each API's key, landing page and versions. The versions come from every rendering of the landing page, because a hidden rendering lists the trees whose content differs from the default. With a key, it returns the API's operations by group. An API with more than 150 operations returns only its group names and counts, and the caller then passesgroup, so a large API like Elasticsearch does not flood the context.Versions and server instructions
Without a version, every tool reads the API's default tree, the documents that are not hidden. With a version, URLs are rebased into that tree. The public profile gains an
Apimodule, and its introduction now points at these tools instead ofsectionFilter: api. Thesearch_docsparameter description stops suggesting theapivalue, which still works. The tools need no feature flag: without API Explorer documents in the index they return nothing.One runner for every MCP tool
Each tool used to repeat the same span, logs and error handling, and only the search tools turned a transient backend failure into a retryable
McpException. Every tool now hands its work toMcpToolRunner, which returns either a JSON reply or a rejection such as "not found". As a result, the coherence tools and the new API tools also report timeouts and overloads as retryable.SearchUnavailableException.IsTransientholds the check, whichFullSearchServiceand the API gateway share. The gateway also catches an overload that the client returns as an invalid response instead of throwing.Verify
Out of scope: the indexed body of an operation page is still a short summary. elastic/docs-eng-team#1176 replaces it with the full operation CommonMark, which improves
includeBody=truewithout changes here.🤖 Generated with Claude Code