cli_simple

command
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 7 Imported by: 0

README

Simple Text Processor

A minimal MCP server demonstrating the basic setup with a single tool. This example showcases both stdio and HTTP transports using the same handler.

Features

  • Single tool: to_upper - converts text to uppercase
  • Dual transport support: stdio (default) or HTTP (with -listen flag)
  • Minimal code demonstrating the core mcp-io API

Running

Stdio Transport (default)
make build-cli-simple
./bin/cli-simple
HTTP Transport
./bin/cli-simple -listen :8080

The server will start on http://localhost:8080/mcp

Testing

Stdio Mode
# List available tools
mcp tools ./bin/cli-simple

# Call the to_upper tool
mcp call to_upper --params '{"text":"hello world"}' ./bin/cli-simple
HTTP Mode
# Start the server in another terminal
./bin/cli-simple -listen :8080

# List available tools
mcp tools http://localhost:8080/mcp

# Call the to_upper tool
mcp call to_upper --params '{"text":"hello world"}' http://localhost:8080/mcp

Transport Selection

This example demonstrates how a single handler can serve multiple transports:

handler, err := mcpio.NewHandler(
    mcpio.WithName("simple-text-processor"),
    mcpio.WithTool("to_upper", "Convert text to uppercase", toUpper),
)

// Choose transport based on CLI flag
if *listen != "" {
    http.Handle("/mcp", handler)
    log.Fatal(http.ListenAndServe(*listen, nil))
} else {
    handler.ServeStdio(context.Background(), os.Stdin, os.Stdout)
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL