Skip to content

[FEAT][Implement MCP into agent.py] #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 176 commits into
base: master
Choose a base branch
from

Conversation

ascender1729
Copy link
Contributor

@ascender1729 ascender1729 commented Apr 18, 2025

Pull Request Description:

Description:
This PR finalizes and stabilizes full MCP (Model Context Protocol) integration into the Swarms multi-agent architecture. It includes the following major improvements:

  • MCP Server Enhancements:

    • Refactored mcp_client.py and mcp_server.py to use FastMCP with correct async and port configurations
    • Fixed server binding, FastMCP initialization, and tool routing
  • Agent & Client Improvements:

    • Updated agent.py to support parallel task execution and prevent duplicate tool calls
    • Corrected MCPServerSseParams initialization and agent response formatting
    • Enhanced client handling with better natural language input parsing and tool schema discovery
  • Testing & Workflow:

    • Added new Replit workflows and refined existing ones to test interactive multi-agent MCP flows using pytest
    • Rewrote integration tests for parallel agent behavior and server communication consistency
  • Output & Logging:

    • Cleaned up console outputs and added visual separators in multi-agent replies
    • Implemented timestamped logging across all components for better observability
  • Documentation:

    • Expanded README and added structured markdown summaries
    • Provided usage examples and configuration guidelines

Issue:
N/A — this is the initial stable release of full MCP multi-agent integration.

Dependencies:
fastmcp, langchain-openai, LiteLLM, anyio

Tag maintainer:
@kyegomez

Twitter handle:
https://twitter.com/the_complex_one

DP37 and others added 30 commits April 17, 2025 16:05
Added necessary modules and Nix configuration for the project's Repl.it environment.  The `.replit` file now includes `python-3.10`, `bash`, and Nix channel configuration.

Replit-Commit-Author: Assistant
- Enhanced `math_server.py` to handle invalid tool requests and unknown inputs gracefully
- Updated `test_integration.py` to include edge case scenarios for validation
- Ensured agents dynamically discover available tools and respond accordingly
- Added a log capturing warnings and errors during a multi-agent test run
- Includes issues related to API key authentication and LiteLLM model selection
- Fixed configuration issues in `math_server.py`
- Integrated API key handling for secure server access
- Modified `test_integration.py` to dynamically use either Swarms or OpenAI key
- Enables flexible backend switching for agent API calls
- Included log file capturing multi-agent interactions for financial analysis
- Documents system behavior and response patterns during testing
- Improved output formatting in `test_integration.py` for clarity
- Updated `math_server.py` configuration for consistent runtime behavior
- Updated input handling to display math calculation results properly
- Added log file documenting the fix for future reference
- Fixed server and agent configuration in `math_server.py` and `test_integration.py`
- Improved response flow when user input is missing or malformed
- Updated `math_server.py` and `test_integration.py` to explicitly use 'gpt-4o-mini'
- Ensures consistent model configuration across test and runtime environments
- Created proper MCP-compatible `math_server.py`
- Set up `test_integration.py` with multi-agent system structure
- Updated `.replit` config for seamless client-server testing
- Added `README.md` outlining how MCP integration was achieved
- Includes details to communicate implementation decisions and task fulfillment
…rage

- Improved `math_server.py` and `test_integration.py` for stability
- Added structured error handling across MCP components
- Aligned implementation with Kye’s task requirements for Swarms MCP integration
- Created `multi_server_test.py` to test coordination across agents and servers
- Added `calc_server.py` for handling computation requests
- Referenced swarms-rs Rust architecture for Python-based design structure
)

# Write results in a single operation
with open(filename, "w") as f:

Check failure

Code scanning / Bearer

Unsanitized dynamic input in file path Error

Unsanitized dynamic input in file path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants