How tdtheautomator/mcp works
Project Type and Purpose
• This is a demo “full-stack” prototype combining a Python back end (MCP clients, servers, LLM agent) with a Gradio-based web UI, integrating external services (Azure OpenAI, web search, stock APIs).
• Its purpose is to showcase MCP tooling: custom MCP server, GitHub MCP server, and custom tools (news search, stock price, historical stock).
File Structure
• Top-level scripts/files:
• llm_agent.py – orchestrates calls between UI, clients, and servers.
• web_host.py – launches the Gradio interface.
• prompt_template.md – LLM prompt blueprint.
• requirements.txt, .gitignore, README.md – meta/config.
• clients/
• custom_mcp_client.py – tool wrappers implementing the MCP client interface.
• github_mcp_client.py – alternate client talking to the GitHub-hosted MCP server.
• servers/
• custom_mcp_server.py – lightweight local MCP server exposing endpoints for tool execution.
• No database layer; external dependencies are Azure OpenAI, web search API, stock APIs.
README Insights
• Confirms use of Azure OpenAI for LLM calls.
• Mentions both a “GitHub MCP Server (on Docker)” and a custom server.
• Shows that the Web UI is Gradio, driven by web_host.py.
• .env holds secrets: GITHUB_TOKEN, AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT.
a. Client-side:
• Web Browser — accesses the Gradio UI.
• web_host.py (Gradio server) — receives user input (queries), forwards to llm_agent.
b. Orchestration:
• llm_agent.py — constructs LLM prompts (prompt_template.md), chooses appropriate tools (clients), communicates via MCP.
c. Tooling Layer (Clients):
• custom_mcp_client — invokes local MCP server endpoints.
• github_mcp_client — invokes GitHub-hosted MCP server endpoints (requires GITHUB_TOKEN).
d. MCP Servers:
• custom_mcp_server.py — local HTTP endpoint for executing “tools.”
• GitHub MCP Server — external Docker container (separate process).
e. External Services:
• Azure OpenAI (LLM inference).
• Web search API (news).
• Stock price API (latest/historical).
Relationships & Data Flow
• Browser → HTTP → Gradio (web_host.py).
• Gradio → Python call → llm_agent.py.
• llm_agent → HTTP (MCP protocol) → MCP Server (custom or GitHub).
• MCP Server → tool implementation → External APIs.
• External API → MCP Server → llm_agent → Gradio → Browser.
• LLM calls: llm_agent → Azure OpenAI REST API → llm_agent.
Architectural Patterns & Principles
• Separation of concerns: UI layer (Gradio) vs. orchestration (llm_agent) vs. tool execution (clients/servers).
• Plugin pattern: each tool is a client plugin; MCP server provides a uniform interface.
• Protocol-driven design: MCP defines a standard request/response for context-heavy operations.
• Microservice-like boundary between orchestrator and tool execution.
• [ ] Annotate key protocols (HTTP/REST for MCP, HTTP for Azure OpenAI).
• [ ] Group clients and servers to reflect the “clients/” and “servers/” directories.
• [ ] Show environment variable dependencies (.env).