Labsco
mcpdotdirect logo

Template MCP Server

โ˜… 75

from mcpdotdirect

A CLI template for quickly bootstrapping an MCP server with FastMCP, supporting both stdio and HTTP transport.

๐Ÿ”ฅโœ“ VerifiedFreeNeeds API keys

@mcpdotdirect/template-mcp-server

A CLI tool to quickly get started building your very own MCP (Model Context Protocol) server using FastMCP

๐Ÿ”ญ What's Included

The template includes:

  • Basic server setup with both stdio and HTTP transport options using FastMCP
  • Structure for defining MCP tools, resources, and prompts
  • TypeScript configuration
  • Development scripts and configuration

โœจ Features

  • FastMCP: Built using the FastMCP framework for simpler implementation
  • Dual Transport Support: Run your MCP server over stdio or HTTP
  • TypeScript: Full TypeScript support for type safety
  • Extensible: Easy to add custom tools, resources, and prompts

๐Ÿ› ๏ธ Adding Custom Tools and Resources

When adding custom tools, resources, or prompts to your FastMCP server:

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}!`;
  }
});

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}`
    };
  }
});

Prompts

server.addPrompt({
  name: "greeting",
  description: "A simple greeting prompt",
  arguments: [
    {
      name: "name",
      description: "Name to greet",
      required: true,
    },
  ],
  load: async ({ name }) => {
    return `Hello, ${name}! How can I help you today?`;
  }
});

๐Ÿ“š Documentation

For more information about FastMCP, visit FastMCP GitHub Repository.

For more information about the Model Context Protocol, visit the MCP Documentation.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.