Documentation
¶
Overview ¶
Package msi provides the "MCP Sandbox Interface" (tentative) that should be reusable for other projects too.
MCP Sandbox Interface defines MCP (Model Context Protocol) tools that can be used for reading, writing, and executing local files with an appropriate sandboxing technology. The sandboxing technology can be more secure and/or efficient than the default tools provided by an AI agent.
MCP Sandbox Interface was inspired by Gemini CLI's built-in tools. https://github.com/google-gemini/gemini-cli/tree/v0.1.12/docs/tools
Notable differences from Gemini CLI's built-in tools:
- the output format is JSON, not a plain text
- the output of SearchFileContent always corresponds to `git grep -n --no-index`
- RunShellCommandParams.Command is a string slice, not a string
- RunShellCommandParams.Directory is an absolute path, not a relative path
- RunShellCommandParams.Directory must not be empty
- Replace does not use an AI model to correct an old_string that does not match
- ReplaceParams.OldString must not be empty; use WriteFile to create a file
Eventually, this package may be split to a separate repository.
Index ¶
- Variables
- type GlobParams
- type GlobResult
- type ListDirectoryParams
- type ListDirectoryResult
- type ListDirectoryResultEntry
- type ReadFileParams
- type ReadFileResult
- type ReplaceParams
- type ReplaceResult
- type RunShellCommandParams
- type RunShellCommandResult
- type SearchFileContentParams
- type SearchFileContentResult
- type WriteFileParams
- type WriteFileResult
Constants ¶
This section is empty.
Variables ¶
var Glob = &mcp.Tool{
Name: "glob",
Description: `Finds files matching specific glob patterns (e.g., src/**/*.ts, *.md)`,
}
var ListDirectory = &mcp.Tool{
Name: "list_directory",
Description: `Lists the names of files and subdirectories directly within a specified directory path.`,
}
var ReadFile = &mcp.Tool{
Name: "read_file",
Description: `Reads and returns the content of a specified file.`,
}
var Replace = &mcp.Tool{
Name: "replace",
Description: `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when expected_replacements is specified. This tool is designed for precise, targeted changes and requires significant context around the old_string to ensure it modifies the correct location.`,
}
var RunShellCommand = &mcp.Tool{
Name: "run_shell_command",
Description: `Executes a given shell command.`,
}
var SearchFileContent = &mcp.Tool{
Name: "search_file_content",
Description: `Searches for a regular expression pattern within the content of files in a specified directory. Internally calls 'git grep -n --no-index'.`,
}
var WriteFile = &mcp.Tool{
Name: "write_file",
Description: `Writes content to a specified file. If the file exists, it will be overwritten. If the file doesn't exist, it (and any necessary parent directories) will be created.`,
}
Functions ¶
This section is empty.
Types ¶
type GlobParams ¶
type GlobResult ¶
type GlobResult struct {
Matches []string `json:"matches" jsonschema:"A list of absolute file paths that match the provided glob pattern."`
}
type ListDirectoryParams ¶
type ListDirectoryParams struct {
Path string `json:"path" jsonschema:"The absolute path to the directory to list."`
}
type ListDirectoryResult ¶
type ListDirectoryResult struct {
Entries []ListDirectoryResultEntry `json:"entries" jsonschema:"The directory content entries."`
}
type ListDirectoryResultEntry ¶
type ListDirectoryResultEntry struct {
Name string `json:"name" jsonschema:"base name of the file"`
Size *int64 `json:"size,omitempty" jsonschema:"length in bytes for regular files; system-dependent for others"`
Mode *fs.FileMode `json:"mode,omitempty" jsonschema:"file mode bits"`
ModTime *time.Time `json:"time,omitempty" jsonschema:"modification time"`
IsDir *bool `json:"is_dir,omitempty" jsonschema:"true for a directory"`
}
ListDirectoryResultEntry is similar to io/fs.FileInfo.
type ReadFileParams ¶
type ReadFileParams struct {
Path string `json:"path" jsonschema:"The absolute path to the file to read."`
}
type ReadFileResult ¶
type ReadFileResult struct {
Content string `json:"content" jsonschema:"The content of the file."`
}
type ReplaceParams ¶ added in v2.3.0
type ReplaceParams struct {
Path string `json:"path" jsonschema:"The absolute path to the file to modify."`
OldString string `` /* 282-byte string literal not displayed */
NewString string `json:"new_string" jsonschema:"The exact literal text to replace old_string with."`
ExpectedReplacements *int `json:"expected_replacements,omitempty" jsonschema:"The number of occurrences to replace. Defaults to 1."`
}
type ReplaceResult ¶ added in v2.3.0
type ReplaceResult struct {
Replacements int `json:"replacements" jsonschema:"The number of occurrences that were replaced."`
}
type RunShellCommandParams ¶
type RunShellCommandResult ¶
type RunShellCommandResult struct {
Stdout string `json:"stdout" jsonschema:"Output from the standard output stream."`
Stderr string `json:"stderr" jsonschema:"Output from the standard error stream."`
Error string `json:"error,omitempty" jsonschema:"Any error message reported by the subprocess."`
ExitCode *int `json:"exit_code,omitempty" jsonschema:"Exit code of the command."`
}
type SearchFileContentParams ¶
type SearchFileContentResult ¶
type SearchFileContentResult struct {
GitGrepOutput string `` /* 152-byte string literal not displayed */
}
type WriteFileParams ¶
type WriteFileResult ¶
type WriteFileResult struct {
}