mcp-leftpad
Version:
An MCP server that exposes left-pad as a tool
81 lines (57 loc) • 1.27 kB
Markdown
# mcp-leftpad
An MCP server that exposes a left-pad tool using the Model Context Protocol.
## Installation
```bash
npm install -g mcp-leftpad
```
## Usage
Start the MCP server:
```bash
mcp-leftpad
```
The server exposes the following tool:
### left-pad
Pads the start of a string to a specified length with a specified string.
**Parameters:**
- `str` (string, required): The string to pad
- `length` (number, required): The target length of the padded string
- `padStr` (string, optional, default: ' '): The string to pad with
**Example:**
```json
{
"name": "left-pad",
"arguments": {
"str": "hello",
"length": 10,
"padStr": "-"
}
}
```
This will return:
```json
{
"content": [
{
"type": "text",
"text": "-----hello"
}
]
}
```
## Development
```bash
# Clone the repository
git clone https://github.com/yourusername/mcp-leftpad.git
cd mcp-leftpad
# Install dependencies
npm install
# Start the server locally
npm start
```
## Implementation
This MCP server is built using the `@modelcontextprotocol/sdk` library and uses:
- The `McpServer` class for creating a compliant MCP server
- The `StdioServerTransport` for communicating over standard input/output
- Zod schemas for parameter validation
## License
MIT