Skip to main content
Glama
IYABAO

fastmcp-enterprise

by IYABAO

Enterprise MCP Server Template

基于 FastMCP 4.x 构建的企业级 MCP Server 脚手架:开箱即用的鉴权、限流、数据脱敏、审计日志与会话隔离,可直接部署到 Kubernetes。 An enterprise-grade Model Context Protocol server scaffold built on FastMCP: auth, rate limiting, desensitization, audit logging and session isolation out of the box, K8s-ready.

CI Python FastMCP License


为什么需要这个模板?

把 MCP Server 从「本地 Demo」推向「生产环境」,需要解决一堆协议之外的企业级问题:

关注点

本地 Demo

生产环境要求

谁能调用

随便

Token 鉴权 / 多租户隔离

调用多快

无限制

限流,防滥用

数据泄露

不关心

手机号/身份证/邮箱脱敏

出了问题

无人知晓

审计日志:谁在何时调了什么

怎么部署

本地跑

Docker / K8s / CI

这个模板把这些横切能力全部内置,你只需要关注业务 Tools

Related MCP server: mcp-server-toolkit

特性 Features

  • 🔐 企业级鉴权:Bearer Token AuthProvider(可扩展 JWT / OAuth2 / mTLS)

  • 🛡 数据脱敏:手机号、身份证、邮箱等 PII 自动脱敏(字段级 + 正则级)

  • 限流:滑动窗口限流器,按客户端维度(可替换 Redis 多实例共享)

  • 📋 审计日志:记录每次工具调用的调用方 / 时间 / 入参 / 出参

  • 🧩 会话隔离:多租户数据隔离,不同 client 只见自己的数据

  • 📦 开箱即用:自带简历检索、人才画像示例业务工具

  • 🚀 部署就绪:Dockerfile / docker-compose / K8s Deployment / GitHub Actions CI

  • 🧪 测试完备:单元 + 集成测试(13 个用例),可直接跑 CI

快速开始 Quick Start

1. 安装

git clone git@github.com:IYABAO/fastmcp-enterprise.git
cd fastmcp-enterprise
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -e ".[test]"

2. 配置

cp .env.example .env
# 按需修改 token、限流阈值等

3. 启动(HTTP 模式)

python -m enterprise_mcp.server
# 默认 http://0.0.0.0:8080/mcp

4. 用 MCP 客户端连接

from fastmcp import Client

async with Client("http://localhost:8080/mcp", auth="你的-token") as client:
    tools = await client.list_tools()          # 列出工具
    result = await client.call_tool("resume_search", {"query": {"keyword": "MCP", "min_years": 5}})

无 token 或 token 错误会被 401 拒绝

5. 本地调试(STDIO 模式)

配合 Claude Code / Cursor 本地调用:

python -m enterprise_mcp.server --stdio

项目结构 Structure

fastmcp-enterprise/
├── src/enterprise_mcp/
│   ├── server.py              # 入口:组装全部能力
│   ├── config/settings.py     # 配置管理(env / .env)
│   ├── auth/
│   │   ├── authenticator.py   # Token 校验 + 会话注册表
│   │   └── provider.py        # FastMCP AuthProvider 实现
│   ├── middleware/
│   │   ├── middleware.py      # 审计 / 脱敏 / 会话隔离 / 限流中间件
│   │   ├── desensitize.py     # PII 脱敏引擎
│   │   ├── audit.py           # 审计日志器
│   │   └── rate_limiter.py    # 滑动窗口限流器
│   └── tools/
│       └── demo_tools.py      # 示例业务工具(简历检索等)
├── deploy/
│   ├── docker/                # Dockerfile + docker-compose
│   └── k8s/                   # K8s Deployment + Service + Ingress
├── tests/                     # 单元 + 集成测试
├── examples/                  # 客户端示例
└── .github/workflows/ci.yml   # GitHub Actions

配置项 Configuration

环境变量

默认值

说明

AUTH_ENABLED

true

是否启用 Token 鉴权

API_TOKENS

dev-token-123,dev-token-456

允许的 Token 列表(逗号分隔)

RATE_LIMIT_ENABLED

true

是否启用限流

RATE_LIMIT_PER_MINUTE

60

每客户端每分钟最大请求数

DESENSITIZE_ENABLED

true

是否启用响应脱敏

DESENSITIZE_FIELDS

phone,id_card,...

需要脱敏的字段名

AUDIT_ENABLED

true

是否启用审计日志

AUDIT_OUTPUT

console

审计输出:console / file

REDIS_ENABLED

false

是否启用 Redis(跨实例限流/会话)

HOST / PORT

0.0.0.0 / 8080

HTTP 监听地址

部署 Deployment

Docker Compose

cd deploy/docker
docker compose up -d --build

Kubernetes

kubectl apply -f deploy/k8s/deployment.yaml
# 生产环境建议:
# 1. Token 通过 Secret 注入(见 deployment.yaml 注释)
# 2. Redis 开启后支持多副本共享限流
# 3. 接入 Ingress + mTLS

如何扩展你的业务 Tools

src/enterprise_mcp/tools/ 下新建模块,注册即可:

# src/enterprise_mcp/tools/my_tools.py
from pydantic import BaseModel, Field
from fastmcp import FastMCP

def register_tools(mcp: FastMCP) -> None:
    @mcp.tool()
    async def your_tool(query: YourQuery) -> dict:
        """你的工具描述(LLM 会看到)。"""
        return {"result": "..."}

然后在 server.py 中调用 register_tools(mcp)

测试 Tests

pytest tests/ -v
# 13 passed

Roadmap

  • Redis 多实例限流 / 会话共享实现

  • JWT / OAuth2 鉴权 Provider 示例

  • Prometheus 指标暴露

  • OpenTelemetry 链路追踪

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A production-ready MCP server scaffold that features built-in authentication, Docker support, and a comprehensive CI/CD release pipeline. It provides a standardized template for deploying servers with multi-transport support and configurable read-only modes.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Production-ready MCP server starter with authentication, observability, and a plugin system for building and deploying MCP servers quickly.
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    A production-ready foundation for building secure, observable MCP servers with built-in authentication, rate limiting, and reference tools like database-query and semantic-search.
    15
    37
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    A production-grade MCP server providing a secure, natural-language interface to Kubernetes for developers and AI agents, with multi-cluster routing, OIDC authentication, RBAC, and audit logging.
    75
    53
    1
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/IYABAO/fastmcp-enterprise'

If you have feedback or need assistance with the MCP directory API, please join our Discord server