holon

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

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 27 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 Docs Go Reference Go Apache 2.0 License Discord

This repository contains the Go runtime for holon.

Install

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

Invoking MCP Servers

Declare dependencies under sh.holon.requires in a server.json beside the server, here the public Hugging Face MCP server:

{
  "name": "com.example/foo",
  "version": "0.1.0",
  "description": "Example Foo",
  "_meta": {
    "io.modelcontextprotocol.registry/publisher-provided": {
      "sh.holon": {
        "requires": {
          "huggingface": { "url": "https://huggingface.co/mcp" }
        }
      }
    }
  }
}
Type-checking MCP invocations
holon types generate
go test ./...

A wrong tool name or argument is a type error:

import apps "example.com/foo/holon"

query, limit := "llama", "3"

apps.Huggingface.HubRepoSearch(ctx, apps.HuggingfaceHubRepoSearchInput{Query: &query})

apps.Huggingface.HubRepoSearch(ctx, apps.HuggingfaceHubRepoSearchInput{Limit: &limit})
// cannot use &limit (value of type *string) as *"encoding/json".Number value in struct literal

apps.Huggingface.HubSearch(ctx, apps.HuggingfaceHubRepoSearchInput{Query: &query})
// apps.Huggingface.HubSearch undefined (type "example.com/foo/holon"._Huggingface has no field or method HubSearch)

Community

Ask questions and share what you're building on the Holon Discord.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotBound = errors.New("not bound")

Functions

func ActAs

func ActAs(ctx context.Context, subject string, opts ...ActAsOption) context.Context

ActAs returns a context in which calls to other apps are made for subject, a person's principal subject, the subject of RFC 8693 §2.1.

func Call

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

func Connect

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

func Serve

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

Serve serves server at /mcp and /mcp/<app> on HOST and PORT, 127.0.0.1:3000 unless they are set, until ctx ends or the process receives SIGTERM, after which requests in flight finish.

Types

type ActAsOption

type ActAsOption func(*acting)

func WithActor

func WithActor(app string) ActAsOption

WithActor names app, when it is not this app, as the one acting for the subject, the actor of RFC 8693 §2.1.

type Answered

type Answered struct{ Result *mcp.CallToolResult }

type Caller

type Caller struct {
	App     string `json:"app"`
	Session string `json:"session"`
}

Caller is the app of the same session that made a request. A lifecycle hook's job calls as its app.

type CancelledTask

type CancelledTask struct{ Task }

type CompletedTask

type CompletedTask struct {
	Task
	Result *mcp.CallToolResult `json:"result"`
}

type ConnectOption

type ConnectOption func(*connecting)

func WithTransport

func WithTransport(wrap func(http.RoundTripper) http.RoundTripper) ConnectOption

type DetailedTask

type DetailedTask interface {
	// contains filtered or unexported methods
}

https://tasks.extensions.modelcontextprotocol.io/specification/2026-07-28/tasks#task-status

type ElicitHandler

type ElicitHandler func(context.Context, *mcp.ElicitParams) (*mcp.ElicitResult, error)

ElicitHandler answers a server's question during one tool call.

type FailedTask

type FailedTask struct {
	Task
	Error *jsonrpc.Error `json:"error"`
}

type InputRequiredTask

type InputRequiredTask struct {
	Task
	InputRequests mcp.InputRequestMap `json:"inputRequests"`
}

type Option

type Option func(*options)

Option configures Serve.

func WithFrontend

func WithFrontend(dir string) Option

WithFrontend serves dir, such as a built view, as the application's page: its files answer every GET and HEAD outside the MCP endpoint. A relative dir is resolved against the working directory.

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"`
	Caller    *Caller    `json:"caller"`
}

func Context

func Context(ctx context.Context) RequestContext

type Started

type Started interface {
	// contains filtered or unexported methods
}

https://tasks.extensions.modelcontextprotocol.io/specification/2026-07-28/tasks#polymorphic-results

type Task

type Task struct {
	ID             TaskID     `json:"taskId"`
	Status         TaskStatus `json:"status"`
	StatusMessage  string     `json:"statusMessage,omitempty"`
	CreatedAt      string     `json:"createdAt"`
	LastUpdatedAt  string     `json:"lastUpdatedAt"`
	TTLMs          *int64     `json:"ttlMs"`
	PollIntervalMs *int64     `json:"pollIntervalMs,omitempty"`
}

https://tasks.extensions.modelcontextprotocol.io/specification/2026-07-28/tasks#tasks-1

type TaskID

type TaskID string

type TaskStatus

type TaskStatus string

https://tasks.extensions.modelcontextprotocol.io/specification/2026-07-28/tasks#task-status

const (
	TaskWorking       TaskStatus = "working"
	TaskInputRequired TaskStatus = "input_required"
	TaskCompleted     TaskStatus = "completed"
	TaskFailed        TaskStatus = "failed"
	TaskCancelled     TaskStatus = "cancelled"
)

type ToolCall

type ToolCall struct {
	App       string `json:"app"`
	Name      string `json:"name"`
	Arguments any    `json:"arguments"`
}

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
}

type WorkingTask

type WorkingTask struct{ Task }

Jump to

Keyboard shortcuts

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