http_example/

directory
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT

README

HTTP Transport Example

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.

Running the Example

  1. First, start the server:

    go run server/main.go
    

    This will start an HTTP server on port 8080.

  2. In another terminal, run the client:

    go run client/main.go
    

The client will:

  1. Connect to the server
  2. List available tools
  3. Call the time tool with different time formats
  4. Display the results

Understanding the Code

  • server/main.go: Shows how to create an MCP server using HTTP transport and register a tool
  • client/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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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