gollem

MCP.Pizza Chef: m-mizutani

gollem is a Go-based client framework designed for building agentic AI applications using the Model Context Protocol (MCP). It provides a common interface to query prompts to various Large Language Model (LLM) services and includes built-in tools to facilitate complex AI workflows. gollem enables developers to create sophisticated AI agents that interact with their environment in real-time, leveraging MCP's modular architecture for seamless integration and extensibility.

Use This MCP client To

Build agentic AI applications with Go and MCP Query multiple LLM services through a unified interface Develop AI agents that interact with real-time context Integrate built-in tools for enhanced AI workflows Create modular AI systems with extensible components Implement multi-step reasoning in AI applications Manage context flow and tool calling in AI agents

README

🤖 gollem Go Reference Test Lint Gosec Trivy

GO for Large LanguagE Model (GOLLEM)

gollem provides:

  • Common interface to query prompt to Large Language Model (LLM) services
  • Framework for building agentic applications of LLMs with
    • Tools by MCP (Model Context Protocol) server and your built-in tools
    • Portable conversational memory with history for stateless/distributed applications

Supported LLMs

Quick Start

Install

go get github.com/m-mizutani/gollem

Example

Query to LLM

llmProvider := os.Args[1]
model := os.Args[2]
prompt := os.Args[3]

var client gollem.LLMClient
var err error

switch llmProvider {
case "gemini":
	client, err = gemini.New(ctx, os.Getenv("GEMINI_PROJECT_ID"), os.Getenv("GEMINI_LOCATION"), gemini.WithModel(model))
case "claude":
	client, err = claude.New(ctx, os.Getenv("ANTHROPIC_API_KEY"), claude.WithModel(model))
case "openai":
	client, err = openai.New(ctx, os.Getenv("OPENAI_API_KEY"), openai.WithModel(model))
}

if err != nil {
	panic(err)
}

ssn, err := client.NewSession(ctx)
if err != nil {
	panic(err)
}

result, err := ssn.GenerateContent(ctx, gollem.Text(prompt))
if err != nil {
	panic(err)
}

fmt.Println(result.Texts)

Agentic application with MCP server

Here's a simple example of creating a custom tool and using it with an LLM:

func main() {
	ctx := context.Background()

	// Create OpenAI client
	client, err := OpenAI.New(ctx, os.Getenv("OPENAI_API_KEY"))
	if err != nil {
		panic(err)
	}

	// Create MCP client with local server
	mcpLocal, err := mcp.NewStdio(ctx, "/path/to/mcp-server", []string{}, mcp.WithEnvVars([]string{"MCP_ENV=test"}))
	if err != nil {
		panic(err)
	}
	defer mcpLocal.Close()

	// Create MCP client with remote server
	mcpRemote, err := mcp.NewSSE(ctx, "http://localhost:8080")
	if err != nil {
		panic(err)
	}
	defer mcpRemote.Close()

	// Create gollem instance
	agent := gollem.New(client,
		gollem.WithToolSets(mcpLocal, mcpRemote),
		gollem.WithTools(&MyTool{}),
		gollem.WithMessageHook(func(ctx context.Context, msg string) error {
			fmt.Printf("🤖 %s\n", msg)
			return nil
		}),
	)

	var history *gollem.History
	for {
		fmt.Print("> ")
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()

		newHistory, err := agent.Prompt(ctx, scanner.Text(), history)
		if err != nil {
			panic(err)
		}
		history = newHistory
	}
}

See the full example in examples/basic, and more examples in examples.

Documentation

For more details and examples, visit our document and godoc.

License

Apache 2.0 License. See LICENSE for details.

gollem FAQ

How does gollem simplify querying multiple LLM services?
gollem provides a common interface that abstracts different LLM APIs, allowing seamless querying across providers like OpenAI, Claude, and Gemini.
Can gollem be used to build complex AI agents?
Yes, gollem is designed as a framework to build agentic AI applications that can manage context, tools, and multi-step reasoning.
What programming language is gollem built with?
gollem is built entirely in Go, making it suitable for Go developers building AI applications.
Does gollem support integration with MCP servers?
Yes, gollem acts as an MCP client that can interact with various MCP servers to access structured data and tools.
Are there built-in tools included in gollem?
Yes, gollem includes built-in tools to facilitate common AI workflows and extend agent capabilities.
Is gollem suitable for real-time AI workflows?
Absolutely, gollem supports real-time context management and interaction for dynamic AI applications.
How does gollem handle multi-step reasoning?
gollem manages context flow and tool calling to enable complex, multi-step reasoning within AI agents.
Where can I find gollem's source code and documentation?
gollem is open source and available on GitHub with comprehensive documentation and examples.