Skip to content

Not triggering the tool methods of mcp server(STREAMABLE HTTP protocol) #691

@829shubhamsingh

Description

@829shubhamsingh

Describe the Problem/Bug

I'm using sap ai sdk version 1.13.0 in my client application.
I have built a mcp server using spring ai sdk version (1.1.2).

While invoking com.sap.ai.sdk.foundationmodels.openai.spring.OpenAiChatModel class call method , tools from mcp server(STREAMABLE HTTP protocol) are not triggered .

When i built mcp server using SSE protocol, with same implementation tool calling works.

Steps to Reproduce

Client side code snippets:

import com.sap.ai.sdk.foundationmodels.openai.OpenAiClient;
import com.sap.ai.sdk.foundationmodels.openai.spring.OpenAiChatModel;
import org.springframework.ai.tool.ToolCallback;

    public OpenAiClient getOpenAiClient() {
        HttpDestination destination = DestinationAccessor.getDestination(aicoreDestinationName).asHttp();
        AiCoreService aiCoreService = new AiCoreService().withBaseDestination(destination);
        var openAiDestination = aiCoreService.getInferenceDestination(resourceGroupName).usingDeploymentId(generatingModelDeploymentId);
        return OpenAiClient.withCustomDestination(openAiDestination);
    }


    public OpenAiChatModel getChatModel() {
        return new OpenAiChatModel(getOpenAiClient());
    }

ToolCallback[] toolCallbacks = toolCallbackProvider.getToolCallbacks();
var options = new DefaultToolCallingChatOptions();
options.setToolCallbacks(List.of(toolCallbacks));
OpenAiChatModel client = getChatModel();

Message system = new SystemMessage(
                """
                       You are a helpful assistant that helps users in resolving customer incidents.
                       Generate response in a markdown format with proper headings, sections and bullet points.                       """);

private static List<Message> messages = new ArrayList<>();

Message user = new UserMessage(promptDTO.getPrompt());
messages.add(system);
messages.add(user);
Prompt prompt = new Prompt(messages, options);
var response = client.call(prompt).getResult().getOutput();

Expected Behavior

It should have triggered tool methods when using STREAMABLE HTTP protocol based mcp server as well.

Screenshots

No response

Used Versions

  • Java : JAVA 17 , Maven : 3.9.8
  • sap ai sdk version 1.13.0 in my client application.
  • I have built a mcp server using spring ai sdk version (1.1.2).

Code Examples

// Your code here

Stack Trace

No response

Log File

Log file ...

Affected Development Phase

Development

Impact

No Impact

Timeline

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions