forge

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMCPServer

func CreateMCPServer(appConfig *AppConfig, version string) (*server.MCPServer, error)

CreateMCPServer creates and configures an MCP server with all tools registered

func ExecuteREST

func ExecuteREST(ctx context.Context, baseURL, method, path string, headers map[string]string, queryParams map[string]string, body []byte, contentType string, token string, isDebug bool) ([]byte, error)

ExecuteREST performs an HTTP request and returns the response body

func RegisterTools

func RegisterTools(srv *server.MCPServer, cfg *ForgeConfig, configDir string, isDebug bool) error

RegisterTools discovers and registers all tools from the config directory

func Serve

func Serve(srv *server.MCPServer, opts ServeOptions) error

Serve starts the MCP server in either HTTP or stdio mode

Types

type AppConfig

type AppConfig struct {
	ConfigDir string
	IsDebug   bool
	Config    *ForgeConfig
}

AppConfig holds the parsed application configuration

func LoadAppConfig

func LoadAppConfig(forgeConfigFlag string, debugEnabled bool) (*AppConfig, error)

LoadAppConfig loads and validates the application configuration

type BodyConfig

type BodyConfig struct {
	ContentType string `yaml:"content_type"`
	Template    string `yaml:"template"`
}

BodyConfig defines the body for the REST request

type CtxAuthKey

type CtxAuthKey struct{}

CtxAuthKey is used as a key for storing auth tokens in context

type ForgeConfig

type ForgeConfig struct {
	Name           string            `yaml:"name"`
	BaseURL        string            `yaml:"base_url"`
	Headers        map[string]string `yaml:"headers,omitempty"`
	TokenCommand   string            `yaml:"token_command"`
	Env            map[string]string `yaml:"env,omitempty"`
	EnvPassthrough bool              `yaml:"env_passthrough,omitempty"`
}

ForgeConfig holds global server settings

func LoadForgeConfig

func LoadForgeConfig(path string) (*ForgeConfig, error)

LoadForgeConfig loads ForgeConfig from the given file path

type HTTPStatusError

type HTTPStatusError struct {
	StatusCode int
	Status     string
	Body       string
}

HTTPStatusError is returned when the upstream REST API responds with a non-2xx status.

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

type InputConfig

type InputConfig struct {
	Name        string `yaml:"name"`
	Type        string `yaml:"type"` // "string" or "number"
	Description string `yaml:"description"`
	Required    bool   `yaml:"required"`
}

InputConfig defines an input parameter for the tool

type QueryParam

type QueryParam struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

QueryParam defines a query parameter for the REST request

type ServeOptions

type ServeOptions struct {
	HTTPAddr string
	IsDebug  bool
}

ServeOptions holds options for serving the MCP server

type ToolAnnotations

type ToolAnnotations struct {
	Title           string `yaml:"title,omitempty"`
	ReadOnlyHint    *bool  `yaml:"readOnlyHint,omitempty"`
	DestructiveHint *bool  `yaml:"destructiveHint,omitempty"`
	IdempotentHint  *bool  `yaml:"idempotentHint,omitempty"`
	OpenWorldHint   *bool  `yaml:"openWorldHint,omitempty"`
}

ToolAnnotations defines the annotations for a tool

type ToolConfig

type ToolConfig struct {
	Name        string            `yaml:"name"`
	Description string            `yaml:"description"`
	Method      string            `yaml:"method"`
	Path        string            `yaml:"path"`
	Headers     map[string]string `yaml:"headers,omitempty"`
	QueryParams []QueryParam      `yaml:"query_params,omitempty"`
	Body        *BodyConfig       `yaml:"body,omitempty"`
	Inputs      []InputConfig     `yaml:"inputs"`
	Annotations ToolAnnotations   `yaml:"annotations,omitempty"`
	Output      string            `yaml:"output,omitempty"` // "raw" (default), "json", or "toon"
}

ToolConfig holds one tool's YAML definition

func LoadToolConfig

func LoadToolConfig(path string) (*ToolConfig, error)

LoadToolConfig loads ToolConfig from the given file path

Jump to

Keyboard shortcuts

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