Skip to content

[Feature][Java] Move MCP resource discovery to runtime#639

Open
yanand0909 wants to merge 1 commit intoapache:mainfrom
yanand0909:runtime_mcp_resource_discovery
Open

[Feature][Java] Move MCP resource discovery to runtime#639
yanand0909 wants to merge 1 commit intoapache:mainfrom
yanand0909:runtime_mcp_resource_discovery

Conversation

@yanand0909
Copy link
Copy Markdown
Collaborator

Linked issue: 608

Purpose of change

MCP tools and prompts were previously discovered at compile time inside AgentPlan.extractJavaMCPServer(): an MCPServer connection was opened, listTools()/listPrompts() were called over the network, results were serialized into the plan, and the connection was immediately closed. This had three problems:

  1. Build-time server dependency — AgentPlan construction failed if the MCP server was unreachable, even though the agent wouldn't run until later.
  2. Static capabilities — Tools and prompts were frozen at compile time; any server-side changes required recompilation.
  3. No connection reuse — The connection opened for discovery was closed immediately; a new one was established later for actual tool calls.

This PR implements Part 1: Runtime Discovery from discussion #543. MCP tool and prompt discovery is moved from AgentPlan construction to ActionExecutionOperator.open():

Tests

  • AgentPlanDeclareMCPServerTest — Updated to assert the new compile-time contract: TOOL and PROMPT providers are absent from AgentPlan providers (deferred to runtime), only MCP_SERVER is registered. Tool/prompt retrieval tests now instantiate the MCPServer directly from the plan's provider, simulating what JavaMCPResourceDiscovery does at operator startup.
  • JavaMCPResourceDiscoveryTest (new) — Six unit tests covering JavaMCPResourceDiscovery with stub objects (no live server required):
    • Happy path: tools and prompts are discovered and placed in ResourceCache
    • supportsPrompts() = false: prompt discovery is skipped
    • Non-JavaResourceProvider entries are ignored

API

No public API changes

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. priority/major Default priority of the PR or issue. labels Apr 24, 2026
@wenjin272
Copy link
Copy Markdown
Collaborator

Thanks for your contribution, @yanand0909. Due to the upcoming traditional Chinese holiday, my review may be slightly delayed.

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

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants