mcp-server-poc

rsathish29/mcp-server-poc

3.2

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.

Tools
5
Resources
0
Prompts
0

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

  1. Clone or download this repository

  2. Navigate to the project directory:

    cd mcp-server-poc
    
  3. 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 write
    • content (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

  1. Calculate: calculator with expression "10 + 5 * 2"
  2. Read a file: read_file with path "/path/to/file.txt"
  3. Write a file: write_file with path "/path/to/newfile.txt" and content "Hello World"
  4. List directory: list_directory with path "/path/to/directory"
  5. Get file info: get_file_info with 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:

  1. Add the tool definition to the ListToolsRequestSchema handler
  2. Add a case for the tool in the CallToolRequestSchema handler
  3. 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

  1. "Cannot find module" errors: Make sure you've run npm install
  2. Permission errors: Ensure the server has appropriate file system permissions
  3. 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.