GM

gomcpgo/mcp

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

4 stars 1 forks 품질 58 트렌드 9

Model Context Protocol (MCP) 서버 구축을 위한 이동 프레임 워크는 대용량 모델(LLMs)을 사용하여 도구 및 데이터 소스에 안전하게 액세스할 수 있습니다.

개요

Model Context Protocol (MCP) 서버 구축을 위한 이동 프레임 워크는 대용량 모델(LLMs)을 사용하여 도구 및 데이터 소스에 안전하게 액세스할 수 있습니다. MCP 서버를 만드는 최소 예입니다. 프레임 워크는 세 가지 유형의 핸들러를 지원합니다. LLMs가 실행할 수 있는 도구 구현: 모든 핸들러 유형을 보여주는 더 완벽한 예입니다: Claude Desktop을 사용하여 MCP 서버를 사용하려면 claude desktop config.json에 추가하십시오. 구성 파일의 위치: - MacOS: ~/Library/Application Support/Claude/claude desktop config.json - Windows: %APPDATA%\Claude\claude desktop config.json 프레임 워크는 MCP 서버를 테스트하기위한 유틸리티가 포함되어 있습니다. 다음은 예입니다:

개요(AI 번역)

Model Context Protocol (MCP) 서버 구축을 위한 이동 프레임 워크는 대용량 모델(LLMs)을 사용하여 도구 및 데이터 소스에 안전하게 액세스할 수 있습니다.

설치

빠른 시작

MCP 서버를 만드는 최소 예입니다.

핸들러 유형

프레임 워크는 세 가지 유형의 핸들러를 지원합니다.

# # 1 도구 핸들러

LLMs가 실행할 수 있는 도구 구현:

##2. 자원 핸들러

LLMs가 읽을 수 있는 exposing 자료:

##3. 신속한 핸들러

신속한 템플릿 제공:

완전한 예

모든 핸들러 유형을 보여주는 더 완벽한 예입니다:

Claude 데스크탑 사용

Claude Desktop을 사용하여 MCP 서버를 사용하려면 claude_desktop_config.json]에 추가하십시오.

구성 파일의 위치:

  • 맥 OS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • 윈도우: %APPDATA%\Claude\claude_desktop_config.json

테스트

프레임 워크는 MCP 서버를 테스트하기위한 유틸리티가 포함되어 있습니다. 다음은 예입니다:

모범 사례

  1. 처리
  • 적절한 오류 유형 사용
  • 의미있는 오류 메시지 제공
  • 모든 오류 사례 처리
  1. ** 구성 **
  • 민감한 데이터에 대한 환경 변수 사용
  • 파일 경로 설정

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

Go MCP Framework

A Go framework for building Model Context Protocol (MCP) servers that enable Large Language Models (LLMs) to securely access tools and data sources.

Installation

go get github.com/gomcpgo/mcp

Quick Start

Here’s a minimal example of creating an MCP server:

package main

import (
    "context"
    "log"

    "github.com/gomcpgo/mcp/pkg/handler"
    "github.com/gomcpgo/mcp/pkg/server"
    "github.com/gomcpgo/mcp/pkg/protocol"
)

func main() {
    // Create handler registry
    registry := handler.NewHandlerRegistry()

    // Register your tool handler
    registry.RegisterToolHandler(&MyToolHandler{})

    // Create and start server
    srv := server.New(server.Options{
        Name:     "my-server",
        Version:  "1.0.0",
        Registry: registry,
    })

    if err := srv.Run(); err != nil {
        log.Fatal(err)
    }
}

// MyToolHandler implements the ToolHandler interface
type MyToolHandler struct{}

func (h *MyToolHandler) ListTools(ctx context.Context) (*protocol.ListToolsResponse, error) {
    return &protocol.ListToolsResponse{
        Tools: []protocol.Tool{
            {
                Name:        "my-tool",
                Description: "Description of my tool",
                InputSchema: json.RawMessage(`{
                    "type": "object",
                    "properties": {
                        "param1": {
                            "type": "string",
                            "description": "Description of param1"
                        }
                    },
                    "required": ["param1"]
                }`),
            },
        },
    }, nil
}

func (h *MyToolHandler) CallTool(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResponse, error) {
    // Handle tool execution
    result := "Tool execution result"
    
    return &protocol.CallToolResponse{
        Content: []protocol.ToolContent{
            {
                Type: "text",
                Text: result,
            },
        },
    }, nil
}

Handler Types

The framework supports three types of handlers:

1. Tool Handler

For implementing tools that LLMs can execute:

type ToolHandler interface {
    ListTools(ctx context.Context) (*ListToolsResponse, error)
    CallTool(ctx context.Context, req *CallToolRequest) (*CallToolResponse, error)
}

2. Resource Handler

For exposing data that LLMs can read:

type ResourceHandler interface {
    ListResources(ctx context.Context) (*ListResourcesResponse, error)
    ReadResource(ctx context.Context, req *ReadResourceRequest) (*ReadResourceResponse, error)
}

3. Prompt Handler

For providing prompt templates:

type PromptHandler interface {
    ListPrompts(ctx context.Context) (*ListPromptsResponse, error)
    GetPrompt(ctx context.Context, req *GetPromptRequest) (*GetPromptResponse, error)
}

Complete Example

Here’s a more complete example showing all handler types:

GitHub에서 전체 README 보기

설치

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

Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →

설정

{ "mcpServers": { "my-server": { "command": "path/to/your/server", "args": ["arg1", "arg2"] } } }