tools

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidInput = "INVALID_INPUT"
	ErrPathNotFound = "PATH_NOT_FOUND"
	ErrAccessDenied = "ACCESS_DENIED"
	ErrFileTooLarge = "FILE_TOO_LARGE"
	ErrIO           = "IO_ERROR"
)

Error code constants for structured error responses. Cross-tool codes

View Source
const (
	ErrBashEmptyCommand = "BASH_EMPTY_COMMAND"
	ErrBashStartFailed  = "BASH_START_FAILED"
	ErrBashTaskLimit    = "BASH_TASK_LIMIT"
	ErrBashTaskNotFound = "BASH_TASK_NOT_FOUND"
)

Bash tool codes

View Source
const (
	ErrStrReplaceNotFound  = "STR_REPLACE_NOT_FOUND"
	ErrStrReplaceAmbiguous = "STR_REPLACE_AMBIGUOUS"
)

Str_replace tool codes

View Source
const (
	ErrGrepInvalidPattern    = "GREP_INVALID_PATTERN"
	ErrGrepInvalidOutputMode = "GREP_INVALID_OUTPUT_MODE"
)

Grep tool codes

View Source
const (
	ErrGlobInvalidPattern = "GLOB_INVALID_PATTERN"
	ErrGlobInvalidType    = "GLOB_INVALID_TYPE"
)

Glob tool codes

View Source
const (
	ErrFileNotViewed = "FILE_NOT_VIEWED"
)

View-before-edit codes

Variables

This section is empty.

Functions

func RegisterAll

func RegisterAll(server *mcp.Server, resolver *pathscope.Resolver, sess *session.Session, cfg Config)

RegisterAll registers all tools with the MCP server.

func ValidateDisableTools

func ValidateDisableTools(names map[string]struct{}, anthropicCompat bool) error

ValidateDisableTools checks that all tool names in the set are valid for the given mode.

Types

type BashArgs

type BashArgs struct {
	Command         string `json:"command" jsonschema:"the shell command to execute"`
	Timeout         int    `json:"timeout,omitempty" jsonschema:"timeout in milliseconds (default 120000, max 600000)"`
	RunInBackground bool   `json:"run_in_background,omitempty" jsonschema:"run command in background, returns a task_id"`
	Description     string `json:"description,omitempty" jsonschema:"optional human-readable description of what this command does"`
}

BashArgs is the input schema for the bash tool.

type Config

type Config struct {
	DisableTools          map[string]struct{}
	MaxFileSize           int64
	DefaultTimeout        int
	Shell                 string
	AnthropicCompat       bool
	BackgroundTaskTimeout int // background task safety-net timeout in seconds (0 = disabled)
	RequireViewBeforeEdit bool

	// RegisterSession is called on first bash/task_output invocation with the
	// SDK session ID. In HTTP mode this registers the Boris session in the
	// SessionRegistry for lifecycle cleanup. Nil in STDIO mode.
	RegisterSession func(sessionID string)
}

Config holds configuration for tool registration.

type CreateFileArgs

type CreateFileArgs struct {
	Path    string `json:"path" jsonschema:"file path to create or overwrite"`
	Content string `json:"content" jsonschema:"file content"`
}

CreateFileArgs is the input schema for the create_file tool.

type EditorCommand

type EditorCommand string

EditorCommand is the command type for the combined str_replace_editor tool.

const (
	EditorCommandView       EditorCommand = "view"
	EditorCommandStrReplace EditorCommand = "str_replace"
	EditorCommandCreate     EditorCommand = "create"
)

type GlobArgs

type GlobArgs struct {
	Pattern string `json:"pattern" jsonschema:"the glob pattern to match files against,required"`
	Path    string `json:"path,omitempty" jsonschema:"the directory to search in (defaults to cwd)"`
	Type    string `json:"type,omitempty" jsonschema:"filter by type: file or directory"`
}

GlobArgs is the input schema for the glob tool (normal MCP mode).

type GlobCompatArgs

type GlobCompatArgs struct {
	Pattern string `json:"pattern" jsonschema:"the glob pattern to match files against,required"`
	Path    string `` /* 307-byte string literal not displayed */
}

GlobCompatArgs is the input schema for the glob tool in --anthropic-compat mode.

type GrepArgs

type GrepArgs struct {
	Pattern         string `json:"pattern" jsonschema:"the regex pattern to search for in file contents,required"`
	Path            string `json:"path,omitempty" jsonschema:"file or directory to search in (defaults to cwd)"`
	Include         string `json:"include,omitempty" jsonschema:"glob pattern to filter files (e.g. '*.js' or '*.{ts,tsx}')"`
	Type            string `json:"type,omitempty" jsonschema:"file type to search (e.g. js, py, go, ts)"`
	OutputMode      string `json:"output_mode,omitempty" jsonschema:"output mode: content, files_with_matches (default), or count"`
	CaseInsensitive bool   `json:"case_insensitive,omitempty" jsonschema:"case-insensitive search"`
	LineNumbers     *bool  `json:"line_numbers,omitempty" jsonschema:"show line numbers in content mode (default true)"`
	Multiline       bool   `json:"multiline,omitempty" jsonschema:"enable multiline mode where . matches newlines"`
	HeadLimit       int    `json:"head_limit,omitempty" jsonschema:"limit output to first N results (0 = unlimited)"`
	Offset          int    `json:"offset,omitempty" jsonschema:"skip first N results before applying head_limit"`
	ContextBefore   *int   `json:"context_before,omitempty" jsonschema:"number of lines to show before each match"`
	ContextAfter    *int   `json:"context_after,omitempty" jsonschema:"number of lines to show after each match"`
	Context         *int   `json:"context,omitempty" jsonschema:"number of lines to show before and after each match"`
}

GrepArgs is the input schema for the grep tool (normal MCP mode).

type GrepCompatArgs

type GrepCompatArgs struct {
	Pattern      string `json:"pattern" jsonschema:"the regex pattern to search for in file contents,required"`
	Path         string `json:"path,omitempty" jsonschema:"file or directory to search in (defaults to cwd)"`
	Glob         string `json:"glob,omitempty" jsonschema:"glob pattern to filter files (e.g. '*.js' or '*.{ts,tsx}')"`
	Type         string `json:"type,omitempty" jsonschema:"file type to search (e.g. js, py, go, ts)"`
	OutputMode   string `json:"output_mode,omitempty" jsonschema:"output mode: content, files_with_matches (default), or count"`
	I            bool   `json:"-i,omitempty" jsonschema:"case-insensitive search"`
	N            *bool  `json:"-n,omitempty" jsonschema:"show line numbers in content mode (default true)"`
	Multiline    bool   `json:"multiline,omitempty" jsonschema:"enable multiline mode where . matches newlines"`
	HeadLimit    int    `json:"head_limit,omitempty" jsonschema:"limit output to first N results (0 = unlimited)"`
	Offset       int    `json:"offset,omitempty" jsonschema:"skip first N results before applying head_limit"`
	B            *int   `json:"-B,omitempty" jsonschema:"number of lines to show before each match"`
	A            *int   `json:"-A,omitempty" jsonschema:"number of lines to show after each match"`
	C            *int   `json:"-C,omitempty" jsonschema:"number of lines to show before and after each match"`
	ContextAlias *int   `json:"context,omitempty" jsonschema:"alias for -C"`
}

GrepCompatArgs is the input schema for the grep tool in --anthropic-compat mode.

type StrReplaceArgs

type StrReplaceArgs struct {
	Path       string `json:"path" jsonschema:"file path"`
	OldStr     string `json:"old_str" jsonschema:"the string to find (must be unique unless replace_all is true)"`
	NewStr     string `json:"new_str,omitempty" jsonschema:"replacement string (empty or omitted to delete)"`
	ReplaceAll bool   `json:"replace_all,omitempty" jsonschema:"replace all occurrences instead of requiring a unique match"`
}

StrReplaceArgs is the input schema for the str_replace tool.

type StrReplaceEditorArgs

type StrReplaceEditorArgs struct {
	Command    EditorCommand `json:"command" jsonschema:"the operation to perform: view, str_replace, or create"`
	Path       string        `json:"path" jsonschema:"file path"`
	ViewRange  ViewRange     `json:"view_range,omitempty" jsonschema:"optional line range [start end] (1-indexed, for view command)"`
	OldStr     string        `json:"old_str,omitempty" jsonschema:"the string to find (for str_replace command)"`
	NewStr     string        `json:"new_str,omitempty" jsonschema:"replacement string (for str_replace command)"`
	ReplaceAll bool          `json:"replace_all,omitempty" jsonschema:"replace all occurrences (for str_replace command)"`
	FileText   string        `json:"file_text,omitempty" jsonschema:"file content (for create command)"`
}

StrReplaceEditorArgs is the input schema for the combined str_replace_editor tool.

type TaskOutputArgs

type TaskOutputArgs struct {
	TaskID string `json:"task_id" jsonschema:"the task ID returned by a background bash command"`
}

TaskOutputArgs is the input schema for the task_output tool.

type ViewArgs

type ViewArgs struct {
	Path      string    `json:"path" jsonschema:"file or directory path to view"`
	ViewRange ViewRange `json:"view_range,omitempty" jsonschema:"optional line range [start end] (1-indexed)"`
}

ViewArgs is the input schema for the view tool.

type ViewRange

type ViewRange []int

ViewRange is a custom type for view_range so that the JSON schema generates {"type": "array"} instead of {"type": ["null", "array"]}.

Jump to

Keyboard shortcuts

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