Skip to main content
Glama
ajith-fullstack

User Management MCP Server

User Management MCP Server

A simple Model Context Protocol (MCP) server for managing users through AI-compatible MCP clients.

This project is built with Node.js, Express, and the official MCP SDK. It demonstrates how to expose backend functionality through MCP Tools, Resources, and Prompts, with Zod-based input validation and Streamable HTTP transport.


Features

  • Create users

  • Get a user by ID

  • Get all users

  • Update users

  • Delete users

  • MCP Tools

  • MCP Resource

  • MCP Prompt

  • Zod input validation

  • Streamable HTTP transport

  • JSON file-based data storage

  • Express HTTP server

  • CORS support

  • Compatible with MCP clients such as Cursor


Related MCP server: Test MCP Server

Tech Stack

  • Node.js

  • Express.js

  • Model Context Protocol (MCP) SDK

  • Zod

  • Streamable HTTP

  • JavaScript (ES Modules)

  • JSON


Project Architecture

┌─────────────────────┐
│     MCP Client      │
│  Cursor / AI Client │
└──────────┬──────────┘
           │
           │ Streamable HTTP
           ▼
┌─────────────────────┐
│     MCP Server      │
│   Express + MCP SDK │
└──────────┬──────────┘
           │
     ┌─────┴─────┐
     │           │
     ▼           ▼
  MCP Tools   MCP Resource
     │           │
     └─────┬─────┘
           │
           ▼
     User Management
           │
           ▼
      users.json

MCP Components

This project demonstrates the three main MCP capabilities:

1. Tools

The server exposes the following tools:

Tool

Description

create_user

Creates a new user

get_user

Retrieves a user by ID

get_all_users

Retrieves all users

update_user

Updates an existing user

delete_user

Deletes an existing user

create_user

Creates a new user.

Required fields:

name
email
address
phone

Example:

{
  "name": "Ajith Kumar",
  "email": "ajith@example.com",
  "address": "Chennai, Tamil Nadu",
  "phone": "9876543210"
}

get_user

Retrieves a specific user using their ID.

Example:

{
  "id": 1
}

get_all_users

Returns all users stored in the user database.

No input is required.


update_user

Updates an existing user.

Required:

id

Optional:

name
email
address
phone

Example:

{
  "id": 1,
  "name": "Ajith Kumar",
  "phone": "9876500000"
}

delete_user

Deletes a user using their ID.

Example:

{
  "id": 1
}

MCP Resource

The server also exposes an MCP Resource named:

user-api-guide

Resource URI:

http://localhost:5001/mcp/guide

The resource provides information about the available user-management tools and their required parameters.

Example information provided by the resource:

User Management MCP API

Available tools:

create_user
- Creates a new user
- Required: name, email, address, phone

get_user
- Gets a user by ID
- Required: id

get_all_users
- Returns all users

update_user
- Updates an existing user
- Required: id
- Optional: name, email, address, phone

delete_user
- Deletes a user
- Required: id

MCP Prompt

The server provides an MCP Prompt:

create-user

The prompt instructs the MCP client to generate a random user and call the create_user tool automatically.

Example workflow:

MCP Client
    ↓
create-user Prompt
    ↓
Generate random user information
    ↓
create_user Tool
    ↓
User saved to users.json

This demonstrates how MCP Prompts can be used to provide reusable instructions to an AI client.


Input Validation

The project uses Zod to validate tool inputs.

Example:

inputSchema: {
  name: z.string(),
  email: z.string(),
  address: z.string(),
  phone: z.string(),
}

For update operations, the fields are optional except for the user ID:

inputSchema: {
  id: z.number(),
  name: z.string().optional(),
  email: z.string().optional(),
  address: z.string().optional(),
  phone: z.string().optional(),
}

This helps ensure that MCP tool calls receive the expected input structure.


Data Storage

For simplicity, this project uses a JSON file as the data store:

model/
└── users.json

User operations read and write directly to this file.

Example:

[
  {
    "id": 1,
    "name": "Ajith Kumar",
    "email": "ajith@example.com",
    "address": "Chennai",
    "phone": "9876543210"
  }
]

This JSON-based storage is intended for learning and demonstration purposes. A production application should use a database such as PostgreSQL, MongoDB, or MySQL.


Project Structure

mcp-server/
│
├── model/
│   └── users.json
│
├── .gitignore
├── package.json
├── package-lock.json
├── server.js
└── README.md

Installation

Clone the repository:

git clone https://github.com/ajith-fullstack/mcp-server.git

Navigate into the project:

cd mcp-server

Install dependencies:

npm install

Run the Server

Start the server:

npm start

The MCP server will start on:

http://localhost:5001

MCP endpoint:

http://localhost:5001/mcp

The project currently uses port 5001 for the Express/MCP server.


Development Mode

The project also includes a development script using Nodemon.

Run:

npm run dev

This automatically restarts the server when source files are changed.


Connecting with Cursor

This MCP server can be connected to MCP-compatible clients such as Cursor.

Example MCP configuration:

{
  "mcpServers": {
    "user-management": {
      "url": "http://localhost:5001/mcp"
    }
  }
}

After connecting the server, the MCP client can discover and use the available tools.

For example:

User:
Create a new user named Ajith Kumar.

        ↓

MCP Client

        ↓

create_user

        ↓

MCP Server

        ↓

users.json

The server can therefore expose existing backend functionality to an AI client through the MCP protocol.


Example MCP Workflow

Create User

AI Client
   ↓
create_user
   ↓
MCP Server
   ↓
User Service
   ↓
users.json

Get User

AI Client
   ↓
get_user
   ↓
MCP Server
   ↓
users.json
   ↓
User information

Update User

AI Client
   ↓
update_user
   ↓
MCP Server
   ↓
users.json

Delete User

AI Client
   ↓
delete_user
   ↓
MCP Server
   ↓
users.json

API Endpoint

MCP Endpoint

POST /mcp

The MCP server uses Streamable HTTP transport to handle MCP requests.

Health / GET Endpoint

GET /mcp

Response:

MCP GET endpoint reached

Dependencies

Main dependencies:

@modelcontextprotocol/sdk
express
zod

Development dependency:

nodemon

The current project uses the MCP SDK, Express 5, Zod 4, CORS, and Nodemon.


What I Learned

This project was built to understand how Model Context Protocol (MCP) can be used to expose backend functionality to AI applications.

Key concepts implemented:

  • MCP Server setup

  • MCP Tool registration

  • MCP Resource registration

  • MCP Prompt registration

  • Tool input validation using Zod

  • Streamable HTTP transport

  • Express integration

  • CRUD operations

  • AI client integration

  • Tool discovery

  • Tool invocation

  • Backend execution through MCP


License

This project is open source and available for learning and development purposes.


Author

Ajithkumar

GitHub:

https://github.com/ajith-fullstack

Repository:

https://github.com/ajith-fullstack/mcp-server


This version matches the implementation in your repository, including the **five tools, `user-api-guide` resource, `create-user` prompt, Zod schemas, and Streamable HTTP endpoint**.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A simple Model Context Protocol (MCP) server that allows LLMs to create and manage user entries in a JSON file system database.
    681 npm
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    A testing server that provides CRUD operations on a JSON user database via MCP tools, enabling AI assistants to list, search, add, update, and delete users.
    1
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    MCP server demonstrating Streamable HTTP with Tools, Resources, and Prompts for user registration, login, and profile management via a REST API.
    -