Client
MCP server: Client
Installation
npx mcp-server-clientAsk AI about Client
Powered by Claude Β· Grounded in docs
I know everything about Client. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
MCP User Management System
A practical implementation of the Model Context Protocol (MCP) demonstrating a client-server architecture for user management with AI-powered query capabilities.
π What is MCP?
The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). Think of it as a universal connector between your AI models and various data sources or tools.
Key Concepts:
- MCP Server: Exposes resources (data), tools (actions), and prompts to clients
- MCP Client: Connects to servers and uses their capabilities
- Resources: Read-only data sources (like database queries)
- Tools: Executable functions that can modify state
- Prompts: Reusable prompt templates
This project demonstrates all these concepts through a simple user management system.
π― What This Project Does
This repository contains:
-
MCP Server (
server.ts): Manages a user database with:- Resources to read user data
- Tools to create users (manually or with AI-generated fake data)
- Prompts for generating fake user profiles
-
MCP Client (
client.ts): Interactive CLI that lets you:- Query the system using natural language (AI-powered)
- Call tools directly
- Read resources
- Use prompts
- Everything integrated with Google's Gemini AI model
π Getting Started
Prerequisites
- Node.js (v18 or higher)
- npm or yarn
- A Google Gemini API key (Get one here)
Installation
-
Clone the repository
git clone <your-repo-url> cd <your-repo-name> -
Install dependencies
npm install -
Set up environment variables
Create a
.envfile in the root directory:GEMINI_API_KEY=your_gemini_api_key_here -
Build the project
npm run build
Running the Application
-
Start the client
node build/client.js -
Choose an option from the menu:
- Query (AI-powered): Ask questions in natural language (e.g., "Create a user named John with email john@example.com")
- Call a Tool: Manually execute tools like creating users
- Read a Resource: View all users or specific user details
- Use a Prompt: Generate fake user data based on templates
- Exit: Close the application
π Project Structure
βββ src/
β βββ client.ts # MCP client implementation
β βββ server.ts # MCP server implementation
β βββ data/
β βββ users.json # User database (auto-created)
βββ build/ # Compiled JavaScript files
βββ .env # Environment variables
βββ package.json
βββ README.md
π§ Available Features
Resources
- Get All Users (
users://all): Retrieve all users from the database - Get User Details (
users://{userId}/profile): Get specific user information
Tools
- create-user: Add a new user with name, email, address, and phone
- create-random-user: Generate and save a fake user using AI
Prompts
- generate-fake-user: Template for creating fake user data based on a name
π‘ Example Usage
Using AI Query
What would you like to do? > Query (AI-powered)
Enter your query: > Create a new user named Alice with email alice@example.com
Reading All Users
What would you like to do? > Read a Resource
Select a resource: > Users (users://all)
Creating a Random User
What would you like to do? > Call a Tool
Select a tool: > Create Random User
π οΈ Development
Build the project
npm run build
Watch mode (auto-rebuild on changes)
npm run build -- --watch
π¦ Dependencies
@ai-sdk/google: Google Gemini AI integration@modelcontextprotocol/sdk: MCP protocol implementationai: Vercel AI SDK for unified AI interactions@inquirer/prompts: Interactive CLI promptszod: Schema validationdotenv: Environment variable management
π€ Contributing
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
π License
[Add your license here]
π Resources
β οΈ Notes
- The user database is stored in
src/data/users.jsonand persists between sessions - User IDs are auto-incremented
- The server uses stdio transport for communication
- All AI operations use Google's Gemini 2.0 Flash model
