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.
- package/README.md +33 -1
- package/dist/{chunk-3JG4FVS2.js → chunk-YISSMIHU.js} +222 -46
- package/dist/cli.js +334 -15
- package/dist/index.d.ts +25 -7
- package/dist/index.js +17 -3
- package/package.json +1 -1
- package/templates/csharp/.env.example +6 -0
- package/templates/csharp/.gitignore.ejs +53 -0
- package/templates/csharp/McpServer.csproj.ejs +19 -0
- package/templates/csharp/README.md.ejs +136 -0
- package/templates/csharp/src/Program.cs.ejs +117 -0
- package/templates/elixir/.env.example +6 -0
- package/templates/elixir/.gitignore.ejs +33 -0
- package/templates/elixir/README.md.ejs +154 -0
- package/templates/elixir/config/config.exs.ejs +9 -0
- package/templates/elixir/config/dev.exs.ejs +3 -0
- package/templates/elixir/config/prod.exs.ejs +3 -0
- package/templates/elixir/lib/application.ex.ejs +19 -0
- package/templates/elixir/lib/cli.ex.ejs +17 -0
- package/templates/elixir/lib/server.ex.ejs +112 -0
- package/templates/elixir/mix.exs.ejs +32 -0
- package/templates/java/gradle/.env.example +6 -0
- package/templates/java/gradle/.gitignore.ejs +48 -0
- package/templates/java/gradle/README.md.ejs +132 -0
- package/templates/java/gradle/build.gradle.ejs +46 -0
- package/templates/java/gradle/settings.gradle.ejs +1 -0
- package/templates/java/gradle/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
- package/templates/java/gradle/src/main/resources/logback.xml +13 -0
- package/templates/java/maven/.env.example +6 -0
- package/templates/java/maven/.gitignore.ejs +53 -0
- package/templates/java/maven/README.md.ejs +131 -0
- package/templates/java/maven/pom.xml.ejs +86 -0
- package/templates/java/maven/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
- package/templates/java/maven/src/main/resources/logback.xml +13 -0
- package/templates/kotlin/gradle/.env.example +6 -0
- package/templates/kotlin/gradle/.gitignore.ejs +45 -0
- package/templates/kotlin/gradle/README.md.ejs +138 -0
- package/templates/kotlin/gradle/build.gradle.kts.ejs +48 -0
- package/templates/kotlin/gradle/settings.gradle.kts.ejs +1 -0
- package/templates/kotlin/gradle/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
- package/templates/kotlin/gradle/src/main/resources/logback.xml +13 -0
- package/templates/kotlin/maven/.env.example +6 -0
- package/templates/kotlin/maven/.gitignore.ejs +50 -0
- package/templates/kotlin/maven/README.md.ejs +96 -0
- package/templates/kotlin/maven/pom.xml.ejs +105 -0
- package/templates/kotlin/maven/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
- package/templates/kotlin/maven/src/main/resources/logback.xml +13 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# <%= name %>
|
|
2
|
+
|
|
3
|
+
<%= description || 'MCP Server generated by mcp-new' %>
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- JDK 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.McpServerKt"
|
|
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
|
+
│ ├── kotlin/
|
|
85
|
+
│ │ └── com/example/mcp/
|
|
86
|
+
│ │ └── McpServer.kt # Main server file
|
|
87
|
+
│ └── resources/
|
|
88
|
+
│ └── logback.xml # Logging configuration
|
|
89
|
+
├── .gitignore
|
|
90
|
+
├── .env.example
|
|
91
|
+
└── README.md
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
<kotlin.version>1.9.22</kotlin.version>
|
|
17
|
+
<maven.compiler.source>17</maven.compiler.source>
|
|
18
|
+
<maven.compiler.target>17</maven.compiler.target>
|
|
19
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
20
|
+
<mcp.sdk.version>0.8.0</mcp.sdk.version>
|
|
21
|
+
</properties>
|
|
22
|
+
|
|
23
|
+
<dependencies>
|
|
24
|
+
<!-- Kotlin -->
|
|
25
|
+
<dependency>
|
|
26
|
+
<groupId>org.jetbrains.kotlin</groupId>
|
|
27
|
+
<artifactId>kotlin-stdlib</artifactId>
|
|
28
|
+
<version>${kotlin.version}</version>
|
|
29
|
+
</dependency>
|
|
30
|
+
<dependency>
|
|
31
|
+
<groupId>org.jetbrains.kotlinx</groupId>
|
|
32
|
+
<artifactId>kotlinx-coroutines-core</artifactId>
|
|
33
|
+
<version>1.7.3</version>
|
|
34
|
+
</dependency>
|
|
35
|
+
|
|
36
|
+
<!-- MCP SDK -->
|
|
37
|
+
<dependency>
|
|
38
|
+
<groupId>io.modelcontextprotocol</groupId>
|
|
39
|
+
<artifactId>sdk</artifactId>
|
|
40
|
+
<version>${mcp.sdk.version}</version>
|
|
41
|
+
</dependency>
|
|
42
|
+
|
|
43
|
+
<!-- Logging -->
|
|
44
|
+
<dependency>
|
|
45
|
+
<groupId>org.slf4j</groupId>
|
|
46
|
+
<artifactId>slf4j-api</artifactId>
|
|
47
|
+
<version>2.0.9</version>
|
|
48
|
+
</dependency>
|
|
49
|
+
<dependency>
|
|
50
|
+
<groupId>ch.qos.logback</groupId>
|
|
51
|
+
<artifactId>logback-classic</artifactId>
|
|
52
|
+
<version>1.4.14</version>
|
|
53
|
+
</dependency>
|
|
54
|
+
|
|
55
|
+
<!-- JSON processing -->
|
|
56
|
+
<dependency>
|
|
57
|
+
<groupId>com.fasterxml.jackson.module</groupId>
|
|
58
|
+
<artifactId>jackson-module-kotlin</artifactId>
|
|
59
|
+
<version>2.16.1</version>
|
|
60
|
+
</dependency>
|
|
61
|
+
</dependencies>
|
|
62
|
+
|
|
63
|
+
<build>
|
|
64
|
+
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
|
65
|
+
<plugins>
|
|
66
|
+
<plugin>
|
|
67
|
+
<groupId>org.jetbrains.kotlin</groupId>
|
|
68
|
+
<artifactId>kotlin-maven-plugin</artifactId>
|
|
69
|
+
<version>${kotlin.version}</version>
|
|
70
|
+
<executions>
|
|
71
|
+
<execution>
|
|
72
|
+
<id>compile</id>
|
|
73
|
+
<phase>compile</phase>
|
|
74
|
+
<goals>
|
|
75
|
+
<goal>compile</goal>
|
|
76
|
+
</goals>
|
|
77
|
+
</execution>
|
|
78
|
+
</executions>
|
|
79
|
+
</plugin>
|
|
80
|
+
|
|
81
|
+
<!-- Create executable JAR with dependencies -->
|
|
82
|
+
<plugin>
|
|
83
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
84
|
+
<artifactId>maven-shade-plugin</artifactId>
|
|
85
|
+
<version>3.5.1</version>
|
|
86
|
+
<executions>
|
|
87
|
+
<execution>
|
|
88
|
+
<phase>package</phase>
|
|
89
|
+
<goals>
|
|
90
|
+
<goal>shade</goal>
|
|
91
|
+
</goals>
|
|
92
|
+
<configuration>
|
|
93
|
+
<transformers>
|
|
94
|
+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
|
95
|
+
<mainClass>com.example.mcp.McpServerKt</mainClass>
|
|
96
|
+
</transformer>
|
|
97
|
+
</transformers>
|
|
98
|
+
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
99
|
+
</configuration>
|
|
100
|
+
</execution>
|
|
101
|
+
</executions>
|
|
102
|
+
</plugin>
|
|
103
|
+
</plugins>
|
|
104
|
+
</build>
|
|
105
|
+
</project>
|
|
@@ -0,0 +1,141 @@
|
|
|
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 org.slf4j.LoggerFactory
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* <%= name %> MCP Server
|
|
16
|
+
* <%= description || 'Generated by mcp-new' %>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
private val logger = LoggerFactory.getLogger("McpServer")
|
|
20
|
+
|
|
21
|
+
fun main() {
|
|
22
|
+
try {
|
|
23
|
+
// Create server options
|
|
24
|
+
val options = McpServerOptions.builder()
|
|
25
|
+
.name("<%= name %>")
|
|
26
|
+
.version("1.0.0")
|
|
27
|
+
.capabilities(
|
|
28
|
+
ServerCapabilities.builder()
|
|
29
|
+
.tools(true)
|
|
30
|
+
.build()
|
|
31
|
+
)
|
|
32
|
+
.build()
|
|
33
|
+
|
|
34
|
+
// Create server instance
|
|
35
|
+
val server = McpServer(options)
|
|
36
|
+
|
|
37
|
+
// Register tools
|
|
38
|
+
registerTools(server)
|
|
39
|
+
|
|
40
|
+
<% if (transport === 'stdio') { %>
|
|
41
|
+
// Create STDIO transport
|
|
42
|
+
val transport = StdioServerTransport()
|
|
43
|
+
server.connect(transport)
|
|
44
|
+
logger.info("<%= name %> MCP server running on stdio")
|
|
45
|
+
<% } else { %>
|
|
46
|
+
// Create SSE transport
|
|
47
|
+
val transport = SseServerTransport(8080, "/messages")
|
|
48
|
+
server.connect(transport)
|
|
49
|
+
logger.info("<%= name %> MCP server running on SSE at http://localhost:8080")
|
|
50
|
+
<% } %>
|
|
51
|
+
|
|
52
|
+
// Keep server running
|
|
53
|
+
Thread.currentThread().join()
|
|
54
|
+
|
|
55
|
+
} catch (e: Exception) {
|
|
56
|
+
logger.error("Fatal error: ", e)
|
|
57
|
+
System.exit(1)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fun registerTools(server: McpServer) {
|
|
62
|
+
<% if (includeExampleTool) { %>
|
|
63
|
+
// Register example_tool
|
|
64
|
+
server.addTool(
|
|
65
|
+
McpSchema.Tool.builder()
|
|
66
|
+
.name("example_tool")
|
|
67
|
+
.description("An example tool that echoes the input")
|
|
68
|
+
.inputSchema(
|
|
69
|
+
mapOf(
|
|
70
|
+
"type" to "object",
|
|
71
|
+
"properties" to mapOf(
|
|
72
|
+
"query" to mapOf(
|
|
73
|
+
"type" to "string",
|
|
74
|
+
"description" to "The query to echo"
|
|
75
|
+
)
|
|
76
|
+
),
|
|
77
|
+
"required" to listOf("query")
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
.build()
|
|
81
|
+
) { request ->
|
|
82
|
+
val query = request.arguments["query"] as String
|
|
83
|
+
McpSchema.CallToolResult.builder()
|
|
84
|
+
.content(
|
|
85
|
+
listOf(
|
|
86
|
+
McpSchema.TextContent.builder()
|
|
87
|
+
.type("text")
|
|
88
|
+
.text("Echo: $query")
|
|
89
|
+
.build()
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
.build()
|
|
93
|
+
}
|
|
94
|
+
<% } %>
|
|
95
|
+
|
|
96
|
+
<% tools.forEach(function(tool) { %>
|
|
97
|
+
// Register <%= tool.name %>
|
|
98
|
+
server.addTool(
|
|
99
|
+
McpSchema.Tool.builder()
|
|
100
|
+
.name("<%= tool.name %>")
|
|
101
|
+
.description("<%= tool.description %>")
|
|
102
|
+
.inputSchema(
|
|
103
|
+
mapOf(
|
|
104
|
+
"type" to "object",
|
|
105
|
+
"properties" to mapOf(
|
|
106
|
+
<% tool.parameters.forEach(function(param, index) { %>
|
|
107
|
+
"<%= param.name %>" to mapOf(
|
|
108
|
+
"type" to "<%= param.type %>",
|
|
109
|
+
"description" to "<%= param.description %>"
|
|
110
|
+
)<%= index < tool.parameters.length - 1 ? ',' : '' %>
|
|
111
|
+
<% }); %>
|
|
112
|
+
),
|
|
113
|
+
"required" to listOf(<%= tool.parameters.filter(p => p.required).map(p => '"' + p.name + '"').join(', ') %>)
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
.build()
|
|
117
|
+
) { request ->
|
|
118
|
+
// TODO: Implement <%= tool.name %> logic
|
|
119
|
+
<% tool.parameters.forEach(function(param) { %>
|
|
120
|
+
<% if (param.type === 'number') { %>
|
|
121
|
+
val <%= param.name %> = request.arguments["<%= param.name %>"] as? Number
|
|
122
|
+
<% } else if (param.type === 'boolean') { %>
|
|
123
|
+
val <%= param.name %> = request.arguments["<%= param.name %>"] as? Boolean
|
|
124
|
+
<% } else { %>
|
|
125
|
+
val <%= param.name %> = request.arguments["<%= param.name %>"] as? String
|
|
126
|
+
<% } %>
|
|
127
|
+
<% }); %>
|
|
128
|
+
|
|
129
|
+
McpSchema.CallToolResult.builder()
|
|
130
|
+
.content(
|
|
131
|
+
listOf(
|
|
132
|
+
McpSchema.TextContent.builder()
|
|
133
|
+
.type("text")
|
|
134
|
+
.text("<%= tool.name %> called with: ${request.arguments}")
|
|
135
|
+
.build()
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
.build()
|
|
139
|
+
}
|
|
140
|
+
<% }); %>
|
|
141
|
+
}
|
|
@@ -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>
|