fastmcp
Сообществоот punkpeye
Упрощает создание MCP серверов с помощью Pythonic интерфейса.
Установка
npm install fastmcpОписание
# FastMCP A TypeScript framework for building [MCP](https://glama.ai/mcp) servers capable of handling client sessions. > [!NOTE] > > For a Python implementation, see [FastMCP](https://github.com/jlowin/fastmcp). ## Features - Simple Tool, Resource, Prompt definition - [Authentication](#authentication) - [Passing headers through context](#passing-headers-through-context) - [Session ID and Request ID tracking](#session-id-and-request-id-tracking) - [Sessions](#sessions) - [Image content](#returning-an-image) - [Audio content](#returning-an-audio) - [Embedded](#embedded-resources) - [Logging](#logging) - [Error handling](#errors) - [HTTP Streaming](#http-streaming) (with SSE compatibility) - [Stateless mode](#stateless-mode) for serverless deployments - CORS (enabled by default) - [Progress notifications](#progress) - [Streaming output](#streaming-output) - [Typed server events](#typed-server-events) - [Prompt argument auto-completion](#prompt-argument-auto-completion) - [Sampling](#requestsampling) - [Configurable ping behavior](#configurable-ping-behavior) - [Health-check endpoint](#health-check-endpoint) - [Roots](#roots-management) - CLI for [testing](#test-with-mcp-cli) and [debugging](#inspect-with-mcp-inspector) ## When to use FastMCP over the official SDK? FastMCP is built on top of the official SDK. The official SDK provides foundational blocks for building MCPs, but leaves many implementation details to you: - [Initiating and configuring](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L664-L744) all the server components - [Handling of connections](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L760-L850) - [Handling of tools](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L1303-L1498) - [Handling of responses](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L989-L1060) - [Handling of resources](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L1151-L1242) - Adding [prompts](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L760-L850), [resources](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L960-L962), [resource templates](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L964-L987) - Embedding [resources](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L1569-L1643), [image](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L51-L111) and [audio](https://github.com/punkpeye/fastmcp/blob/06c2af7a3d7e3d8c638deac1964ce269ce8e518b/src/FastMCP.ts#L113-L173) content blocks FastMCP eliminates this complexity by providing an opinionated framework that: - Handles all the boilerplate automatically - Provides simple, intuitive APIs for common tasks - Includes built-in best practices and error handling - Lets you focus on your MCP's core functionality **When to choose FastMCP:** You want to build MCP servers quickly without dealing with low-level implementation details. **When to use the official SDK:** You need maximum control or have specific architectural requirements. In this case, we encourage referencing FastMCP's implementation to avoid common pitfalls. ## Installation ```bash npm install fastmcp ``` ## Quickstart > [!NOTE] > > There are many real-world examples of using FastMCP in the wild. See the [Showcase](#showcase) for examples. ```ts import { FastMCP } from "fastmcp"; import { z } from "zod"; // Or any validation library that supports Standard Schema const server = new FastMCP({ name: "My Server", version: "1.0.0", }); server.addTool({ name: "add", description: "Add two numbers", parameters: z.object({ a: z.number(), b: z.number(), }), execute: async (args) => { return String(args.a + args.b); }, }); server.start({ transportType: "stdio", }); ``` _That's it!_ You have a working MCP server. You can test the server in terminal with: ```bash git clone https://github.com/punkpeye/fastmcp.git cd fastmcp pnpm install pnpm build # Test the addition server example using CLI: npx fastmcp dev src/examples/addition.ts # Test the addition server example using MCP Inspector: npx fastmcp inspect src/examples/addition.ts ``` If you are looking for a boilerplate repository to build your own MCP server, check out [fastmcp-boilerplate](https://github.com/punkpeye/fastmcp-boilerplate). ### Remote Server Options FastMCP supports multiple transport options for remote communication, allowing an MCP hosted on a remote machine to be accessed over the network. #### HTTP Streaming [HTTP streaming](https://www.cloudflare.com/learning/video/what-is-http-live-streaming/) provides a more e
Отзывы (0)
Пока нет отзывов. Будьте первым!
Статистика
Информация
Технологии
Похожие серверы
GitHub MCP
Полная интеграция с GitHub API: репозитории, issues, pull requests, actions и многое другое.
Filesystem MCP
Безопасный доступ к файловой системе для чтения, записи и управления файлами с настраиваемыми разрешениями.
Context7 MCP
Доступ к актуальной документации библиотек и фреймворков.
Serena MCP
Мощный MCP сервер для семантической навигации по коду и рефакторинга.