hello

command
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 9 Imported by: 0

README

Hello World Example

A minimal MCP server that demonstrates basic server setup with a single "hello" tool.

What This Example Demonstrates

  • Basic server configuration
  • Tool registration with input schema
  • Stdio transport setup
  • Graceful shutdown handling
  • Logging

Running the Example

go run main.go

Testing with MCP Inspector

npm install -g @modelcontextprotocol/inspector
mcp-inspector go run main.go

Then in the inspector, call the hello tool with:

{
  "name": "World"
}

Testing with Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "hello": {
      "command": "go",
      "args": ["run", "/absolute/path/to/examples/hello/main.go"]
    }
  }
}

Restart Claude Desktop and try:

"Use the hello tool to greet Alice"

Code Structure

  • Configuration: Sets up server name and version
  • Tool Registration: Registers a single "hello" tool
  • Handler Function: Simple greeting logic
  • Shutdown Handling: Graceful shutdown on SIGTERM/SIGINT
  • Transport: Uses stdio for communication

Next Steps

  • Add more tools with different input schemas
  • Use the HTTP client for external API calls
  • Add caching for expensive operations
  • Register resources alongside tools

See the weather example for a more complex server.

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