A Model Context Protocol (MCP) server that provides CRUD operations for user management via HTTP/SSE transport. This server connects to a BasicCrud API to perform database operations and exposes them as MCP tools for use with n8n and other MCP clients.
- Complete CRUD Operations: Create, Read, Update, Delete users
- MCP Protocol Support: HTTP/SSE transport for MCP communication
- Session Management: Multi-client support with automatic cleanup
- Docker Integration: Works with containerized BasicCrud API and PostgreSQL
- Turkish ID Validation: 11-digit TC number validation for users
- setup_database - Initialize/reset the database table
- create_user - Create a new user (requires: name, age, TC number)
- get_all_users - Retrieve all users from the database
- update_user - Update existing user information (requires: ID, name, age, TC number)
- delete_user - Delete a user by ID
- Node.js 18+
- Docker and Docker Compose
- BasicCrud API (included in docker-compose)
- PostgreSQL database (included in docker-compose)
- Clone the repository:
git clone <repository-url>
cd user-crud-mcp-server- Install dependencies:
npm install- Start the database and BasicCrud API:
docker-compose up -d- Build the TypeScript code:
npm run build- Start the MCP server:
Option A: Standard MCP Server (for n8n/programmatic use):
npm startOption B: MCP Server with Web Interface (for easy testing):
npm run start:webEnvironment variables:
CRUD_API_URL: BasicCrud API URL (default: http://localhost:3000)HTTP_PORT: MCP server port (default: 8080)
The docker-compose.yaml includes:
- PostgreSQL Database (port 5433)
- BasicCrud API (port 3000)
The MCP server runs locally and connects to these services.
- GET /sse - Establish SSE connection for MCP
- POST /messages?sessionId= - Send MCP JSON-RPC messages
- GET /health - Health check and server status
When using npm run start:web, you can access a beautiful web interface at http://localhost:8080 that provides:
- Visual forms for each CRUD operation
- Real-time results display
- Input validation for TC numbers and age ranges
- Color-coded success/error messages
- Responsive design that works on desktop and mobile
This is perfect for testing the MCP tools and demonstrating functionality.
When using npm start, you get the standard MCP server for programmatic use:
- Connect to the SSE endpoint:
http://localhost:8080/sse - Send JSON-RPC messages to:
http://localhost:8080/messages?sessionId=<session_id> - Use the available tools for user management operations
{
"method": "tools/call",
"params": {
"name": "create_user",
"arguments": {
"isim": "John Doe",
"yas": 30,
"tc": "12345678901"
}
}
}{
"method": "tools/call",
"params": {
"name": "get_all_users",
"arguments": {}
}
}npm run build- Compile TypeScriptnpm start- Start standard MCP server (for n8n)npm run start:web- Start MCP server with web interfacenpm test- Run tests (not implemented)
├── src/
│ ├── index.ts # Standard MCP server (for n8n)
│ └── indexNew.ts # MCP server with web interface
├── public/
│ └── index.html # Web interface for testing tools
├── basicCrud/ # BasicCrud API source
├── docker-compose.yaml # Docker services
├── Dockerfile # MCP server container (unused in current setup)
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
- Port conflicts: Change the
HTTP_PORTenvironment variable - Database connection issues: Ensure Docker services are running
- API errors: Check BasicCrud API logs with
docker-compose logs basiccrud
ISC
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request