MCP Framework

0.2.22 · active · verified Sun Apr 19

MCP-Framework is a TypeScript-first development framework designed for building Model Context Protocol (MCP) servers with reduced boilerplate compared to the official SDK. Currently at version 0.2.22, the package maintains a rapid release cadence, with multiple minor versions published frequently, indicating active and ongoing development towards its 1.0 stable release. Key differentiators include CLI scaffolding for quick project setup, an elegant class-based approach for defining tools, resources, and prompts, and integrated Zod validation for schemas. It offers built-in authentication mechanisms (JWT, API Key, OAuth 2.1) and supports multiple transports like stdio, SSE, and HTTP Stream, with explicit support for serverless environments like AWS Lambda. The framework focuses on automatic discovery and loading of server components, providing full type inference and simplifying complex AI agent integrations.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install the global CLI, scaffold a new MCP server project, install dependencies, add a new class-based tool using the `@tool` decorator and Zod schemas, and then build and run the server.

npm install -g mcp-framework

# Create a new MCP server project (default uses stdio transport)
mcp create my-mcp-server

# Navigate to your project directory
cd my-mcp-server

# Install project dependencies
npm install

# Add a new tool to your project
mcp add tool price-fetcher

# Open src/tools/price-fetcher.ts and define your tool logic using Zod for schema validation:
// import { Tool, tool } from '@mcp-framework/core';
// import { z } from 'zod';
//
// @tool({
//   name: 'fetchStockPrice',
//   description: 'Fetches the current stock price for a given ticker symbol.',
//   inputSchema: z.object({
//     ticker: z.string().describe('The stock ticker symbol (e.g., AAPL).'),
//   }),
//   outputSchema: z.object({
//     price: z.number().describe('The current stock price.'),
//     currency: z.string().describe('The currency of the price.'),
//   }),
// })
// export class PriceFetcherTool extends Tool<typeof PriceFetcherTool> {
//   async execute({ ticker }: z.infer<typeof PriceFetcherTool.inputSchema>) {
//     // In a real application, this would call an external API
//     console.log(`Fetching price for ${ticker}...`);
//     const price = Math.random() * 1000 + 10;
//     return { price: parseFloat(price.toFixed(2)), currency: 'USD' };
//   }
// }

# Build and run your server
npm run build
npm start

view raw JSON →