langchaingo-mcp-adapters
langchaingo-mcp-adapters is an adapter built in Go that facilitates integration with the LangChain framework. This allows developers to create automated workflows and connect with various data sources and APIs seamlessly. It is particularly rich in features aimed at optimizing data retrieval and processing, making it a valuable tool for developers looking to streamline their applications.
GitHub Stars
4
User Rating
Not Rated
Favorites
0
Views
17
Forks
0
Issues
8
LangchainGo MCP Adapters
This library provides a lightweight wrapper that makes Model Context Protocol (MCP) tools compatible with LangchainGo.
Features
- 🛠️ Convert MCP tools into LangchainGo tools that can be used with LangchainGo agents.
- 📦 A client implementation (
MultiServerMCPClient) that allows you to connect to multiple MCP servers (via stdio or SSE) and load tools from them.
References: The MCP adapters of Python implementation and TypeScript implementation.
Installation
go get github.com/akihiro-fukuchi/langchaingo-mcp-adapters
You will also need to install the underlying MCP Go SDK and LangchainGo:
go get github.com/mark3labs/mcp-go
go get github.com/tmc/langchaingo
Quickstart
Here is a simple example of using MCP tools with a LangchainGo agent.
Server
First, let's build an example MCP server that can add and multiply numbers.
Build the server: go build -o math-server examples/math-server/main.go
Client
Now, use the MultiServerMCPClient to connect to the server and use its tools with a LangchainGo agent.
Run the client: go run examples/agent/main.go
Note: OPENAI_API_KEY is required to run the agent. It is expect to be set as an environment variable.
Multiple MCP Servers
The MultiServerMCPClient is designed to handle connections to multiple servers simultaneously. Simply add more entries to the connections map during initialization, specifying either StdioConnection or SSEConnection for each server.
// Example with Math (stdio) and Weather (sse) servers
connections := map[string]mcpclient.ConnectionConfig{
"math": mcpclient.StdioConnection{
Transport: "stdio",
Command: "/path/to/your/go/math-server", // Absolute path
Args: []string{},
},
"weather": mcpclient.SSEConnection{
Transport: "sse",
URL: "http://localhost:8081/sse", // URL of your Go weather server SSE endpoint
},
}
client := mcpclient.NewMultiServerMCPClient(connections, mcp.Implementation{}, mcp.ClientCapabilities{})
// ... start client, get tools, run agent ...
The client.GetTools() method will return a combined list of tools from all successfully connected and initialized servers.
0
Followers
0
Repositories
0
Gists
0
Total Contributions