使用说明
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
- Make sure you have Python 3 and the Google Cloud CLI installed.
- 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 - Set the project for the client:
export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID export GOOGLE_CLOUD_LOCATION=global - Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate - Install the necessary dependencies from
requirements.txt:python -m pip install -r requirements.txt
Usage
-
Run the Server: Start the MCP time tool server:
python3 app.pyThe server will start and listen on
http://127.0.0.1:5000. -
Run the Client: In a separate terminal, run the example client to send a request to the server:
python3 client.pyThe client will send a request to the server and print the JSON response it receives.