GoCopilotAgentToDoList
About
A Go-based HTTP server that provides a time API using Dockerized Model Context Protocol (MCP). Accepts a timezone and returns the current time, demonstrating Go, Docker, and JSON API integration. Includes unit tests and is ready for extension with new features.
Details
- Author
- iancarpenter
- Downloads
- 278
- Categories
- Developer Tools
Jump to
- Provides a POST /mcp/time endpoint that returns the current time for a given timezone
- Uses Docker to run the MCP service for time retrieval
- All communication is JSON-based for requests and responses
- Includes unit tests for request and response marshaling
- Reserved todos.json file hints at future to-do list features
Build and run the server by executing go run package\ main.go in the project directory. The server listens on http://localhost:8080. To get the current time, send a POST request to /mcp/time with a JSON body containing the timezone (e.g., {"timezone": "America/New_York"}). A curl example is provided: curl -X POST http://localhost:8080/mcp/time -H "Content-Type: application/json" -d '{"timezone":"America/New_York"}'.
GoCopilotAgentToDoList
Overview
GoCopilotAgentToDoList is a Go-based HTTP server that provides an API endpoint for retrieving the current time in a specified timezone. The server interacts with a Dockerized Model Context Protocol (MCP) service to fetch the time, making it a practical example of integrating Go, Docker, and external services.Features
- /mcp/time API endpoint: Accepts a POST request with a timezone and returns the current time for that timezone. - Docker integration: Uses Docker to run the MCP service for time retrieval. - JSON-based communication: Both requests and responses use JSON. - Unit tests: Includes basic unit tests for request and response marshaling.Prerequisites
- Go 1.18 or later - Docker installed and running - MCP Docker image (mcp:latest) available locally
- Windows OS (but code is cross-platform)
Project Structure
go.mod # Go module definition
package main.go # Main application source code
package_main_test.go # Unit tests for the project
todos.json # (Reserved for future to-do list features)
Usage
1. Build and Run the Server
Open a terminal in the project directory and run:go run package\ main.go
The server will start and listen on http://localhost:8080.
2. API Endpoint
POST /mcp/time
- Request Body:
{
"timezone": "America/New_York"
}
- Response Body:
{
"time": "2025-05-27T12:34:56Z"
}
- Example with curl:
curl -X POST http://localhost:8080/mcp/time -H "Content-Type: application/json" -d '{"timezone":"America/New_York"}'
3. How It Works
- The server receives a POST request at/mcp/time with a JSON body specifying the timezone.
- It marshals the request and pipes it to a Docker container running the MCP service (mcp:latest), specifically the mcp/time command.
- The output from the container is parsed and returned as a JSON response.
Running Tests
To run the unit tests, execute:go test -v
Extending the Project
- To-Do List Feature: The presence oftodos.json suggests future plans for a to-do list API.
- Additional Endpoints: You can add more endpoints by defining new handlers in package main.go.
- Error Handling: Improve error messages and logging for production use.
Troubleshooting
- Ensure Docker is running and themcp:latest image is available locally.
- If you encounter permission issues with Docker, run your terminal as administrator.
- The server listens on port 8080 by default. Change this in package main.go if needed.
License
This project is provided as-is for educational and demonstration purposes.Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





