mcp

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: EUPL-1.2 Imports: 11 Imported by: 0

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

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

type CreateDirectoryOutput struct {
	Success bool   `json:"success"`
	Path    string `json:"path"`
}

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

type DeleteFileOutput struct {
	Success bool   `json:"success"`
	Path    string `json:"path"`
}

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

type DetectLanguageOutput struct {
	Language string `json:"language"`
	Path     string `json:"path"`
}

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

type Option func(*Service) error

Option configures a Service.

func WithWorkspaceRoot added in v0.0.4

func WithWorkspaceRoot(root string) Option

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

type RenameFileInput struct {
	OldPath string `json:"oldPath"`
	NewPath string `json:"newPath"`
}

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

func New(opts ...Option) (*Service, error)

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

func (s *Service) Run(ctx context.Context) error

Run starts the MCP server. If MCP_ADDR is set, it starts a TCP server. Otherwise, it starts a Stdio server.

func (*Service) ServeTCP added in v0.0.4

func (s *Service) ServeTCP(ctx context.Context, addr string) error

ServeTCP starts a TCP server for the MCP service. It accepts connections and spawns a new MCP server session for each connection.

func (*Service) Server

func (s *Service) Server() *mcp.Server

Server returns the underlying MCP server for advanced configuration.

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

type WriteFileInput struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

WriteFileInput contains parameters for writing a file.

type WriteFileOutput

type WriteFileOutput struct {
	Success bool   `json:"success"`
	Path    string `json:"path"`
}

WriteFileOutput contains the result of writing a file.

Jump to

Keyboard shortcuts

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