Skip to content

[GSOC] Add sse mcp server #3503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

sarthakeash
Copy link
Contributor

@sarthakeash sarthakeash commented Jun 24, 2025

What's changed?

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

sarthakeash and others added 17 commits June 9, 2025 18:18
- Make the mcp a bean and run as the process as original spring boot
Removed previous LLM service implementations and introduced a unified ChatClientProviderService to handle interactions with LLM providers. Implemented ConversationService enhancements with new capabilities like streaming responses, conversation history, and management. Updated configurations and dependencies to support these changes.
Removed unused imports, methods, and annotations to streamline the codebase and improve maintainability. Updated `pom.xml` to add necessary dependencies and repositories for AI functionality. Refactored controllers to include standard REST mappings for improved API structure.
- MCP server - working
- Chat Client - working
- Client able to access the tools - working
- dependencies resolved
Removed `AgentApplication` configuration class, shifting `ToolCallbackProvider` setup to `McpServerServiceImpl`. Refactored `ChatClientProviderService` to unify chat handling logic and added support for streaming chat responses via `ChatController`. These changes improve modularity and simplify chat-related operations.
Removed unused MCP configuration classes and updated method and bean names to replace "monitorTools" with "hertzbeatTools" for better clarity and consistency. This improves code readability and aligns naming with project conventions.
Renamed and updated methods for better clarity and functionality, such as `listMonitors` replacing `getMonitors`. Introduced `PromptProvider` to standardize AI prompts for monitoring operations. Enhanced error handling and logging for the `MonitorServiceAdapterImpl` to improve debugging and reliability.
@tomsun28 tomsun28 added this to the 1.7.3 milestone Jun 24, 2025
@tomsun28 tomsun28 changed the title Add sse mcp server [GSOC] Add sse mcp server Jun 24, 2025
Comment on lines -50 to -54

@PostConstruct
public void init() {
System.setProperty("jdk.jndi.object.factoriesFilter", "!com.zaxxer.hikari.HikariJNDIFactory");
}
Copy link
Member

@tomsun28 tomsun28 Jun 27, 2025

Choose a reason for hiding this comment

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

hi please not delete these code, if anyelse reason to delete them?

}

assert monitorService != null;
System.out.println("MonitorServiceImpl found: " + Arrays.toString(monitorService.getClass().getMethods()));
Copy link
Member

Choose a reason for hiding this comment

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

please use log to instead of System.out.println

Comment on lines +39 to +50
public SseEmitter streamChat(@RequestBody ChatRequestContext context) {
SseEmitter emitter = new SseEmitter();
new Thread(() -> {
try {
String aiResponse = chatClientProviderService.streamChat(context);
emitter.send(aiResponse);
emitter.complete();
} catch (Exception e) {
emitter.completeWithError(e);
}
}).start();
return emitter;
Copy link
Member

Choose a reason for hiding this comment

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

how about use the webflux and reactor likeFlux<ServerSentEvent<XX>>

Copy link
Member

Choose a reason for hiding this comment

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

@tomsun28
Copy link
Member

hi please add the apache license header and fix backend ci.

</plugins>
</build>

</project>
Copy link
Member

Choose a reason for hiding this comment

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

All files in the project should end with a blank line.
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206

public class LlmConfig {
@Bean
public ChatClient openAiChatClient(OpenAiChatModel chatModel) {
return ChatClient.create(chatModel);
Copy link
Member

Choose a reason for hiding this comment

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

Is the create method used directly here to create the ChatClient instance? Do we need some other parameters?

* Static version of the HertzBeat monitoring prompt
*/
public static final String HERTZBEAT_MONITORING_PROMPT =
"You are an AI assistant specialized in monitoring infrastructure and applications with HertzBeat. "
Copy link
Member

Choose a reason for hiding this comment

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

IMO, we can use java17 string blocks to write promotion, which is more readable.

such as:

String content = """
 prompt content
""";

private final ChatClientProviderService chatClientProviderService;

@Autowired
public ChatController(@Qualifier("openAiChatClient") ChatClient openAiChatClient,
Copy link
Member

@yuluo-yx yuluo-yx Jul 2, 2025

Choose a reason for hiding this comment

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

I saw that only openai starter was referenced in the project. So I don't think it is necessary to use it here @Qualifier("openAiChatClient". Unless we have plans to introduce other models

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

Successfully merging this pull request may close these issues.

6 participants