mcp-new 1.2.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +33 -1
  2. package/dist/{chunk-3JG4FVS2.js → chunk-YISSMIHU.js} +222 -46
  3. package/dist/cli.js +334 -15
  4. package/dist/index.d.ts +25 -7
  5. package/dist/index.js +17 -3
  6. package/package.json +1 -1
  7. package/templates/csharp/.env.example +6 -0
  8. package/templates/csharp/.gitignore.ejs +53 -0
  9. package/templates/csharp/McpServer.csproj.ejs +19 -0
  10. package/templates/csharp/README.md.ejs +136 -0
  11. package/templates/csharp/src/Program.cs.ejs +117 -0
  12. package/templates/elixir/.env.example +6 -0
  13. package/templates/elixir/.gitignore.ejs +33 -0
  14. package/templates/elixir/README.md.ejs +154 -0
  15. package/templates/elixir/config/config.exs.ejs +9 -0
  16. package/templates/elixir/config/dev.exs.ejs +3 -0
  17. package/templates/elixir/config/prod.exs.ejs +3 -0
  18. package/templates/elixir/lib/application.ex.ejs +19 -0
  19. package/templates/elixir/lib/cli.ex.ejs +17 -0
  20. package/templates/elixir/lib/server.ex.ejs +112 -0
  21. package/templates/elixir/mix.exs.ejs +32 -0
  22. package/templates/java/gradle/.env.example +6 -0
  23. package/templates/java/gradle/.gitignore.ejs +48 -0
  24. package/templates/java/gradle/README.md.ejs +132 -0
  25. package/templates/java/gradle/build.gradle.ejs +46 -0
  26. package/templates/java/gradle/settings.gradle.ejs +1 -0
  27. package/templates/java/gradle/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
  28. package/templates/java/gradle/src/main/resources/logback.xml +13 -0
  29. package/templates/java/maven/.env.example +6 -0
  30. package/templates/java/maven/.gitignore.ejs +53 -0
  31. package/templates/java/maven/README.md.ejs +131 -0
  32. package/templates/java/maven/pom.xml.ejs +86 -0
  33. package/templates/java/maven/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
  34. package/templates/java/maven/src/main/resources/logback.xml +13 -0
  35. package/templates/kotlin/gradle/.env.example +6 -0
  36. package/templates/kotlin/gradle/.gitignore.ejs +45 -0
  37. package/templates/kotlin/gradle/README.md.ejs +138 -0
  38. package/templates/kotlin/gradle/build.gradle.kts.ejs +48 -0
  39. package/templates/kotlin/gradle/settings.gradle.kts.ejs +1 -0
  40. package/templates/kotlin/gradle/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
  41. package/templates/kotlin/gradle/src/main/resources/logback.xml +13 -0
  42. package/templates/kotlin/maven/.env.example +6 -0
  43. package/templates/kotlin/maven/.gitignore.ejs +50 -0
  44. package/templates/kotlin/maven/README.md.ejs +96 -0
  45. package/templates/kotlin/maven/pom.xml.ejs +105 -0
  46. package/templates/kotlin/maven/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
  47. package/templates/kotlin/maven/src/main/resources/logback.xml +13 -0
