Content
# Making an MCP Agent with Python
This is an example of implementing a YouTube agent with YouTube search, summarization, and channel analysis features using MCP.
## Introduction to MCP (Model Context Protocol)
- A standardized way for AI to effectively connect to tools of external data
- Especially used a lot for standardized connection of various tools
- **MCP Server**: Plays the role of defining and providing available tools
- **MCP Client**: Imports and uses defined tools (Claude Desktop, Cursor, OpenAI Agents SDK)
- In this example, we will create an MCP Server for YouTube content analysis and connect it with an MCP Client based on the OpenAI Agents SDK.

## Initial Setup
1. Clone or download the repository
```bash
git clone https://github.com/dabidstudio/python-mcp-agent.git
cd python-mcp-agent
```
2. [Issue an OpenAI key](https://github.com/dabidstudio/dabidstudio_guides/blob/main/get-openai-api-key.md)
3. [Issue a YouTube Data API Key](https://github.com/dabidstudio/dabidstudio_guides/blob/main/get-youtube-data-api.md)
4. Copy .env.example, enter the API key, and save as .env
```bash
OPENAI_API_KEY=api_key_input
YOUTUBE_API_KEY=api_key_input
```
5. [Set up a Python virtual environment](https://github.com/dabidstudio/dabidstudio_guides/blob/main/python-set-venv.md)
```bash
python -m venv venv
venv\Scripts\activate # Mac is source venv/bin/activate
```
6. Install packages
```bash
pip install mcp openai-agents streamlit youtube-transcript-api python-dotenv requests
```
## Preparation for MCP Client Integration
To integrate a local MCP server with MCP client applications such as Claude and Cursor,
you must enter the **Python executable path** and **MCP server script path** required to run the server in the JSON settings.
- Modify mcp.json to match your path.
### Path Configuration Example
#### ✅ Windows Example
(e.g., if the project folder is `C:\projects\dabidstudio_videos\python_mcp_agent`)
> **Note:** In Windows, you must use `\\` (double backslash) instead of `\` in JSON syntax.
```json
{
"mcpServers": {
"mcp-test": {
"command": "C:\\projects\\dabidstudio_videos\\python_mcp_agent\\venv\\Scripts\\python.exe",
"args": [
"C:\\projects\\dabidstudio_videos\\python_mcp_agent\\2_mcp_server.py"
]
}
}
}
```
---
#### ✅ macOS / Linux Example
(e.g., if the project folder is `/Users/yourname/projects/python_mcp_agent`)
```json
{
"mcpServers": {
"mcp-test": {
"command": "/Users/yourname/projects/python_mcp_agent/venv/bin/python",
"args": [
"/Users/yourname/projects/python_mcp_agent/2_mcp_server.py"
]
}
}
}
```
---
## Folder Structure
```
python-mcp-agent/
├── 1_mcp_server_functions.ipynb # MCP server function example notebook
├── 2_mcp_server.py # MCP server implementation example
├── 3_openai_agents_basics.py # OpenAI Agent basic example
├── 4_mcp_client.py # Streamlit MCP Client example
├── .env.example # Environment variable example file
└── mcp.json # MCP server configuration file
```
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
everything-claude-code
Complete Claude Code configuration collection - agents, skills, hooks,...
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.