Back to MCP Catalog

Template MCP Server

Developer ToolsTypeScript
A template for quickly creating your own Model Context Protocol server
Available Tools

hello_world

Example tool that demonstrates the basic structure of an MCP tool

name

The MCP Server Template provides a streamlined foundation for building custom Model Context Protocol (MCP) servers using the FastMCP framework. It offers dual transport support for both stdio and HTTP communication, allowing developers to create tools that can be used locally or shared across a team. With TypeScript integration and a well-structured codebase, this template simplifies the process of extending AI capabilities with custom tools, resources, and prompts.

Overview

The MCP Server Template is a CLI tool designed to help you quickly set up and build your own Model Context Protocol (MCP) server using the FastMCP framework. This template provides everything you need to create custom AI tools that can be integrated with Cursor and other MCP-compatible clients.

Installation

You can create a new MCP server project using one of the following methods:

# Using npx
npx @mcpdotdirect/create-mcp-server

# Using npm
npm init @mcpdotdirect/mcp-server

After creating your project, install the dependencies:

# Using npm
npm install

# Using yarn
yarn

# Using pnpm
pnpm install

# Using bun
bun install

Running Your MCP Server

The template supports two transport methods:

stdio Transport (Command Line Mode)

This mode runs on your local machine and communicates via stdout:

# Start the stdio server
npm start

# Development mode with auto-reload
npm run dev

HTTP Transport (Web Mode)

This mode runs as an HTTP server that can be accessed locally or remotely:

# Start the HTTP server
npm run start:http

# Development mode with auto-reload
npm run dev:http

By default, the HTTP server runs on port 3001. You can change this by setting the PORT environment variable:

PORT=8080 npm run start:http

Connecting to Your MCP Server

From Cursor

  1. Open Cursor and go to Settings (gear icon)
  2. Click on "Features" in the left sidebar
  3. Scroll down to "MCP Servers" section
  4. Click "Add new MCP server"
  5. Enter the server details:
    • For stdio mode:
      • Type: command
      • Command: The path to your server executable, e.g., npm start
    • For HTTP mode:
      • Type: url
      • URL: http://localhost:3001/sse

Using mcp.json Configuration

For a more portable configuration, create an .cursor/mcp.json file in your project:

{
  "mcpServers": {
    "my-mcp-stdio": {
      "command": "npm",
      "args": ["start"],
      "env": {
        "NODE_ENV": "development"
      }
    },
    "my-mcp-sse": {
      "url": "http://localhost:3001/sse"
    }
  }
}

You can also create a global configuration at ~/.cursor/mcp.json to make your MCP servers available in all workspaces.

Customizing Your MCP Server

The template provides a structured way to add custom tools, resources, and prompts:

Adding Custom Tools

Edit the server configuration to add your own tools:

server.addTool({
  name: "hello_world",
  description: "A simple hello world tool",
  parameters: z.object({
    name: z.string().describe("Name to greet")
  }),
  execute: async (params) => {
    return `Hello, ${params.name}!`;
  }
});

Adding Resources

server.addResourceTemplate({
  uriTemplate: "example://{id}",
  name: "Example Resource",
  mimeType: "text/plain",
  arguments: [
    {
      name: "id",
      description: "Resource ID",
      required: true,
    },
  ],
  async load({ id }) {
    return {
      text: `This is an example resource with ID: ${id}`
    };
  }
});

Adding Prompts

server.addPrompt({
  name: "greeting",
  description: "A simple greeting prompt",
  arguments: [
    {
      name: "name",
      description: "Name to greet",
      required: true,
    },
  ],
  template: "Hello, {{name}}! How can I assist you today?"
});

Testing Your Server

FastMCP provides built-in tools for testing:

# Test with mcp-cli
npx fastmcp dev server.js

# Inspect with MCP Inspector
npx fastmcp inspect server.ts

Related MCPs

Apple Shortcuts
Developer ToolsJavaScript

Control Apple Shortcuts automations from AI assistants

Clojars Dependency Lookup
Developer ToolsJavaScript

Fetch dependency information from Clojars, the Clojure community's artifact repository

Simple Timeserver
Developer ToolsPython

Provides Claude with current time and timezone information

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.