Development Guide
Learn how to develop, build, and test your MCP servers with ModelFetch's powerful development tools and workflow.
Development Server
The development server provides live reload, automatic TypeScript compilation, and real-time testing capabilities for your MCP server.
Development server features:
Automatic TypeScript compilation Live reload on file changes Real-time error reporting Source map support for debugging
The development server runs your MCP server in a local environment where you can test and debug your tools before deployment. Any changes to your source code will automatically restart the server.
Building Your MCP Server
Build your MCP server for production or testing with the build command:
This creates an optimized, minified bundle in the dist/
directory:
Build optimizations:
Code minification and tree shaking
External Node.js modules are excluded
TypeScript compilation with type checking
ESM format for modern environments
Source maps for production debugging
Writing MCP Tools
MCP tools are the core functionality of your server. Here's how to create them:
Tool best practices:
Use descriptive tool names and descriptions
Validate input parameters with Zod schemas
Handle errors gracefully and return meaningful messages
Use async/await for asynchronous operations
Return structured content with appropriate types
Type System: The Options
type and other ModelFetch types are automatically available through the triple-slash reference /// <reference types="@modelfetch/node" />
in your src/env.d.ts
file. This eliminates the need to explicitly import types in your implementation files.
Testing Your MCP Server
There are several ways to test your MCP server during development:
Local Testing with AI Clients
Start your MCP server locally (either in development or production mode) and connect it to AI clients for testing:
Once your MCP server is running locally, you can connect it to AI clients that support MCP servers. Here are some popular options:
MCP Inspector (recommended)
A dedicated testing tool for MCP servers with a graphical interface.
Cursor
Add to your Cursor MCP configuration file:
Windsurf
Add to your Windsurf MCP configuration file:
VS Code
Add to your VS Code MCP configuration file:
Claude Desktop
Add to your Claude Desktop configuration file:
Connection: All clients connect to your running MCP server via http://localhost:33333/mcp
. Some older MCP clients only support the SSE protocol, if your client doesn't work with /mcp
, try using /sse
instead. Make sure your MCP server is running before connecting the AI clients. If you've configured a different port using the PORT
environment variable, update the URL accordingly.
Available Scripts
Your MCP server project comes with these npm scripts:
Script | Command | Description |
---|
npm run deploy | modelfetch deploy | Deploy to ModelFetch platform |
npm run dev | modelfetch dev | Start development server |
npm run build | modelfetch build | Build production server |
npm start | node dist/__modelfetch__.js | Run the production server locally |
Environment Variables
Use environment variables for configuration that changes between environments:
Create a .env
file for local development:
Security: Never commit .env
files or sensitive credentials to version control. Use environment variables for production deployment.
Next Steps
Now that you understand the development workflow, you can:
Ready to ship? Your development workflow is complete! Test your MCP server thoroughly with AI clients, then deploy to production when you're confident in your implementation.