@leanmcp/cli 0.5.4-alpha.11.2ed1026 → 0.5.4-alpha.17.873b525
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/dist/index.js +74 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2987,12 +2987,16 @@ vite.config.ts.timestamp-*
|
|
|
2987
2987
|
var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import { Tool, Resource, Prompt, SchemaConstraint, Optional } from "@leanmcp/core";
|
|
2988
2988
|
|
|
2989
2989
|
/**
|
|
2990
|
-
*
|
|
2990
|
+
* ${projectName} - Production-ready MCP server example
|
|
2991
2991
|
*
|
|
2992
|
-
* This
|
|
2992
|
+
* This example demonstrates LeanMCP's core features:
|
|
2993
|
+
* - Schema validation with decorators
|
|
2994
|
+
* - Type-safe tool definitions
|
|
2995
|
+
* - Resource and prompt capabilities
|
|
2996
|
+
* - Production-ready structure
|
|
2993
2997
|
*/
|
|
2994
2998
|
|
|
2995
|
-
// Input
|
|
2999
|
+
// Input schemas with validation decorators
|
|
2996
3000
|
class CalculateInput {
|
|
2997
3001
|
@SchemaConstraint({ description: "First number" })
|
|
2998
3002
|
a!: number;
|
|
@@ -3017,13 +3021,13 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3017
3021
|
message!: string;
|
|
3018
3022
|
}
|
|
3019
3023
|
|
|
3020
|
-
export class
|
|
3024
|
+
export class ${projectName}Service {
|
|
3025
|
+
// CALCULATION TOOL - Shows schema validation
|
|
3021
3026
|
@Tool({
|
|
3022
3027
|
description: "Perform arithmetic operations with automatic schema validation",
|
|
3023
3028
|
inputClass: CalculateInput
|
|
3024
3029
|
})
|
|
3025
3030
|
async calculate(input: CalculateInput) {
|
|
3026
|
-
// Ensure numerical operations by explicitly converting to numbers
|
|
3027
3031
|
const a = Number(input.a);
|
|
3028
3032
|
const b = Number(input.b);
|
|
3029
3033
|
let result: number;
|
|
@@ -3052,14 +3056,17 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3052
3056
|
text: JSON.stringify({
|
|
3053
3057
|
operation: input.operation || "add",
|
|
3054
3058
|
operands: { a: input.a, b: input.b },
|
|
3055
|
-
result
|
|
3059
|
+
result,
|
|
3060
|
+
timestamp: new Date().toISOString(),
|
|
3061
|
+
server: "${projectName}"
|
|
3056
3062
|
}, null, 2)
|
|
3057
3063
|
}]
|
|
3058
3064
|
};
|
|
3059
3065
|
}
|
|
3060
3066
|
|
|
3067
|
+
// ECHO TOOL - Shows basic functionality
|
|
3061
3068
|
@Tool({
|
|
3062
|
-
description: "Echo a message back",
|
|
3069
|
+
description: "Echo a message back with timestamp",
|
|
3063
3070
|
inputClass: EchoInput
|
|
3064
3071
|
})
|
|
3065
3072
|
async echo(input: EchoInput) {
|
|
@@ -3068,13 +3075,15 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3068
3075
|
type: "text" as const,
|
|
3069
3076
|
text: JSON.stringify({
|
|
3070
3077
|
echoed: input.message,
|
|
3071
|
-
timestamp: new Date().toISOString()
|
|
3078
|
+
timestamp: new Date().toISOString(),
|
|
3079
|
+
server: "${projectName}"
|
|
3072
3080
|
}, null, 2)
|
|
3073
3081
|
}]
|
|
3074
3082
|
};
|
|
3075
3083
|
}
|
|
3076
3084
|
|
|
3077
|
-
|
|
3085
|
+
// SERVER INFO RESOURCE - Shows resource capabilities
|
|
3086
|
+
@Resource({ description: "Get server information and health status" })
|
|
3078
3087
|
async serverInfo() {
|
|
3079
3088
|
return {
|
|
3080
3089
|
contents: [{
|
|
@@ -3083,25 +3092,45 @@ var getExampleServiceTemplate = /* @__PURE__ */ __name((projectName) => `import
|
|
|
3083
3092
|
text: JSON.stringify({
|
|
3084
3093
|
name: "${projectName}",
|
|
3085
3094
|
version: "1.0.0",
|
|
3086
|
-
|
|
3095
|
+
status: "healthy",
|
|
3096
|
+
uptime: Math.floor(process.uptime()),
|
|
3097
|
+
memory: {
|
|
3098
|
+
used: Math.round(process.memoryUsage().heapUsed / 1024 / 1024),
|
|
3099
|
+
total: Math.round(process.memoryUsage().heapTotal / 1024 / 1024)
|
|
3100
|
+
},
|
|
3101
|
+
features: [
|
|
3102
|
+
"Schema validation with decorators",
|
|
3103
|
+
"Type-safe tool definitions",
|
|
3104
|
+
"Resource endpoints",
|
|
3105
|
+
"Prompt templates"
|
|
3106
|
+
],
|
|
3107
|
+
timestamp: new Date().toISOString()
|
|
3087
3108
|
}, null, 2)
|
|
3088
3109
|
}]
|
|
3089
3110
|
};
|
|
3090
3111
|
}
|
|
3091
3112
|
|
|
3092
|
-
|
|
3093
|
-
|
|
3113
|
+
// WELCOME PROMPT - Shows prompt capabilities
|
|
3114
|
+
@Prompt({ description: "Generate a welcome prompt for the server" })
|
|
3115
|
+
async welcome(args: { name?: string }) {
|
|
3094
3116
|
return {
|
|
3095
3117
|
messages: [{
|
|
3096
3118
|
role: "user" as const,
|
|
3097
3119
|
content: {
|
|
3098
3120
|
type: "text" as const,
|
|
3099
|
-
text: \`
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3121
|
+
text: \`Welcome \${args.name || 'there'} to ${projectName}!
|
|
3122
|
+
|
|
3123
|
+
Your MCP server is running with these tools:
|
|
3124
|
+
- calculate: Perform arithmetic operations
|
|
3125
|
+
- echo: Echo messages back
|
|
3126
|
+
- serverInfo: Get server status and information
|
|
3127
|
+
|
|
3128
|
+
Try calling these tools to see LeanMCP in action!\`
|
|
3129
|
+
}
|
|
3130
|
+
}]
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3105
3134
|
`, "getExampleServiceTemplate");
|
|
3106
3135
|
|
|
3107
3136
|
// src/templates/main_ts_v1.ts
|
|
@@ -3111,6 +3140,14 @@ import { createHTTPServer } from "@leanmcp/core";
|
|
|
3111
3140
|
// Load environment variables
|
|
3112
3141
|
dotenv.config();
|
|
3113
3142
|
|
|
3143
|
+
console.log("Starting ${projectName} MCP Server...");
|
|
3144
|
+
console.log("Features included:");
|
|
3145
|
+
console.log(" Schema validation with decorators");
|
|
3146
|
+
console.log(" Resource endpoints");
|
|
3147
|
+
console.log(" Prompt templates");
|
|
3148
|
+
console.log(" Type-safe tool definitions");
|
|
3149
|
+
console.log("");
|
|
3150
|
+
|
|
3114
3151
|
// Services are automatically discovered from ./mcp directory
|
|
3115
3152
|
await createHTTPServer({
|
|
3116
3153
|
name: "${projectName}",
|
|
@@ -3118,10 +3155,27 @@ await createHTTPServer({
|
|
|
3118
3155
|
port: 3001,
|
|
3119
3156
|
cors: true,
|
|
3120
3157
|
logging: true${dashboardLine}
|
|
3121
|
-
// stateless: false, // Enable stateful mode (uses DynamoDB on Lambda for session persistence)
|
|
3122
3158
|
});
|
|
3123
3159
|
|
|
3124
|
-
console.log("\\n${projectName} MCP Server");
|
|
3160
|
+
console.log("\\n${projectName} MCP Server is running!");
|
|
3161
|
+
console.log("\\nTry these commands to test your server:");
|
|
3162
|
+
console.log("");
|
|
3163
|
+
console.log("# Test calculation tool (schema validation)");
|
|
3164
|
+
console.log('curl -X POST http://localhost:3001/mcp \\\\');
|
|
3165
|
+
console.log(' -H "Content-Type: application/json" \\\\');
|
|
3166
|
+
console.log(' -d '{"method": "tools/call", "params": {"name": "calculate", "arguments": {"a": 10, "b": 5, "operation": "add"}}}'');
|
|
3167
|
+
console.log("");
|
|
3168
|
+
console.log("# Test echo tool");
|
|
3169
|
+
console.log('curl -X POST http://localhost:3001/mcp \\\\');
|
|
3170
|
+
console.log(' -H "Content-Type: application/json" \\\\');
|
|
3171
|
+
console.log(' -d '{"method": "tools/call", "params": {"name": "echo", "arguments": {"message": "Hello LeanMCP!"}}}'');
|
|
3172
|
+
console.log("");
|
|
3173
|
+
console.log("# Get server information (resource)");
|
|
3174
|
+
console.log('curl -X POST http://localhost:3001/mcp \\\\');
|
|
3175
|
+
console.log(' -H "Content-Type: application/json" \\\\');
|
|
3176
|
+
console.log(' -d '{"method": "resources/read", "params": {"uri": "server://info"}}'');
|
|
3177
|
+
console.log("");
|
|
3178
|
+
console.log("Ready to customize - add your own tools, resources, and prompts!");
|
|
3125
3179
|
`, "getMainTsTemplate");
|
|
3126
3180
|
|
|
3127
3181
|
// src/templates/service_index_v1.ts
|