MCP makes Eino more powerful: a practical guide

The deep integration of Eino and MCP protocol creates a new experience of efficient server-side development.
Core content:
1. Analysis of the new architecture of Eino supporting MCP protocol
2. Steps of transforming MCP Server from stdio to sse
3. Practical exercises on using Eino to build Agent and connect to MCP Server
// Only check for "sse" since stdio is the defaultif transport == "sse" { serverUrl := "http://" + serverlisten sseServer := server.NewSSEServer(s, server.WithBaseURL(serverUrl)) log.Printf("SSE server listening on %s", serverlisten) if err := sseServer.Start(serverlisten); err != nil { log.Fatalf("Server error: %v", err) }} else { if err := server.ServeStdio(s); err != nil { log.Fatalf("Server error: %v", err) }}
// Initialize MCP client using SSE
ctx := context.Background ( )
cli, _ := client. NewSSEMCPClient ( "http://localhost:8080/sse" )
cli.Start (ctx )
defer cli. Close ()
// Send init request
initRequest := mcp.InitializeRequest{}
initRequest.Params.ProtocolVersion = mcp.LATEST_PROTOCOL_VERSION
initRequest.Params.ClientInfo = mcp.Implementation{
Name: "current-time" ,
Version: "1.0.0" ,
}
cli.Initialize (ctx, initRequest )
// Query the tools provided by MCP Server
tools, _ := eino_mcp. GetTools (ctx, &eino_mcp.Config{ Cli : cli})
// Bind MCP Tools to Eino
llm, _ := openai. NewChatModel (context. Background (), &openai.ChatModelConfig{
BaseURL : os. Getenv ( "OPENAI_API_URL" ),
Model : os. Getenv ( "MODEL_ID" ),
APIKey : os. Getenv ( "OPENAI_API_KEY" ),
})
agent, _ := react. NewAgent (ctx, &react.AgentConfig{
Model : llm,
ToolsConfig : compose.ToolsNodeConfig{ Tools : tools},
})
run (agent)
First start the mcp server, which listens to port 8080 by default
$ go run tools/mcp-time/main.go --transport sse2025/03/23 18:55:03 SSE server listening on localhost:8080
Run eino mcp demo
$ go run main.go
Welcome to use eino with mcp demo.
Please enter the operation: Beijing current time
The current time in Beijing is 2025-03-23 18 : 56 : 59.061851 + 0800 CST. Please note that this may be an answer based on an assumed date and the actual time will vary.
Please enter the operation: Chicago current time
The current time in Chicago is 23 March 2025 05:57:13 ( CDT ) .
Please input operation: tell me shanghai current time
The current time in Shanghai is 2025-03-23 18 : 57 : 26.192551 + 0800 CST.
Please enter the operation: bye
Welcome to use again, goodbye.
Eino moves really fast. It took only a few weeks from the time community users proposed the MCP requirement to its final implementation. The main point is to listen to advice.
After Eino has converted the Tools of the remote MCP Server into its own available ToolNode for unified orchestration capabilities, when building intelligent entities in the cloud, it can consider unified management of some reusable public capabilities through the MCP Server, without the need for each Eino Agent to actually implement them. With the MCP Server, it is more convenient for the openness and fine-grained management of data in various departments of the enterprise.