Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides LangChain4j patterns for implementing MCP (Model Context Protocol) servers, creating Java AI tools, exposing tool calling capabilities, and integrating MCP clients with AI services. Use when building a Java MCP server, implementing tool calling in Java, connecting LangChain4j to external MCP servers, or securing tool exposure for agent workflows.
.claude/skills/giuseppe-trisciuoglio-langchain4j-mcp-server-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-12 | ✗→✓ | ▲ Improved | 2% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -5% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 3% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 24% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 2% | 0% |
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:
javaclass 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.
javaMcpToolProvider 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-ai clean-architecture| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-04 | pass→pass | 12,549 | 8,617 | -31% | 1 | 1 | 0% | 2,237 | 2,853 | +28% | 0 | 0 | — |
case-11 | pass→pass | 13,229 | 8,617 | -35% | 1 | 1 | 0% | 2,081 | 2,544 | +22% | 0 | 0 | — |
case-12 | fail→pass | 16,969 | 13,017 | -23% | 1 | 1 | 0% | 3,219 | 3,295 | +2% | 0 | 0 | — |
case-01 | fail→pass | 25,660 | 9,468 | -63% | 1 | 1 | 0% | 3,079 | 2,914 | -5% | 0 | 0 | — |
case-02 | pass→pass | 26,887 | 14,680 | -45% | 1 | 1 | 0% | 4,145 | 3,884 | -6% | 0 | 0 | — |
case-03 | pass→pass | 16,544 | 11,329 | -32% | 1 | 1 | 0% | 3,208 | 3,455 | +8% | 0 | 0 | — |
case-05 | pass→pass | 11,018 | 7,066 | -36% | 1 | 1 | 0% | 2,074 | 2,628 | +27% | 0 | 0 | — |
case-06 | pass→pass | 12,744 | 11,906 | -7% | 1 | 1 | 0% | 2,064 | 3,314 | +61% | 0 | 0 | — |
case-07 | pass→pass | 15,701 | 5,697 | -64% | 1 | 1 | 0% | 2,528 | 2,133 | -16% | 0 | 0 | — |
case-08 | fail→pass | 18,312 | 11,728 | -36% | 1 | 1 | 0% | 3,283 | 3,374 | +3% | 0 | 0 | — |
case-09 | fail→pass | 12,715 | 8,876 | -30% | 1 | 1 | 0% | 2,412 | 2,987 | +24% | 0 | 0 | — |
case-10 | fail→pass | 15,582 | 8,860 | -43% | 1 | 1 | 0% | 2,789 | 2,846 | +2% | 0 | 0 | — |
case-13 | fail→pass | 10,995 | 6,289 | -43% | 1 | 1 | 0% | 1,835 | 2,308 | +26% | 0 | 0 | — |
case-14 | pass→pass | 12,177 | 7,569 | -38% | 1 | 1 | 0% | 1,928 | 2,363 | +23% | 0 | 0 | — |
case-15 | pass→pass | 29,668 | 17,239 | -42% | 1 | 1 | 0% | 3,540 | 3,994 | +13% | 0 | 0 | — |
case-16 | pass→pass | 14,174 | 17,229 | +22% | 1 | 1 | 0% | 2,166 | 2,851 | +32% | 0 | 0 | — |
case-17 | fail→pass | 14,353 | 11,301 | -21% | 1 | 1 | 0% | 2,337 | 3,056 | +31% | 0 | 0 | — |
case-18 | fail→fail | 8,912 | 6,614 | -26% | 1 | 1 | 0% | 1,401 | 2,277 | +63% | 0 | 0 | — |
case-19 | pass→pass | 16,896 | 10,986 | -35% | 1 | 1 | 0% | 2,640 | 3,119 | +18% | 0 | 0 | — |
case-20 | pass→pass | 22,723 | 9,667 | -57% | 1 | 1 | 0% | 2,259 | 2,723 | +21% | 0 | 0 | — |
case-21 | fail→pass | 18,883 | 7,101 | -62% | 1 | 1 | 0% | 2,908 | 2,391 | -18% | 0 | 0 | — |
case-22 | fail→pass | 8,229 | 4,237 | -49% | 1 | 1 | 0% | 1,270 | 2,099 | +65% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +41 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.