Only one template for now
This commit is contained in:
parent
261c566d49
commit
76295f6b2f
6 changed files with 2 additions and 2 deletions
|
|
@ -12,7 +12,7 @@
|
|||
},
|
||||
"files": [
|
||||
"build",
|
||||
"templates"
|
||||
"template"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc && shx chmod +x build/index.js",
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ async function createServer(directory: string, options: any = {}) {
|
|||
await fs.mkdir(directory, { recursive: true });
|
||||
|
||||
// Copy template files
|
||||
const templateDir = path.join(__dirname, "../templates");
|
||||
const templateDir = path.join(__dirname, "../template");
|
||||
const files = await fs.readdir(templateDir, { recursive: true });
|
||||
|
||||
for (const file of files) {
|
||||
|
|
|
|||
3
template/.gitignore
vendored
Normal file
3
template/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
node_modules/
|
||||
build/
|
||||
*.log
|
||||
18
template/package.json.ejs
Normal file
18
template/package.json.ejs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "<%= name %>",
|
||||
"version": "0.1.0",
|
||||
"description": "<%= description %>",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"start": "node build/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.24",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
63
template/src/index.ts.ejs
Normal file
63
template/src/index.ts.ejs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import {
|
||||
ListResourcesRequestSchema,
|
||||
ListToolsRequestSchema,
|
||||
} from "@modelcontextprotocol/sdk/types.js";
|
||||
|
||||
const server = new Server(
|
||||
{
|
||||
name: "<%= name %>",
|
||||
version: "0.1.0",
|
||||
},
|
||||
{
|
||||
capabilities: {
|
||||
resources: {},
|
||||
tools: {},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
||||
return {
|
||||
resources: [
|
||||
{
|
||||
uri: "example://hello",
|
||||
mimeType: "text/plain",
|
||||
name: "Example resource",
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
return {
|
||||
tools: [
|
||||
{
|
||||
name: "example",
|
||||
description: "An example tool",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
message: {
|
||||
type: "string",
|
||||
description: "Message to echo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("Server error:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
15
template/tsconfig.json
Normal file
15
template/tsconfig.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Loading…
Reference in a new issue