OkanKerem/MCP_server
If you are the rightful owner of MCP_server 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.
A Model Context Protocol (MCP) server that provides CRUD operations for user management via HTTP/SSE transport.
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
User CRUD MCP Server
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.
Features
- 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
Available Tools
- 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
Prerequisites
- Node.js 18+
- Docker and Docker Compose
- BasicCrud API (included in docker-compose)
- PostgreSQL database (included in docker-compose)
Installation
- 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 start
Option B: MCP Server with Web Interface (for easy testing):
npm run start:web
Configuration
Environment variables:
CRUD_API_URL
: BasicCrud API URL (default: http://localhost:3000)HTTP_PORT
: MCP server port (default: 8080)
Docker Services
The docker-compose.yaml
includes:
- PostgreSQL Database (port 5433)
- BasicCrud API (port 3000)
The MCP server runs locally and connects to these services.
API Endpoints
- GET /sse - Establish SSE connection for MCP
- POST /messages?sessionId=
- Send MCP JSON-RPC messages - GET /health - Health check and server status
Usage Options
Option 1: Web Interface (Easy Testing)
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.
Option 2: Programmatic Access (n8n Integration)
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
Example Tool Usage
Create User
{
"method": "tools/call",
"params": {
"name": "create_user",
"arguments": {
"isim": "John Doe",
"yas": 30,
"tc": "12345678901"
}
}
}
Get All Users
{
"method": "tools/call",
"params": {
"name": "get_all_users",
"arguments": {}
}
}
Development
Scripts
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)
Project Structure
āāā 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
Troubleshooting
- Port conflicts: Change the
HTTP_PORT
environment variable - Database connection issues: Ensure Docker services are running
- API errors: Check BasicCrud API logs with
docker-compose logs basiccrud
License
ISC
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request