This example demonstrates how to use the HTTP transport in MCP. It consists of a server that provides a simple time tool and a client that connects to it.
-
First, start the server:
go run server/main.go
This will start an HTTP server on port 8080.
-
In another terminal, run the client:
go run client/main.go
The client will:
- Connect to the server
- List available tools
- Call the time tool with different time formats
- Display the results
server/main.go
: Shows how to create an MCP server using HTTP transport and register a toolclient/main.go
: Shows how to create an MCP client that connects to an HTTP server and calls tools
The example demonstrates:
- Setting up HTTP transport
- Tool registration and description
- Tool parameter handling
- Making tool calls with different arguments
- Handling tool responses