Skip to main content
Glama
Utility MCP Server

Utility MCP Server

MCP Server - 通用功能服务器

一个基于 Model Context Protocol (MCP) 的通用功能服务器,为 AI 提供扩展能力。

支持 本地模式 (stdio) 与 远程模式 (Streamable HTTP / SSE) 双模式运行,并可将 ChatBI -> MCP -> Langfuse 的观测链路串起来。

✨ 功能

🕐 时间工具

工具

描述

get_current_time

获取指定时区的当前时间

get_timestamp

获取当前 Unix 时间戳

format_timestamp

将时间戳转换为可读格式

📊 ChatBI 数据分析工具

工具

描述

schema_search

基于向量召回 + 关键词检索返回项目相关 Schema

execute_sql

执行只读 PostgreSQL 查询并返回 JSON 结果

🔭 Langfuse 链路观测

  • schema_search 会记录嵌套阶段:分词、Embedding、向量检索、关键词检索、融合裁剪。

  • execute_sql 会记录嵌套阶段:SQL Guardrail 校验、SQL 执行。

  • 当上游 ChatBI 通过 traceparent 和 x-chatbi-* 头透传上下文时,MCP 工具观测会自动挂到同一条 Langfuse Trace 下。

Related MCP server: Time

🚀 快速开始

安装依赖

uv sync

本地模式运行

uv run mcp-server

远程模式运行(默认推荐)

uv run mcp-server --remote --transport streamable-http --port 8000

启动后可访问:

  • MCP: http://localhost:8000/mcp

  • Health: http://localhost:8000/health

  • SSE 兼容端点: http://localhost:8000/sse

SSE 兼容模式

uv run mcp-server --remote --transport sse --port 8000

🔌 客户端集成

本地模式配置

适用于 Cursor / Claude Desktop:

{
  "mcpServers": {
    "utility-server": {
      "command": "uv",
      "args": ["--directory", "/path/to/mcp-server", "run", "mcp-server"]
    }
  }
}

远程模式配置

ChatBI / LangChain4j

直接连接 Streamable HTTP 端点:

http://your-server:8000/mcp

兼容 mcp-remote 的 SSE 客户端

{
  "mcpServers": {
    "utility-server": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "http://your-server:8000/sse"]
    }
  }
}

🐳 Docker 部署

使用 Docker Compose(推荐)

docker compose up -d

docker compose logs -f

docker compose down

手动 Docker 命令

docker build -t mcp-server .

docker run -d -p 8000:8000 --name mcp-server mcp-server

docker run -d -p 9000:9000 -e PORT=9000 --name mcp-server mcp-server

🔐 Langfuse 配置

在 .env 中配置:

LANGFUSE_ENABLED=true
LANGFUSE_HOST=https://cloud.langfuse.com
LANGFUSE_PUBLIC_KEY=pk-lf-xxxx
LANGFUSE_SECRET_KEY=sk-lf-xxxx
LANGFUSE_ENVIRONMENT=production
MCP_SERVER_RELEASE=2026.03.09

如果未配置 Langfuse 凭证,服务仍可正常提供 MCP 工具,只是不会上报 tracing 数据。

🧪 开发测试

uv run mcp dev src/mcp_server/server.py
uv run mcp-server --help

📖 架构说明

ChatBI Java Service
    |
    |  traceparent + x-chatbi-* headers
    v
External MCP Server (/mcp)
    |
    |-- schema_search
    |     |-- tokenize
    |     |-- embedding
    |     |-- vector_search
    |     |-- keyword_search
    |     `-- fusion
    |
    `-- execute_sql
          |-- validate
          `-- query

All observations -> Langfuse

📄 许可证

MIT

Available Tools

3 tools
format_timestampA
将Unix时间戳转换为指定时区的可读时间格式

Args:
    timestamp: Unix时间戳(秒)
    timezone: 目标时区名称,默认为中国标准时间

Returns:
    格式化的时间字符串,格式为: YYYY-MM-DD HH:MM:SS 时区

Raises:
    ValueError: 当时区名称无效或时间戳不合法时

Inputs: timestamp (required), timezone. Returns: result

get_current_timeA
获取指定时区的当前时间

当AI需要知道当前时间时可以调用此工具。
支持世界各地的时区,默认使用中国标准时间。

Args:
    timezone: 时区名称,常用时区包括:
        - Asia/Shanghai (中国标准时间)
        - UTC (协调世界时)
        - America/New_York (美国东部时间)
        - Europe/London (英国时间)
        - Asia/Tokyo (日本时间)

Returns:
    格式化的当前时间字符串,格式为: YYYY-MM-DD HH:MM:SS 时区

Raises:
    ValueError: 当提供的时区名称无效时

Inputs: timezone. Returns: result

get_timestampA
获取当前Unix时间戳(秒)

返回从1970年1月1日00:00:00 UTC至今的秒数。
这个值在全球任何时区都是相同的。

Returns:
    当前的Unix时间戳(整数,单位为秒)

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: format_timestamp converts a given timestamp to a readable format, get_current_time retrieves the current time in a specified timezone, and get_timestamp returns the current Unix timestamp. There is no overlap in functionality, making it easy for an agent to select the correct tool based on the need.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern (format_timestamp, get_current_time, get_timestamp) using snake_case. The naming is predictable and readable, with no deviations or mixed conventions.

    Tool Count5/5

    With 3 tools, the server is well-scoped for its utility purpose focused on time-related operations. Each tool earns its place by covering distinct aspects of time handling, avoiding bloat or thinness.

    Completeness5/5

    The tool set provides complete coverage for time-related utilities: formatting timestamps, getting current time in timezones, and obtaining Unix timestamps. There are no obvious gaps, and agents can handle common time queries without dead ends.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      The Time MCP Server is a Model Context Protocol (MCP) server that provides AI assistants and other MCP clients with standardized tools to perform time and date-related operations. This server acts as a bridge between AI tools and a robust time-handling back
      167 npm
      25
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A self-contained, dependency-free MCP server that provides utility tools for time, date, mathematical calculations, and shell command execution. It supports remote connectivity through SSE and is designed for easy deployment via Docker.
      GPL 3.0
    • A
      license
      D
      quality
      C
      maintenance
      A lightweight MCP server that provides date and time tools, including the ability to retrieve current timestamps and parse date strings with IANA timezone support. It enables AI models to interact with the host OS clock and perform temporal calculations via stdio transport.
      3
      10 npm
      7
      MIT