@frontmcp/sdk

中文文档
1.12.2发布于 2026/11/15Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 4.4万

TypeScript framework for building MCP servers: tools, resources and prompts as decorated classes, with transports, sessions, auth and dependency injection

原始使用文档
文档目录7 节
  1. Install
  2. A server in one file
  3. What the SDK covers
  4. Compared with other frameworks
  5. Related packages
  6. Contributing
  7. License

@frontmcp/sdk

The core of FrontMCP, a TypeScript framework for building Model Context Protocol (MCP) servers. You write tools, resources and prompts as decorated classes; the SDK handles the protocol, the transports, sessions, authentication, dependency injection and the request pipeline. The same server runs on your machine, in Docker, on Vercel or AWS Lambda, and on Cloudflare Workers.

Use it to build an MCP server, or to run one inside another program. The frontmcp CLI creates, runs, tests and builds the project around it.

npm Node License

Install

Start a new project with the CLI, which sets everything up:

npx frontmcp create my-app

Or add the SDK to a project you already have:

npm install @frontmcp/sdk reflect-metadata
npm install -D frontmcp typescript @types/node@^24
npx frontmcp init

FrontMCP needs Node.js 24 or later. frontmcp init turns on experimentalDecorators and emitDecoratorMetadata in tsconfig.json. Import reflect-metadata once, at the top of your entry file, before anything from FrontMCP.

npm and pnpm install the SDK's required peer dependencies (express, cors, content-type and raw-body) for you; with Yarn, add them yourself. The optional ones turn on features:

InstallTo
@frontmcp/storage-sqliteKeep sessions, tasks and events in SQLite
@frontmcp/observability, @opentelemetry/api, @opentelemetry/sdk-trace-baseTrace and log requests with OpenTelemetry
openai or @anthropic-ai/sdkRun an @Agent on OpenAI or Anthropic models
@enclave-vm/coreRun dynamic jobs (scripts) in a sandbox

A server in one file

import 'reflect-metadata';

import { App, FrontMcp, Tool, ToolContext, z } from '@frontmcp/sdk';

@Tool({
  name: 'add',
  description: 'Add two numbers',
  inputSchema: { a: z.number(), b: z.number() },
})
class AddTool extends ToolContext {
  async execute(input: { a: number; b: number }) {
    return input.a + input.b;
  }
}

@App({ id: 'calc', name: 'Calculator', tools: [AddTool] })
class CalcApp {}

@FrontMcp({
  info: { name: 'Demo', version: '0.1.0' },
  apps: [CalcApp],
  http: { port: 3000, entryPath: '/mcp' },
})
export default class Server {}

Save it as src/main.ts and run npx frontmcp dev. The server reloads when you edit it, and answers MCP requests at http://localhost:3000/mcp (at / without entryPath). Try it with the MCP Inspector, npx frontmcp inspector, or add it to Claude Code:

claude mcp add --transport http demo http://localhost:3000/mcp

A tool is a class: @Tool describes it to the model, inputSchema validates its input with Zod (the SDK exports z), and execute returns the result. An @App groups tools, resources, prompts and providers, and @FrontMcp is the server. The Quick Start walks through each piece.

What the SDK covers

AreaWhat you useDocs
Server and apps@FrontMcp, @AppServer, Apps
What clients call@Tool, @Resource, @ResourceTemplate, @Prompt, @SkillTools, Resources, Prompts, Skills
Work that takes time@Agent, @Job, @Workflow, background tasksAgents, Jobs, Workflows, Tasks
Your own code@Provider (dependency injection), hooks, @Plugin, @AdapterProviders, Hooks, Plugins
Who may callAuth modes (public, static keys, transparent JWT, local or remote OAuth), sessions, authoritiesAuthentication
ProtocolEvery MCP revision from 2024-11-05 to 2026-07-28 on one endpoint, chosen per requestProtocol versions
Running itStreamable HTTP or stdio; in process with create(); as tools for OpenAI, Claude, LangChain and the Vercel AI SDK with connect*()Deployment, create(), connect()

The SDK reference lists every decorator, context method and option.

Compared with other frameworks

TypeScript MCP server frameworks for production compares FrontMCP with the official TypeScript SDK, FastMCP, mcp-framework, mcp-use, ViteMCP and xmcp, on auth, testing, protocol support and deployment. To move a server over, see Migrate from the TypeScript SDK and Migrate from FastMCP. Longer guides and measurements are on the blog.

Keep every @frontmcp/* package on the same version: they depend on each other at exact versions.

Contributing

Source: libs/sdk. Issues and pull requests are welcome; see CONTRIBUTING.md.

License

Apache-2.0. See LICENSE.

版本与发布记录

@frontmcp/sdk 共发布 129 个版本,首次发布于 2025/11/05;过去 12 个月发布了 119 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.12.2latest2026/11/151 天前
1.12.12026/11/132 天前
1.12.02026/11/114 天前
1.12.0-rc.1rc2026/11/114 天前
1.11.32026/11/106 天前
1.11.22026/11/096 天前

其他发布通道:beta → 1.1.2-beta.1,rc → 1.12.0-rc.1。

关于 @frontmcp/sdk 的常见问题

@frontmcp/sdk 是什么?

TypeScript framework for building MCP servers: tools, resources and prompts as decorated classes, with transports, sessions, auth and dependency injection

如何安装 @frontmcp/sdk?

在项目目录运行 npm install @frontmcp/sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:cors(^2.8.5)、express(^4.18.0 || ^5.0.0)、raw-body(^3.0.0)、content-type(^1.0.5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@frontmcp/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@frontmcp/sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@frontmcp/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@frontmcp/sdk 可以商用吗?

@frontmcp/sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@frontmcp/sdk 的下载量有多少?

根据 npm 官方下载统计,@frontmcp/sdk 在 2026/10/16 – 2026/11/14 这 30 天内被下载 44,309 次,日均约 1,477 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frontmcp/sdk 还在维护吗?

最新版本 1.12.2 发布于 2026/11/15(1 天前);至今共发布 129 个版本,其中过去 12 个月发布了 119 个;首次发布于 2025/11/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。