home / mcp / mcp python examples mcp server
Demonstrates an authenticated MCP server and a GenAI-powered weather agent with Python-based tools.
Configuration
View docs{
"mcpServers": {
"agentworkshop-mcp": {
"url": "http://localhost:8000/mcp"
}
}
}MCP (Model Context Protocol) lets you interact with dedicated servers that expose tools you can call from a client. It is useful for building interoperable toolchains, authenticating access, and orchestrating actions across services with a consistent interface.
You can connect to an MCP server to discover available tools and call them from a client. Start by running the server your chosen example provides, then run a client that discovers tools and executes them against that server. For authenticated scenarios, you’ll set an access token in your environment so the client can authenticate with the server.
Prerequisites you need before setup: Python 3.10+, pip, and a suitable shell. You also benefit from a Make tool on Linux/macOS or a standard Command Prompt on Windows.
1. Set up your environment and fetch the examples.
# Linux/macOS
git clone https://github.com/AgentWorkshop/mcp.git
cd mcp
make setup
source venv/bin/activate
cp .env.example .env
# Add your API key if you are using GenAI features
# GENAI_API_KEY=your_google_ai_api_key
# Windows
git clone https://github.com/AgentWorkshop/mcp.git
cd mcp
run.bat setup
venv\Scripts\activate.bat
copy .env.example .env
```} ,{Notes on running and testing the examples help you get practical results quickly.
Security and environment: For protected endpoints, use a token provided by the server. Set MCP_CLIENT_TOKEN in your shell before starting the client, for example as shown in the commands below.
A simple authenticated tool that responds with a greeting message to demonstrate basic MCP server access.
Provides weather forecast data for a specified location using the Weather Tool Server.
Returns weather alerts for a specified area from the Weather Tool Server.