Skip to main content
Glama
data-tool-xjc

data-tool-xjc

data-tool-xjc

一个基于 MCP(Model Context Protocol) Python SDK 的最小 MCP Server 示例,通过 stdio 传输向大模型客户端暴露工具能力。

仓库地址:https://github.com/xjc12138-shift/MCP12138

功能

工具名

描述

返回值

get_time

返回当前的年月日

形如 2026-11-26 的字符串

Related MCP server: datetime-mcp-server

目录结构

.
├── mcp-server-stdio.py   # MCP Server 入口,定义工具并启动 stdio 服务
├── requirements.txt      # 依赖清单
├── chatmcp.yaml          # MCP 托管/发布描述文件
├── LICENSE
└── README.md

环境要求

  • Python 3.10+

  • 依赖:mcp>=1.28.1

安装

从源码安装:

git clone https://github.com/xjc12138-shift/MCP12138.git
cd MCP12138
pip install -r requirements.txt

运行

python mcp-server-stdio.py

启动后进程会以 stdio 方式等待 JSON-RPC 消息,不要手动在终端输入内容,应由 MCP 客户端连接。直接在终端运行看起来像“卡住”,属于正常现象。

工具说明

get_time() 无需参数,返回服务器本地时区的当前日期:

@mcp.tool()
def get_time():
    """返回当前的年月日,格式YYYY-MM-DD"""
    return datetime.now().strftime('%Y-%m-%d')

接入 MCP 客户端

方式一:Claude Desktop / 兼容客户端配置

{
  "mcpServers": {
    "data-tool-xjc": {
      "command": "python",
      "args": ["/absolute/path/to/MCP12138/mcp-server-stdio.py"]
    }
  }
}

方式二:LangChain / LangGraph 客户端

from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient({
    "data-tool-xjc": {
        "transport": "stdio",
        "command": "python",
        "args": ["mcp-server-stdio.py"],
    }
})

tools = await client.get_tools()

注意事项

  • command 建议使用当前环境的绝对路径(例如 E:\soft\Anaconda\envs\env\python.exe),避免因 PATH 找不到解释器导致 FileNotFoundError。

  • stdio 传输只适合本地进程调用,如需公网共享请改用 streamable_http 或 SSE 传输。

  • 若客户端报 Connection closed,先在终端用同样的 command + args 手动启动一次,确认服务端没有启动即退出的错误。

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol server built with FastMCP that provides tools for retrieving the current local date and time. It allows LLMs to access precise temporal information directly from the host environment.
      9
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides a tool to retrieve the current date and time with customizable formatting placeholders for year, month, day, hour, minute, and second. It supports both stdio and HTTP transport modes for integration with Model Context Protocol clients.
      1
      16 npm
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Minimal MCP server exposing a single tool, run_date, to execute the local date command via a Streamable HTTP endpoint.
      -