Skip to content

feat: support MCP tool calls#200

Merged
Pasichniuk merged 22 commits intodevelopmentfrom
mcp-tools-try-out
Mar 9, 2026
Merged

feat: support MCP tool calls#200
Pasichniuk merged 22 commits intodevelopmentfrom
mcp-tools-try-out

Conversation

@Pasichniuk
Copy link
Collaborator

@Pasichniuk Pasichniuk commented Mar 6, 2026

Applicable issues

Description of changes

Added new endpoint to call MCP server tools: POST /api/v1/deployments/mcp/{deploymentId}/call-tool

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Pasichniuk Pasichniuk self-assigned this Mar 6, 2026
@ai-dial-actions
Copy link
Contributor

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 1 package(s) with unknown licenses.
See the Details below.

License Issues

settings.gradle

PackageVersionLicenseIssue Type
com.gradle:develocity-gradle-plugin4.3.1NullUnknown License

OpenSSF Scorecard

PackageVersionScoreDetails
maven/com.gradle:develocity-gradle-plugin 4.3.1 UnknownUnknown

Scanned Files

  • settings.gradle

@Pasichniuk Pasichniuk changed the base branch from 001-deployment-topics to development March 6, 2026 15:46
# Conflicts:
#	src/test/java/com/epam/aidial/deployment/manager/functional/tests/TopicFunctionalTest.java
@ai-dial-actions
Copy link
Contributor

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 2 package(s) with unknown licenses.
See the Details below.

License Issues

settings.gradle

PackageVersionLicenseIssue Type
com.gradle:common-custom-user-data-gradle-plugin2.1NullUnknown License
com.gradle:develocity-gradle-plugin4.3.1NullUnknown License

OpenSSF Scorecard

PackageVersionScoreDetails
maven/com.gradle:common-custom-user-data-gradle-plugin 2.1 UnknownUnknown
maven/com.gradle:develocity-gradle-plugin 4.3.1 UnknownUnknown

Scanned Files

  • settings.gradle

@Pasichniuk Pasichniuk marked this pull request as ready for review March 6, 2026 15:48
Copy link
Contributor

@oleksii-donets oleksii-donets left a comment

Choose a reason for hiding this comment

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

Review: feat: support MCP tool calls

Overall the feature is clean and well-scoped. A few issues to address:

1. Code duplication — callTool duplicates the get() template pattern

McpService.callTool() manually repeats the same steps as the private get() method: get deployment → resolve endpoint → create client → initialize → call → catch. Consider extracting a shared execute helper that both get() and callTool() can use:

private <T> T execute(String deploymentId, Function<McpSyncClient, T> operation) {
    var deployment = getDeployment(deploymentId);
    var endpointPath = mcpEndpointPathResolver.resolveEndpointPath(deployment);
    try (var mcpClient = mcpClientFactory.create(deployment.getUrl(), endpointPath, deployment.getTransport())) {
        mcpClient.initialize();
        return operation.apply(mcpClient);
    } catch (Exception e) {
        // unified error handling
    }
}

Then callTool becomes a one-liner, and get() delegates to execute as well.

2. Potential NPE — ExceptionUtils.getRootCause(e) can return null

From the Apache Commons docs: getRootCause() returns null if the throwable has no cause chain (i.e., it is the root cause). This means ExceptionUtils.getRootCause(e).getMessage() will throw an NPE in that case.

Use ExceptionUtils.getRootCauseMessage(e) instead, or fall back:

var root = ExceptionUtils.getRootCause(e);
String reason = root != null ? root.getMessage() : e.getMessage();

3. @Transactional(readOnly = true) inconsistency

The new callTool method has @Transactional(readOnly = true), but the existing listing methods (getTools, getResources, getPrompts) don't. Either all MCP service methods that read deployments should have it, or none should. I'd suggest removing it from callTool to stay consistent with existing methods, unless there's a specific reason it was added.

4. Different error message style

The existing get() method uses a user-friendly message: "Failed to connect to MCP server. Make sure transport '...' and path '...' are correct." The new callTool uses a more technical message with root cause extraction. Consider keeping the error message style consistent — the user-friendly pattern from get() is preferable.

5. Test style inconsistency — JSON path constants

Existing tests in McpControllerTest inline the JSON resource paths directly in ResourceUtils.readResource() calls (e.g. ResourceUtils.readResource("/mcp/mcp_tools_response.json")). The new test extracts them into private static final constants (CALL_TOOL_REQUEST_DTO_JSON_PATH, CALL_TOOL_RESULT_DTO_JSON_PATH) even though each is used only once. Better to keep one style — inline them to match the existing pattern.

6. Minor — test JSON files missing trailing newline

Both call_tool_request_dto.json and call_tool_result_dto.json are missing a trailing newline (\ No newline at end of file).

@ai-dial-actions
Copy link
Contributor

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 2 package(s) with unknown licenses.
See the Details below.

License Issues

settings.gradle

PackageVersionLicenseIssue Type
com.gradle:common-custom-user-data-gradle-plugin2.1NullUnknown License
com.gradle:develocity-gradle-plugin4.3.1NullUnknown License

OpenSSF Scorecard

PackageVersionScoreDetails
maven/com.gradle:common-custom-user-data-gradle-plugin 2.1 UnknownUnknown
maven/com.gradle:develocity-gradle-plugin 4.3.1 UnknownUnknown

Scanned Files

  • settings.gradle

@ai-dial-actions
Copy link
Contributor

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 2 package(s) with unknown licenses.
See the Details below.

License Issues

settings.gradle

PackageVersionLicenseIssue Type
com.gradle:common-custom-user-data-gradle-plugin2.1NullUnknown License
com.gradle:develocity-gradle-plugin4.3.1NullUnknown License

OpenSSF Scorecard

PackageVersionScoreDetails
maven/com.gradle:common-custom-user-data-gradle-plugin 2.1 UnknownUnknown
maven/com.gradle:develocity-gradle-plugin 4.3.1 UnknownUnknown

Scanned Files

  • settings.gradle

@Pasichniuk Pasichniuk merged commit ee5b321 into development Mar 9, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP tools try out

3 participants