时间查询工具

MCP Time Tool 是一款面向 AI 应用的轻量级时间查询服务,通过单一端点提供当前日期与时间信息,适用于需要实时时间数据的集成与自动化场景。

  • by vreyespue
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 vreyespue/mcp-tool-test

使用说明

MCP Time Tool

This project is a simple, self-contained example of an MCP-based "Time Tool" server. It's built with Python and Flask.

The server provides a single endpoint that an AI application can call to get the current date and time.

Setup

  1. Make sure you have Python 3 and the Google Cloud CLI installed.
  2. Authenticate with Application Default Credentials using Vertex AI:
    gcloud auth application-default login
    gcloud auth application-default set-quota-project YOUR_PROJECT_ID
    gcloud services enable aiplatform.googleapis.com --project YOUR_PROJECT_ID
    
  3. Set the project for the client:
    export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID
    export GOOGLE_CLOUD_LOCATION=global
    
  4. Create and activate a virtual environment:
    python3 -m venv .venv
    source .venv/bin/activate
    
  5. Install the necessary dependencies from requirements.txt:
    python -m pip install -r requirements.txt
    

Usage

  1. Run the Server: Start the MCP time tool server:

    python3 app.py
    

    The server will start and listen on http://127.0.0.1:5000.

  2. Run the Client: In a separate terminal, run the example client to send a request to the server:

    python3 client.py
    

    The client will send a request to the server and print the JSON response it receives.