
mcp4go/mcp4go
Deployment & DevOpsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
A comprehensive Go SDK for the Model Context Protocol (MCP) - simplifying AI application development by abstracting away protocol complexities.
Обзор
MCP4Go is a Go implementation of the Model Context Protocol (MCP), designed to simplify the development of AI applications by abstracting away protocol complexities. - Complete MCP protocol implementation in pure Go - High-level abstractions for common MCP resources - Pluggable architecture for custom extensions - Comprehensive documentation and examples - Production-ready with robust error handling MCP4Go requires Go 1.18 or later. Install it using Go modules: To get started with MCP4Go, import the package in your Go application: MCP4Go provides a complete implementation of the Model Context Protocol with support for: - JSON-RPC communication - Resource lifecycle management - Prompt engineering - Tool definitions and invocations - Sampling parameters - Logging and diagnostics This project is licensed under the MIT License Contributions are welcome! Please see our Contributing Guide for more information.
README
Показан фрагмент оригинального README. Открыть оригинал.
MCP4Go
MCP4Go is a Go implementation of the Model Context Protocol (MCP), designed to simplify the development of AI applications by abstracting away protocol complexities.
Features
- Complete MCP protocol implementation in pure Go
- High-level abstractions for common MCP resources
- Pluggable architecture for custom extensions
- Comprehensive documentation and examples
- Production-ready with robust error handling
Installation
MCP4Go requires Go 1.18 or later. Install it using Go modules:
go get github.com/mcp4go/mcp4go
Getting Started
To get started with MCP4Go, import the package in your Go application:
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/mcp4go/mcp4go/pkg/logger"
"github.com/mcp4go/mcp4go/protocol"
"github.com/mcp4go/mcp4go/server"
"github.com/mcp4go/mcp4go/server/iface"
"github.com/mcp4go/mcp4go/server/transport"
_ "time/tzdata" // Load all time zones
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_logger := logger.DefaultLog
// Listen for interrupt signals for graceful exit
signalCh := make(chan os.Signal, 1)
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)
go func() {
<-signalCh
_logger.Logf(ctx, logger.LevelWarn, "Received shutdown signal")
cancel()
}()
type timeRequest struct {
TimeZone string `json:"time_zone,omitempty" description:"time zone default is Asia/Shanghai"`
}
// Create standard input/output transport layer
stdioTransport := transport.NewStdioTransport()
// Create MCP server and configure options
Установка
This server does not publish a one-line install command.
Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →