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.
Files changed (50) hide show
  1. package/README.md +33 -1
  2. package/dist/{chunk-3JG4FVS2.js → chunk-LJNMSDBU.js} +1157 -212
  3. package/dist/cli.js +1287 -18
  4. package/dist/index.d.ts +43 -10
  5. package/dist/index.js +22 -35
  6. package/package.json +4 -2
  7. package/templates/ci/circleci/config.yml.ejs +219 -0
  8. package/templates/ci/github/ci.yml.ejs +184 -0
  9. package/templates/ci/gitlab/.gitlab-ci.yml.ejs +233 -0
  10. package/templates/csharp/.env.example +6 -0
  11. package/templates/csharp/.gitignore.ejs +53 -0
  12. package/templates/csharp/McpServer.csproj.ejs +19 -0
  13. package/templates/csharp/README.md.ejs +136 -0
  14. package/templates/csharp/src/Program.cs.ejs +117 -0
  15. package/templates/elixir/.env.example +6 -0
  16. package/templates/elixir/.gitignore.ejs +33 -0
  17. package/templates/elixir/README.md.ejs +154 -0
  18. package/templates/elixir/config/config.exs.ejs +9 -0
  19. package/templates/elixir/config/dev.exs.ejs +3 -0
  20. package/templates/elixir/config/prod.exs.ejs +3 -0
  21. package/templates/elixir/lib/application.ex.ejs +19 -0
  22. package/templates/elixir/lib/cli.ex.ejs +17 -0
  23. package/templates/elixir/lib/server.ex.ejs +112 -0
  24. package/templates/elixir/mix.exs.ejs +32 -0
  25. package/templates/java/gradle/.env.example +6 -0
  26. package/templates/java/gradle/.gitignore.ejs +48 -0
  27. package/templates/java/gradle/README.md.ejs +132 -0
  28. package/templates/java/gradle/build.gradle.ejs +46 -0
  29. package/templates/java/gradle/settings.gradle.ejs +1 -0
  30. package/templates/java/gradle/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
  31. package/templates/java/gradle/src/main/resources/logback.xml +13 -0
  32. package/templates/java/maven/.env.example +6 -0
  33. package/templates/java/maven/.gitignore.ejs +53 -0
  34. package/templates/java/maven/README.md.ejs +131 -0
  35. package/templates/java/maven/pom.xml.ejs +86 -0
  36. package/templates/java/maven/src/main/java/com/example/mcp/McpServer.java.ejs +149 -0
  37. package/templates/java/maven/src/main/resources/logback.xml +13 -0
  38. package/templates/kotlin/gradle/.env.example +6 -0
  39. package/templates/kotlin/gradle/.gitignore.ejs +45 -0
  40. package/templates/kotlin/gradle/README.md.ejs +138 -0
  41. package/templates/kotlin/gradle/build.gradle.kts.ejs +48 -0
  42. package/templates/kotlin/gradle/settings.gradle.kts.ejs +1 -0
  43. package/templates/kotlin/gradle/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
  44. package/templates/kotlin/gradle/src/main/resources/logback.xml +13 -0
  45. package/templates/kotlin/maven/.env.example +6 -0
  46. package/templates/kotlin/maven/.gitignore.ejs +50 -0
  47. package/templates/kotlin/maven/README.md.ejs +96 -0
  48. package/templates/kotlin/maven/pom.xml.ejs +105 -0
  49. package/templates/kotlin/maven/src/main/kotlin/com/example/mcp/McpServer.kt.ejs +141 -0
  50. package/templates/kotlin/maven/src/main/resources/logback.xml +13 -0
