About urfave-cli-mcp
urfave-cli-mcp adapts an urfave/cli application into an MCP server by turning its command tree into tools. It is aimed at Go developers who want to reuse query-oriented CLIs or develop tools through a CLI first.
Key features
- 01Exposes subcommands as MCP tools
- 02Supports descriptions, flags, defaults, and required flags
- 03Runs tools by forking the current process
- 04Returns command stdout as the result
Use cases
- 01Expose a query-only urfave/cli app to MCP clients
- 02Prototype MCP tools by first building CLI commands
MCP support
It converts an urfave/cli command tree into MCP tools, allowing MCP clients to invoke the commands and receive their stdout.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEurfave-cli-mcp
This is a quick hack for reusing a 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
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)
}
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.