-
-
Notifications
You must be signed in to change notification settings - Fork 207
Added Model Context Protocol #1093
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
Merged
+630
−152
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f938513
Added MCP Controller, Changed content field name to value, upgraded c…
germanosin 6893e2a
Fixed naming errors
germanosin 111c267
Fixed fe test
germanosin 04453dc
Merge branch 'main' into mcp
germanosin 776f97f
minor code fix
germanosin a3fc7cf
Fixed PR comments
germanosin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
api/src/main/java/io/kafbat/ui/config/JsonSchemaConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package io.kafbat.ui.config; | ||
|
|
||
| import com.github.victools.jsonschema.generator.OptionPreset; | ||
| import com.github.victools.jsonschema.generator.SchemaGenerator; | ||
| import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder; | ||
| import com.github.victools.jsonschema.generator.SchemaVersion; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Configuration | ||
| public class JsonSchemaConfig { | ||
| @Bean | ||
| public SchemaGenerator schemaGenerator() { | ||
| SchemaGeneratorConfigBuilder configBuilder = | ||
| new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON); | ||
| return new SchemaGenerator(configBuilder.build()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package io.kafbat.ui.config; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import io.kafbat.ui.service.mcp.McpSpecificationGenerator; | ||
| import io.kafbat.ui.service.mcp.McpTool; | ||
| import io.modelcontextprotocol.server.McpAsyncServer; | ||
| import io.modelcontextprotocol.server.McpServer; | ||
| import io.modelcontextprotocol.server.McpServerFeatures.AsyncPromptSpecification; | ||
| import io.modelcontextprotocol.server.McpServerFeatures.AsyncToolSpecification; | ||
| import io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider; | ||
| import io.modelcontextprotocol.spec.McpSchema; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.reactive.function.server.RouterFunction; | ||
|
|
||
| @Configuration | ||
| @RequiredArgsConstructor | ||
| @ConditionalOnProperty(value = "mcp.enabled", havingValue = "true") | ||
| public class McpConfig { | ||
|
|
||
| private final List<McpTool> mcpTools; | ||
| private final McpSpecificationGenerator mcpSpecificationGenerator; | ||
|
|
||
| // SSE transport | ||
| @Bean | ||
| public WebFluxSseServerTransportProvider sseServerTransport(ObjectMapper mapper) { | ||
| return new WebFluxSseServerTransportProvider(mapper, "/mcp/message", "/mcp/sse"); | ||
| } | ||
|
|
||
| // Router function for SSE transport used by Spring WebFlux to start an HTTP | ||
| // server. | ||
|
|
||
| @Bean | ||
| public RouterFunction<?> mcpRouterFunction(WebFluxSseServerTransportProvider transport) { | ||
| return transport.getRouterFunction(); | ||
| } | ||
|
|
||
| @Bean | ||
| public McpAsyncServer mcpServer(WebFluxSseServerTransportProvider transport) { | ||
|
|
||
| // Configure server capabilities with resource support | ||
| var capabilities = McpSchema.ServerCapabilities.builder() | ||
| .resources(false, true) | ||
| .tools(true) // Tool support with list changes notifications | ||
| .prompts(false) // Prompt support with list changes notifications | ||
| .logging() // Logging support | ||
| .build(); | ||
|
|
||
| // Create the server with both tool and resource capabilities | ||
| return McpServer.async(transport) | ||
| .serverInfo("Kafka UI MCP", "0.0.1") | ||
| .capabilities(capabilities) | ||
| .tools(tools()) | ||
| .build(); | ||
| } | ||
|
|
||
| private List<AsyncToolSpecification> tools() { | ||
| List<AsyncToolSpecification> tools = new ArrayList<>(); | ||
| for (McpTool mcpTool : mcpTools) { | ||
| tools.addAll(mcpSpecificationGenerator.convertTool(mcpTool)); | ||
| } | ||
| return tools; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.