| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | package msi |
| 10 | |
| 11 | import ( |
| 12 | "io/fs" |
| 13 | "time" |
| 14 | |
| 15 | "github.com/modelcontextprotocol/go-sdk/mcp" |
| 16 | ) |
| 17 | |
| 18 | var ListDirectory = &mcp.Tool{ |
| 19 | Name: "list_directory", |
| 20 | Description: `Lists the names of files and subdirectories directly within a specified directory path.`, |
| 21 | } |
| 22 | |
| 23 | type ListDirectoryParams struct { |
| 24 | Path string `json:"path" jsonschema:"The absolute path to the directory to list."` |
| 25 | } |
| 26 | |
| 27 | |
| 28 | type ListDirectoryResultEntry struct { |
| 29 | Name string `json:"name" jsonschema:"base name of the file"` |
| 30 | Size *int64 `json:"size,omitempty" jsonschema:"length in bytes for regular files; system-dependent for others"` |
| 31 | Mode *fs.FileMode `json:"mode,omitempty" jsonschema:"file mode bits"` |
| 32 | ModTime *time.Time `json:"time,omitempty" jsonschema:"modification time"` |
| 33 | IsDir *bool `json:"is_dir,omitempty" jsonschema:"true for a directory"` |
| 34 | } |
| 35 | |
| 36 | type ListDirectoryResult struct { |
| 37 | Entries []ListDirectoryResultEntry `json:"entries" jsonschema:"The directory content entries."` |
| 38 | } |
| 39 | |
| 40 | var ReadFile = &mcp.Tool{ |
| 41 | Name: "read_file", |
| 42 | Description: `Reads and returns the content of a specified file.`, |
| 43 | } |
| 44 | |
| 45 | type ReadFileResult struct { |
| 46 | Content string `json:"content" jsonschema:"The content of the file."` |
| 47 | } |
| 48 | |
| 49 | type ReadFileParams struct { |
| 50 | Path string `json:"path" jsonschema:"The absolute path to the file to read."` |
| 51 | TODO: |
| 52 | TODO: |
| 53 | } |
| 54 | |
| 55 | var WriteFile = &mcp.Tool{ |
| 56 | Name: "write_file", |
| 57 | 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.`, |
| 58 | } |
| 59 | |
| 60 | type WriteFileResult struct { |
| 61 | |
| 62 | } |
| 63 | |
| 64 | type WriteFileParams struct { |
| 65 | Path string `json:"path" jsonschema:"The absolute path to the file to write to."` |
| 66 | Content string `json:"content" jsonschema:"The content to write into the file."` |
| 67 | } |
| 68 | |
| 69 | var Glob = &mcp.Tool{ |
| 70 | Name: "glob", |
| 71 | Description: `Finds files matching specific glob patterns (e.g., src/**/*.ts, *.md)`, |
| 72 | } |
| 73 | |
| 74 | type GlobParams struct { |
| 75 | Pattern string `json:"pattern" jsonschema:"The glob pattern to match against (e.g., '*.py', 'src/**/*.js')."` |
| 76 | Path *string `json:"path,omitempty" jsonschema:"The absolute path to the directory to search within. If omitted, searches the tool's root directory."` |
| 77 | TODO: |
| 78 | } |
| 79 | |
| 80 | type GlobResult struct { |
| 81 | Matches []string `json:"matches" jsonschema:"A list of absolute file paths that match the provided glob pattern."` |
| 82 | } |
| 83 | |
| 84 | var SearchFileContent = &mcp.Tool{ |
| 85 | Name: "search_file_content", |
| 86 | Description: `Searches for a regular expression pattern within the content of files in a specified directory. Internally calls 'git grep -n --no-index'.`, |
| 87 | } |
| 88 | |
| 89 | type SearchFileContentParams struct { |
| 90 | Pattern string `json:"pattern" jsonschema:"The regular expression (regex) to search for (e.g., 'function\\s+myFunction')."` |
| 91 | Path *string `json:"path,omitempty" jsonschema:"The absolute path to the directory to search within. Defaults to the current working directory."` |
| 92 | Include *string `json:"include,omitempty" jsonschema:"A glob pattern to filter which files are searched (e.g., '*.js', 'src/**/*.{ts,tsx}'). If omitted, searches most files (respecting common ignores)."` |
| 93 | } |
| 94 | |
| 95 | type SearchFileContentResult struct { |
| 96 | GitGrepOutput string `json:"git_grep_output" jsonschema:"The raw output from the 'git grep -n --no-index' command, containing matching lines with filenames and line numbers."` |
| 97 | } |
| 98 | |
| 99 | TODO: |