$npx -y skills add github/awesome-copilot --skill java-mcp-server-generatorGenerate a complete Model Context Protocol server project in Java using the official MCP Java SDK with reactive streams and optional Spring Boot integration.
| 1 | # Java MCP Server Generator |
| 2 | |
| 3 | Generate a complete, production-ready MCP server in Java using the official Java SDK with Maven or Gradle. |
| 4 | |
| 5 | ## Project Generation |
| 6 | |
| 7 | When asked to create a Java MCP server, generate a complete project with this structure: |
| 8 | |
| 9 | ``` |
| 10 | my-mcp-server/ |
| 11 | ├── pom.xml (or build.gradle.kts) |
| 12 | ├── src/ |
| 13 | │ ├── main/ |
| 14 | │ │ ├── java/ |
| 15 | │ │ │ └── com/example/mcp/ |
| 16 | │ │ │ ├── McpServerApplication.java |
| 17 | │ │ │ ├── config/ |
| 18 | │ │ │ │ └── ServerConfiguration.java |
| 19 | │ │ │ ├── tools/ |
| 20 | │ │ │ │ ├── ToolDefinitions.java |
| 21 | │ │ │ │ └── ToolHandlers.java |
| 22 | │ │ │ ├── resources/ |
| 23 | │ │ │ │ ├── ResourceDefinitions.java |
| 24 | │ │ │ │ └── ResourceHandlers.java |
| 25 | │ │ │ └── prompts/ |
| 26 | │ │ │ ├── PromptDefinitions.java |
| 27 | │ │ │ └── PromptHandlers.java |
| 28 | │ │ └── resources/ |
| 29 | │ │ └── application.properties (if using Spring) |
| 30 | │ └── test/ |
| 31 | │ └── java/ |
| 32 | │ └── com/example/mcp/ |
| 33 | │ └── McpServerTest.java |
| 34 | └── README.md |
| 35 | ``` |
| 36 | |
| 37 | ## Maven pom.xml Template |
| 38 | |
| 39 | ```xml |
| 40 | <?xml version="1.0" encoding="UTF-8"?> |
| 41 | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| 42 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 43 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
| 44 | http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 45 | <modelVersion>4.0.0</modelVersion> |
| 46 | |
| 47 | <groupId>com.example</groupId> |
| 48 | <artifactId>my-mcp-server</artifactId> |
| 49 | <version>1.0.0</version> |
| 50 | <packaging>jar</packaging> |
| 51 | |
| 52 | <name>My MCP Server</name> |
| 53 | <description>Model Context Protocol server implementation</description> |
| 54 | |
| 55 | <properties> |
| 56 | <java.version>17</java.version> |
| 57 | <maven.compiler.source>17</maven.compiler.source> |
| 58 | <maven.compiler.target>17</maven.compiler.target> |
| 59 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| 60 | <mcp.version>0.14.1</mcp.version> |
| 61 | <slf4j.version>2.0.9</slf4j.version> |
| 62 | <logback.version>1.4.11</logback.version> |
| 63 | <junit.version>5.10.0</junit.version> |
| 64 | </properties> |
| 65 | |
| 66 | <dependencies> |
| 67 | <!-- MCP Java SDK --> |
| 68 | <dependency> |
| 69 | <groupId>io.modelcontextprotocol.sdk</groupId> |
| 70 | <artifactId>mcp</artifactId> |
| 71 | <version>${mcp.version}</version> |
| 72 | </dependency> |
| 73 | |
| 74 | <!-- Logging --> |
| 75 | <dependency> |
| 76 | <groupId>org.slf4j</groupId> |
| 77 | <artifactId>slf4j-api</artifactId> |
| 78 | <version>${slf4j.version}</version> |
| 79 | </dependency> |
| 80 | <dependency> |
| 81 | <groupId>ch.qos.logback</groupId> |
| 82 | <artifactId>logback-classic</artifactId> |
| 83 | <version>${logback.version}</version> |
| 84 | </dependency> |
| 85 | |
| 86 | <!-- Testing --> |
| 87 | <dependency> |
| 88 | <groupId>org.junit.jupiter</groupId> |
| 89 | <artifactId>junit-jupiter</artifactId> |
| 90 | <version>${junit.version}</version> |
| 91 | <scope>test</scope> |
| 92 | </dependency> |
| 93 | <dependency> |
| 94 | <groupId>io.projectreactor</groupId> |
| 95 | <artifactId>reactor-test</artifactId> |
| 96 | <scope>test</scope> |
| 97 | </dependency> |
| 98 | </dependencies> |
| 99 | |
| 100 | <build> |
| 101 | <plugins> |
| 102 | <plugin> |
| 103 | <groupId>org.apache.maven.plugins</groupId> |
| 104 | <artifactId>maven-compiler-plugin</artifactId> |
| 105 | <version>3.11.0</version> |
| 106 | </plugin> |
| 107 | <plugin> |
| 108 | <groupId>org.apache.maven.plugins</groupId> |
| 109 | <artifactId>maven-surefire-plugin</artifactId> |
| 110 | <version>3.1.2</version> |
| 111 | </plugin> |
| 112 | <plugin> |
| 113 | <groupId>org.apache.maven.plugins</groupId> |
| 114 | <artifactId>maven-shade-plugin</artifactId> |
| 115 | <version>3.5.0</version> |
| 116 | <executions> |
| 117 | <execution> |
| 118 | <phase>package</phase> |
| 119 | <goals> |
| 120 | <goal>shade</goal> |
| 121 | </goals> |
| 122 | <configuration> |
| 123 | <transformers> |
| 124 | <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> |
| 125 | <mainClass>com.example.mcp.McpServerApplication</mainClass> |
| 126 | </transformer> |
| 127 | </transformers> |
| 128 | </configuration> |
| 129 | </execution> |
| 130 | </executions> |
| 131 | </plugin> |
| 132 | </plugins> |
| 133 | </build> |
| 134 | </project> |
| 135 | ``` |
| 136 | |
| 137 | ## Gradle build.gradle.kts Template |
| 138 | |
| 139 | ```kotlin |
| 140 | plugins { |
| 141 | id("java") |
| 142 | id("application") |
| 143 | } |
| 144 | |
| 145 | group = "com.example" |
| 146 | version = "1.0.0" |
| 147 | |
| 148 | java { |
| 149 | sourceCompatibility = JavaVersi |