Token导航 LogoToken导航TokenDH.com
Field Template MCP logo
运维云端stdio官方级别未说明来源级核验

Field Template MCP

MCP Server

一个基于FastMCP的AI模型上下文协议服务器模板,支持Docker部署、环境变量配置和内置AI文本摘要工具,适用于快速构建和部署AI服务。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
AI服务PythonFastMCPDocker

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

OmniMCP-AI

提供方

OmniMCP-AI

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -e .

详细介绍

AI字段模板

使用FastMCP构建模型上下文协议(MCP)服务器的模板。

特性

  • 🚀 基于FastMCP的服务器实现
  • 🐳 Docker和Docker Compose支持
  • 📦 使用pyproject.toml配置Python包
  • 🔧 环境变量配置
  • 📁 组织良好的文件夹结构
  • 🤖 使用OpenAI/OpenRouter的内置AI文本摘要工具
  • 🧪 具有SSE客户端支持的全面测试套件

项目结构

.
├── docs/           # Documentation files
├── tests/          # Test files
├── src/            # Source code
├── main.py         # Main entry point
├── pyproject.toml  # Python project configuration
├── Dockerfile      # Docker configuration
├── docker-compose.yml
├── .env            # Environment variables
├── .gitignore      # Git ignore rules
└── README.md       # This file

安装

使用pip

pip install -e .

使用Docker

docker-compose up --build

用法

在本地运行

# stdio mode (default)
python main.py

# HTTP mode (default port: 8322)
python main.py --transport streamable-http --port 8322

使用Docker运行

# Build and run
docker-compose up --build

# Run in detached mode
docker-compose up -d

# Stop the container
docker-compose down

服务器将在以下时间可用 http://localhost:8322

配置

创建一个 .env 示例中的文件:

cp env.example .env

编辑 .env 文件以配置API密钥:

OpenRouter配置

如果你想使用 OpenRouter 用于访问多个LLM提供商:

可用工具

1.分类_by_llm

使用LLM将每个输入精确地分类到一个最匹配的类别中。

参数:

  • input (列表):要分类的项目
  • categories (list\[str\]):可能的类别(互斥,至少2个)
  • prompt (str,可选):自定义分类说明
  • args (dict,可选):附加配置(型号、温度等)

例子:

result = await session.call_tool(
    "classify_by_llm",
    {
        "input": ["Apple releases iPhone", "Lakers win game"],
        "categories": ["tech", "sports", "politics"]
    }
)
# Returns: [{"id": 0, "result": "tech"}, {"id": 1, "result": "sports"}]

2.标签_by_llm

将预定义集合中的多个相关标签应用于每个输入。

参数:

  • input (列表):要标记的项目
  • tags (list\[str\]):可能的标签(非互斥)
  • prompt (str,可选):自定义标记说明
  • args (dict,可选):附加配置(max_tags、min_relevance等)

例子:

result = await session.call_tool(
    "tag_by_llm",
    {
        "input": ["Python REST API", "React app"],
        "tags": ["python", "javascript", "backend", "frontend"]
    }
)
# Returns: [{"id": 0, "result": ["python", "backend"]}, ...]

3.提取物_by_llm

使用LLM从非结构化文本中提取特定字段。

参数:

  • input (列表):要提取的项目
  • fields (list\[str\],可选):要提取的字段名
  • response_format (dict,可选):用于结构化输出的JSON模式
  • args (dict,可选):附加配置(型号、温度等)

例子:

result = await session.call_tool(
    "extract_by_llm",
    {
        "input": ["Article by Wade on 2025-10-12"],
        "fields": ["author", "date"]
    }
)
# Returns: [{"id": 0, "result": {"author": "Wade", "date": "2025-10-12"}}]

测试

该项目包括对所有MCP工具的全面测试。

运行测试

# Make sure the server is running first
python main.py --transport streamable-http --port 8322

# In another terminal, run the tests
# Run all tests
rye run python tests/test_mcp_client.py --env=local --test=all

# Run specific test
rye run python tests/test_mcp_client.py --env=local --test=classify
rye run python tests/test_mcp_client.py --env=local --test=tag
rye run python tests/test_mcp_client.py --env=local --test=extract

# Test against a remote server
rye run python tests/test_mcp_client.py --env=remote --url=https://your-server.com --test=all

测试要求

为了使LLM工具测试工作,您需要:

  1. OPENAI_API_KEY 在你的 .env 文件(请参阅env.example)
  2. 可选配置 OPENAI_BASE_URL 适用于OpenRouter
  3. 确保服务器在端口8322上运行

发展

项目设置

  1. 克隆此仓库
  2. 安装依赖项: pip install -e .
  3. 在中配置环境变量 .env
  4. 开始开发 src/ 目录

添加工具

在中添加您的MCP工具 main.py 或在中创建单独的模块 src/ 目录:

@mcp.tool()
def your_tool(param: str) -> str:
    """
    Description of your tool.
    
    Args:
        param: Parameter description
    
    Returns:
        Result description
    """
    # Your implementation
    return result

Docker支持

模板包括:

  • Dockerfile:采用安全最佳实践的多阶段构建
  • docker-compose.yml:容器编排简单
  • 非root用户:出于安全考虑,以无特权用户身份运行
  • 健康检查:内置健康监测

需求

  • Python>=3.11
  • 快速MCP>=2.3.3
  • Docker(可选)

许可证

MIT许可证

贡献

欢迎投稿!请随时提交拉取请求。

目录标签

目录标签

AI服务PythonFastMCPDocker本地部署Docker部署文本摘要Python开发

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosession部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP