
i2y/langchaingo-mcp-adapter
Developer tools이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
모델 Context Protocol (MCP) 서버와 LangChain Go 도구가 있는 Go 어댑터입니다.
개요
모델 Context Protocol (MCP) 서버와 LangChain Go 도구가 있는 Go 어댑터입니다. 이 어댑터는 MCP 서버에서 LangChain Go 라이브러리로 정의된 도구를 사용할 수 있습니다. 필요한 인터페이스를 구현하여 MCP 툴을 LangChain Go의 에이전트 인프라와 원활하게 통합합니다. - MCP 서버에 연결 - 지정된 MCP 서버에서 MCP 도구를 자동으로 발견하고 LangChain Go - LangChain Go 도구로 MCP 도구를 랩 할 수 있습니다 완전한 예제를 위한 예제 디렉토리를 참조: - 예 / 시약 : 다양한 LLM 제공 업체 (Google AI, OpenAI, Anthropic)와 어댑터를 사용하는 방법을 민주화합니다. 예 / 서버 : URL fetching 도구를 제공하는 최소 MCP 서버 예 예제 에이전트는 여러 LLM 공급자를 지원합니다. - : GOOGLE API KEY - : Set OPENAI API KEY - : Set ANTHROPIC API KEY 예제는 Windows, macOS 및 Linux에서 교차 플랫폼 및 작동입니다. 예제는 자동으로 소스에서 MCP 서버를 구축하고 실행합니다.
개요(AI 번역)
모델 Context Protocol (MCP) 서버와 LangChain Go 도구가 있는 Go 어댑터입니다.
개요
이 어댑터는 MCP 서버에서 LangChain Go 라이브러리로 정의된 도구를 사용할 수 있습니다. 필요한 인터페이스를 구현하여 MCP 툴을 LangChain Go의 에이전트 인프라와 원활하게 통합합니다.
특징
- 모든 MCP 서버에 연결
- 지정된 MCP 서버에서 MCP 도구를 자동으로 발견하고 LangChain Go에 사용할 수 있습니다.
- LangChain Go 도구로 MCP 도구를 랩
설치
사용법
예제 응용 프로그램
example] 전체 예제의 디렉토리를 참조:
example/agent: 다양한 LLM 제공 업체와 어댑터를 사용하는 방법 (Google AI, OpenAI, Anthropic)example/server: URL fetching 도구를 제공하는 최소 MCP 서버 예
예 에이전트는 여러 LLM 공급자를 지원합니다.
- Google AI (Gemini): 설정
GOOGLE_API_KEY-OpenAI: 설정OPENAI_API_KEY - **Anthropic (Claude) ** :
ANTHROPIC_API_KEY설정
예제는 Windows, macOS 및 Linux에서 교차 플랫폼 및 작동입니다. 예제는 자동으로 소스에서 MCP 서버를 구축하고 실행합니다. 상세한 설정 지침에 대한 예제 README를 참조하십시오.
이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.
README
원문 README의 일부입니다. 원문 보기.
LangChainGo MCP Adapter
A Go adapter that bridges LangChain Go tools with Model Context Protocol (MCP) servers.
Overview
This adapter allows you to use tools defined on an MCP server with the LangChain Go library. It implements the necessary interfaces to integrate MCP tools seamlessly with LangChain Go’s agent infrastructure.
Features
- Connect to any MCP server
- Automatically discover MCP tools from a specified MCP server and make them available to LangChain Go
- Wrap MCP tools as LangChain Go tools
Installation
go get github.com/i2y/langchaingo-mcp-adapter
Usage
package main
import (
"context"
"log"
"os"
"github.com/i2y/langchaingo-mcp-adapter"
"github.com/mark3labs/mcp-go/client"
"github.com/tmc/langchaingo/agents"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/llms/googleai"
"github.com/tmc/langchaingo/tools"
)
func main() {
// Create an MCP client using stdio
mcpClient, err := client.NewStdioMCPClient(
"./an-mcp-server", // Path to an MCP server executable
nil, // Additional environment variables if needed
)
if err != nil {
log.Fatalf("Failed to create MCP client: %v", err)
}
defer mcpClient.Close()
// Create the adapter
adapter, err := langchaingo_mcp_adapter.New(mcpClient)
if err != nil {
log.Fatalf("Failed to create adapter: %v", err)
}
// Get all tools from MCP server
mcpTools, err := adapter.Tools()
if err != nil {
log.Fatalf("Failed to get tools: %v", err)
}
ctx := context.Background()
// Create a Google AI LLM client
llm, err := googleai.New(
ctx,
googleai.WithDefaultModel("gemini-2.0-flash"),
googleai.WithAPIKey(os.Getenv("GOOGLE_API_KEY")),
)
if err != nil {
log.Fatalf("Create Google AI client: %v", err)
}
// Create a agent with the tools
agent := agents.NewOneShotAgent(
llm,
mcpTools,
agents.WithMaxIterations(3),
)
executor := agents.NewExecutor(agent)
// Use the agent
question := "Can you help me analyze this data using the available tools?"
result, err := chains.Run(
ctx,
executor,
question,
)
if err != nil {
log.Fatalf("Agent execution error: %v", err)
}
log.Printf("Agent result: %s", result)
}
Example Applications
See the example directory for complete examples:
example/agent: Demonstrates how to use the adapter with various LLM providers (Google AI, OpenAI, Anthropic)example/server: A minimal MCP server example that provides a URL fetching tool
The example agent supports multiple LLM providers:
- Google AI (Gemini): Set
GOOGLE_API_KEY - OpenAI: Set
OPENAI_API_KEY - Anthropic (Claude): Set
ANTHROPIC_API_KEY
설치
This server does not publish a one-line install command.
Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →