Documentation
¶
Overview ¶
Package mcp provides a lightweight MCP (Model Context Protocol) server for CLI use. For full GUI integration (display, webview, process management), see core-gui/pkg/mcp.
Index ¶
- type CreateDirectoryInput
- type CreateDirectoryOutput
- type DeleteFileInput
- type DeleteFileOutput
- type DetectLanguageInput
- type DetectLanguageOutput
- type DirectoryEntry
- type EditDiffInput
- type EditDiffOutput
- type FileExistsInput
- type FileExistsOutput
- type GetSupportedLanguagesInput
- type GetSupportedLanguagesOutput
- type LanguageInfo
- type ListDirectoryInput
- type ListDirectoryOutput
- type Option
- type ReadFileInput
- type ReadFileOutput
- type RenameFileInput
- type RenameFileOutput
- type Service
- type TCPTransport
- type WriteFileInput
- type WriteFileOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateDirectoryInput ¶
type CreateDirectoryInput struct {
Path string `json:"path"`
}
CreateDirectoryInput contains parameters for creating a directory.
type CreateDirectoryOutput ¶
CreateDirectoryOutput contains the result of creating a directory.
type DeleteFileInput ¶
type DeleteFileInput struct {
Path string `json:"path"`
}
DeleteFileInput contains parameters for deleting a file.
type DeleteFileOutput ¶
DeleteFileOutput contains the result of deleting a file.
type DetectLanguageInput ¶
type DetectLanguageInput struct {
Path string `json:"path"`
}
DetectLanguageInput contains parameters for detecting file language.
type DetectLanguageOutput ¶
DetectLanguageOutput contains the detected programming language.
type DirectoryEntry ¶
type DirectoryEntry struct {
Name string `json:"name"`
Path string `json:"path"`
IsDir bool `json:"isDir"`
Size int64 `json:"size"`
}
DirectoryEntry represents a single entry in a directory listing.
type EditDiffInput ¶
type EditDiffInput struct {
Path string `json:"path"`
OldString string `json:"old_string"`
NewString string `json:"new_string"`
ReplaceAll bool `json:"replace_all,omitempty"`
}
EditDiffInput contains parameters for editing a file via diff.
type EditDiffOutput ¶
type EditDiffOutput struct {
Path string `json:"path"`
Success bool `json:"success"`
Replacements int `json:"replacements"`
}
EditDiffOutput contains the result of a diff-based edit operation.
type FileExistsInput ¶
type FileExistsInput struct {
Path string `json:"path"`
}
FileExistsInput contains parameters for checking file existence.
type FileExistsOutput ¶
type FileExistsOutput struct {
Exists bool `json:"exists"`
IsDir bool `json:"isDir"`
Path string `json:"path"`
}
FileExistsOutput contains the result of checking file existence.
type GetSupportedLanguagesInput ¶
type GetSupportedLanguagesInput struct{}
GetSupportedLanguagesInput is an empty struct for the languages query.
type GetSupportedLanguagesOutput ¶
type GetSupportedLanguagesOutput struct {
Languages []LanguageInfo `json:"languages"`
}
GetSupportedLanguagesOutput contains the list of supported languages.
type LanguageInfo ¶
type LanguageInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Extensions []string `json:"extensions"`
}
LanguageInfo describes a supported programming language.
type ListDirectoryInput ¶
type ListDirectoryInput struct {
Path string `json:"path"`
}
ListDirectoryInput contains parameters for listing a directory.
type ListDirectoryOutput ¶
type ListDirectoryOutput struct {
Entries []DirectoryEntry `json:"entries"`
Path string `json:"path"`
}
ListDirectoryOutput contains the result of listing a directory.
type Option ¶ added in v0.0.4
Option configures a Service.
func WithWorkspaceRoot ¶ added in v0.0.4
WithWorkspaceRoot restricts file operations to the given directory. All paths are validated to be within this directory. An empty string disables the restriction (not recommended).
type ReadFileInput ¶
type ReadFileInput struct {
Path string `json:"path"`
}
ReadFileInput contains parameters for reading a file.
type ReadFileOutput ¶
type ReadFileOutput struct {
Content string `json:"content"`
Language string `json:"language"`
Path string `json:"path"`
}
ReadFileOutput contains the result of reading a file.
type RenameFileInput ¶
RenameFileInput contains parameters for renaming a file.
type RenameFileOutput ¶
type RenameFileOutput struct {
Success bool `json:"success"`
OldPath string `json:"oldPath"`
NewPath string `json:"newPath"`
}
RenameFileOutput contains the result of renaming a file.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides a lightweight MCP server with file operations only. For full GUI features, use the core-gui package.
func New ¶
New creates a new MCP service with file operations. By default, restricts file access to the current working directory. Use WithWorkspaceRoot("") to disable restrictions (not recommended). Returns an error if initialization fails.
func (*Service) Run ¶
Run starts the MCP server. If MCP_ADDR is set, it starts a TCP server. Otherwise, it starts a Stdio server.
type TCPTransport ¶ added in v0.0.4
type TCPTransport struct {
// contains filtered or unexported fields
}
TCPTransport manages a TCP listener for MCP.
func NewTCPTransport ¶ added in v0.0.4
func NewTCPTransport(addr string) (*TCPTransport, error)
NewTCPTransport creates a new TCP transport listener. It listens on the provided address (e.g. "localhost:9100").
type WriteFileInput ¶
WriteFileInput contains parameters for writing a file.
type WriteFileOutput ¶
WriteFileOutput contains the result of writing a file.