@@ -0,0 +1,132 @@
1
+ # <%= name %>
2
+
3
+ <%= description || 'MCP Server generated by mcp-new' %>
4
+
5
+ ## Prerequisites
6
+
7
+ - Java 17 or higher
8
+ - Gradle 8.0+ (or use included Gradle wrapper)
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ # Install dependencies and build
14
+ ./gradlew build
15
+
16
+ # Or on Windows
17
+ gradlew.bat build
18
+ ```
19
+
20
+ ## Running the Server
21
+
22
+ ### Development
23
+
24
+ ```bash
25
+ # Run directly with Gradle
26
+ ./gradlew run
27
+ ```
28
+
29
+ ### Production
30
+
31
+ ```bash
32
+ # Build executable JAR (shadow JAR with all dependencies)
33
+ ./gradlew shadowJar
34
+
35
+ # Run the JAR
36
+ java -jar build/libs/<%= name %>-1.0.0.jar
37
+ ```
38
+
39
+ ## Configuration with Claude Desktop
40
+
41
+ Add this to your Claude Desktop config file:
42
+
43
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
44
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "<%= name %>": {
50
+ "command": "java",
51
+ "args": ["-jar", "/path/to/<%= name %>/build/libs/<%= name %>-1.0.0.jar"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ## Available Tools
58
+
59
+ <% if (includeExampleTool) { %>
60
+ ### example_tool
61
+ An example tool that echoes the input
62
+
63
+ **Parameters:**
64
+ - `query` (string, required): The query to echo
65
+ <% } %>
66
+
67
+ <% tools.forEach(function(tool) { %>
68
+ ### <%= tool.name %>
69
+ <%= tool.description %>
70
+
71
+ **Parameters:**
72
+ <% tool.parameters.forEach(function(param) { %>
73
+ - `<%= param.name %>` (<%= param.type %><%= param.required ? ', required' : '' %>): <%= param.description %>
74
+ <% }); %>
75
+ <% }); %>
76
+
77
+ ## Project Structure
78
+
79
+ ```
80
+ <%= name %>/
81
+ ├── build.gradle # Gradle configuration
82
+ ├── settings.gradle # Project settings
83
+ ├── src/
84
+ │ └── main/
85
+ │ ├── java/
86
+ │ │ └── com/example/mcp/
87
+ │ │ └── McpServer.java # Main server file
88
+ │ └── resources/
89
+ │ └── logback.xml # Logging configuration
90
+ ├── .gitignore
91
+ ├── .env.example
92
+ └── README.md
93
+ ```
94
+
95
+ ## Development
96
+
97
+ ### Adding a New Tool
98
+
99
+ 1. Open `src/main/java/com/example/mcp/McpServer.java`
100
+ 2. Add a new tool registration in the `registerTools` method:
101
+
102
+ ```java
103
+ server.addTool(
104
+ McpSchema.Tool.builder()
105
+ .name("my_new_tool")
106
+ .description("Description of my tool")
107
+ .inputSchema(createInputSchema(
108
+ Map.of("param1", Map.of(
109
+ "type", "string",
110
+ "description", "Parameter description"
111
+ )),
112
+ List.of("param1") // required parameters
113
+ ))
114
+ .build(),
115
+ (request) -> {
116
+ String param1 = (String) request.getArguments().get("param1");
117
+ // Your tool logic here
118
+ return McpSchema.CallToolResult.builder()
119
+ .content(List.of(
120
+ McpSchema.TextContent.builder()
121
+ .type("text")
122
+ .text("Result: " + param1)
123
+ .build()
124
+ ))
125
+ .build();
126
+ }
127
+ );
128
+ ```
129
+
130
+ ## License
131
+
132
+ MIT
@@ -0,0 +1,46 @@
1
+ plugins {
2
+ id 'java'
3
+ id 'application'
4
+ id 'com.github.johnrengelman.shadow' version '8.1.1'
5
+ }
6
+
7
+ group = 'com.example'
8
+ version = '1.0.0'
9
+
10
+ java {
11
+ sourceCompatibility = JavaVersion.VERSION_17
12
+ targetCompatibility = JavaVersion.VERSION_17
13
+ }
14
+
15
+ repositories {
16
+ mavenCentral()
17
+ }
18
+
19
+ dependencies {
20
+ // MCP SDK
21
+ implementation 'io.modelcontextprotocol:sdk:0.8.0'
22
+
23
+ // Logging
24
+ implementation 'org.slf4j:slf4j-api:2.0.9'
25
+ implementation 'ch.qos.logback:logback-classic:1.4.14'
26
+
27
+ // JSON processing
28
+ implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
29
+ }
30
+
31
+ application {
32
+ mainClass = 'com.example.mcp.McpServer'
33
+ }
34
+
35
+ shadowJar {
36
+ archiveBaseName.set('<%= name %>')
37
+ archiveClassifier.set('')
38
+ archiveVersion.set('1.0.0')
39
+ manifest {
40
+ attributes 'Main-Class': 'com.example.mcp.McpServer'
41
+ }
42
+ }
43
+
44
+ tasks.named('build') {
45
+ dependsOn shadowJar
46
+ }
@@ -0,0 +1 @@
1
+ rootProject.name = '<%= name %>'
@@ -0,0 +1,149 @@
1
+ package com.example.mcp;
2
+
3
+ import io.modelcontextprotocol.server.McpServer;
4
+ import io.modelcontextprotocol.server.McpServerOptions;
5
+ import io.modelcontextprotocol.server.ServerCapabilities;
6
+ <% if (transport === 'stdio') { %>
7
+ import io.modelcontextprotocol.server.transport.StdioServerTransport;
8
+ <% } else { %>
9
+ import io.modelcontextprotocol.server.transport.SseServerTransport;
10
+ <% } %>
11
+ import io.modelcontextprotocol.spec.McpSchema;
12
+ import com.fasterxml.jackson.databind.ObjectMapper;
13
+ import org.slf4j.Logger;
14
+ import org.slf4j.LoggerFactory;
15
+
16
+ import java.util.ArrayList;
17
+ import java.util.HashMap;
18
+ import java.util.List;
19
+ import java.util.Map;
20
+
21
+ /**
22
+ * <%= name %> MCP Server
23
+ * <%= description || 'Generated by mcp-new' %>
24
+ */
25
+ public class McpServer {
26
+ private static final Logger logger = LoggerFactory.getLogger(McpServer.class);
27
+ private static final ObjectMapper objectMapper = new ObjectMapper();
28
+
29
+ public static void main(String[] args) {
30
+ try {
31
+ // Create server options
32
+ McpServerOptions options = McpServerOptions.builder()
33
+ .name("<%= name %>")
34
+ .version("1.0.0")
35
+ .capabilities(ServerCapabilities.builder()
36
+ .tools(true)
37
+ .build())
38
+ .build();
39
+
40
+ // Create server instance
41
+ io.modelcontextprotocol.server.McpServer server =
42
+ new io.modelcontextprotocol.server.McpServer(options);
43
+
44
+ // Register tools
45
+ registerTools(server);
46
+
47
+ <% if (transport === 'stdio') { %>
48
+ // Create STDIO transport
49
+ StdioServerTransport transport = new StdioServerTransport();
50
+ server.connect(transport);
51
+ logger.info("<%= name %> MCP server running on stdio");
52
+ <% } else { %>
53
+ // Create SSE transport
54
+ SseServerTransport transport = new SseServerTransport(8080, "/messages");
55
+ server.connect(transport);
56
+ logger.info("<%= name %> MCP server running on SSE at http://localhost:8080");
57
+ <% } %>
58
+
59
+ // Keep server running
60
+ Thread.currentThread().join();
61
+
62
+ } catch (Exception e) {
63
+ logger.error("Fatal error: ", e);
64
+ System.exit(1);
65
+ }
66
+ }
67
+
68
+ private static void registerTools(io.modelcontextprotocol.server.McpServer server) {
69
+ <% if (includeExampleTool) { %>
70
+ // Register example_tool
71
+ server.addTool(
72
+ McpSchema.Tool.builder()
73
+ .name("example_tool")
74
+ .description("An example tool that echoes the input")
75
+ .inputSchema(createInputSchema(
76
+ Map.of("query", Map.of(
77
+ "type", "string",
78
+ "description", "The query to echo"
79
+ )),
80
+ List.of("query")
81
+ ))
82
+ .build(),
83
+ (request) -> {
84
+ String query = (String) request.getArguments().get("query");
85
+ return McpSchema.CallToolResult.builder()
86
+ .content(List.of(
87
+ McpSchema.TextContent.builder()
88
+ .type("text")
89
+ .text("Echo: " + query)
90
+ .build()
91
+ ))
92
+ .build();
93
+ }
94
+ );
95
+ <% } %>
96
+
97
+ <% tools.forEach(function(tool) { %>
98
+ // Register <%= tool.name %>
99
+ server.addTool(
100
+ McpSchema.Tool.builder()
101
+ .name("<%= tool.name %>")
102
+ .description("<%= tool.description %>")
103
+ .inputSchema(createInputSchema(
104
+ Map.of(
105
+ <% tool.parameters.forEach(function(param, index) { %>
106
+ "<%= param.name %>", Map.of(
107
+ "type", "<%= param.type %>",
108
+ "description", "<%= param.description %>"
109
+ )<%= index < tool.parameters.length - 1 ? ',' : '' %>
110
+ <% }); %>
111
+ ),
112
+ List.of(<%= tool.parameters.filter(p => p.required).map(p => '"' + p.name + '"').join(', ') %>)
113
+ ))
114
+ .build(),
115
+ (request) -> {
116
+ // TODO: Implement <%= tool.name %> logic
117
+ <% tool.parameters.forEach(function(param) { %>
118
+ <% if (param.type === 'number') { %>
119
+ Number <%= param.name %> = (Number) request.getArguments().get("<%= param.name %>");
120
+ <% } else if (param.type === 'boolean') { %>
121
+ Boolean <%= param.name %> = (Boolean) request.getArguments().get("<%= param.name %>");
122
+ <% } else { %>
123
+ String <%= param.name %> = (String) request.getArguments().get("<%= param.name %>");
124
+ <% } %>
125
+ <% }); %>
126
+
127
+ return McpSchema.CallToolResult.builder()
128
+ .content(List.of(
129
+ McpSchema.TextContent.builder()
130
+ .type("text")
131
+ .text("<%= tool.name %> called with: " + request.getArguments())
132
+ .build()
133
+ ))
134
+ .build();
135
+ }
136
+ );
137
+ <% }); %>
138
+ }
139
+
140
+ private static Map<String, Object> createInputSchema(
141
+ Map<String, Map<String, String>> properties,
142
+ List<String> required) {
143
+ Map<String, Object> schema = new HashMap<>();
144
+ schema.put("type", "object");
145
+ schema.put("properties", properties);
146
+ schema.put("required", required);
147
+ return schema;
148
+ }
149
+ }
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <configuration>
3
+ <appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
4
+ <target>System.err</target>
5
+ <encoder>
6
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
7
+ </encoder>
8
+ </appender>
9
+
10
+ <root level="INFO">
11
+ <appender-ref ref="STDERR"/>
12
+ </root>
13
+ </configuration>
@@ -0,0 +1,6 @@
1
+ # Environment variables for MCP Server
2
+ # Copy this file to .env and fill in your values
3
+
4
+ # Add your environment variables here
5
+ # API_KEY=your_api_key
6
+ # DATABASE_URL=your_database_url
@@ -0,0 +1,53 @@
1
+ # Compiled class files
2
+ *.class
3
+
4
+ # Log files
5
+ *.log
6
+
7
+ # BlueJ files
8
+ *.ctxt
9
+
10
+ # Mobile Tools for Java (J2ME)
11
+ .mtj.tmp/
12
+
13
+ # Package Files
14
+ *.jar
15
+ *.war
16
+ *.nar
17
+ *.ear
18
+ *.zip
19
+ *.tar.gz
20
+ *.rar
21
+
22
+ # Maven
23
+ target/
24
+ pom.xml.tag
25
+ pom.xml.releaseBackup
26
+ pom.xml.versionsBackup
27
+ pom.xml.next
28
+ release.properties
29
+ dependency-reduced-pom.xml
30
+ buildNumber.properties
31
+ .mvn/timing.properties
32
+ .mvn/wrapper/maven-wrapper.jar
33
+
34
+ # IDE
35
+ .idea/
36
+ *.iml
37
+ *.ipr
38
+ *.iws
39
+ .project
40
+ .classpath
41
+ .settings/
42
+ .vscode/
43
+ *.swp
44
+ *.swo
45
+ *~
46
+
47
+ # OS
48
+ .DS_Store
49
+ Thumbs.db
50
+
51
+ # Environment
52
+ .env
53
+ .env.local
@@ -0,0 +1,131 @@
1
+ # <%= name %>
2
+
3
+ <%= description || 'MCP Server generated by mcp-new' %>
4
+
5
+ ## Prerequisites
6
+
7
+ - Java 17 or higher
8
+ - Maven 3.8+
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ # Install dependencies and build
14
+ mvn install
15
+
16
+ # Or just compile
17
+ mvn compile
18
+ ```
19
+
20
+ ## Running the Server
21
+
22
+ ### Development
23
+
24
+ ```bash
25
+ # Run directly with Maven
26
+ mvn exec:java -Dexec.mainClass="com.example.mcp.McpServer"
27
+ ```
28
+
29
+ ### Production
30
+
31
+ ```bash
32
+ # Build executable JAR
33
+ mvn package
34
+
35
+ # Run the JAR
36
+ java -jar target/<%= name %>-1.0.0.jar
37
+ ```
38
+
39
+ ## Configuration with Claude Desktop
40
+
41
+ Add this to your Claude Desktop config file:
42
+
43
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
44
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "<%= name %>": {
50
+ "command": "java",
51
+ "args": ["-jar", "/path/to/<%= name %>/target/<%= name %>-1.0.0.jar"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ## Available Tools
58
+
59
+ <% if (includeExampleTool) { %>
60
+ ### example_tool
61
+ An example tool that echoes the input
62
+
63
+ **Parameters:**
64
+ - `query` (string, required): The query to echo
65
+ <% } %>
66
+
67
+ <% tools.forEach(function(tool) { %>
68
+ ### <%= tool.name %>
69
+ <%= tool.description %>
70
+
71
+ **Parameters:**
72
+ <% tool.parameters.forEach(function(param) { %>
73
+ - `<%= param.name %>` (<%= param.type %><%= param.required ? ', required' : '' %>): <%= param.description %>
74
+ <% }); %>
75
+ <% }); %>
76
+
77
+ ## Project Structure
78
+
79
+ ```
80
+ <%= name %>/
81
+ ├── pom.xml # Maven configuration
82
+ ├── src/
83
+ │ └── main/
84
+ │ ├── java/
85
+ │ │ └── com/example/mcp/
86
+ │ │ └── McpServer.java # Main server file
87
+ │ └── resources/
88
+ │ └── logback.xml # Logging configuration
89
+ ├── .gitignore
90
+ ├── .env.example
91
+ └── README.md
92
+ ```
93
+
94
+ ## Development
95
+
96
+ ### Adding a New Tool
97
+
98
+ 1. Open `src/main/java/com/example/mcp/McpServer.java`
99
+ 2. Add a new tool registration in the `registerTools` method:
100
+
101
+ ```java
102
+ server.addTool(
103
+ McpSchema.Tool.builder()
104
+ .name("my_new_tool")
105
+ .description("Description of my tool")
106
+ .inputSchema(createInputSchema(
107
+ Map.of("param1", Map.of(
108
+ "type", "string",
109
+ "description", "Parameter description"
110
+ )),
111
+ List.of("param1") // required parameters
112
+ ))
113
+ .build(),
114
+ (request) -> {
115
+ String param1 = (String) request.getArguments().get("param1");
116
+ // Your tool logic here
117
+ return McpSchema.CallToolResult.builder()
118
+ .content(List.of(
119
+ McpSchema.TextContent.builder()
120
+ .type("text")
121
+ .text("Result: " + param1)
122
+ .build()
123
+ ))
124
+ .build();
125
+ }
126
+ );
127
+ ```
128
+
129
+ ## License
130
+
131
+ MIT
@@ -0,0 +1,86 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://maven.apache.org/POM/4.0.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+ <modelVersion>4.0.0</modelVersion>
6
+
7
+ <groupId>com.example</groupId>
8
+ <artifactId><%= name %></artifactId>
9
+ <version>1.0.0</version>
10
+ <packaging>jar</packaging>
11
+
12
+ <name><%= name %></name>
13
+ <description><%= description || 'MCP Server generated by mcp-new' %></description>
14
+
15
+ <properties>
16
+ <maven.compiler.source>17</maven.compiler.source>
17
+ <maven.compiler.target>17</maven.compiler.target>
18
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19
+ <mcp.sdk.version>0.8.0</mcp.sdk.version>
20
+ </properties>
21
+
22
+ <dependencies>
23
+ <!-- MCP SDK -->
24
+ <dependency>
25
+ <groupId>io.modelcontextprotocol</groupId>
26
+ <artifactId>sdk</artifactId>
27
+ <version>${mcp.sdk.version}</version>
28
+ </dependency>
29
+
30
+ <!-- Logging -->
31
+ <dependency>
32
+ <groupId>org.slf4j</groupId>
33
+ <artifactId>slf4j-api</artifactId>
34
+ <version>2.0.9</version>
35
+ </dependency>
36
+ <dependency>
37
+ <groupId>ch.qos.logback</groupId>
38
+ <artifactId>logback-classic</artifactId>
39
+ <version>1.4.14</version>
40
+ </dependency>
41
+
42
+ <!-- JSON processing -->
43
+ <dependency>
44
+ <groupId>com.fasterxml.jackson.core</groupId>
45
+ <artifactId>jackson-databind</artifactId>
46
+ <version>2.16.1</version>
47
+ </dependency>
48
+ </dependencies>
49
+
50
+ <build>
51
+ <plugins>
52
+ <plugin>
53
+ <groupId>org.apache.maven.plugins</groupId>
54
+ <artifactId>maven-compiler-plugin</artifactId>
55
+ <version>3.11.0</version>
56
+ <configuration>
57
+ <source>17</source>
58
+ <target>17</target>
59
+ </configuration>
60
+ </plugin>
61
+
62
+ <!-- Create executable JAR with dependencies -->
63
+ <plugin>
64
+ <groupId>org.apache.maven.plugins</groupId>
65
+ <artifactId>maven-shade-plugin</artifactId>
66
+ <version>3.5.1</version>
67
+ <executions>
68
+ <execution>
69
+ <phase>package</phase>
70
+ <goals>
71
+ <goal>shade</goal>
72
+ </goals>
73
+ <configuration>
74
+ <transformers>
75
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
76
+ <mainClass>com.example.mcp.McpServer</mainClass>
77
+ </transformer>
78
+ </transformers>
79
+ <createDependencyReducedPom>false</createDependencyReducedPom>
80
+ </configuration>
81
+ </execution>
82
+ </executions>
83
+ </plugin>
84
+ </plugins>
85
+ </build>
86
+ </project>