holon

package module
v0.0.1-dev.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Holon Go SDK

CI Go Reference Go Apache 2.0 License

This repository contains the Go runtime for holon.

Install

go get github.com/holon-sh/sdk-go@latest

Invoking MCP Servers

The Holon Go SDK allows generation of type-safe MCP clients. See Example for an explanation, or Dependencies to understand dependency resolution.

Type-checking MCP invocations
holon types generate
go test ./...

Clients are generated into the project's holon/ package.

Call a tool

import apps "example.com/foo/holon"

func greet(ctx context.Context, name string) (string, error) {
	greeting, err := apps.Bar.Greet(ctx, apps.BarGreetInput{Name: name})
	if err != nil {
		return "", err
	}
	return greeting.Result, nil
}

Arguments are validated before sending; the result is validated against the output schema and returned.

Handle errors

var failure *holon.ToolCallError
if errors.As(err, &failure) {
	failure.Code   // "tool_error" or "input_required"
	failure.Result // the original MCP result
}

Read the whole result

CallTool returns the full MCP result instead of an error:

result, err := apps.Bar.CallTool(ctx, &mcp.CallToolParams{
	Name:      "greet",
	Arguments: apps.BarGreetInput{Name: "world"},
})

Serve under Holon

Register typed tools with the official MCP Go SDK and pass the server to holon.Serve. Run the executable under Holon's host, which supplies HOLON_HOST_URL.

server := mcp.NewServer(&mcp.Implementation{Name: "foo", Version: "1.0.0"}, nil)
err := holon.Serve(ctx, server)

Inside a tool handler, holon.Context(ctx).Principal is the admitted caller, or nil for anonymous requests. holon.Connect(ctx, "bar") opens an MCP client session to a declared dependency for the current request.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call[Output any](ctx context.Context, dependency *Dependency, name string, input any) (Output, error)

func Connect

func Connect(ctx context.Context, name string) (*mcp.ClientSession, error)

func Serve

func Serve(ctx context.Context, server *mcp.Server) error

Types

type Dependency

type Dependency struct {
	Name  string
	Tools map[string]ToolSchema
}

func (*Dependency) CallTool

func (d *Dependency) CallTool(ctx context.Context, params *mcp.CallToolParams) (*mcp.CallToolResult, error)

type Principal

type Principal struct {
	Issuer   string                     `json:"issuer"`
	Subject  string                     `json:"subject"`
	ClientID string                     `json:"clientId"`
	Scopes   []string                   `json:"scopes"`
	Claims   map[string]json.RawMessage `json:"claims"`
	Actor    json.RawMessage            `json:"actor,omitempty"`
}

type RequestContext

type RequestContext struct {
	Principal *Principal `json:"principal"`
}

func Context

func Context(ctx context.Context) RequestContext

type ToolCallError

type ToolCallError struct {
	App    string
	Tool   string
	Code   string
	Result *mcp.CallToolResult
}

func (*ToolCallError) Error

func (e *ToolCallError) Error() string

type ToolSchema

type ToolSchema struct {
	Input, Output string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL