mcp-new 0.1.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/LICENSE +21 -0
- package/README.md +184 -0
- package/bin/mcp-new.js +3 -0
- package/dist/chunk-QRUHMGU5.js +1540 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/index.d.ts +516 -0
- package/dist/index.js +351 -0
- package/package.json +73 -0
- package/templates/python/.env.example +8 -0
- package/templates/python/.gitignore.ejs +37 -0
- package/templates/python/README.md.ejs +78 -0
- package/templates/python/pyproject.toml.ejs +20 -0
- package/templates/python/requirements.txt.ejs +1 -0
- package/templates/python/src/__init__.py.ejs +3 -0
- package/templates/python/src/server.py.ejs +98 -0
- package/templates/python/src/tools/__init__.py.ejs +1 -0
- package/templates/python/src/tools/example_tool.py.ejs +47 -0
- package/templates/typescript/.env.example +8 -0
- package/templates/typescript/.gitignore.ejs +22 -0
- package/templates/typescript/README.md.ejs +78 -0
- package/templates/typescript/package.json.ejs +29 -0
- package/templates/typescript/src/index.ts.ejs +121 -0
- package/templates/typescript/src/tools/example-tool.ts.ejs +36 -0
- package/templates/typescript/tsconfig.json.ejs +19 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Example tool implementation
|
|
3
|
+
This file demonstrates how to structure a tool handler
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from mcp.types import Tool
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class ExampleToolInput:
|
|
12
|
+
query: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class ExampleToolOutput:
|
|
17
|
+
result: str
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async def example_tool(input_data: ExampleToolInput) -> ExampleToolOutput:
|
|
21
|
+
"""
|
|
22
|
+
Example tool that processes a query.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
input_data: The input containing the query
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
The processed result
|
|
29
|
+
"""
|
|
30
|
+
result = f"Processed: {input_data.query}"
|
|
31
|
+
return ExampleToolOutput(result=result)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
EXAMPLE_TOOL_SCHEMA = Tool(
|
|
35
|
+
name="example_tool",
|
|
36
|
+
description="An example tool that demonstrates the basic structure",
|
|
37
|
+
inputSchema={
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {
|
|
40
|
+
"query": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "The query to process",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
"required": ["query"],
|
|
46
|
+
},
|
|
47
|
+
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# <%= name %>
|
|
2
|
+
|
|
3
|
+
<%= description || 'MCP Server generated by create-mcp-server' %>
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
npm run build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Running the server
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm start
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Development mode
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm run dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Using with MCP Inspector
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm run inspector
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
### Claude Desktop
|
|
35
|
+
|
|
36
|
+
Add this to your Claude Desktop config file:
|
|
37
|
+
|
|
38
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
39
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"<%= name %>": {
|
|
45
|
+
"command": "node",
|
|
46
|
+
"args": ["<path-to-project>/dist/index.js"]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Available Tools
|
|
53
|
+
|
|
54
|
+
<% if (includeExampleTool) { %>
|
|
55
|
+
### example_tool
|
|
56
|
+
|
|
57
|
+
A sample tool that demonstrates basic MCP tool functionality.
|
|
58
|
+
|
|
59
|
+
**Parameters:**
|
|
60
|
+
- `query` (string, required): The query parameter
|
|
61
|
+
|
|
62
|
+
<% } %>
|
|
63
|
+
<% tools.forEach(function(tool) { %>
|
|
64
|
+
### <%= tool.name %>
|
|
65
|
+
|
|
66
|
+
<%= tool.description %>
|
|
67
|
+
|
|
68
|
+
<% if (tool.parameters && tool.parameters.length > 0) { %>
|
|
69
|
+
**Parameters:**
|
|
70
|
+
<% tool.parameters.forEach(function(param) { %>
|
|
71
|
+
- `<%= param.name %>` (<%= param.type %><%= param.required ? ', required' : '' %>): <%= param.description %>
|
|
72
|
+
<% }); %>
|
|
73
|
+
<% } %>
|
|
74
|
+
<% }); %>
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= name %>",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "<%= description || 'MCP Server generated by create-mcp-server' %>",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"<%= name %>": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"start": "node dist/index.js",
|
|
15
|
+
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^20.0.0",
|
|
27
|
+
"typescript": "^5.4.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
4
|
+
<% if (transport === 'stdio') { %>
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
<% } else { %>
|
|
7
|
+
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
8
|
+
<% } %>
|
|
9
|
+
import {
|
|
10
|
+
CallToolRequestSchema,
|
|
11
|
+
ListToolsRequestSchema,
|
|
12
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
13
|
+
|
|
14
|
+
const server = new Server(
|
|
15
|
+
{
|
|
16
|
+
name: "<%= name %>",
|
|
17
|
+
version: "1.0.0",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
capabilities: {
|
|
21
|
+
tools: {},
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Define available tools
|
|
27
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
28
|
+
tools: [
|
|
29
|
+
<% if (includeExampleTool) { %>
|
|
30
|
+
{
|
|
31
|
+
name: "example_tool",
|
|
32
|
+
description: "An example tool that echoes the input",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
query: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "The query to echo",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ["query"],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
<% } %>
|
|
45
|
+
<% tools.forEach(function(tool) { %>
|
|
46
|
+
{
|
|
47
|
+
name: "<%= tool.name %>",
|
|
48
|
+
description: "<%= tool.description %>",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
<% tool.parameters.forEach(function(param, index) { %>
|
|
53
|
+
<%= param.name %>: {
|
|
54
|
+
type: "<%= param.type %>",
|
|
55
|
+
description: "<%= param.description %>",
|
|
56
|
+
}<%= index < tool.parameters.length - 1 ? ',' : '' %>
|
|
57
|
+
<% }); %>
|
|
58
|
+
},
|
|
59
|
+
required: [<%- tool.parameters.filter(p => p.required).map(p => '"' + p.name + '"').join(', ') %>],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
<% }); %>
|
|
63
|
+
],
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
// Handle tool calls
|
|
67
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
68
|
+
const { name, arguments: args } = request.params;
|
|
69
|
+
|
|
70
|
+
<% if (includeExampleTool) { %>
|
|
71
|
+
if (name === "example_tool") {
|
|
72
|
+
const query = args?.query as string;
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: "text",
|
|
77
|
+
text: `Echo: ${query}`,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
<% } %>
|
|
83
|
+
|
|
84
|
+
<% tools.forEach(function(tool) { %>
|
|
85
|
+
if (name === "<%= tool.name %>") {
|
|
86
|
+
// TODO: Implement <%= tool.name %> logic
|
|
87
|
+
<% tool.parameters.forEach(function(param) { %>
|
|
88
|
+
const <%= param.name %> = args?.<%= param.name %> as <%= param.type === 'number' ? 'number' : param.type === 'boolean' ? 'boolean' : 'string' %>;
|
|
89
|
+
<% }); %>
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
content: [
|
|
93
|
+
{
|
|
94
|
+
type: "text",
|
|
95
|
+
text: `<%= tool.name %> called with: ${JSON.stringify(args)}`,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
<% }); %>
|
|
101
|
+
|
|
102
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Start the server
|
|
106
|
+
async function main() {
|
|
107
|
+
<% if (transport === 'stdio') { %>
|
|
108
|
+
const transport = new StdioServerTransport();
|
|
109
|
+
await server.connect(transport);
|
|
110
|
+
console.error("<%= name %> MCP server running on stdio");
|
|
111
|
+
<% } else { %>
|
|
112
|
+
const transport = new SSEServerTransport("/messages", response);
|
|
113
|
+
await server.connect(transport);
|
|
114
|
+
console.error("<%= name %> MCP server running on SSE");
|
|
115
|
+
<% } %>
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
main().catch((error) => {
|
|
119
|
+
console.error("Fatal error:", error);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example tool implementation
|
|
3
|
+
* This file demonstrates how to structure a tool handler
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface ExampleToolInput {
|
|
7
|
+
query: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ExampleToolOutput {
|
|
11
|
+
result: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function exampleTool(input: ExampleToolInput): Promise<ExampleToolOutput> {
|
|
15
|
+
const { query } = input;
|
|
16
|
+
|
|
17
|
+
// Your tool logic here
|
|
18
|
+
const result = `Processed: ${query}`;
|
|
19
|
+
|
|
20
|
+
return { result };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const exampleToolSchema = {
|
|
24
|
+
name: "example_tool",
|
|
25
|
+
description: "An example tool that demonstrates the basic structure",
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object" as const,
|
|
28
|
+
properties: {
|
|
29
|
+
query: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "The query to process",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: ["query"],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|