GitHub·· 7 天前AI 评分60
FrontMCP 发布:用装饰器编写 MCP 服务端,本地与生产同一套代码
agentfront/frontmcp
AI 导读
FrontMCP 是一个 MCP 服务端框架,用类与装饰器定义工具,由框架处理传输、依赖注入、会话、鉴权和执行流程,同一服务端可本地与生产环境不加改动运行。
正文
Write a tool. Ship a server.
Classes in, protocol out. FrontMCP handles transport, DI, sessions, auth and execution flow, and the same server runs locally and in production unchanged.
import 'reflect-metadata'; import { App, FrontMcp, Tool, ToolContext, z } from '@frontmcp/sdk'; @Tool({ name: 'add', description: 'Adds two numbers together', 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 }, }) export default class Server {}
Start
npx frontmcp create my-app # new project (Node 24+) npx frontmcp init # or add FrontMCP to an existing one
Then follow Learn on frontmcp.dev, or browse Tools, Resources, Prompts, Agents, Auth, Plugins, Tool UI, Testing and Deployment. Try it live in the Playground.
Packages
Install frontmcp (CLI) and @frontmcp/sdk. The rest is pulled in for you, or opt-in. Keep every @frontmcp/* package on the same version; a mismatch fails fast at boot (why).
Core and extensions
| Package | What it does |
|---|---|
frontmcp |
CLI: create, init, dev, build, inspect, doctor |
@frontmcp/sdk |
Core framework: decorators, DI, flows, transport, MCP protocol |
@frontmcp/auth |
OAuth, JWKS, DCR/CIMD, sessions, credential vault |
@frontmcp/testing |
E2E test framework with fixtures and matchers |
@frontmcp/adapters |
Generate tools from an OpenAPI spec |
@frontmcp/skills |
Curated SKILL.md catalog for scaffolding and skills install |
@frontmcp/guard |
Rate limits, concurrency and policy guards |
@frontmcp/observability |
Structured logging, metrics and tracing |
@frontmcp/react |
React hooks and client for a FrontMCP server |
@frontmcp/ui / uipack |
Widgets, SSR renderers, MCP Bridge, themes |
@frontmcp/edge |
Run a server on Cloudflare Workers / V8 isolates |
@frontmcp/storage-sqlite |
SQLite session, task and elicitation stores |
@frontmcp/nx |
Nx generators and executors |
Internal, published so the above resolve: protocol, di, utils, lazy-zod.
Official plugins
| Package | What it does |
|---|---|
@frontmcp/plugin-cache |
Cache tool results with a TTL |
@frontmcp/plugin-remember |
Per-session memory (this.remember) |
@frontmcp/plugin-approval |
Human approval gates before a tool runs |
@frontmcp/plugin-codecall |
Let the model compose tool calls as code |
@frontmcp/plugin-dashboard |
Built-in web dashboard |
@frontmcp/plugin-feature-flags |
Toggle tools and apps at runtime |
@frontmcp/plugin-skilled-openapi |
OpenAPI to skills and meta-tools for big APIs |
@frontmcp/plugin-webmcp |
Expose in-page tools to browser agents (WebMCP) |
来源:GitHub · github.com