Skip to content

Commit 60c59c0

Browse files
authored
Merge pull request #20 from f/feature/template
template feature.
2 parents 00cdf9f + d1ed58d commit 60c59c0

File tree

12 files changed

+582
-4
lines changed

12 files changed

+582
-4
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@ test: check-go
2929
lint: check-go
3030
@echo "$(BLUE)Running linter...$(NC)"
3131
golangci-lint run ./...
32+
33+
dist:
34+
mkdir -p dist
35+
36+
clean:
37+
rm -rf bin/* dist/*
38+
39+
release: clean lint test build

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ A command-line interface for interacting with MCP (Model Context Protocol) serve
2121
- [Output Formats](#output-formats)
2222
- [Commands](#commands)
2323
- [Interactive Shell](#interactive-shell)
24+
- [Project Scaffolding](#project-scaffolding)
2425
- [Server Aliases](#server-aliases)
2526
- [Server Modes](#server-modes)
2627
- [Mock Server Mode](#mock-server-mode)
@@ -42,6 +43,7 @@ MCP Tools provides a versatile CLI for working with Model Context Protocol (MCP)
4243
- Create mock servers for testing client applications
4344
- Proxy MCP requests to shell scripts for easy extensibility
4445
- Create interactive shells for exploring and using MCP servers
46+
- Scaffold new MCP projects with TypeScript support
4547
- Format output in various styles (JSON, pretty-printed, table)
4648
- Support all transport methods (HTTP, stdio)
4749

@@ -96,6 +98,7 @@ Available Commands:
9698
call Call a tool, resource, or prompt on the MCP server
9799
help Help about any command
98100
mock Create a mock MCP server with tools, prompts, and resources
101+
new Create a new MCP project from templates
99102
proxy Proxy MCP tool requests to shell scripts
100103
prompts List available prompts on the MCP server
101104
resources List available resources on the MCP server
@@ -272,6 +275,50 @@ Special Commands:
272275
/q, /quit, exit Exit the shell
273276
```
274277

278+
### Project Scaffolding
279+
280+
MCP Tools provides a scaffolding feature to quickly create new MCP servers with TypeScript:
281+
282+
```bash
283+
mkdir my-mcp-server
284+
cd my-mcp-server
285+
286+
# Create a project with specific components
287+
mcp new tool:calculate resource:file prompt:greet
288+
289+
# Create a project with a specific SDK (currently only TypeScript/ts supported)
290+
mcp new tool:calculate --sdk=ts
291+
292+
# Create a project with a specific transport type
293+
mcp new tool:calculate --transport=stdio
294+
mcp new tool:calculate --transport=sse
295+
```
296+
297+
The scaffolding creates a complete project structure with:
298+
299+
- Server setup with chosen transport (stdio or SSE)
300+
- TypeScript configuration with modern ES modules
301+
- Component implementations with proper MCP interfaces
302+
- Automatic wiring of imports and initialization
303+
304+
After scaffolding, you can build and run your MCP server:
305+
306+
```bash
307+
# Install dependencies
308+
npm install
309+
310+
# Build the TypeScript code
311+
npm run build
312+
313+
# Test the server with MCP Tools
314+
mcp tools node build/index.js
315+
```
316+
317+
Project templates are stored in either:
318+
- Local `./templates/` directory
319+
- User's home directory: `~/.mcputils/templates/`
320+
- Next to the MCP Tools executable
321+
275322
## Server Aliases
276323

277324
MCP Tools allows you to save and reuse server commands with friendly aliases:

cmd/mcptools/main.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func main() {
9696
newMockCmd(),
9797
proxyCmd(),
9898
aliasCmd(),
99+
newNewCmd(),
99100
)
100101

101102
if err := rootCmd.Execute(); err != nil {
@@ -1282,10 +1283,19 @@ func aliasListCmd() *cobra.Command {
12821283

12831284
func aliasRemoveCmd() *cobra.Command {
12841285
return &cobra.Command{
1285-
Use: "remove [alias]",
1286+
Use: "remove <name>",
12861287
Short: "Remove an MCP server alias",
1287-
Args: cobra.ExactArgs(1),
1288-
RunE: func(_ *cobra.Command, args []string) error {
1288+
Long: `Remove a registered alias for an MCP server command.
1289+
1290+
Example:
1291+
mcp alias remove myfs`,
1292+
Args: cobra.ExactArgs(1),
1293+
RunE: func(thisCmd *cobra.Command, args []string) error {
1294+
if len(args) == 1 && (args[0] == flagHelp || args[0] == flagHelpShort) {
1295+
_ = thisCmd.Help()
1296+
return nil
1297+
}
1298+
12891299
aliasName := args[0]
12901300

12911301
aliases, err := alias.Load()
@@ -1294,7 +1304,7 @@ func aliasRemoveCmd() *cobra.Command {
12941304
}
12951305

12961306
if _, exists := aliases[aliasName]; !exists {
1297-
return fmt.Errorf("alias '%s' not found", aliasName)
1307+
return fmt.Errorf("alias '%s' does not exist", aliasName)
12981308
}
12991309

13001310
delete(aliases, aliasName)

0 commit comments

Comments
 (0)