altafshaikh/getting-started-with-mcp-servers
If you are the rightful owner of getting-started-with-mcp-servers and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Model Context Protocol (MCP) server is a comprehensive implementation designed for AI-powered user management, featuring both server and client components.
🚀 Getting Started with MCP Servers
A complete Model Context Protocol (MCP) implementation featuring both server and client components for AI-powered user management. This project demonstrates how to build production-ready MCP servers with modern JavaScript and AI integration.
✨ What's Inside
| Component | Description | Features |
|---|---|---|
| 🖥️ MCP Server | User management system | Resources, Tools, Prompts, AI Sampling |
| 🔄 MCP Client | Interactive CLI interface | Google Gemini AI, Real-time interactions |
| 📊 Database | JSON-based storage | Auto-incrementing IDs, File persistence |
| 🤖 AI Integration | Smart data generation | Fake user creation, Natural language processing |
🚀 Quick Start
Prerequisites
- Node.js 18+ installed (Download here)
- Cursor IDE for MCP integration (Get Cursor)
- Google Gemini API Key for client usage (Get API Key)
Installation
# Clone the repository
git clone https://github.com/altafshaikh/getting-started-with-mcp-servers.git
cd getting-started-with-mcp-servers
# Install dependencies
npm install
# Start the MCP server
npm start
🔧 Setup with Cursor
- Restart Cursor after starting the server
- Check MCP Panel - You should see "my-mcp-server" with tools enabled
- Start using tools directly in Cursor's interface
🎯 Features Overview
🛠️ Available Tools
| Tool | Purpose | Usage |
|---|---|---|
create-user | Manual user creation | Requires: name, email, address, phone |
create-random-user | AI-generated users | No parameters - fully automated |
Example Usage:
// Manual user creation
{
"name": "John Doe",
"email": "john.doe@example.com",
"address": "123 Main St, City",
"phone": "555-0123"
}
📊 Available Resources
| Resource | URI Pattern | Description |
|---|---|---|
users | users://all | Retrieve all users from database |
user-details | users://{userId}/profile | Get specific user by ID |
Example Queries:
users://all → All users
users://1/profile → User with ID 1
users://4/profile → User with ID 4 (teachmebro)
💬 Available Prompts
| Prompt | Parameters | Purpose |
|---|---|---|
generate-fake-user | name (string) | AI assistance for creating realistic user data |
🏗️ Project Architecture
getting-started-with-mcp-servers/
├── 📁 src/
│ ├── 🖥️ index.js # MCP Server (main)
│ ├── 👤 client.js # MCP Client with AI
│ └── 📁 data/
│ └── 👥 users.json # User database
├── 📄 package.json # Dependencies & scripts
├── 📄 README.md # This file
└── 🚫 .gitignore # Git ignore patterns
🔧 Core Components
MCP Server (src/index.js)
- Framework: Model Context Protocol SDK
- Transport: Standard IO (for Cursor integration)
- Database: File-based JSON storage
- AI Features: Server-initiated sampling for data generation
MCP Client (src/client.js)
- AI Engine: Google Gemini 1.5 Flash
- Interface: Interactive CLI with inquirer prompts
- Features: Tool execution, Resource queries, Prompt handling
📋 Development Guide
Available Scripts
| Command | Purpose | Description |
|---|---|---|
npm start | Production server | Start MCP server for Cursor |
npm run dev | Development mode | Auto-reload on file changes |
npm run client | Run client | Interactive MCP client |
npm run inspect | Debug server | MCP Inspector interface |
🔍 Development Workflow
# 1. Start server in dev mode
npm run dev
# 2. In another terminal, test with client
npm run client
# 3. Debug with MCP Inspector
npm run inspect
🐛 Debugging Tips
- Server not connecting? Check if port is available
- Tools not showing? Restart Cursor after server changes
- Client errors? Verify Google API key in
.envfile
🌟 Advanced Usage
Creating Custom Tools
mcpServer.tool(
"tool-name",
"Description of the tool",
{
param1: z.string(),
param2: z.number(),
},
async (params) => {
// Tool implementation
return {
content: [{ type: "text", text: "Result" }],
};
}
);
Adding Resources
mcpServer.resource(
"resource-name",
"resource://uri/pattern",
{
description: "Resource description",
mimeType: "application/json",
},
async (uri) => {
// Resource implementation
return {
contents: [{ uri: uri.href, text: "data" }],
};
}
);
🤝 Contributing
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📝 Code Style
- Use ESLint configuration provided
- Follow conventional commits format
- Add JSDoc comments for functions
- Include tests for new features
📚 Resources & Links
📄 License
This project is licensed under the MIT License - see the file for details.
⭐ Show Your Support
If this project helped you, please consider giving it a ⭐ star on GitHub!
Built with ❤️ using Model Context Protocol