MM

mcp4go/mcp4go

Deployment & DevOps

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

5 stars 2 forks 品質 43 トレンド 13MIT

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
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →