https://github.com/thepwagner/urfave-cli-mcp
Expose https://github.com/urfave/cli app as an MCP server
https://github.com/thepwagner/urfave-cli-mcp
golang-library model-context-protocol urfave-cli
Last synced: 4 months ago
JSON representation
Expose https://github.com/urfave/cli app as an MCP server
- Host: GitHub
- URL: https://github.com/thepwagner/urfave-cli-mcp
- Owner: thepwagner
- License: mit
- Created: 2025-05-24T00:56:43.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-06-05T20:58:59.000Z (6 months ago)
- Last Synced: 2025-07-04T12:08:41.164Z (5 months ago)
- Topics: golang-library, model-context-protocol, urfave-cli
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mcp-servers - **urfave-cli-mcp** - Expose https://github.com/urfave/cli app as an MCP server `go` `golang-library` `model-context-protocol` `urfave-cli` `mcp` `go install thepwagner/urfave-cli-mcp@latest` (⚙️ DevOps)
README
# urfave-cli-mcp
This is a quick hack for reusing a [urfave/cli](https://github.com/urfave/cli) app as an Model Context Protocol server.
It crawls the `Command` tree provided and exposes subcommands as MCP tools. Supports descriptions, flags, default values, and required flags.
Tools are invoked by forking the current process, and returning stdout as the result.
I'm using it to reuse query-only CLIs as an MCP server with one line of code.
It might also be useful to create new MCP servers, as you can iterate tools as a CLI before exposing to an MCP client.
### Example
```golang
package main
import (
"context"
"fmt"
"os"
urfaveclimcp "github.com/thepwagner/urfave-cli-mcp"
"github.com/urfave/cli/v3"
)
var App = &cli.Command{
Name: "hello",
Usage: "say hello",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "the name to say hello to",
Value: "World",
},
},
Action: func(_ context.Context, c *cli.Command) error {
fmt.Println("Hello,", c.String("name"))
return nil
},
}
func main() {
// Pass the root command you want to expose, then add the "mcp" command to your App
App.Commands = append(App.Commands, urfaveclimcp.NewMCPCommand(App))
App.Run(context.Background(), os.Args)
}
```