bmullan-code/stock-mcp
If you are the rightful owner of stock-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Model Context Protocol (MCP) server is a specialized server designed to handle model context requests, providing a structured and efficient way to manage and deploy machine learning models in various environments.
Stock-mcp
Simple MCP server example with deployment instructions for GCP Cloud Run.
Server get_stock_price function from Bo Yangs '2 Min Adk' article
Setup
Install the gcloud cli https://cloud.google.com/sdk/docs/install and authenticate with
gcloud auth application-default login
Setup python environment
# setup python environment
python -m venv .venv
pip install uv
pip install -r requirements.txt
Build & Deploy
In the GCP console go to Artifact Registry and locate or create an artifact (docker) repository. Copy the path to the repository. Will look something like this
{region}/{project-id}/{repo-name}
eg.
us-central1-docker.pkg.dev/mullan-gmail-com/cloud-run-source-deploy
Use the following commands to build the container and deploy to cloud run
# replace with your repo
export repo=us-central1-docker.pkg.dev/mullan-gmail-com/cloud-run-source-deploy
export image=$repo/stock-mcp
# build
gcloud builds submit --region=us-central1 --tag $image
# deploy
gcloud run deploy stock-mcp --region=us-central1 --no-allow-unauthenticated --image $image
Client
Test the server using the client.py client.
Get the server url
export url=$(gcloud run services describe stock-mcp --format="value(status.url)" --region=us-central1)
Get an identity token to authenticate with
export token=$(gcloud auth print-identity-token)
Run the client
uv run client.py
Output ...
CallToolResult(content=[TextContent(type='text', text='237.49', annotations=None, meta=None)], structured_content={'result': 237.49}, data=237.49, is_error=False)
Authenticate using proxy
As an alternative to using an identity token you can run the cloud run proxy and connect to it without a token.
gcloud run services proxy stock-mcp --port=8080 --region=us-central1
export url=http://localhost:8080
export token=
uv run client.py
Agent
The agent directory contains an agent example to test our mcp server.
Setup
Edit the agent/.env-template file and set your GCP project id and copy to agent/.env
cp agent/.env-template agent/.env
Run the adk web user interface
adk web
And browse to http://localhost:8000
In the agent chat ask some stock related questions; you should see the tool calls to our mcp server. You can examine the input and output.
