Skip to content
Back to skills

Java Mcp Server Generator

ASecurity

Generate a complete Model Context Protocol server project in Java using the official MCP Java SDK with reactive streams and optional Spring Boot integration. Use this skill when the user asks for project generation.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 4, 2026
ai-agentsgojavakotlinreactspringtestinggitapi

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 4, 2026

npx -y skills add paulasilvatech/awesome-harness-primitives --skill java-mcp-server-generator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Java Mcp Server Generator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Java Mcp Server Generator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/paulasilvatech-java-mcp-server-generator/badge)](https://www.skillsdirectory.com/skills/paulasilvatech-java-mcp-server-generator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: java-mcp-server-generator
description: >-
  Generate a complete Model Context Protocol server project in Java using the official MCP Java
  SDK with reactive streams and optional Spring Boot integration. Use this skill when the user
  asks for project generation.
---

<!-- Generated from harness/github-copilot/plugins/java-mcp-development/skills/java-mcp-server-generator/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->

# Java MCP server generator

Generate a Java Model Context Protocol server project with Maven or Gradle build files, SDK dependencies, stdio transport wiring, handlers for tools, resources, and prompts, tests, and optional Spring Boot configuration.

Generate a complete, production-ready MCP server in Java using the official Java SDK with Maven or Gradle.

## When to invoke

- "Generate a Java MCP server project."
- "Create a Maven MCP server using the Java SDK."
- "Scaffold MCP tools, resources, and prompts in Java."
- "Add stdio transport to a Java MCP server."
- "Make a Gradle Java MCP server template."

## Project generation

When asked to create a Java MCP server, generate a complete project with this structure:

```
my-mcp-server/
├── pom.xml (or build.gradle.kts)
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/example/mcp/
│   │   │       ├── McpServerApplication.java
│   │   │       ├── config/
│   │   │       │   └── ServerConfiguration.java
│   │   │       ├── tools/
│   │   │       │   ├── ToolDefinitions.java
│   │   │       │   └── ToolHandlers.java
│   │   │       ├── resources/
│   │   │       │   ├── ResourceDefinitions.java
│   │   │       │   └── ResourceHandlers.java
│   │   │       └── prompts/
│   │   │           ├── PromptDefinitions.java
│   │   │           └── PromptHandlers.java
│   │   └── resources/
│   │       └── application.properties (if using Spring)
│   └── test/
│       └── java/
│           └── com/example/mcp/
│               └── McpServerTest.java
└── README.md
```

## Maven pom.xml template

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/"
         "POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>my-mcp-server</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>My MCP Server</name>
    <description>Model Context Protocol server implementation</description>

    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mcp.version>0.14.1</mcp.version>
        <slf4j.version>2.0.9</slf4j.version>
        <logback.version>1.4.11</logback.version>
        <junit.version>5.10.0</junit.version>
    </properties>

    <dependencies>
        <!-- MCP Java SDK -->
        <dependency>
            <groupId>io.modelcontextprotocol.sdk</groupId>
            <artifactId>mcp</artifactId>
            <version>${mcp.version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.1.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.5.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.example.mcp.McpServerApplication</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
```

## Gradle build.gradle.kts template

```kotlin
plugins {
    id("java")
    id("application")
}

group = "com.example"
version = "1.0.0"

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

repositories {
    mavenCentral()
}

dependencies {
    // MCP Java SDK
    implementation("io.modelcontextprotocol.sdk:mcp:0.14.1")
    
    // Logging
    implementation("org.slf4j:slf4j-api:2.0.9")
    implementation("ch.qos.logback:logback-classic:1.4.11")
    
    // Testing
    testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
    testImplementation("io.projectreactor:reactor-test:3.5.0")
}

application {
    mainClass.set("com.example.mcp.McpServerApplication")
}

tasks.test {
    useJUnitPlatform()
}
```

## McpServerApplication.java template

```java
package com.example.mcp;

import com.example.mcp.tools.ToolHandlers;
import com.example.mcp.resources.ResourceHandlers;
import com.example.mcp.prompts.PromptHandlers;
import io.mcp.server.McpServer;
import io.mcp.server.McpServerBuilder;
import io.mcp.server.transport.StdioServerTransport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.Disposable;

public class McpServerApplication {
    
    private static final Logger log = LoggerFactory.getLogger(McpServerApplication.class);
    
    public static void main(String[] args) {
        log.info("Starting MCP Server...");
        
        try {
            McpServer server = createServer();
            StdioServerTransport transport = new StdioServerTransport();
            
            // Start server
            Disposable serverDisposable = server.start(transport).subscribe();
            
            // Graceful shutdown
            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
                log.info("Shutting down MCP server");
                serverDisposable.dispose();
                server.stop().block();
            }));
            
            log.info("MCP Server started successfully");
            
            // Keep running
            Thread.currentThread().join();
            
        } catch (Exception e) {
            log.error("Failed to start MCP server", e);
            System.exit(1);
        }
    }
    
    private static McpServer createServer() {
        McpServer server = McpServerBuilder.builder()
            .serverInfo("my-mcp-server", "1.0.0")
            .capabilities(capabilities -> capabilities
                .tools(true)
                .resources(true)
                .prompts(true))
            .build();
        
        // Register handlers
        ToolHandlers.register(server);
        ResourceHandlers.register(server);
        PromptHandlers.register(server);
        
        return server;
    }
}
```
## Progressive disclosure and bundled resources

Additional detailed guidance was moved to [references/extended-guide.md](references/extended-guide.md) to keep this skill within the progressive-disclosure budget.

## Output template

```markdown
## Java MCP server generation result

**Status:** generated | plan only | blocked
**Build tool:** Maven | Gradle
**Package:** `com.example.mcp`

### Files
- `pom.xml` or `build.gradle.kts`
- `src/main/java/com/example/mcp/McpServerApplication.java`
- `src/main/java/com/example/mcp/tools/ToolDefinitions.java`
- `src/main/java/com/example/mcp/tools/ToolHandlers.java`
- `src/main/java/com/example/mcp/resources/ResourceDefinitions.java`
- `src/main/java/com/example/mcp/resources/ResourceHandlers.java`
- `src/main/java/com/example/mcp/prompts/PromptDefinitions.java`
- `src/main/java/com/example/mcp/prompts/PromptHandlers.java`
- `src/test/java/com/example/mcp/McpServerTest.java`

### Validation
- `mvn test` or `gradle test`: pass | fail | not run
- Main class: `com.example.mcp.McpServerApplication`
- Transport: `StdioServerTransport`
```

## Quality gate

- [ ] The generated structure includes build file, `src/main/java`, `src/main/resources`, `src/test/java`, and `README.md`.
- [ ] Maven output keeps `io.modelcontextprotocol.sdk:mcp`, `slf4j-api`, `logback-classic`, JUnit Jupiter, `reactor-test`, compiler, surefire, and shade plugins.
- [ ] Gradle output keeps `java`, `application`, Maven Central, `JavaVersion.VERSION_17`, SDK, logging, and test dependencies.
- [ ] `McpServerApplication` registers `ToolHandlers`, `ResourceHandlers`, and `PromptHandlers`.
- [ ] Server startup uses `StdioServerTransport`, subscribes to start, and disposes the `Disposable` on shutdown.
- [ ] The extended guidance is read from `references/extended-guide.md` when the requested server needs deeper implementation detail.

Files in this skill

  • SKILL.md10.2 KB
  • references/extended-guide.md13.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…