{"id":28863231,"url":"https://github.com/extrawest/agent_with_multiple_mcp_servers","last_synced_at":"2026-05-01T08:31:45.004Z","repository":{"id":298508324,"uuid":"1000094226","full_name":"extrawest/agent_with_multiple_mcp_servers","owner":"extrawest","description":"A modular system for creating AI agents using the Model Context Protocol (MCP). This framework allows connecting to multiple MCP servers simultaneously, aggregating tools, and executing queries using LangChain agents","archived":false,"fork":false,"pushed_at":"2025-06-13T17:15:29.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-20T07:02:49.387Z","etag":null,"topics":["agent","ai","langchain","mcp","openai","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/extrawest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-11T08:56:36.000Z","updated_at":"2025-06-13T17:15:32.000Z","dependencies_parsed_at":"2025-06-11T13:49:23.776Z","dependency_job_id":"70d92116-551c-4537-b9c5-7b4655a9ab3d","html_url":"https://github.com/extrawest/agent_with_multiple_mcp_servers","commit_stats":null,"previous_names":["extrawest/agent_with_multiple_mcp_servers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/extrawest/agent_with_multiple_mcp_servers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Fagent_with_multiple_mcp_servers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Fagent_with_multiple_mcp_servers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Fagent_with_multiple_mcp_servers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Fagent_with_multiple_mcp_servers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extrawest","download_url":"https://codeload.github.com/extrawest/agent_with_multiple_mcp_servers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Fagent_with_multiple_mcp_servers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32490810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","langchain","mcp","openai","python"],"created_at":"2025-06-20T07:02:17.868Z","updated_at":"2026-05-01T08:31:44.999Z","avatar_url":"https://github.com/extrawest.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 MCP Agent Framework\n\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)]()\n[![Maintainer](https://img.shields.io/static/v1?label=Yevhen%20Ruban\u0026message=Maintainer\u0026color=red)]()\n[![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)]()\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n![GitHub release](https://img.shields.io/badge/release-v1.0.0-blue)\n\nA modular system for creating AI agents using the Model Context Protocol (MCP). This framework allows connecting to multiple MCP servers simultaneously, aggregating tools, and executing queries using LangChain agents.\n\n## 🌟 Features\n\n- 🔌 **Multi-server Connection**: Connect to multiple MCP servers simultaneously\n- 🛠️ **Tool Aggregation**: Automatically collect and combine tools from all connected servers\n- 🤖 **LangChain Integration**: Create React agents using the LangChain library\n- 🔄 **Asynchronous Processing**: Fully asynchronous code with proper resource management\n- 🧠 **OpenAI Integration**: Seamless integration with OpenAI models for intelligent agent responses\n- 📊 **Detailed Logging**: Comprehensive logging of all operational stages for debugging\n- 🧩 **Modular Architecture**: Clear separation into client and agent components\n\n\n## Demo\n\n\n\nhttps://github.com/user-attachments/assets/6ea18497-79b7-4ed9-8bc0-d211a6f3efd9\n\n\n\nhttps://github.com/user-attachments/assets/31aec298-4a60-430c-b8aa-e5c525ebce06\n\n\n\n## 🚀 Quick Start\n\n### 1. Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/extrawest/agent_with_multiple_mcp_servers.git\ncd agent_with_multiple_mcp_servers\n\n# Install dependencies\npip install -r requirements.txt\n```\n\n### 2. Configuration\n\nCopy the example environment file and configure your settings:\n\n```bash\ncp .env.example .env\n```\n\n### 3. Start MCP Servers\n\nBefore running the agent, you need to start the MCP servers. The project includes two different servers:\n\n#### Stocks Server\nProvides financial data tools using yfinance:\n```bash\n# Start the stocks server on port 7860\npython -m mcp_components.server.stocks_server\n```\n\n#### News Server\nProvides news retrieval tools using NewsAPI:\n```bash\n# Start the news server on port 7861\npython -m mcp_components.server.news_server\n```\n\n### 4. Run the Agent\n\nOnce the servers are running, you can start the agent:\n```bash\n# Run the agent with connections to both MCP servers\npython run_agent.py\n```\n\n### 5. Cursor IDE Integration\n\nYou can add the MCP servers to Cursor IDE by adding the following configuration to your Cursor settings:\n\n```json\n{\n  \"mcpServers\": {\n    \"stocks-mcp-server\": {\n      \"url\": \"http://127.0.0.1:7860/sse\"\n    },\n    \"news-mcp-server\": {\n      \"url\": \"http://127.0.0.1:7861/sse\"\n    } \n  }\n}\n```\n\nMake sure both servers are running before connecting through Cursor IDE.\n\n## 📦 Project Structure\n\n```\nmcp_components/\n├── agent/\n│   └── agent.py       # AgentRunner implementation for working with MCP servers\n├── client/\n│   └── client.py      # Client for connecting to MCP servers\n├── server/\n│   ├── stocks_server.py  # MCP server providing stock market tools\n│   └── news_server.py    # MCP server providing news retrieval tools\n```\n\n## 💻 Usage\n\n### Direct MCP Client Usage\n\n```python\nfrom mcp_components.client.client import MCPClientWrapper\nfrom typing import List, Any, Tuple\n\nasync def get_mcp_client(server_url: str) -\u003e Tuple[MCPClientWrapper, List[Any]]:\n    client = MCPClientWrapper(server_url)\n    await client.connect()\n    tools = await client.load_tools()\n    return client, tools\n```\n\n## 🔧 Components\n\n### AgentRunner\n\nClass for creating and managing agents that can use tools from multiple MCP servers:\n\n- `setup_with_multiple_mcp_servers()`: Connect to multiple MCP servers and aggregate tools\n- `run_query()`: Execute a query using the agent\n- `cleanup()`: Close all connections and free resources\n\n### MCPClientWrapper\n\nClass for connecting to MCP servers and loading tools:\n\n- `connect()`: Establish a connection with an MCP server\n- `load_tools()`: Load available tools from the server\n- `close()`: Close the connection to the server\n\n### MCP Servers\n\nThe framework includes two specialized MCP servers:\n\n#### Stocks Server\n- Provides financial data tools using yfinance\n- Runs on port 7860 by default\n- Tools:\n  - `fetch_stock_info`: Get general company information\n  - `fetch_quarterly_financials`: Get quarterly financial data\n  - `fetch_annual_financials`: Get annual financial data\n\n#### News Server\n- Provides news retrieval tools using NewsAPI\n- Runs on port 7861 by default\n- Tools:\n  - `fetch_news`: Get news articles related to a query\n\n## 📋 Requirements\n\n- Python 3.9+\n- MCP 1.9.3+\n- LangChain\n- OpenAI API key (for using OpenAI models)\n- NewsAPI key (for the news server)\n- yfinance (for the stocks server)\n\n## 🔍 Implementation Details\n\n- **Asynchronous Context Managers**: Proper management of asynchronous resources using `AsyncExitStack`\n- **Error Handling**: Robust exception handling at all levels\n- **Connection Preservation**: Maintaining active connections for tool usage\n- **Tool Aggregation**: Combining tools from different servers into a unified list\n\nDeveloped by [extrawest](https://extrawest.com/). Software development company\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrawest%2Fagent_with_multiple_mcp_servers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextrawest%2Fagent_with_multiple_mcp_servers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrawest%2Fagent_with_multiple_mcp_servers/lists"}