rsathish29/mcp-server-poc
If you are the rightful owner of mcp-server-poc and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A simple Proof of Concept (POC) for a Model Context Protocol (MCP) server that provides basic tools for calculations and file operations.
MCP Server POC
A simple Proof of Concept (POC) for a Model Context Protocol (MCP) server that provides basic tools for calculations and file operations.
Features
This MCP server provides the following tools:
- Calculator: Perform basic arithmetic calculations safely
- File Operations: Read, write, and get information about files
- Directory Operations: List directory contents and get file/directory information
Prerequisites
- Node.js 18.0.0 or higher
- npm or yarn package manager
Installation
-
Clone or download this repository
-
Navigate to the project directory:
cd mcp-server-poc -
Install dependencies:
npm install
Usage
Running the Server
Start the MCP server:
npm start
Or for development with auto-restart:
npm run dev
The server will run on stdio and wait for MCP client connections.
Available Tools
1. Calculator
- Name:
calculator - Description: Perform basic arithmetic calculations
- Parameters:
expression(string): Mathematical expression to evaluate (e.g., "2 + 3 * 4")
2. Read File
- Name:
read_file - Description: Read the contents of a file
- Parameters:
path(string): Path to the file to read
3. Write File
- Name:
write_file - Description: Write content to a file
- Parameters:
path(string): Path to the file to writecontent(string): Content to write to the file
4. List Directory
- Name:
list_directory - Description: List files and directories in a given path
- Parameters:
path(string): Path to the directory to list
5. Get File Info
- Name:
get_file_info - Description: Get information about a file or directory
- Parameters:
path(string): Path to the file or directory
Example Usage
Using with Claude Desktop
To use this MCP server with Claude Desktop, add the following to your Claude Desktop configuration:
{
"mcpServers": {
"simple-mcp-server": {
"command": "node",
"args": ["/path/to/your/mcp-server-poc/server.js"],
"env": {}
}
}
}
Example Tool Calls
- Calculate:
calculatorwith expression "10 + 5 * 2" - Read a file:
read_filewith path "/path/to/file.txt" - Write a file:
write_filewith path "/path/to/newfile.txt" and content "Hello World" - List directory:
list_directorywith path "/path/to/directory" - Get file info:
get_file_infowith path "/path/to/file.txt"
Security Notes
- The calculator tool uses safe evaluation that only allows numbers and basic mathematical operators
- File operations are performed with the same permissions as the running process
- Always validate file paths when using file operations in production
Development
Project Structure
mcp-server-poc/
├── package.json # Project configuration and dependencies
├── server.js # Main MCP server implementation
└── README.md # This file
Adding New Tools
To add new tools to the server:
- Add the tool definition to the
ListToolsRequestSchemahandler - Add a case for the tool in the
CallToolRequestSchemahandler - Implement the tool logic in a new handler method
Example:
// In setupToolHandlers()
{
name: 'my_new_tool',
description: 'Description of what the tool does',
inputSchema: {
type: 'object',
properties: {
param1: { type: 'string', description: 'Parameter description' }
},
required: ['param1']
}
}
// In the CallToolRequestSchema handler
case 'my_new_tool':
return await this.handleMyNewTool(args);
// Add the handler method
async handleMyNewTool(args) {
// Tool implementation
}
License
MIT License - feel free to use this code for your own MCP server implementations.
Troubleshooting
Common Issues
- "Cannot find module" errors: Make sure you've run
npm install - Permission errors: Ensure the server has appropriate file system permissions
- Connection issues: Verify that the MCP client is properly configured to connect to this server
Debug Mode
To run with additional logging, you can modify the server to include more verbose output or use Node.js debugging tools.