mcp-new 1.2.2 → 1.6.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-LJNMSDBU.js} +1157 -212
- package/dist/cli.js +1287 -18
- package/dist/index.d.ts +43 -10
- package/dist/index.js +22 -35
- package/package.json +4 -2
- package/templates/ci/circleci/config.yml.ejs +219 -0
- package/templates/ci/github/ci.yml.ejs +184 -0
- package/templates/ci/gitlab/.gitlab-ci.yml.ejs +233 -0
- 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,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>
|