
Langchain4j Mcp Server Patterns
Bootstrap a LangChain4j MCP server with Spring Boot wiring for tools, resources, prompts, and stdio transport.
Overview
langchain4j-mcp-server-patterns is an agent skill for the Build phase that provides LangChain4j and Spring Boot MCP server templates with tools, resources, prompts, and stdio transport.
Install
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill langchain4j-mcp-server-patternsWhat is this skill?
- Spring Boot @SpringBootApplication entry with MCPServer @Bean assembly
- StdioServer transport builder for Claude Desktop-style MCP hosting
- Composable ToolProvider, ResourceListProvider, and PromptListProvider registration
- MCPServer builder with optional logging enablement
- Starter structure for MCP clients connecting to external MCP endpoints
- Registers three provider types: tools, resources, and prompts
- Uses StdioServer builder for MCP transport
Adoption & trust: 1.1k installs on skills.sh; 271 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need an MCP server on Java/Spring but lack a proven LangChain4j layout for tools, resources, prompts, and stdio hosting.
Who is it for?
JVM-focused solo builders spinning up LangChain4j MCP servers alongside existing Spring services.
Skip if: Python or Node-only stacks, or teams that only consume MCP clients without hosting a server.
When should I use this skill?
User is implementing or scaffolding a LangChain4j-based MCP server with Spring Boot integration.
What do I get? / Deliverables
You get a Spring Boot MCP server skeleton with provider hooks and transport configuration ready for your custom tool and resource implementations.
- Spring Boot MCP server class structure with MCPServer bean
- Provider extension points for domain-specific tools and resources
Recommended Skills
Journey fit
How it compares
A Java MCP server template skill—not a hosted MCP marketplace listing or a generic REST API generator.
Common Questions / FAQ
Who is langchain4j-mcp-server-patterns for?
Developers shipping agent features on Spring Boot who want LangChain4j-native MCP server structure instead of porting examples from other languages.
When should I use langchain4j-mcp-server-patterns?
During Build agent-tooling work when you are creating a new MCP server with tools, resources, prompts, and stdio transport for Claude or compatible clients.
Is langchain4j-mcp-server-patterns safe to install?
Treat it as code you will run locally; review the skill bundle and Security Audits panel on this page before enabling shell, network, or deployment automation around your server.
SKILL.md
READMESKILL.md - Langchain4j Mcp Server Patterns
package com.example.mcp; import dev.langchain4j.mcp.*; import dev.langchain4j.mcp.transport.*; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import java.util.List; // Helper imports import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.Map; /** * Template for creating MCP servers with LangChain4j. * * This template provides a starting point for building MCP servers with: * - Tool providers * - Resource providers * - Prompt providers * - Spring Boot integration * - Configuration management */ @SpringBootApplication public class MCPServerTemplate { public static void main(String[] args) { SpringApplication.run(MCPServerTemplate.class, args); } /** * Configure and build the main MCP server instance. */ @Bean public MCPServer mcpServer( List<ToolProvider> toolProviders, List<ResourceListProvider> resourceProviders, List<PromptListProvider> promptProviders) { return MCPServer.builder() .server(new StdioServer.Builder()) .addToolProvider(toolProviders) .addResourceProvider(resourceProviders) .addPromptProvider(promptProviders) .enableLogging(true) .build(); } /** * Configure MCP clients for connecting to external MCP servers. */ @Bean public McpClient mcpClient() { StdioMcpTransport transport = new StdioMcpTransport.Builder() .command(List.of("npm", "exec", "@modelcontextprotocol/server-everything@0.6.2")) .logEvents(true) .build(); return new DefaultMcpClient.Builder() .key("template-client") .transport(transport) .cacheToolList(true) .build(); } /** * Configure MCP tool provider for AI services integration. */ @Bean public McpToolProvider mcpToolProvider(McpClient mcpClient) { return McpToolProvider.builder() .mcpClients(mcpClient) .failIfOneServerFails(false) .build(); } } /** * Example tool provider implementing a simple calculator. */ class CalculatorToolProvider implements ToolProvider { @Override public List<ToolSpecification> listTools() { return List.of( ToolSpecification.builder() .name("add") .description("Add two numbers") .inputSchema(Map.of( "type", "object", "properties", Map.of( "a", Map.of("type", "number", "description", "First number"), "b", Map.of("type", "number", "description", "Second number") ), "required", List.of("a", "b") )) .build(), ToolSpecification.builder() .name("multiply") .description("Multiply two numbers") .inputSchema(Map.of( "type", "object", "properties", Map.of( "a", Map.of("type", "number", "description", "First number"), "b", Map.of("type", "number", "description", "Second number") ), "required", List.of("a", "b") )) .build() ); } @Override public String executeTool(String name, String arguments) { try { // Parse JSON arguments ObjectMapper mapper = new ObjectMapper(); JsonNode argsNode = mapper.readTree(arguments); double a = argsNode.get("a").asDouble(); double b = argsNode.get("b").asDouble(); switch (name) { case "add": return String.valueOf(a + b);