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,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,45 @@
|
|
|
1
|
+
# Compiled class files
|
|
2
|
+
*.class
|
|
3
|
+
|
|
4
|
+
# Log files
|
|
5
|
+
*.log
|
|
6
|
+
|
|
7
|
+
# Package Files
|
|
8
|
+
*.jar
|
|
9
|
+
*.war
|
|
10
|
+
*.nar
|
|
11
|
+
*.ear
|
|
12
|
+
*.zip
|
|
13
|
+
*.tar.gz
|
|
14
|
+
*.rar
|
|
15
|
+
|
|
16
|
+
# Gradle
|
|
17
|
+
.gradle/
|
|
18
|
+
build/
|
|
19
|
+
gradle-app.setting
|
|
20
|
+
!gradle-wrapper.jar
|
|
21
|
+
.gradletasknamecache
|
|
22
|
+
|
|
23
|
+
# Kotlin
|
|
24
|
+
*.kotlin_module
|
|
25
|
+
|
|
26
|
+
# IDE
|
|
27
|
+
.idea/
|
|
28
|
+
*.iml
|
|
29
|
+
*.ipr
|
|
30
|
+
*.iws
|
|
31
|
+
.project
|
|
32
|
+
.classpath
|
|
33
|
+
.settings/
|
|
34
|
+
.vscode/
|
|
35
|
+
*.swp
|
|
36
|
+
*.swo
|
|
37
|
+
*~
|
|
38
|
+
|
|
39
|
+
# OS
|
|
40
|
+
.DS_Store
|
|
41
|
+
Thumbs.db
|
|
42
|
+
|
|
43
|
+
# Environment
|
|
44
|
+
.env
|
|
45
|
+
.env.local
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# <%= name %>
|
|
2
|
+
|
|
3
|
+
<%= description || 'MCP Server generated by mcp-new' %>
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- JDK 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.kts # Gradle configuration (Kotlin DSL)
|
|
82
|
+
├── settings.gradle.kts # Project settings
|
|
83
|
+
├── src/
|
|
84
|
+
│ └── main/
|
|
85
|
+
│ ├── kotlin/
|
|
86
|
+
│ │ └── com/example/mcp/
|
|
87
|
+
│ │ └── McpServer.kt # 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/kotlin/com/example/mcp/McpServer.kt`
|
|
100
|
+
2. Add a new tool registration in the `registerTools` function:
|
|
101
|
+
|
|
102
|
+
```kotlin
|
|
103
|
+
server.addTool(
|
|
104
|
+
McpSchema.Tool.builder()
|
|
105
|
+
.name("my_new_tool")
|
|
106
|
+
.description("Description of my tool")
|
|
107
|
+
.inputSchema(
|
|
108
|
+
mapOf(
|
|
109
|
+
"type" to "object",
|
|
110
|
+
"properties" to mapOf(
|
|
111
|
+
"param1" to mapOf(
|
|
112
|
+
"type" to "string",
|
|
113
|
+
"description" to "Parameter description"
|
|
114
|
+
)
|
|
115
|
+
),
|
|
116
|
+
"required" to listOf("param1")
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
.build()
|
|
120
|
+
) { request ->
|
|
121
|
+
val param1 = request.arguments["param1"] as? String
|
|
122
|
+
// Your tool logic here
|
|
123
|
+
McpSchema.CallToolResult.builder()
|
|
124
|
+
.content(
|
|
125
|
+
listOf(
|
|
126
|
+
McpSchema.TextContent.builder()
|
|
127
|
+
.type("text")
|
|
128
|
+
.text("Result: $param1")
|
|
129
|
+
.build()
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
.build()
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
kotlin("jvm") version "1.9.22"
|
|
3
|
+
application
|
|
4
|
+
id("com.github.johnrengelman.shadow") version "8.1.1"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
group = "com.example"
|
|
8
|
+
version = "1.0.0"
|
|
9
|
+
|
|
10
|
+
repositories {
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
dependencies {
|
|
15
|
+
// MCP SDK
|
|
16
|
+
implementation("io.modelcontextprotocol:sdk:0.8.0")
|
|
17
|
+
|
|
18
|
+
// Kotlin coroutines
|
|
19
|
+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
|
|
20
|
+
|
|
21
|
+
// Logging
|
|
22
|
+
implementation("org.slf4j:slf4j-api:2.0.9")
|
|
23
|
+
implementation("ch.qos.logback:logback-classic:1.4.14")
|
|
24
|
+
|
|
25
|
+
// JSON processing
|
|
26
|
+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
kotlin {
|
|
30
|
+
jvmToolchain(17)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
application {
|
|
34
|
+
mainClass.set("com.example.mcp.McpServerKt")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
tasks.shadowJar {
|
|
38
|
+
archiveBaseName.set("<%= name %>")
|
|
39
|
+
archiveClassifier.set("")
|
|
40
|
+
archiveVersion.set("1.0.0")
|
|
41
|
+
manifest {
|
|
42
|
+
attributes["Main-Class"] = "com.example.mcp.McpServerKt"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
tasks.build {
|
|
47
|
+
dependsOn(tasks.shadowJar)
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rootProject.name = "<%= name %>"
|
|
@@ -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>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Compiled class files
|
|
2
|
+
*.class
|
|
3
|
+
|
|
4
|
+
# Log files
|
|
5
|
+
*.log
|
|
6
|
+
|
|
7
|
+
# Package Files
|
|
8
|
+
*.jar
|
|
9
|
+
*.war
|
|
10
|
+
*.nar
|
|
11
|
+
*.ear
|
|
12
|
+
*.zip
|
|
13
|
+
*.tar.gz
|
|
14
|
+
*.rar
|
|
15
|
+
|
|
16
|
+
# Maven
|
|
17
|
+
target/
|
|
18
|
+
pom.xml.tag
|
|
19
|
+
pom.xml.releaseBackup
|
|
20
|
+
pom.xml.versionsBackup
|
|
21
|
+
pom.xml.next
|
|
22
|
+
release.properties
|
|
23
|
+
dependency-reduced-pom.xml
|
|
24
|
+
buildNumber.properties
|
|
25
|
+
.mvn/timing.properties
|
|
26
|
+
.mvn/wrapper/maven-wrapper.jar
|
|
27
|
+
|
|
28
|
+
# Kotlin
|
|
29
|
+
*.kotlin_module
|
|
30
|
+
|
|
31
|
+
# IDE
|
|
32
|
+
.idea/
|
|
33
|
+
*.iml
|
|
34
|
+
*.ipr
|
|
35
|
+
*.iws
|
|
36
|
+
.project
|
|
37
|
+
.classpath
|
|
38
|
+
.settings/
|
|
39
|
+
.vscode/
|
|
40
|
+
*.swp
|
|
41
|
+
*.swo
|
|
42
|
+
*~
|
|
43
|
+
|
|
44
|
+
# OS
|
|
45
|
+
.DS_Store
|
|
46
|
+
Thumbs.db
|
|
47
|
+
|
|
48
|
+
# Environment
|
|
49
|
+
.env
|
|
50
|
+
.env.local
|