quarkus-mcp-server
by: quarkiverse
This extension enables developers to implement the MCP server features easily.
📌Overview
Purpose: To provide a framework for enabling seamless integration between large language model (LLM) applications and external data sources through the Model Context Protocol (MCP).
Overview: The Quarkus Model Context Protocol (MCP) Server facilitates the implementation of the MCP, offering developers both declarative and programmatic APIs to easily build server features that integrate with LLM applications. This allows for enhanced interactions with external resources and tools, making development streamlined and efficient.
Key Features:
-
Declarative and Programmatic APIs: Enables developers to define server features through annotations on business methods, simplifying the creation and management of functionalities like prompts and tools.
-
Integration with LangChain4j: Provides client functionality for MCP, either through a low-level programmatic API or full integration into AI-infused applications, enhancing its versatility and usability.
Quarkus Model Context Protocol (MCP) Server
"Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools."
This extension provides declarative and programmatic APIs for implementing MCP server features.
Get Started
Step 1
Add the following dependency to your POM file:
<dependency>
<groupId>io.quarkiverse.mcp</groupId>
<artifactId>quarkus-mcp-server-sse</artifactId>
<version>${project-version}</version>
</dependency>
Step 2
Add server features (prompts, resources, and tools) represented by annotated business methods of CDI beans.
import jakarta.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import io.quarkiverse.mcp.server.BlobResourceContents;
import io.quarkiverse.mcp.server.Prompt;
import io.quarkiverse.mcp.server.PromptArg;
import io.quarkiverse.mcp.server.PromptMessage;
import io.quarkiverse.mcp.server.Tool;
import io.quarkiverse.mcp.server.Resource;
import io.quarkiverse.mcp.server.TextContent;
public class ServerFeatures {
@Inject
CodeService codeService;
@Tool(description = "Converts the string value to lower case")
String toLowerCase(String value) {
return value.toLowerCase();
}
@Prompt(name = "code_assist")
PromptMessage codeAssist(@PromptArg(name = "lang") String language) {
return PromptMessage.withUserRole(new TextContent(codeService.assist(language)));
}
@Resource(uri = "file:///project/alpha")
BlobResourceContents alpha(RequestUri uri) throws IOException {
return BlobResourceContents.create(uri.value(), Files.readAllBytes(Paths.ALPHA));
}
}
Step 3
Run your Quarkus app and enjoy!
Documentation
The full documentation is available at Quarkus MCP Server Documentation.
Contributors ✨
Thanks to these contributors for their support:
This project follows the all-contributors specification. Contributions of any kind welcome!