返回市场
夸克斯-MCP服务器

夸克斯-MCP服务器

作者:quarkiverse164 星标更新:2025-11-21

项目介绍

Quarkus MCP 服务器

<!-- ALL-CONTRIBUTORS-BADGE:START - 不要删除或修改此部分 -->

所有贡献者

<!-- ALL-CONTRIBUTORS-BADGE:END -->

版本

这个Quarkus扩展提供了声明式和编程式的API,使开发者能够轻松实现MCP1服务器特性。

[!NOTE] LangChain4j项目提供了MCP客户端功能,既可以作为低级别的编程API,也可以作为完全集成到AI增强应用中的功能。

开始使用

步骤 #1

在你的POM文件中添加以下依赖项:

<dependency>
    <groupId>io.quarkiverse.mcp</groupId>
    <artifactId>quarkus-mcp-server-sse</artifactId>
    <version>${quarkus-mcp-server-version}</version>
</dependency>

[!NOTE] 这个依赖项包括HTTP/SSE传输。如果你想要使用STDIO传输,请使用quarkus-mcp-server-stdio artifactId。更多信息请参阅文档中的支持的传输方式部分。

步骤 #2

添加服务器特性(提示、资源和工具),这些特性由CDI bean的注解业务方法表示。

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.Resource;
import io.quarkiverse.mcp.server.TextContent;
import io.quarkiverse.mcp.server.Tool;

// 此类自动注册为@Singleton CDI bean
public class MyServerFeatures {

    @Inject
    CodeService codeService;

    @Tool(description = "将字符串值转换为小写")
    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(Path.of("alpha.txt")));
    }

}

步骤 #3

运行你的Quarkus应用并享受吧!

文档

完整的文档可以在 https://quarkiverse.github.io/quarkiverse-docs/quarkus-mcp-server/dev/index.html 获取。

贡献者 ✨

感谢以下杰出人士的贡献 (表情符号键):

<!-- ALL-CONTRIBUTORS-LIST:START - 不要删除或修改此部分 --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/mkouba"><img src="https://avatars.githubusercontent.com/u/913004?v=4?s=100" width="100px;" alt="Martin Kouba"/><br /><sub><b>Martin Kouba</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=mkouba" title="代码">💻</a> <a href="#maintenance-mkouba" title="维护">🚧</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/geoand"><img src="https://avatars.githubusercontent.com/u/4374975?v=4?s=100" width="100px;" alt="Georgios Andrianakis"/><br /><sub><b>Georgios Andrianakis</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=geoand" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://xam.dk"><img src="https://gips2.baidu.com/it/u=3776264418,2370630295&fm=3081&app=3081&f=JPEG?w=460&h=460" width="100px;" alt="Max Rydahl Andersen"/><br /><sub><b>Max Rydahl Andersen</b></sub></a><br /><a href="#example-maxandersen" title="示例">💡</a></td> <td align="center" valign="top" width="14.28%"><a href="https://twitter.com/r_svoboda"><img src="https://gips1.baidu.com/it/u=989002851,3989556279&fm=3081&app=3081&f=JPEG?w=460&h=460" width="100px;" alt="Rostislav Svoboda"/><br /><sub><b>Rostislav Svoboda</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=rsvoboda" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/gastaldi"><img src="https://gips1.baidu.com/it/u=3726191944,1543268553&fm=3081&app=3081&f=JPEG?w=376&h=376" width="100px;" alt="George Gastaldi"/><br /><sub><b>George Gastaldi</b></sub></a><br /><a href="#infra-gastaldi" title="基础设施 (托管、构建工具等)">🚇</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jmartisk"><img src="https://gips0.baidu.com/it/u=666248629,3422340865&fm=3081&app=3081&f=PNG?w=342&h=342" width="100px;" alt="Jan Martiska"/><br /><sub><b>Jan Martiska</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=jmartisk" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="http://iocanel.com"><img src="https://avatars.githubusercontent.com/u/402008?v=4?s=100" width="100px;" alt="Ioannis Canellos"/><br /><sub><b>Ioannis Canellos</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=iocanel" title="代码">💻</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/sberyozkin"><img src="https://avatars.githubusercontent.com/u/467639?v=4?s=100" width="100px;" alt="Sergey Beryozkin"/><br /><sub><b>Sergey Beryozkin</b></sub></a><br /><a href="#example-sberyozkin" title="示例">💡</a></td> <td align="center" valign="top" width="14.28%"><a href="http://kpavlov.me"><img src="https://gips2.baidu.com/it/u=1816607458,2322400713&fm=3081&app=3081&f=JPEG?w=460&h=460" width="100px;" alt="Konstantin Pavlov"/><br /><sub><b>Konstantin Pavlov</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=kpavlov" title="测试">⚠️</a> <a href="#infra-kpavlov" title="基础设施 (托管、构建工具等)">🚇</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/mvduijnhoven"><img src="https://gips2.baidu.com/it/u=2386998153,2554212890&fm=3081&app=3081&f=JPEG?w=460&h=460" width="100px;" alt="Martijn van Duijnhoven"/><br /><sub><b>Martijn van Duijnhoven</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=mvduijnhoven" title="代码">💻</a> <a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=mvduijnhoven" title="测试">⚠️</a> <a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=mvduijnhoven" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/PierreBtz"><img src="https://avatars.githubusercontent.com/u/9881659?v=4?s=100" width="100px;" alt="Pierre Beitz"/><br /><sub><b>Pierre Beitz</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=PierreBtz" title="代码">💻</a> <a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=PierreBtz" title="测试">⚠️</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/mrecouly"><img src="https://gips3.baidu.com/it/u=912857257,1260889279&fm=3081&app=3081&f=JPEG?w=460&h=460" width="100px;" alt="Matthieu Recouly"/><br /><sub><b>Matthieu Recouly</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-mcp-server/commits?author=mrecouly" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://wjglerum.nl"><img src="https://avatars.githubusercontent.com/u/7404187?v=4?s=100" width="100px;" alt="Willem Jan Glerum"/><br /><sub><b>Willem Jan Glerum</b></sub></a><br /><a href="#infra-wjglerum" title="基础设施 (托管、构建工具等)">🚇</a></td> </tr> </tbody> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

本项目遵循all-contributors规范。欢迎任何形式的贡献!

Footnotes

  1. "模型上下文协议 (MCP) 是一个开放协议,它使得大型语言模型应用程序与外部数据源和工具之间的无缝集成成为可能。"