holon

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

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 24 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

This section is empty.

Functions

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) (*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 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 Dependency

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

func (*Dependency) CallTool

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

type ElicitHandler

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

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

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 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