@@ -0,0 +1,154 @@
1
+ # <%= name %>
2
+
3
+ <%= description || 'MCP Server generated by mcp-new' %>
4
+
5
+ ## Prerequisites
6
+
7
+ - Elixir 1.15 or higher
8
+ - Erlang/OTP 25 or higher
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ # Install dependencies
14
+ mix deps.get
15
+
16
+ # Compile
17
+ mix compile
18
+ ```
19
+
20
+ ## Running the Server
21
+
22
+ ### Development
23
+
24
+ ```bash
25
+ # Run in interactive mode
26
+ iex -S mix
27
+
28
+ # Or run directly
29
+ mix run --no-halt
30
+ ```
31
+
32
+ ### Production
33
+
34
+ ```bash
35
+ # Build release
36
+ MIX_ENV=prod mix release
37
+
38
+ # Or build escript
39
+ mix escript.build
40
+
41
+ # Run escript
42
+ ./<%= packageName %>
43
+ ```
44
+
45
+ ## Configuration with Claude Desktop
46
+
47
+ Add this to your Claude Desktop config file:
48
+
49
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
50
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
51
+
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "<%= name %>": {
56
+ "command": "mix",
57
+ "args": ["run", "--no-halt"],
58
+ "cwd": "/path/to/<%= name %>"
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ Or with escript:
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "<%= name %>": {
70
+ "command": "/path/to/<%= name %>/<%= packageName %>"
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ ## Available Tools
77
+
78
+ <% if (includeExampleTool) { %>
79
+ ### example_tool
80
+ An example tool that echoes the input
81
+
82
+ **Parameters:**
83
+ - `query` (string, required): The query to echo
84
+ <% } %>
85
+
86
+ <% tools.forEach(function(tool) { %>
87
+ ### <%= tool.name %>
88
+ <%= tool.description %>
89
+
90
+ **Parameters:**
91
+ <% tool.parameters.forEach(function(param) { %>
92
+ - `<%= param.name %>` (<%= param.type %><%= param.required ? ', required' : '' %>): <%= param.description %>
93
+ <% }); %>
94
+ <% }); %>
95
+
96
+ ## Project Structure
97
+
98
+ ```
99
+ <%= name %>/
100
+ ├── mix.exs # Project configuration
101
+ ├── config/
102
+ │ ├── config.exs # Base configuration
103
+ │ ├── dev.exs # Development config
104
+ │ └── prod.exs # Production config
105
+ ├── lib/
106
+ │ ├── application.ex # Application entry point
107
+ │ ├── server.ex # MCP Server implementation
108
+ │ └── cli.ex # CLI entry point
109
+ ├── .gitignore
110
+ ├── .env.example
111
+ └── README.md
112
+ ```
113
+
114
+ ## Development
115
+
116
+ ### Adding a New Tool
117
+
118
+ 1. Open `lib/server.ex`
119
+ 2. Add a new tool to the `register_tools` function:
120
+
121
+ ```elixir
122
+ %{
123
+ name: "my_new_tool",
124
+ description: "Description of my tool",
125
+ input_schema: %{
126
+ type: "object",
127
+ properties: %{
128
+ param1: %{
129
+ type: "string",
130
+ description: "Parameter description"
131
+ }
132
+ },
133
+ required: ["param1"]
134
+ },
135
+ handler: &handle_my_new_tool/1
136
+ }
137
+ ```
138
+
139
+ 3. Add the handler function:
140
+
141
+ ```elixir
142
+ defp handle_my_new_tool(%{"param1" => param1}) do
143
+ # Your tool logic here
144
+ {:ok, %{
145
+ content: [
146
+ %{type: "text", text: "Result: #{param1}"}
147
+ ]
148
+ }}
149
+ end
150
+ ```
151
+
152
+ ## License
153
+
154
+ MIT
@@ -0,0 +1,9 @@
1
+ import Config
2
+
3
+ config :logger,
4
+ level: :info,
5
+ format: "$time $metadata[$level] $message\n",
6
+ metadata: [:request_id]
7
+
8
+ # Import environment specific config
9
+ import_config "#{config_env()}.exs"
@@ -0,0 +1,3 @@
1
+ import Config
2
+
3
+ config :logger, level: :debug
@@ -0,0 +1,3 @@
1
+ import Config
2
+
3
+ config :logger, level: :info
@@ -0,0 +1,19 @@
1
+ defmodule <%= namespace %>.Application do
2
+ @moduledoc """
3
+ <%= name %> MCP Server Application
4
+ <%= description || 'Generated by mcp-new' %>
5
+ """
6
+
7
+ use Application
8
+ require Logger
9
+
10
+ @impl true
11
+ def start(_type, _args) do
12
+ children = [
13
+ {<%= namespace %>.Server, []}
14
+ ]
15
+
16
+ opts = [strategy: :one_for_one, name: <%= namespace %>.Supervisor]
17
+ Supervisor.start_link(children, opts)
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ defmodule <%= namespace %>.CLI do
2
+ @moduledoc """
3
+ CLI entry point for <%= name %> MCP Server
4
+ """
5
+
6
+ require Logger
7
+
8
+ def main(_args) do
9
+ Logger.info("<%= name %> MCP server running on stdio")
10
+
11
+ # Start the application
12
+ Application.ensure_all_started(:<%= packageName %>)
13
+
14
+ # Keep the process alive
15
+ Process.sleep(:infinity)
16
+ end
17
+ end
@@ -0,0 +1,112 @@
1
+ defmodule <%= namespace %>.Server do
2
+ @moduledoc """
3
+ MCP Server implementation for <%= name %>
4
+ """
5
+
6
+ use GenServer
7
+ require Logger
8
+
9
+ def start_link(opts \\ []) do
10
+ GenServer.start_link(__MODULE__, opts, name: __MODULE__)
11
+ end
12
+
13
+ @impl true
14
+ def init(_opts) do
15
+ Logger.info("<%= name %> MCP server starting...")
16
+
17
+ # Register tools
18
+ tools = register_tools()
19
+
20
+ {:ok, %{tools: tools}}
21
+ end
22
+
23
+ defp register_tools do
24
+ [
25
+ <% if (includeExampleTool) { %>
26
+ %{
27
+ name: "example_tool",
28
+ description: "An example tool that echoes the input",
29
+ input_schema: %{
30
+ type: "object",
31
+ properties: %{
32
+ query: %{
33
+ type: "string",
34
+ description: "The query to echo"
35
+ }
36
+ },
37
+ required: ["query"]
38
+ },
39
+ handler: &handle_example_tool/1
40
+ },
41
+ <% } %>
42
+ <% tools.forEach(function(tool) { %>
43
+ %{
44
+ name: "<%= tool.name %>",
45
+ description: "<%= tool.description %>",
46
+ input_schema: %{
47
+ type: "object",
48
+ properties: %{
49
+ <% tool.parameters.forEach(function(param, index) { %>
50
+ <%= param.name %>: %{
51
+ type: "<%= param.type %>",
52
+ description: "<%= param.description %>"
53
+ }<%= index < tool.parameters.length - 1 ? ',' : '' %>
54
+ <% }); %>
55
+ },
56
+ required: [<%= tool.parameters.filter(p => p.required).map(p => '"' + p.name + '"').join(', ') %>]
57
+ },
58
+ handler: &handle_<%= tool.name %>/1
59
+ },
60
+ <% }); %>
61
+ ]
62
+ end
63
+
64
+ <% if (includeExampleTool) { %>
65
+ defp handle_example_tool(%{"query" => query}) do
66
+ {:ok, %{
67
+ content: [
68
+ %{type: "text", text: "Echo: #{query}"}
69
+ ]
70
+ }}
71
+ end
72
+ <% } %>
73
+
74
+ <% tools.forEach(function(tool) { %>
75
+ defp handle_<%= tool.name %>(args) do
76
+ # TODO: Implement <%= tool.name %> logic
77
+ <% tool.parameters.forEach(function(param) { %>
78
+ _<%= param.name %> = Map.get(args, "<%= param.name %>")
79
+ <% }); %>
80
+
81
+ {:ok, %{
82
+ content: [
83
+ %{type: "text", text: "<%= tool.name %> called with: #{inspect(args)}"}
84
+ ]
85
+ }}
86
+ end
87
+ <% }); %>
88
+
89
+ # Handle incoming MCP messages
90
+ @impl true
91
+ def handle_info({:mcp, :list_tools}, state) do
92
+ tools = Enum.map(state.tools, fn tool ->
93
+ %{
94
+ name: tool.name,
95
+ description: tool.description,
96
+ inputSchema: tool.input_schema
97
+ }
98
+ end)
99
+
100
+ {:noreply, state, {:reply, %{tools: tools}}}
101
+ end
102
+
103
+ @impl true
104
+ def handle_info({:mcp, :call_tool, name, arguments}, state) do
105
+ result = case Enum.find(state.tools, fn t -> t.name == name end) do
106
+ nil -> {:error, "Unknown tool: #{name}"}
107
+ tool -> tool.handler.(arguments)
108
+ end
109
+
110
+ {:noreply, state, {:reply, result}}
111
+ end
112
+ end
@@ -0,0 +1,32 @@
1
+ defmodule <%= namespace %>.MixProject do
2
+ use Mix.Project
3
+
4
+ def project do
5
+ [
6
+ app: :<%= packageName %>,
7
+ version: "1.0.0",
8
+ elixir: "~> 1.15",
9
+ start_permanent: Mix.env() == :prod,
10
+ deps: deps(),
11
+ escript: escript()
12
+ ]
13
+ end
14
+
15
+ def application do
16
+ [
17
+ extra_applications: [:logger],
18
+ mod: {<%= namespace %>.Application, []}
19
+ ]
20
+ end
21
+
22
+ defp deps do
23
+ [
24
+ {:mcp, "~> 0.1.0"},
25
+ {:jason, "~> 1.4"}
26
+ ]
27
+ end
28
+
29
+ defp escript do
30
+ [main_module: <%= namespace %>.CLI]
31
+ end
32
+ end
@@ -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,48 @@
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
+ # Gradle
23
+ .gradle/
24
+ build/
25
+ gradle-app.setting
26
+ !gradle-wrapper.jar
27
+ .gradletasknamecache
28
+
29
+ # IDE
30
+ .idea/
31
+ *.iml
32
+ *.ipr
33
+ *.iws
34
+ .project
35
+ .classpath
36
+ .settings/
37
+ .vscode/
38
+ *.swp
39
+ *.swo
40
+ *~
41
+
42
+ # OS
43
+ .DS_Store
44
+ Thumbs.db
45
+
46
+ # Environment
47
+ .env
48
+ .env.local
@@ -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 %>'