Skip to content

Commit 89d1509

Browse files
authored
fix(cli): fix generated Go MCP server run and doc (#104)
This fixes the kmcp run command for mcp servers generated with kmcp init go and updates the generated README with the accurate file paths ### Before these change kmcp run results in the following error ``` Running server directly: go run main.go Server is running and waiting for MCP protocol input on stdin... Press Ctrl+C to stop the server stat main.go: no such file or directory Error: exit status 1 ``` ### After these changes - Docs reference the proper file paths - `kmcp run` uses the right path to main.go to start the server - The mcp inspector server config uses the right path to main.go Signed-off-by: kevdkr <[email protected]>
1 parent 78d7e1a commit 89d1509

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

pkg/cli/internal/commands/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ func runMCPGo(projectDir string, manifest *manifest.ProjectManifest) error {
168168

169169
if noInspector {
170170
// Run the server directly
171-
fmt.Printf("Running server directly: go run main.go\n")
171+
fmt.Printf("Running server directly: go run cmd/server/main.go\n")
172172
fmt.Printf("Server is running and waiting for MCP protocol input on stdin...\n")
173173
fmt.Printf("Press Ctrl+C to stop the server\n")
174174

175-
serverCmd := exec.Command("go", "run", "main.go")
175+
serverCmd := exec.Command("go", "run", "cmd/server/main.go")
176176
serverCmd.Dir = projectDir
177177
serverCmd.Stdout = os.Stdout
178178
serverCmd.Stderr = os.Stderr
@@ -183,7 +183,7 @@ func runMCPGo(projectDir string, manifest *manifest.ProjectManifest) error {
183183
// Create server configuration for inspector
184184
serverConfig := map[string]interface{}{
185185
"command": "go",
186-
"args": []string{"run", "main.go"},
186+
"args": []string{"run", "cmd/server/main.go"},
187187
}
188188

189189
// Create MCP inspector config

pkg/cli/internal/frameworks/golang/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (g *Generator) GenerateTool(projectroot string, config templates.ToolConfig
6161
fmt.Printf("\nNext steps:\n")
6262
fmt.Printf("1. Edit internal/tools/%s.go to implement your tool logic\n", toolNameSnakeCase)
6363
fmt.Printf("2. Configure any required environment variables in kmcp.yaml\n")
64-
fmt.Printf("3. Run 'go run main.go' to start the server\n")
64+
fmt.Printf("3. Run 'go run cmd/server/main.go' to start the server\n")
6565

6666
return nil
6767
}

pkg/cli/internal/frameworks/golang/templates/README.md.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This project was generated with [`kmcp`](https://github.com/kagent-dev/kmcp).
2020

2121
2. **Run the server:**
2222
```bash
23-
go run main.go
23+
go run cmd/server/main.go
2424
```
2525

2626
### Building the Docker Image
@@ -51,4 +51,4 @@ To add a new tool to your project, use the `kmcp add-tool` command:
5151
kmcp add-tool <tool-name>
5252
```
5353

54-
This will generate a new Go file in the `tools/` directory with a template for your new tool. You will need to add the new tool to the `main.go` file.
54+
This will generate a new Go file in the `internal/tools/` directory with a template for your new tool. You will need to add the new tool to the `main.go` file.

0 commit comments

Comments
 (0)