MCP cover image
See in Github
2025-05-28

GO-MCP est une version GO (Golang) puissante du SDK MCP qui implémente le protocole de contexte du modèle (MCP) pour faciliter la communication transparente entre les systèmes externes et les applications d'IA.

8

Github Watches

45

Github Forks

306

Github Stars

Go-MCP

go-mcp docs/images/img_2.png

Release Stars Forks Issues Pull Requests License Contributors Last Commit

Go Reference Go Report Go Tests

中文文档

🚀 Overview

Go-MCP is a powerful Go version of the MCP SDK that implements the Model Context Protocol (MCP) to facilitate seamless communication between external systems and AI applications. Based on the strong typing and performance advantages of the Go language, it provides a concise and idiomatic API to facilitate your integration of external systems into AI applications.

✨ Key Features

  • 🔄 Complete Protocol Implementation: Full implementation of the MCP specification, ensuring seamless integration with all compatible services
  • 🏗️ Elegant Architecture Design: Adopts a clear three-layer architecture, supports bidirectional communication, ensuring code modularity and extensibility
  • 🔌 Seamless Integration with Web Frameworks: Provides MCP protocol-compliant http.Handler, allowing developers to integrate MCP into their service frameworks
  • 🛡️ Type Safety: Leverages Go's strong type system for clear, highly maintainable code
  • 📦 Simple Deployment: Benefits from Go's static compilation, eliminating complex dependency management
  • High-Performance Design: Fully utilizes Go's concurrency capabilities, maintaining excellent performance and low resource overhead across various scenarios

🛠️ Installation

go get github.com/ThinkInAIXYZ/go-mcp

Requires Go 1.18 or higher.

🎯 Quick Start

Client Example

package main

import (
	"context"
	"log"

	"github.com/ThinkInAIXYZ/go-mcp/client"
	"github.com/ThinkInAIXYZ/go-mcp/transport"
)

func main() {
	// Create SSE transport client
	transportClient, err := transport.NewSSEClientTransport("http://127.0.0.1:8080/sse")
	if err != nil {
		log.Fatalf("Failed to create transport client: %v", err)
	}

	// Initialize MCP client
	mcpClient, err := client.NewClient(transportClient)
	if err != nil {
		log.Fatalf("Failed to create MCP client: %v", err)
	}
	defer mcpClient.Close()

	// Get available tools
	tools, err := mcpClient.ListTools(context.Background())
	if err != nil {
		log.Fatalf("Failed to list tools: %v", err)
	}
	log.Printf("Available tools: %+v", tools)
}

Server Example

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/ThinkInAIXYZ/go-mcp/protocol"
	"github.com/ThinkInAIXYZ/go-mcp/server"
	"github.com/ThinkInAIXYZ/go-mcp/transport"
)

type TimeRequest struct {
	Timezone string `json:"timezone" description:"timezone" required:"true"` // Use field tag to describe input schema
}

func main() {
	// Create SSE transport server
	transportServer, err := transport.NewSSEServerTransport("127.0.0.1:8080")
	if err != nil {
		log.Fatalf("Failed to create transport server: %v", err)
	}

	// Initialize MCP server
	mcpServer, err := server.NewServer(transportServer)
	if err != nil {
		log.Fatalf("Failed to create MCP server: %v", err)
	}

	// Register time query tool
	tool, err := protocol.NewTool("current time", "Get current time for specified timezone", TimeRequest{})
	if err != nil {
		log.Fatalf("Failed to create tool: %v", err)
		return
	}
	mcpServer.RegisterTool(tool, handleTimeRequest)

	// Start server
	if err = mcpServer.Run(); err != nil {
		log.Fatalf("Server failed to start: %v", err)
	}
}

func handleTimeRequest(req *protocol.CallToolRequest) (*protocol.CallToolResult, error) {
	var timeReq TimeRequest
	if err := protocol.VerifyAndUnmarshal(req.RawArguments, &timeReq); err != nil {
		return nil, err
	}

	loc, err := time.LoadLocation(timeReq.Timezone)
	if err != nil {
		return nil, fmt.Errorf("invalid timezone: %v", err)
	}

	return &protocol.CallToolResult{
		Content: []protocol.Content{
			protocol.TextContent{
				Type: "text",
				Text: time.Now().In(loc).String(),
			},
		},
	}, nil
}

🏗️ Architecture Design

Go-MCP adopts an elegant three-layer architecture:

Architecture Overview

  1. Transport Layer: Handles underlying communication implementation, supporting multiple transport protocols
  2. Protocol Layer: Handles MCP protocol encoding/decoding and data structure definitions
  3. User Layer: Provides friendly client and server APIs

Currently supported transport methods:

Transport Methods

  • HTTP SSE/POST: HTTP-based server push and client requests, suitable for web scenarios
  • Stdio: Standard input/output stream-based, suitable for local inter-process communication

The transport layer uses a unified interface abstraction, making it simple to add new transport methods (like Streamable HTTP, WebSocket, gRPC) without affecting upper-layer code.

🤝 Contributing

We welcome all forms of contributions! Please see CONTRIBUTING.md for details.

📄 License

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

📞 Contact Us

WeChat QR Code

✨ Contributors

Thanks to all developers who have contributed to this project!

Contributors

📈 Project Trends

Star History

相关推荐

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • Beria Joey
  • 你的职业规划师,不走弯路就问我。Sponsor:小红书“ ItsJoe就出行 ”

  • jae-jae
  • MCP Server pour récupérer le contenu de la page Web à l'aide du navigateur sans tête du dramwright.

  • Mintplex-Labs
  • L'application tout-en-un desktop et Docker AI avec chiffon intégré, agents AI, constructeur d'agent sans code, compatibilité MCP, etc.

  • patruff
  • Pont entre les serveurs Olllama et MCP, permettant aux LLM locaux d'utiliser des outils de protocole de contexte de modèle

  • pontusab
  • La communauté du curseur et de la planche à voile, recherchez des règles et des MCP

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 LLM 资料总结 (数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Résumé des meilleures ressources LLM du monde.

  • n8n-io
  • Plateforme d'automatisation de workflow à code équitable avec des capacités d'IA natives. Combinez le bâtiment visuel avec du code personnalisé, de l'auto-hôte ou du cloud, 400+ intégrations.

  • av
  • Exécutez sans effort LLM Backends, API, Frontends et Services avec une seule commande.

  • appcypher
  • Serveurs MCP géniaux - une liste organisée de serveurs de protocole de contexte de modèle

  • 1Panel-dev
  • 🔥 1Panel fournit une interface Web intuitive et un serveur MCP pour gérer des sites Web, des fichiers, des conteneurs, des bases de données et des LLM sur un serveur Linux.

  • Azure
  • Ce référentiel est pour le développement du serveur MCP Azure, apportant la puissance d'Azure à vos agents.

    Reviews

    3 (1)
    Avatar
    user_M7dyWlqL
    2025-04-17

    I've been using go-mcp by ThinkInAIXYZ and it's fantastic! This application delivers a smooth and efficient performance consistent with MCP principles. It's easy to navigate and integrates seamlessly with my workflow. For anyone considering it, check out the official repository at https://github.com/ThinkInAIXYZ/go-mcp. Highly recommended!