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,233 @@
|
|
|
1
|
+
stages:
|
|
2
|
+
- build
|
|
3
|
+
- test
|
|
4
|
+
|
|
5
|
+
variables:
|
|
6
|
+
PROJECT_NAME: "<%= projectName %>"
|
|
7
|
+
|
|
8
|
+
<% if (language === 'typescript') { %>
|
|
9
|
+
image: node:<%= nodeVersion %>
|
|
10
|
+
|
|
11
|
+
cache:
|
|
12
|
+
paths:
|
|
13
|
+
- node_modules/
|
|
14
|
+
|
|
15
|
+
install:
|
|
16
|
+
stage: build
|
|
17
|
+
script:
|
|
18
|
+
- <%= installCommand %>
|
|
19
|
+
artifacts:
|
|
20
|
+
paths:
|
|
21
|
+
- node_modules/
|
|
22
|
+
|
|
23
|
+
<% if (buildCommand) { %>
|
|
24
|
+
build:
|
|
25
|
+
stage: build
|
|
26
|
+
script:
|
|
27
|
+
- <%= installCommand %>
|
|
28
|
+
- <%= buildCommand %>
|
|
29
|
+
artifacts:
|
|
30
|
+
paths:
|
|
31
|
+
- dist/
|
|
32
|
+
<% } %>
|
|
33
|
+
|
|
34
|
+
<% if (testCommand) { %>
|
|
35
|
+
test:
|
|
36
|
+
stage: test
|
|
37
|
+
script:
|
|
38
|
+
- <%= installCommand %>
|
|
39
|
+
- <%= testCommand %>
|
|
40
|
+
<% } %>
|
|
41
|
+
<% } else if (language === 'python') { %>
|
|
42
|
+
image: python:<%= pythonVersion %>
|
|
43
|
+
|
|
44
|
+
cache:
|
|
45
|
+
paths:
|
|
46
|
+
- .pip-cache/
|
|
47
|
+
|
|
48
|
+
variables:
|
|
49
|
+
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
|
|
50
|
+
|
|
51
|
+
install:
|
|
52
|
+
stage: build
|
|
53
|
+
script:
|
|
54
|
+
- python -m pip install --upgrade pip
|
|
55
|
+
- <%= installCommand %>
|
|
56
|
+
|
|
57
|
+
<% if (testCommand) { %>
|
|
58
|
+
test:
|
|
59
|
+
stage: test
|
|
60
|
+
script:
|
|
61
|
+
- python -m pip install --upgrade pip
|
|
62
|
+
- <%= installCommand %>
|
|
63
|
+
- pip install pytest
|
|
64
|
+
- <%= testCommand %>
|
|
65
|
+
<% } %>
|
|
66
|
+
<% } else if (language === 'go') { %>
|
|
67
|
+
image: golang:<%= goVersion %>
|
|
68
|
+
|
|
69
|
+
cache:
|
|
70
|
+
paths:
|
|
71
|
+
- /go/pkg/mod/
|
|
72
|
+
|
|
73
|
+
install:
|
|
74
|
+
stage: build
|
|
75
|
+
script:
|
|
76
|
+
- <%= installCommand %>
|
|
77
|
+
|
|
78
|
+
<% if (buildCommand) { %>
|
|
79
|
+
build:
|
|
80
|
+
stage: build
|
|
81
|
+
script:
|
|
82
|
+
- <%= installCommand %>
|
|
83
|
+
- <%= buildCommand %>
|
|
84
|
+
<% } %>
|
|
85
|
+
|
|
86
|
+
<% if (testCommand) { %>
|
|
87
|
+
test:
|
|
88
|
+
stage: test
|
|
89
|
+
script:
|
|
90
|
+
- <%= installCommand %>
|
|
91
|
+
- <%= testCommand %>
|
|
92
|
+
<% } %>
|
|
93
|
+
<% } else if (language === 'rust') { %>
|
|
94
|
+
image: rust:<%= rustVersion %>
|
|
95
|
+
|
|
96
|
+
cache:
|
|
97
|
+
paths:
|
|
98
|
+
- target/
|
|
99
|
+
- .cargo/
|
|
100
|
+
|
|
101
|
+
variables:
|
|
102
|
+
CARGO_HOME: "$CI_PROJECT_DIR/.cargo"
|
|
103
|
+
|
|
104
|
+
install:
|
|
105
|
+
stage: build
|
|
106
|
+
script:
|
|
107
|
+
- <%= installCommand %>
|
|
108
|
+
|
|
109
|
+
<% if (buildCommand) { %>
|
|
110
|
+
build:
|
|
111
|
+
stage: build
|
|
112
|
+
script:
|
|
113
|
+
- <%= buildCommand %>
|
|
114
|
+
<% } %>
|
|
115
|
+
|
|
116
|
+
<% if (testCommand) { %>
|
|
117
|
+
test:
|
|
118
|
+
stage: test
|
|
119
|
+
script:
|
|
120
|
+
- <%= testCommand %>
|
|
121
|
+
<% } %>
|
|
122
|
+
<% } else if (language === 'java' || language === 'kotlin') { %>
|
|
123
|
+
image: eclipse-temurin:<%= javaVersion %>
|
|
124
|
+
|
|
125
|
+
<% if (installCommand.includes('gradle')) { %>
|
|
126
|
+
cache:
|
|
127
|
+
paths:
|
|
128
|
+
- .gradle/
|
|
129
|
+
- build/
|
|
130
|
+
|
|
131
|
+
variables:
|
|
132
|
+
GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle"
|
|
133
|
+
|
|
134
|
+
<% if (buildCommand) { %>
|
|
135
|
+
build:
|
|
136
|
+
stage: build
|
|
137
|
+
script:
|
|
138
|
+
- <%= buildCommand %>
|
|
139
|
+
artifacts:
|
|
140
|
+
paths:
|
|
141
|
+
- build/libs/
|
|
142
|
+
<% } %>
|
|
143
|
+
|
|
144
|
+
<% if (testCommand) { %>
|
|
145
|
+
test:
|
|
146
|
+
stage: test
|
|
147
|
+
script:
|
|
148
|
+
- <%= testCommand %>
|
|
149
|
+
<% } %>
|
|
150
|
+
<% } else { %>
|
|
151
|
+
cache:
|
|
152
|
+
paths:
|
|
153
|
+
- .m2/repository/
|
|
154
|
+
|
|
155
|
+
variables:
|
|
156
|
+
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
|
|
157
|
+
|
|
158
|
+
<% if (buildCommand) { %>
|
|
159
|
+
build:
|
|
160
|
+
stage: build
|
|
161
|
+
script:
|
|
162
|
+
- <%= buildCommand %>
|
|
163
|
+
artifacts:
|
|
164
|
+
paths:
|
|
165
|
+
- target/
|
|
166
|
+
<% } %>
|
|
167
|
+
|
|
168
|
+
<% if (testCommand) { %>
|
|
169
|
+
test:
|
|
170
|
+
stage: test
|
|
171
|
+
script:
|
|
172
|
+
- <%= testCommand %>
|
|
173
|
+
<% } %>
|
|
174
|
+
<% } %>
|
|
175
|
+
<% } else if (language === 'csharp') { %>
|
|
176
|
+
image: mcr.microsoft.com/dotnet/sdk:<%= dotnetVersion %>
|
|
177
|
+
|
|
178
|
+
cache:
|
|
179
|
+
paths:
|
|
180
|
+
- packages/
|
|
181
|
+
|
|
182
|
+
install:
|
|
183
|
+
stage: build
|
|
184
|
+
script:
|
|
185
|
+
- <%= installCommand %>
|
|
186
|
+
|
|
187
|
+
<% if (buildCommand) { %>
|
|
188
|
+
build:
|
|
189
|
+
stage: build
|
|
190
|
+
script:
|
|
191
|
+
- <%= installCommand %>
|
|
192
|
+
- <%= buildCommand %>
|
|
193
|
+
artifacts:
|
|
194
|
+
paths:
|
|
195
|
+
- bin/
|
|
196
|
+
<% } %>
|
|
197
|
+
|
|
198
|
+
<% if (testCommand) { %>
|
|
199
|
+
test:
|
|
200
|
+
stage: test
|
|
201
|
+
script:
|
|
202
|
+
- <%= installCommand %>
|
|
203
|
+
- <%= testCommand %>
|
|
204
|
+
<% } %>
|
|
205
|
+
<% } else if (language === 'elixir') { %>
|
|
206
|
+
image: elixir:<%= elixirVersion %>
|
|
207
|
+
|
|
208
|
+
cache:
|
|
209
|
+
paths:
|
|
210
|
+
- deps/
|
|
211
|
+
- _build/
|
|
212
|
+
|
|
213
|
+
install:
|
|
214
|
+
stage: build
|
|
215
|
+
script:
|
|
216
|
+
- <%= installCommand %>
|
|
217
|
+
|
|
218
|
+
<% if (buildCommand) { %>
|
|
219
|
+
build:
|
|
220
|
+
stage: build
|
|
221
|
+
script:
|
|
222
|
+
- <%= installCommand %>
|
|
223
|
+
- <%= buildCommand %>
|
|
224
|
+
<% } %>
|
|
225
|
+
|
|
226
|
+
<% if (testCommand) { %>
|
|
227
|
+
test:
|
|
228
|
+
stage: test
|
|
229
|
+
script:
|
|
230
|
+
- <%= installCommand %>
|
|
231
|
+
- <%= testCommand %>
|
|
232
|
+
<% } %>
|
|
233
|
+
<% } %>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Build results
|
|
2
|
+
[Dd]ebug/
|
|
3
|
+
[Dd]ebugPublic/
|
|
4
|
+
[Rr]elease/
|
|
5
|
+
[Rr]eleases/
|
|
6
|
+
x64/
|
|
7
|
+
x86/
|
|
8
|
+
[Ww][Ii][Nn]32/
|
|
9
|
+
[Aa][Rr][Mm]/
|
|
10
|
+
[Aa][Rr][Mm]64/
|
|
11
|
+
bld/
|
|
12
|
+
[Bb]in/
|
|
13
|
+
[Oo]bj/
|
|
14
|
+
[Ll]og/
|
|
15
|
+
[Ll]ogs/
|
|
16
|
+
|
|
17
|
+
# Visual Studio
|
|
18
|
+
.vs/
|
|
19
|
+
*.user
|
|
20
|
+
*.userosscache
|
|
21
|
+
*.sln.docstates
|
|
22
|
+
*.suo
|
|
23
|
+
*.cache
|
|
24
|
+
*.sln.ide/
|
|
25
|
+
|
|
26
|
+
# Rider
|
|
27
|
+
.idea/
|
|
28
|
+
*.sln.iml
|
|
29
|
+
|
|
30
|
+
# NuGet
|
|
31
|
+
*.nupkg
|
|
32
|
+
*.snupkg
|
|
33
|
+
.nuget/
|
|
34
|
+
packages/
|
|
35
|
+
*.packages.targets
|
|
36
|
+
|
|
37
|
+
# dotnet
|
|
38
|
+
project.lock.json
|
|
39
|
+
project.fragment.lock.json
|
|
40
|
+
artifacts/
|
|
41
|
+
|
|
42
|
+
# Test results
|
|
43
|
+
[Tt]est[Rr]esult*/
|
|
44
|
+
[Bb]uild[Ll]og.*
|
|
45
|
+
|
|
46
|
+
# OS
|
|
47
|
+
.DS_Store
|
|
48
|
+
Thumbs.db
|
|
49
|
+
|
|
50
|
+
# Environment
|
|
51
|
+
.env
|
|
52
|
+
.env.local
|
|
53
|
+
appsettings.Development.json
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<OutputType>Exe</OutputType>
|
|
5
|
+
<TargetFramework>net8.0</TargetFramework>
|
|
6
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
|
+
<Nullable>enable</Nullable>
|
|
8
|
+
<RootNamespace><%= namespace %></RootNamespace>
|
|
9
|
+
<AssemblyName><%= name %></AssemblyName>
|
|
10
|
+
</PropertyGroup>
|
|
11
|
+
|
|
12
|
+
<ItemGroup>
|
|
13
|
+
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.1" />
|
|
14
|
+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
|
15
|
+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
|
16
|
+
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
|
17
|
+
</ItemGroup>
|
|
18
|
+
|
|
19
|
+
</Project>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# <%= name %>
|
|
2
|
+
|
|
3
|
+
<%= description || 'MCP Server generated by mcp-new' %>
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- .NET 8.0 SDK or higher
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Restore dependencies
|
|
13
|
+
dotnet restore
|
|
14
|
+
|
|
15
|
+
# Build
|
|
16
|
+
dotnet build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Running the Server
|
|
20
|
+
|
|
21
|
+
### Development
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
dotnet run
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Production
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Build release version
|
|
31
|
+
dotnet publish -c Release -o publish
|
|
32
|
+
|
|
33
|
+
# Run
|
|
34
|
+
./publish/<%= name %>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration with Claude Desktop
|
|
38
|
+
|
|
39
|
+
Add this to your Claude Desktop config file:
|
|
40
|
+
|
|
41
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
42
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"mcpServers": {
|
|
47
|
+
"<%= name %>": {
|
|
48
|
+
"command": "dotnet",
|
|
49
|
+
"args": ["run", "--project", "/path/to/<%= name %>"]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Or with published binary:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"<%= name %>": {
|
|
61
|
+
"command": "/path/to/<%= name %>/publish/<%= name %>"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Available Tools
|
|
68
|
+
|
|
69
|
+
<% if (includeExampleTool) { %>
|
|
70
|
+
### example_tool
|
|
71
|
+
An example tool that echoes the input
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
- `query` (string, required): The query to echo
|
|
75
|
+
<% } %>
|
|
76
|
+
|
|
77
|
+
<% tools.forEach(function(tool) { %>
|
|
78
|
+
### <%= tool.name %>
|
|
79
|
+
<%= tool.description %>
|
|
80
|
+
|
|
81
|
+
**Parameters:**
|
|
82
|
+
<% tool.parameters.forEach(function(param) { %>
|
|
83
|
+
- `<%= param.name %>` (<%= param.type %><%= param.required ? ', required' : '' %>): <%= param.description %>
|
|
84
|
+
<% }); %>
|
|
85
|
+
<% }); %>
|
|
86
|
+
|
|
87
|
+
## Project Structure
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
<%= name %>/
|
|
91
|
+
├── <%= name %>.csproj # Project file
|
|
92
|
+
├── src/
|
|
93
|
+
│ └── Program.cs # Main server file
|
|
94
|
+
├── .gitignore
|
|
95
|
+
├── .env.example
|
|
96
|
+
└── README.md
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
|
|
101
|
+
### Adding a New Tool
|
|
102
|
+
|
|
103
|
+
1. Open `src/Program.cs`
|
|
104
|
+
2. Add a new tool registration in the `RegisterTools` method:
|
|
105
|
+
|
|
106
|
+
```csharp
|
|
107
|
+
services.AddMcpTool("my_new_tool", "Description of my tool", async (args, cancellationToken) =>
|
|
108
|
+
{
|
|
109
|
+
var param1 = args.GetProperty("param1").GetString();
|
|
110
|
+
// Your tool logic here
|
|
111
|
+
return new ToolResult
|
|
112
|
+
{
|
|
113
|
+
Content = new[]
|
|
114
|
+
{
|
|
115
|
+
new TextContent { Text = $"Result: {param1}" }
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
new ToolInputSchema
|
|
120
|
+
{
|
|
121
|
+
Type = "object",
|
|
122
|
+
Properties = new Dictionary<string, ToolPropertySchema>
|
|
123
|
+
{
|
|
124
|
+
["param1"] = new ToolPropertySchema
|
|
125
|
+
{
|
|
126
|
+
Type = "string",
|
|
127
|
+
Description = "Parameter description"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
Required = new[] { "param1" }
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
using Microsoft.Extensions.DependencyInjection;
|
|
2
|
+
using Microsoft.Extensions.Hosting;
|
|
3
|
+
using Microsoft.Extensions.Logging;
|
|
4
|
+
using ModelContextProtocol.Server;
|
|
5
|
+
using System.Text.Json;
|
|
6
|
+
|
|
7
|
+
namespace <%= namespace %>;
|
|
8
|
+
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// <%= name %> MCP Server
|
|
11
|
+
/// <%= description || 'Generated by mcp-new' %>
|
|
12
|
+
/// </summary>
|
|
13
|
+
class Program
|
|
14
|
+
{
|
|
15
|
+
static async Task Main(string[] args)
|
|
16
|
+
{
|
|
17
|
+
var builder = Host.CreateApplicationBuilder(args);
|
|
18
|
+
|
|
19
|
+
builder.Logging.AddConsole();
|
|
20
|
+
builder.Logging.SetMinimumLevel(LogLevel.Information);
|
|
21
|
+
|
|
22
|
+
builder.Services.AddMcpServer(options =>
|
|
23
|
+
{
|
|
24
|
+
options.ServerInfo = new ServerInfo
|
|
25
|
+
{
|
|
26
|
+
Name = "<%= name %>",
|
|
27
|
+
Version = "1.0.0"
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Register tools
|
|
32
|
+
RegisterTools(builder.Services);
|
|
33
|
+
|
|
34
|
+
var host = builder.Build();
|
|
35
|
+
|
|
36
|
+
<% if (transport === 'stdio') { %>
|
|
37
|
+
// Start STDIO server
|
|
38
|
+
Console.Error.WriteLine("<%= name %> MCP server running on stdio");
|
|
39
|
+
await host.RunMcpServerAsync();
|
|
40
|
+
<% } else { %>
|
|
41
|
+
// Start SSE server
|
|
42
|
+
Console.Error.WriteLine("<%= name %> MCP server running on SSE at http://localhost:8080");
|
|
43
|
+
await host.RunMcpSseServerAsync(8080);
|
|
44
|
+
<% } %>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static void RegisterTools(IServiceCollection services)
|
|
48
|
+
{
|
|
49
|
+
<% if (includeExampleTool) { %>
|
|
50
|
+
// Register example_tool
|
|
51
|
+
services.AddMcpTool("example_tool", "An example tool that echoes the input", async (args, cancellationToken) =>
|
|
52
|
+
{
|
|
53
|
+
var query = args.GetProperty("query").GetString() ?? "";
|
|
54
|
+
return new ToolResult
|
|
55
|
+
{
|
|
56
|
+
Content = new[]
|
|
57
|
+
{
|
|
58
|
+
new TextContent { Text = $"Echo: {query}" }
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
new ToolInputSchema
|
|
63
|
+
{
|
|
64
|
+
Type = "object",
|
|
65
|
+
Properties = new Dictionary<string, ToolPropertySchema>
|
|
66
|
+
{
|
|
67
|
+
["query"] = new ToolPropertySchema
|
|
68
|
+
{
|
|
69
|
+
Type = "string",
|
|
70
|
+
Description = "The query to echo"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
Required = new[] { "query" }
|
|
74
|
+
});
|
|
75
|
+
<% } %>
|
|
76
|
+
|
|
77
|
+
<% tools.forEach(function(tool) { %>
|
|
78
|
+
// Register <%= tool.name %>
|
|
79
|
+
services.AddMcpTool("<%= tool.name %>", "<%= tool.description %>", async (args, cancellationToken) =>
|
|
80
|
+
{
|
|
81
|
+
// TODO: Implement <%= tool.name %> logic
|
|
82
|
+
<% tool.parameters.forEach(function(param) { %>
|
|
83
|
+
<% if (param.type === 'number') { %>
|
|
84
|
+
var <%= param.name %> = args.GetProperty("<%= param.name %>").GetDouble();
|
|
85
|
+
<% } else if (param.type === 'boolean') { %>
|
|
86
|
+
var <%= param.name %> = args.GetProperty("<%= param.name %>").GetBoolean();
|
|
87
|
+
<% } else { %>
|
|
88
|
+
var <%= param.name %> = args.GetProperty("<%= param.name %>").GetString();
|
|
89
|
+
<% } %>
|
|
90
|
+
<% }); %>
|
|
91
|
+
|
|
92
|
+
return new ToolResult
|
|
93
|
+
{
|
|
94
|
+
Content = new[]
|
|
95
|
+
{
|
|
96
|
+
new TextContent { Text = $"<%= tool.name %> called with: {args}" }
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
new ToolInputSchema
|
|
101
|
+
{
|
|
102
|
+
Type = "object",
|
|
103
|
+
Properties = new Dictionary<string, ToolPropertySchema>
|
|
104
|
+
{
|
|
105
|
+
<% tool.parameters.forEach(function(param, index) { %>
|
|
106
|
+
["<%= param.name %>"] = new ToolPropertySchema
|
|
107
|
+
{
|
|
108
|
+
Type = "<%= param.type %>",
|
|
109
|
+
Description = "<%= param.description %>"
|
|
110
|
+
}<%= index < tool.parameters.length - 1 ? ',' : '' %>
|
|
111
|
+
<% }); %>
|
|
112
|
+
},
|
|
113
|
+
Required = new[] { <%= tool.parameters.filter(p => p.required).map(p => '"' + p.name + '"').join(', ') %> }
|
|
114
|
+
});
|
|
115
|
+
<% }); %>
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
/deps/
|
|
3
|
+
/_build/
|
|
4
|
+
/cover/
|
|
5
|
+
/doc/
|
|
6
|
+
|
|
7
|
+
# Dialyzer
|
|
8
|
+
/priv/plts/
|
|
9
|
+
|
|
10
|
+
# Generated files
|
|
11
|
+
*.beam
|
|
12
|
+
*.ez
|
|
13
|
+
erl_crash.dump
|
|
14
|
+
|
|
15
|
+
# Release
|
|
16
|
+
/rel/
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.idea/
|
|
20
|
+
*.iml
|
|
21
|
+
.vscode/
|
|
22
|
+
*.swp
|
|
23
|
+
*.swo
|
|
24
|
+
*~
|
|
25
|
+
|
|
26
|
+
# OS
|
|
27
|
+
.DS_Store
|
|
28
|
+
Thumbs.db
|
|
29
|
+
|
|
30
|
+
# Environment
|
|
31
|
+
.env
|
|
32
|
+
.env.local
|
|
33
|
+
*.secret.exs
|