Skip to content

Expose MCP as toolset, and move prompts and handlers to shared package#20

Merged
openshift-merge-bot[bot] merged 8 commits intorhobs:mainfrom
saswatamcode:toolset
Feb 9, 2026
Merged

Expose MCP as toolset, and move prompts and handlers to shared package#20
openshift-merge-bot[bot] merged 8 commits intorhobs:mainfrom
saswatamcode:toolset

Conversation

@saswatamcode
Copy link
Member

No description provided.

Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
@saswatamcode saswatamcode marked this pull request as ready for review February 6, 2026 09:32
@saswatamcode saswatamcode requested a review from a team February 6, 2026 09:32
@saswatamcode saswatamcode changed the title experiment: Expose MCP as toolset Expose MCP as toolset, and move prompts and handlers to shared package Feb 6, 2026
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>

return mcp.NewToolResultStructured(output, string(jsonResult)), nil
return handlers.ExecuteRangeQueryHandler(ctx, promClient, handlers.RangeQueryInput{
Query: req.GetString("query", ""),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of this duplication of param extraction. Couldn't we make the handlers.ExecuteRangeQueryHandle accept the api.ToolHandlerParams and here provide just the appropriate implementation for ToolCallRequest? It seems it only requires GetArguments to be implemented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could still keep the wrapper for the output, to keep the ToMCPResult and ToToolsetResult, though to avoid some weird stuff with different output depending on which way one runs the mcp server, I would be for unifying the output as much as possible as well.

pkg/mcp/tools.go Outdated
The 'query' parameter MUST use metric names that were returned by list_metrics.
`),
mcp.WithDescription(prompts.ExecuteInstantQueryPrompt),
mcp.WithString("query",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly with the duplication on the handlers params request. Could we use the toolets definitions as source of truth and use the WithRawInputSchema to convert it to the required format?

@@ -1,2 +1,2 @@
golang-version=1.24
golang-version=1.25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be we can wait till ocp has go 1.25 else ci will fail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know when OCP will have go 1.25?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still waiting for it for updating other downstream forks, probably by next week I hope

@slashpai
Copy link
Member

slashpai commented Feb 9, 2026

triggering the openshift ci to see its working
/retest

@openshift-ci
Copy link

openshift-ci bot commented Feb 9, 2026

@saswatamcode: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-obs-mcp-gcp 223c797 link false /test e2e-obs-mcp-gcp

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@slashpai
Copy link
Member

slashpai commented Feb 9, 2026

Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
@openshift-ci openshift-ci bot added the approved label Feb 9, 2026

// All tool definitions as a single source of truth
var (
ListMetrics = ToolDef{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about restructuring the packages a bit so that:

  • tooldef only contains the types and generic functionality to define the tools (but nothing about specific tool instance).
  • rename the pkg/handlers to pkg/tools/ where handlers would be just part (but also added the tool definitions and request input mappings)
  • the definitions move to pkg/tools/tools.go
  • the conversion functions from bind.go could move to pkg/tools/handlers.go (IMO it would read easier, as it's just a transformation to prepare for the expected handler input). I could imagine other places, but the key part is all the tool-specific things inside pkg/tools package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, the prompts could go to pkg/tools to have most of the real meat in one place, and the rest serving more as plumbing to serve it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I just removed tooldefs and prompts, in favor of a centralized tools package with the core stuff

Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Copy link
Contributor

@iNecas iNecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @saswatamcode

@openshift-ci
Copy link

openshift-ci bot commented Feb 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iNecas, saswatamcode

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [iNecas,saswatamcode]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 171c4ad into rhobs:main Feb 9, 2026
6 of 7 checks passed
restConfig.TLSClientConfig = tlsConfig

// Create HTTP client with Kubernetes authentication
rt, err := rest.TransportFor(restConfig)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saswatamcode I am getting:

"failed to get label names: error fetching label names: Post "https://thanos-querier.openshift-monitoring.svc:9091/api/v1/labels": failed to make request: AccessControlRoundTripper failed to get kind for gvr /v1, Resource=labels: no matches for /v1, Resource=labels"

with some hacks I got beyond that.

The rest.TransportFor(...) call seems to inherit the wrapped AccessControlRoundTripper from the Kubernetes MCP server.

While the build-in prometheus client did build its on http.Client, which carries only bearer tokens and
TLS settings.

See: https://github.com/openshift/openshift-mcp-server/blob/main/pkg/prometheus/client.go#L140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants