atman-33/mcp-ts-minimal
If you are the rightful owner of mcp-ts-minimal and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This document provides a structured overview of a minimal Model Context Protocol (MCP) server implemented in TypeScript, showcasing its features, tools, and usage.
MCP TypeScript Minimal Server
A minimal Model Context Protocol (MCP) server implementation in TypeScript that demonstrates basic tool functionality with hello and echo commands.
Features
- Hello Tool: Returns a simple greeting message
- Echo Tool: Echoes back any message you provide
- Built with TypeScript and the official MCP SDK
- Input validation using Zod schemas
- Development tools: Biome for linting/formatting, Husky for git hooks
Installation
Prerequisites
- Node.js (version 18 or higher)
- npm or yarn
Setup
- Clone the repository:
git clone <repository-url>
cd mcp-ts-minimal
- Install dependencies:
npm install
- Build the project:
npm run build
Usage
Running the Server
Development Mode
npm run dev
Production Mode
npm start
Available Tools
1. Hello Tool
- Name:
hello - Description: Responds with a greeting message
- Parameters: None
- Example Response: "Hello from MCP server"
2. Echo Tool
- Name:
echo - Description: Echoes the provided message
- Parameters:
message(string, required): The message to echo back
- Example Response: "Echo: Your message here"
MCP Client Configuration
To use this server with an MCP client, add the following configuration to your MCP settings:
Using with npx (Recommended)
If you publish this package to npm, you can use it with npx:
{
"mcpServers": {
"mcp-ts-minimal": {
"command": "npx",
"args": ["mcp-ts-minimal@latest"],
"disabled": false
}
}
}
Development
Available Scripts
npm run build- Build the TypeScript projectnpm run dev- Run in development mode with ts-nodenpm start- Run the built JavaScript versionnpm run lint- Lint the code with Biomenpm run lint:fix- Lint and fix issues automaticallynpm run format- Format code with Biomenpm run format:check- Check code formattingnpm run check- Run Biome checks and fix issuesnpm run check:ci- Run Biome checks for CInpm run typecheck- Run TypeScript type checkingnpm run quality- Run type checking and CI checksnpm run quality:fix- Run type checking and fix issues
Project Structure
mcp-ts-minimal/
├── src/
│ └── index.ts # Main server implementation
├── dist/ # Built JavaScript files
├── .husky/ # Git hooks
├── biome.json # Biome configuration
├── tsconfig.json # TypeScript configuration
├── package.json # Project dependencies and scripts
└── README.md # This file
Adding New Tools
To add a new tool to the server:
- Define the input schema using Zod:
const MyToolInputSchema = z.object({
param1: z.string(),
param2: z.number().optional(),
});
- Add the tool handler in the
CallToolRequestSchemahandler:
case 'my-tool': {
const parsed = MyToolInputSchema.safeParse(args);
if (!parsed.success) {
return {
content: [{ type: 'text', text: `Invalid arguments: ${parsed.error}` }],
isError: true,
};
}
// Your tool logic here
return {
content: [{ type: 'text', text: 'Tool response' }],
};
}
- Add the tool definition in the
ListToolsRequestSchemahandler:
{
name: 'my-tool',
description: 'Description of what your tool does',
inputSchema: zodToJsonSchema(MyToolInputSchema),
}
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run
npm run quality:fixto ensure code quality - Commit your changes (Husky will run pre-commit hooks)
- Push to your branch
- Create a Pull Request
Troubleshooting
Common Issues
- Server not starting: Ensure all dependencies are installed and the project is built
- Tools not appearing: Check that the MCP client configuration points to the correct path
- Permission errors: Make sure the built JavaScript file has execute permissions
Debug Mode
To enable debug logging, set the environment variable:
DEBUG=mcp* npm start