Getting Started
Create your first MCP server with ModelFetch in minutes
Automatic Installation
The quickest way to get started with ModelFetch is to use our create-modelfetch
CLI. It sets up everything you need in seconds.
npx -y create-modelfetch@latest
The CLI will guide you through:
- Choosing a runtime - Node.js, Bun, Deno, AWS Lambda, Vercel, Cloudflare, or Netlify
- Selecting a language - TypeScript or JavaScript
- Picking a package manager - npm, pnpm, bun, or yarn
Manual Installation
If you prefer to set up manually, install the ModelFetch package for your runtime:
npm install @modelfetch/node
Then, create the following files:
Server File
Create a server file to define your McpServer
using the official MCP TypeScript SDK:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
const server = new McpServer({
title: "My MCP Server",
name: "my-mcp-server",
version: "1.0.0",
});
server.registerTool(
"roll_dice",
{
title: "Roll Dice",
description: "Rolls an N-sided dice",
inputSchema: { sides: z.number().int().min(2) },
},
({ sides }) => ({
content: [
{
type: "text",
text: `🎲 You rolled a ${1 + Math.floor(Math.random() * sides)}!`,
},
],
}),
);
export default server;
Entry Point File
Create an entry point file to run your McpServer
using the ModelFetch package for your runtime:
import handle from "@modelfetch/node"; // Choose your runtime
import server from "./server"; // Import your server
handle(server); // Let ModelFetch handle all runtime-specific details
See Runtime Packages for runtime-specific guides, examples, and API references.