Introduction
Create your first MCP server in minutes with ModelFetch's CLI tools. This guide will walk you through setting up a new project, understanding the structure, and running your server locally.
Prerequisites
Before you begin, make sure you have Node.js 22 installed on your system. You'll also need a package manager like npm, pnpm, bun, or yarn.
Step 1: Create Your MCP Server
Use the create-modelfetch
CLI to scaffold a new MCP server project:
This command will create a new directory with your project name, scaffold the project structure, and install all necessary dependencies automatically.
What happens during creation:
Creates project directory structure Installs TypeScript and MCP dependencies Sets up development and build scripts Generates example MCP server code
Step 2: Navigate to Your Project
Step 3: Understanding the Project Structure
Your new MCP server project will have this structure:
Key files explained:
src/index.ts
- Main MCP server implementation with example toolssrc/env.d.ts
- TypeScript environment declarations and global type referencespackage.json
- Contains scripts for development, building, and deployment
Step 4: Examine the Example Code
The generated src/index.ts
file contains a complete example MCP server:
The src/index.ts
file:
The src/env.d.ts
file:
This example demonstrates the basic structure of an MCP server with a simple tool that rolls a dice. The Options
type is automatically available through the triple-slash reference in env.d.ts
, eliminating the need for explicit imports. You can modify this code to implement your own business logic and tools.
Step 5: Start Development Server
Start the development server to test your MCP server locally:
What happens in development mode:
TypeScript files are compiled automatically
Server restarts on code changes (live reload)
Your MCP server runs on port 33333 (default)
Ready to connect with AI clients for testing
Step 6: Test Your MCP Server
Once your development server is running, you can test your MCP server by connecting it to AI clients. Your server is available at http://localhost:33333/mcp
and ready for connections.
Here are some popular ways to test your MCP server:
MCP Inspector (recommended)
A dedicated testing tool with an intuitive graphical interface:
AI Editors (Cursor, VS Code, etc.)
Add to your MCP configuration file:
Test your tools: Once connected, try using the example dice rolling tool or any custom tools you've implemented. The MCP Inspector is the easiest way to test individual tools and see their responses. For more testing options and detailed client configurations, check out our development guide.
Next Steps
Congratulations! You now have a working MCP server. Here's what you can do next:
Need help? Check out our CLI reference for detailed command documentation, or reach out to our support team.