MCP Sample Server

April 6, 2025 · View on GitHub

This is a simple MCP (Model Context Protocol) server implementation that provides a file listing functionality.

Setup

  1. Install dependencies:
npm install
  1. Build the TypeScript code:
npm run build
  1. Start the server:
npm start

Configuring in Cursor

To use this MCP server in Cursor:

  1. Open Cursor settings (⚙️ icon or Ctrl + ,)
  2. Find the MCP section
  3. Add a new MCP server configuration:
{
  "mcpServers": {
    "file-lister": {
      "command": "node",
      "args": ["PATH_TO_YOUR_PROJECT/build/mcp-server.js"],
      "cwd": "PATH_TO_YOUR_PROJECT"
    }
  }
}

Replace PATH_TO_YOUR_PROJECT with the absolute path to your project directory.

Available Tools

listFiles

Lists all files in a specified directory.

Parameters:

  • path: The directory path to list files from

Returns:

  • Array of file objects containing:
    • name: File name
    • path: Full file path