m2e

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

README

m2e - American to British English Converter

This tool provides conversion from American English to British English (en-GB) using the excellent m2e library.

Features

  • Converts American spellings to British equivalents
  • Preserves formatting, capitalisation, and punctuation
  • Code-aware processing to avoid converting code elements
  • Supports smart quote normalisation
  • Uses both built-in and user-defined dictionaries
  • Default: Updates files in place
  • Alternative: Inline text conversion

Operation Modes

Default: Update File Mode

Provide a file path and the tool will update the file in place, returning only a success confirmation.

Alternative: Inline Mode

Provide text directly and receive the converted text in the response.

Parameters

  • file_path (default mode): Fully qualified absolute path to the file to update in place
  • text (alternative mode): The text to convert and return inline
  • keep_smart_quotes (optional, default: false): Whether to keep smart quotes and em-dashes as-is (default: false, meaning they will be normalised to standard quotes)

Note: Provide either file_path OR text, not both.

Usage Examples

Default: File Update Examples

Update a file in place:

{
  "file_path": "/Users/username/Documents/readme.md"
}

Update a file whilst keeping smart quotes:

{
  "file_path": "/Users/username/Documents/readme.md",
  "keep_smart_quotes": true
}
Alternative: Inline Mode Examples

Convert text inline:

{
  "text": "I need to organize my favorite colors."
}

Convert whilst keeping smart quotes:

{
  "text": "This "color" is my favorite!",
  "keep_smart_quotes": true
}

Notes

The tool uses the m2e library which includes comprehensive American-to-British spelling dictionaries and sophisticated text processing that preserves code blocks, URLs, and formatting whilst converting natural language text.

The tool will only write the file if changes were made, avoiding unnecessary file modifications.

By default, smart quotes and em-dashes are normalised to standard quotes and hyphens. Use keep_smart_quotes: true to preserve them.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConvertRequest

type ConvertRequest struct {
	Text            string `json:"text,omitempty"`              // For inline mode
	FilePath        string `json:"file_path,omitempty"`         // For update_file mode (default)
	KeepSmartQuotes bool   `json:"keep_smart_quotes,omitempty"` // Whether to keep smart quotes (default: false, i.e., normalise them)
}

ConvertRequest represents the request parameters for text conversion

type ConvertResponse

type ConvertResponse struct {
	ConvertedText string `json:"converted_text"`
	OriginalText  string `json:"original_text"`
	ChangesCount  int    `json:"changes_count"`
}

ConvertResponse represents the response from text conversion

type M2ETool

type M2ETool struct{}

M2ETool implements the American to British English converter tool

func (*M2ETool) Definition

func (m *M2ETool) Definition() mcp.Tool

Definition returns the tool's definition for MCP registration

func (*M2ETool) Execute

func (m *M2ETool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]interface{}) (*mcp.CallToolResult, error)

Execute executes the m2e tool

Jump to

Keyboard shortcuts

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