mcp-new 1.2.1 → 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 +48 -1
- package/dist/{chunk-BHGUGEHE.js → chunk-YISSMIHU.js} +223 -46
- package/dist/cli.js +817 -51
- 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
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const LanguageSchema: z.ZodEnum<["typescript", "python", "go", "rust"]>;
|
|
3
|
+
declare const LanguageSchema: z.ZodEnum<["typescript", "python", "go", "rust", "java", "kotlin", "csharp", "elixir"]>;
|
|
4
4
|
type Language = z.infer<typeof LanguageSchema>;
|
|
5
|
+
declare const JavaBuildToolSchema: z.ZodEnum<["maven", "gradle"]>;
|
|
6
|
+
type JavaBuildTool = z.infer<typeof JavaBuildToolSchema>;
|
|
5
7
|
declare const TransportSchema: z.ZodEnum<["stdio", "sse"]>;
|
|
6
8
|
type Transport = z.infer<typeof TransportSchema>;
|
|
7
9
|
declare const ToolParameterSchema: z.ZodObject<{
|
|
@@ -80,7 +82,7 @@ type ResourceConfig = z.infer<typeof ResourceConfigSchema>;
|
|
|
80
82
|
declare const ProjectConfigSchema: z.ZodObject<{
|
|
81
83
|
name: z.ZodString;
|
|
82
84
|
description: z.ZodDefault<z.ZodString>;
|
|
83
|
-
language: z.ZodEnum<["typescript", "python", "go", "rust"]>;
|
|
85
|
+
language: z.ZodEnum<["typescript", "python", "go", "rust", "java", "kotlin", "csharp", "elixir"]>;
|
|
84
86
|
transport: z.ZodEnum<["stdio", "sse"]>;
|
|
85
87
|
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
86
88
|
name: z.ZodString;
|
|
@@ -139,10 +141,11 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
139
141
|
includeExampleTool: z.ZodDefault<z.ZodBoolean>;
|
|
140
142
|
skipInstall: z.ZodDefault<z.ZodBoolean>;
|
|
141
143
|
initGit: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
+
javaBuildTool: z.ZodOptional<z.ZodEnum<["maven", "gradle"]>>;
|
|
142
145
|
}, "strip", z.ZodTypeAny, {
|
|
143
146
|
name: string;
|
|
144
147
|
description: string;
|
|
145
|
-
language: "typescript" | "python" | "go" | "rust";
|
|
148
|
+
language: "typescript" | "python" | "go" | "rust" | "java" | "kotlin" | "csharp" | "elixir";
|
|
146
149
|
transport: "stdio" | "sse";
|
|
147
150
|
tools: {
|
|
148
151
|
name: string;
|
|
@@ -163,9 +166,10 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
163
166
|
includeExampleTool: boolean;
|
|
164
167
|
skipInstall: boolean;
|
|
165
168
|
initGit: boolean;
|
|
169
|
+
javaBuildTool?: "maven" | "gradle" | undefined;
|
|
166
170
|
}, {
|
|
167
171
|
name: string;
|
|
168
|
-
language: "typescript" | "python" | "go" | "rust";
|
|
172
|
+
language: "typescript" | "python" | "go" | "rust" | "java" | "kotlin" | "csharp" | "elixir";
|
|
169
173
|
transport: "stdio" | "sse";
|
|
170
174
|
description?: string | undefined;
|
|
171
175
|
tools?: {
|
|
@@ -187,6 +191,7 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
187
191
|
includeExampleTool?: boolean | undefined;
|
|
188
192
|
skipInstall?: boolean | undefined;
|
|
189
193
|
initGit?: boolean | undefined;
|
|
194
|
+
javaBuildTool?: "maven" | "gradle" | undefined;
|
|
190
195
|
}>;
|
|
191
196
|
type ProjectConfig = z.infer<typeof ProjectConfigSchema>;
|
|
192
197
|
interface GeneratorContext {
|
|
@@ -201,6 +206,12 @@ interface CLIOptions {
|
|
|
201
206
|
python?: boolean;
|
|
202
207
|
go?: boolean;
|
|
203
208
|
rust?: boolean;
|
|
209
|
+
java?: boolean;
|
|
210
|
+
kotlin?: boolean;
|
|
211
|
+
csharp?: boolean;
|
|
212
|
+
elixir?: boolean;
|
|
213
|
+
maven?: boolean;
|
|
214
|
+
gradle?: boolean;
|
|
204
215
|
skipInstall?: boolean;
|
|
205
216
|
fromOpenapi?: string;
|
|
206
217
|
fromPrompt?: boolean;
|
|
@@ -361,6 +372,9 @@ declare abstract class BaseGenerator {
|
|
|
361
372
|
private installPythonDependencies;
|
|
362
373
|
private installGoDependencies;
|
|
363
374
|
private installRustDependencies;
|
|
375
|
+
private installJavaDependencies;
|
|
376
|
+
private installDotnetDependencies;
|
|
377
|
+
private installElixirDependencies;
|
|
364
378
|
private checkCommand;
|
|
365
379
|
protected initializeGit(): Promise<void>;
|
|
366
380
|
protected checkOutputDir(): Promise<boolean>;
|
|
@@ -401,6 +415,7 @@ interface PresetGeneratorOptions {
|
|
|
401
415
|
language?: Language;
|
|
402
416
|
skipInstall?: boolean;
|
|
403
417
|
useDefaults?: boolean;
|
|
418
|
+
javaBuildTool?: JavaBuildTool;
|
|
404
419
|
}
|
|
405
420
|
declare function generateFromPreset(options: PresetGeneratorOptions): Promise<void>;
|
|
406
421
|
declare function validatePresetId(presetId: string): presetId is PresetId;
|
|
@@ -432,7 +447,7 @@ declare const logger: {
|
|
|
432
447
|
list: (items: string[]) => void;
|
|
433
448
|
code: (code: string) => void;
|
|
434
449
|
box: (title: string, content: string[]) => void;
|
|
435
|
-
nextSteps: (projectName: string, language: string) => void;
|
|
450
|
+
nextSteps: (projectName: string, language: string, javaBuildTool?: string) => void;
|
|
436
451
|
};
|
|
437
452
|
|
|
438
453
|
interface SpinnerInstance {
|
|
@@ -518,14 +533,17 @@ declare function promptGenerationMethod(): Promise<GenerationMethod>;
|
|
|
518
533
|
|
|
519
534
|
declare function promptPreset(): Promise<PresetId>;
|
|
520
535
|
|
|
536
|
+
declare function promptJavaBuildTool(): Promise<JavaBuildTool>;
|
|
537
|
+
|
|
521
538
|
interface WizardOptions {
|
|
522
539
|
defaultName?: string;
|
|
523
540
|
skipDescription?: boolean;
|
|
524
541
|
skipAdvanced?: boolean;
|
|
525
542
|
presetLanguage?: Language;
|
|
543
|
+
presetJavaBuildTool?: JavaBuildTool;
|
|
526
544
|
}
|
|
527
545
|
declare function runWizard(options?: WizardOptions): Promise<ProjectConfig>;
|
|
528
|
-
declare function runQuickWizard(defaultName?: string, presetLanguage?: Language): Promise<ProjectConfig>;
|
|
546
|
+
declare function runQuickWizard(defaultName?: string, presetLanguage?: Language, presetJavaBuildTool?: JavaBuildTool): Promise<ProjectConfig>;
|
|
529
547
|
|
|
530
548
|
declare function createCommand(projectName: string | undefined, options: CLIOptions): Promise<void>;
|
|
531
549
|
|
|
@@ -544,4 +562,4 @@ interface AddToolOptions {
|
|
|
544
562
|
}
|
|
545
563
|
declare function addToolCommand(options: AddToolOptions): Promise<void>;
|
|
546
564
|
|
|
547
|
-
export { BaseGenerator, type CLIOptions, type GenerationMethod, type GeneratorContext, type Language, LanguageSchema, type MCPPrompt, type MCPPromptArgument, type MCPPropertySchema, type MCPResource, type MCPServerCapabilities, type MCPServerInfo, type MCPTool, type MCPToolInputSchema, type OpenAPIComponents, OpenAPIGenerator, type OpenAPIInfo, type OpenAPIMediaType, type OpenAPIOperation, type OpenAPIParameter, type OpenAPIPathItem, type OpenAPIRequestBody, type OpenAPIResponse, type OpenAPISchema, type OpenAPIServer, type OpenAPISpec, type ParsedEndpoint, type ParsedParameter, type ParsedRequestBody, PresetGenerator, type PresetGeneratorOptions, type PresetId$1 as PresetId, PresetIdSchema, type ProjectConfig, ProjectConfigSchema, PromptGenerator, type ResourceConfig, ResourceConfigSchema, type SpinnerInstance, type ToolConfig, ToolConfigSchema, type ToolParameter, ToolParameterSchema, type Transport, TransportSchema, WizardGenerator, type WizardOptions, addToolCommand, copyDir, copyFile, createCommand, createGeneratorContext, createInitialCommit, createSpinner, endpointToMCPTool, ensureDir, exists, generateFromOpenAPI, generateFromPreset, generateFromPrompt, generateFromWizard, getGitUser, getTemplateDir, initCommand, initGitRepository, isDirectory, isGitInstalled, isInsideGitRepository, logger, parseAndValidate, parseOpenAPISpec, parsePostmanCollection, parseSwaggerSpec, projectNameRegex, promptAddResources, promptAddTools, promptGenerationMethod, promptIncludeExampleTool, promptLanguage, promptMultipleResources, promptMultipleTools, promptPreset, promptProjectDescription, promptProjectName, promptResourceConfig, promptToolConfig, promptTransport, readDir, readFile, remove, renderTemplate, renderTemplateToFile, resolveOutputPath, runQuickWizard, runWizard, safeParseAndValidate, selectEndpoints, validateFilePath, validatePresetId, validateProjectName, validateToolName, validateUrl, walkDir, withSpinner, writeFile };
|
|
565
|
+
export { BaseGenerator, type CLIOptions, type GenerationMethod, type GeneratorContext, type JavaBuildTool, JavaBuildToolSchema, type Language, LanguageSchema, type MCPPrompt, type MCPPromptArgument, type MCPPropertySchema, type MCPResource, type MCPServerCapabilities, type MCPServerInfo, type MCPTool, type MCPToolInputSchema, type OpenAPIComponents, OpenAPIGenerator, type OpenAPIInfo, type OpenAPIMediaType, type OpenAPIOperation, type OpenAPIParameter, type OpenAPIPathItem, type OpenAPIRequestBody, type OpenAPIResponse, type OpenAPISchema, type OpenAPIServer, type OpenAPISpec, type ParsedEndpoint, type ParsedParameter, type ParsedRequestBody, PresetGenerator, type PresetGeneratorOptions, type PresetId$1 as PresetId, PresetIdSchema, type ProjectConfig, ProjectConfigSchema, PromptGenerator, type ResourceConfig, ResourceConfigSchema, type SpinnerInstance, type ToolConfig, ToolConfigSchema, type ToolParameter, ToolParameterSchema, type Transport, TransportSchema, WizardGenerator, type WizardOptions, addToolCommand, copyDir, copyFile, createCommand, createGeneratorContext, createInitialCommit, createSpinner, endpointToMCPTool, ensureDir, exists, generateFromOpenAPI, generateFromPreset, generateFromPrompt, generateFromWizard, getGitUser, getTemplateDir, initCommand, initGitRepository, isDirectory, isGitInstalled, isInsideGitRepository, logger, parseAndValidate, parseOpenAPISpec, parsePostmanCollection, parseSwaggerSpec, projectNameRegex, promptAddResources, promptAddTools, promptGenerationMethod, promptIncludeExampleTool, promptJavaBuildTool, promptLanguage, promptMultipleResources, promptMultipleTools, promptPreset, promptProjectDescription, promptProjectName, promptResourceConfig, promptToolConfig, promptTransport, readDir, readFile, remove, renderTemplate, renderTemplateToFile, resolveOutputPath, runQuickWizard, runWizard, safeParseAndValidate, selectEndpoints, validateFilePath, validatePresetId, validateProjectName, validateToolName, validateUrl, walkDir, withSpinner, writeFile };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
promptAddTools,
|
|
34
34
|
promptGenerationMethod,
|
|
35
35
|
promptIncludeExampleTool,
|
|
36
|
+
promptJavaBuildTool,
|
|
36
37
|
promptLanguage,
|
|
37
38
|
promptMultipleResources,
|
|
38
39
|
promptMultipleTools,
|
|
@@ -60,11 +61,21 @@ import {
|
|
|
60
61
|
walkDir,
|
|
61
62
|
withSpinner,
|
|
62
63
|
writeFile
|
|
63
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-YISSMIHU.js";
|
|
64
65
|
|
|
65
66
|
// src/types/config.ts
|
|
66
67
|
import { z } from "zod";
|
|
67
|
-
var LanguageSchema = z.enum([
|
|
68
|
+
var LanguageSchema = z.enum([
|
|
69
|
+
"typescript",
|
|
70
|
+
"python",
|
|
71
|
+
"go",
|
|
72
|
+
"rust",
|
|
73
|
+
"java",
|
|
74
|
+
"kotlin",
|
|
75
|
+
"csharp",
|
|
76
|
+
"elixir"
|
|
77
|
+
]);
|
|
78
|
+
var JavaBuildToolSchema = z.enum(["maven", "gradle"]);
|
|
68
79
|
var TransportSchema = z.enum(["stdio", "sse"]);
|
|
69
80
|
var ToolParameterSchema = z.object({
|
|
70
81
|
name: z.string(),
|
|
@@ -92,7 +103,8 @@ var ProjectConfigSchema = z.object({
|
|
|
92
103
|
resources: z.array(ResourceConfigSchema).default([]),
|
|
93
104
|
includeExampleTool: z.boolean().default(true),
|
|
94
105
|
skipInstall: z.boolean().default(false),
|
|
95
|
-
initGit: z.boolean().default(true)
|
|
106
|
+
initGit: z.boolean().default(true),
|
|
107
|
+
javaBuildTool: JavaBuildToolSchema.optional()
|
|
96
108
|
});
|
|
97
109
|
var PresetIdSchema = z.enum(["database", "rest-api", "filesystem"]);
|
|
98
110
|
|
|
@@ -291,6 +303,7 @@ function nameToOperationId(name) {
|
|
|
291
303
|
}
|
|
292
304
|
export {
|
|
293
305
|
BaseGenerator,
|
|
306
|
+
JavaBuildToolSchema,
|
|
294
307
|
LanguageSchema,
|
|
295
308
|
OpenAPIGenerator,
|
|
296
309
|
PresetGenerator,
|
|
@@ -333,6 +346,7 @@ export {
|
|
|
333
346
|
promptAddTools,
|
|
334
347
|
promptGenerationMethod,
|
|
335
348
|
promptIncludeExampleTool,
|
|
349
|
+
promptJavaBuildTool,
|
|
336
350
|
promptLanguage,
|
|
337
351
|
promptMultipleResources,
|
|
338
352
|
promptMultipleTools,
|
package/package.json
CHANGED
|
@@ -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
|