Skip to content

A comprehensive, production-ready implementation of the Model Context Protocol (MCP) in Go, providing a robust foundation for building AI-powered applications with multiple transport protocols and advanced workflow capabilities.

Notifications You must be signed in to change notification settings

wongpinter/agent-property-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ProperMCP - Model Context Protocol Framework for Go

A comprehensive, production-ready implementation of the Model Context Protocol (MCP) in Go, providing a robust foundation for building AI-powered applications with multiple transport protocols and advanced workflow capabilities.

πŸš€ Features

Core MCP Implementation

  • Complete MCP Specification: Full implementation of Tools, Prompts, and Resources
  • Multi-Transport Support: HTTP, stdio, and Server-Sent Events (SSE)
  • Type-Safe Operations: Comprehensive parameter validation and type checking
  • Error Handling: Standardized error responses with detailed context
  • Lifecycle Management: Proper resource initialization and cleanup

Advanced Capabilities

  • Smart Tool Orchestration: Automatic prerequisite tool execution with prompts
  • Service Layer Integration: Clean adapter patterns for existing business services
  • Complex Workflows: Multi-step business process automation
  • Real-time Monitoring: Performance metrics and business KPI tracking
  • Business Intelligence: Analytics, reporting, and forecasting capabilities

Transport Protocols

  • HTTP: Traditional REST-like API with JSON request/response
  • stdio: Standard input/output for command-line tools and process communication
  • SSE: Server-Sent Events for real-time streaming and push notifications

πŸ“¦ Installation

go get repo.nusatek.id/sugeng/propermcp

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MCP Client    │───▢│  Transport       │───▢│  MCP Server     β”‚
β”‚                 β”‚    β”‚  Layer           β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚                        β”‚
                                β–Ό                        β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚  HTTP/stdio/SSE  β”‚    β”‚  Tools/Prompts  β”‚
                       β”‚  Protocols       β”‚    β”‚  Resources      β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Project Structure

propermcp/
β”œβ”€β”€ pkg/
β”‚   β”œβ”€β”€ mcp/           # Core MCP interfaces and types
β”‚   β”œβ”€β”€ server/        # Server implementation
β”‚   └── transport/     # Multi-transport support
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ calculator/    # Basic examples
β”‚   β”œβ”€β”€ filesystem/    # File operations
β”‚   β”œβ”€β”€ database/      # Database integration
β”‚   β”œβ”€β”€ workflows/     # Complex business workflows
β”‚   └── transports/    # Transport protocol examples
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ unit/          # Unit tests
β”‚   └── integration/   # Integration tests
└── docs/              # Documentation

πŸš€ Quick Start

Basic MCP Server

package main

import (
    "context"
    "log"

    "repo.nusatek.id/sugeng/propermcp/pkg/mcp"
    "repo.nusatek.id/sugeng/propermcp/pkg/server"
)

// Define a simple tool
type CalculatorTool struct {
    name        string
    description string
    operations  []mcp.Operation
}

func NewCalculatorTool() *CalculatorTool {
    return &CalculatorTool{
        name:        "calculator",
        description: "Basic mathematical operations",
        operations: []mcp.Operation{
            {
                Name:        "add",
                Description: "Add two numbers",
                Parameters: []mcp.ToolParameter{
                    mcp.WithNumberParameter("a", true, "First number"),
                    mcp.WithNumberParameter("b", true, "Second number"),
                },
            },
        },
    }
}

func (t *CalculatorTool) Name() string { return t.name }
func (t *CalculatorTool) Description() string { return t.description }
func (t *CalculatorTool) Operations() []mcp.Operation { return t.operations }

// Implement the tool handler
type CalculatorHandler struct{}

func (h *CalculatorHandler) Handle(ctx context.Context, operation string, args map[string]interface{}) (interface{}, error) {
    switch operation {
    case "add":
        a := args["a"].(float64)
        b := args["b"].(float64)
        return map[string]interface{}{
            "result": a + b,
            "operation": "addition",
        }, nil
    default:
        return nil, mcp.NewMCPError(mcp.ErrorCodeOperationNotFound, "unknown operation", operation)
    }
}

func main() {
    // Create server
    s := server.NewServer("Calculator MCP Server", "1.0.0",
        server.WithToolCapabilities(true),
        server.WithHost("localhost"),
        server.WithPort(8080),
    )

    // Register tool
    tool := NewCalculatorTool()
    handler := &CalculatorHandler{}

    if err := s.RegisterTool(tool, handler); err != nil {
        log.Fatalf("Failed to register tool: %v", err)
    }

    // Start server
    if err := s.Start(":8080"); err != nil {
        log.Fatalf("Failed to start server: %v", err)
    }
}

Using the Server

# Get server status
curl http://localhost:8080/mcp/status

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

# Invoke a tool
curl -X POST http://localhost:8080/mcp/tools/invoke \
  -H "Content-Type: application/json" \
  -d '{
    "tool_name": "calculator",
    "operation_name": "add",
    "arguments": {"a": 5, "b": 3}
  }'

πŸ“š Examples

Basic Examples

Advanced Workflows

Transport Examples

πŸ”§ Configuration

Server Configuration

s := server.NewServer("My MCP Server", "1.0.0",
    server.WithToolCapabilities(true),
    server.WithPromptCapabilities(true),
    server.WithResourceCapabilities(true),
    server.WithHost("localhost"),
    server.WithPort(8080),
    server.WithCORS(true),
    server.WithTimeout(30*time.Second),
)

Transport Configuration

// HTTP Transport (default)
httpConfig := transport.DefaultHTTPConfig()

// stdio Transport
stdioConfig := transport.DefaultStdioConfig()
stdioConfig.UseStderr = true
stdioConfig.LineDelimited = true

// SSE Transport
sseConfig := transport.DefaultSSEConfig()
sseConfig.Port = 8080
sseConfig.KeepAliveInterval = 30 * time.Second

πŸ› οΈ Development

Running Examples

# Basic calculator example
go run examples/calculator/main.go

# Complex e-commerce workflow
go run examples/workflows/ecommerce_workflow.go

# Multi-transport server
go run examples/transports/multi_transport_server.go

# Using the workflow runner
go run examples/workflows/workflow_runner.go ecommerce

Testing

# Run all tests
go test ./...

# Run with coverage
go test -cover ./...

# Run specific test suites
go test ./tests/unit/
go test ./tests/integration/

πŸ“– Documentation

Core Concepts

Advanced Topics

API Reference

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/your-org/propermcp.git
cd propermcp

# Install dependencies
go mod tidy

# Run tests
go test ./...

# Run examples
go run examples/calculator/main.go

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support


ProperMCP - Building the future of AI-powered applications with Go πŸš€

About

A comprehensive, production-ready implementation of the Model Context Protocol (MCP) in Go, providing a robust foundation for building AI-powered applications with multiple transport protocols and advanced workflow capabilities.

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages