langchain4j-mcp-server-patterns by giuseppe-trisciuoglio/developer-kit
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill langchain4j-mcp-server-patterns使用此技能来设计和实现与 LangChain4j 的模型上下文协议(MCP)集成。
主要关注点包括:
保持 SKILL.md 专注于实现流程。使用捆绑的参考资料获取扩展示例和 API 级别的详细信息。
在以下情况下使用此技能:
典型的触发短语包括 langchain4j mcp、java mcp server、mcp tool provider、spring boot mcp 和 connect langchain4j to mcp。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
决定服务器应暴露哪些内容:
保持名称稳定,描述具体,模式足够小,以便客户端或模型快速理解。
为每个关注点使用单独的类:
在执行前验证参数,并为无效输入或不可用的依赖项返回清晰的错误消息。
使用:
固定外部服务器版本,并记录进程如何启动、认证和监控。
当从 LangChain4j 消费 MCP 服务器时:
至少应做到:
在发布前:
class WeatherToolProvider implements ToolProvider {
@Override
public List<ToolSpecification> listTools() {
return List.of(
ToolSpecification.builder()
.name("get_weather")
.description("Return the current weather for a city")
.inputSchema(Map.of(
"type", "object",
"properties", Map.of(
"city", Map.of("type", "string")
),
"required", List.of("city")
))
.build()
);
}
@Override
public String executeTool(String name, String arguments) {
return weatherService.lookup(arguments);
}
}
MCPServer server = MCPServer.builder()
.server(new StdioServer.Builder())
.addToolProvider(new WeatherToolProvider())
.build();
server.start();
此模式适用于本地工具执行或由其他应用程序启动的 sidecar 进程。
McpToolProvider toolProvider = McpToolProvider.builder()
.mcpClients(mcpClients)
.failIfOneServerFails(false)
.filter((client, tool) -> !tool.name().startsWith("admin_"))
.build();
Assistant assistant = AiServices.builder(Assistant.class)
.chatModel(chatModel)
.toolProvider(toolProvider)
.build();
当您希望 LangChain4j 消费外部 MCP 服务器,同时仍强制执行信任边界时,使用此模式。
references/ 中,而不是无限扩展 SKILL.md。references/examples.mdreferences/api-reference.mdprompt-engineeringspring-aiclean-architecture每周安装次数
340
代码仓库
GitHub 星标数
173
首次出现
2026年2月3日
安全审计
安装于
claude-code271
gemini-cli258
opencode257
cursor254
codex253
github-copilot236
Use this skill to design and implement Model Context Protocol (MCP) integrations with LangChain4j.
The main concerns are:
Keep SKILL.md focused on the implementation flow. Use the bundled references for expanded examples and API-level detail.
Use this skill when:
Typical trigger phrases include langchain4j mcp, java mcp server, mcp tool provider, spring boot mcp, and connect langchain4j to mcp.
Decide what the server should expose:
Keep names stable, descriptions concrete, and schemas small enough for a client or model to understand quickly.
Use separate classes for each concern:
Validate arguments before execution and return clear error messages for invalid input or unavailable dependencies.
Use:
Pin external server versions and document how the process is started, authenticated, and monitored.
When consuming MCP servers from LangChain4j:
At minimum:
Before shipping:
class WeatherToolProvider implements ToolProvider {
@Override
public List<ToolSpecification> listTools() {
return List.of(
ToolSpecification.builder()
.name("get_weather")
.description("Return the current weather for a city")
.inputSchema(Map.of(
"type", "object",
"properties", Map.of(
"city", Map.of("type", "string")
),
"required", List.of("city")
))
.build()
);
}
@Override
public String executeTool(String name, String arguments) {
return weatherService.lookup(arguments);
}
}
MCPServer server = MCPServer.builder()
.server(new StdioServer.Builder())
.addToolProvider(new WeatherToolProvider())
.build();
server.start();
Use this pattern for local tool execution or a sidecar process started by another application.
McpToolProvider toolProvider = McpToolProvider.builder()
.mcpClients(mcpClients)
.failIfOneServerFails(false)
.filter((client, tool) -> !tool.name().startsWith("admin_"))
.build();
Assistant assistant = AiServices.builder(Assistant.class)
.chatModel(chatModel)
.toolProvider(toolProvider)
.build();
Use this pattern when you want LangChain4j to consume external MCP servers while still enforcing trust boundaries.
references/ instead of expanding SKILL.md indefinitely.references/examples.mdreferences/api-reference.mdprompt-engineeringspring-aiclean-architectureWeekly Installs
340
Repository
GitHub Stars
173
First Seen
Feb 3, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code271
gemini-cli258
opencode257
cursor254
codex253
github-copilot236
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
竞争对手研究指南:SEO、内容、反向链接与定价分析工具
231 周安装
Azure 工作负载自动升级评估工具 - 支持 Functions、App Service 计划与 SKU 迁移
231 周安装
Kaizen持续改进方法论:软件开发中的渐进式优化与防错设计实践指南
231 周安装
软件UI/UX设计指南:以用户为中心的设计原则、WCAG可访问性与平台规范
231 周安装
Apify 网络爬虫和自动化平台 - 无需编码抓取亚马逊、谷歌、领英等网站数据
231 周安装
llama.cpp 中文指南:纯 C/C++ LLM 推理,CPU/非 NVIDIA 硬件优化部署
231 周安装