create-strawberry-toolserver
Version:
Create a new Strawberry Tool Server project
55 lines (52 loc) • 1.71 kB
JavaScript
;
const giget = require('giget');
const citty = require('citty');
const DEFAULT_TEMPLATE = "strawberry";
const DEFAULT_REGISTRY = "https://gist.githubusercontent.com/cryppadotta/6734b1217387c1404a4de662c15dab7f/raw/58e798cd7365edfa5c580e29961635b01f37e669";
citty.runMain({
args: {
name: {
type: "string",
description: "Name of the template to use",
required: false
},
registry: {
type: "string",
description: "Registry URL to download the template from",
default: DEFAULT_REGISTRY
},
dir: {
type: "string",
description: "Directory where the project will be created",
required: false
},
_dir: {
type: "positional",
default: ".",
description: "Project directory (prefer using --dir)"
}
},
async run(context) {
try {
const templateName = context.args.name || DEFAULT_TEMPLATE;
const targetDir = context.args.dir || context.args._dir;
console.log(`Creating new Strawberry Tool Server in ${targetDir}...`);
const res = await giget.downloadTemplate(templateName, {
registry: context.args.registry,
dir: targetDir
});
console.log(`
Success! Created Strawberry Tool Server at ${res.dir}`);
console.log("\nGetting Started:");
console.log(` cd ${res.dir}`);
console.log(" npm install");
console.log(" npm start");
console.log("\nTo test the server:");
console.log(" npx @strawberryprotocol/mcp-cli --sse http://localhost:3000/sse");
} catch (error) {
console.error("Error:", "message" in error ? error.message : "unknown error");
process.exit(1);
}
}
});