feat(agentenv-mcp): Environment with MCP-configurable action space#68
feat(agentenv-mcp): Environment with MCP-configurable action space#68supmo668 wants to merge 1 commit intoWooooDyy:mainfrom
Conversation
Adds a modular framework for creating RL environments that expose their action space as MCP tools using FastMCP for both server and client. Key features: - mcp_servers/ submodule with extensible base classes - DirectionalMCPServer as example implementation - FastMCP client for tool discovery and execution - MCPAgent for environment interaction - Centralized logging configuration - End-to-end test demonstrating full workflow Architecture: - MCP servers register tools via @mcp.tool() decorators - Agent connects via FastMCP Client to list_tools() and call_tool() - Environment provides Gym-like interface (reset/step) Usage: uv run agentenv-mcp server --port 8001 uv run agentenv-mcp agent --server-url http://localhost:8001/sse
9a2f17a to
3baa483
Compare
|
Thanks a lot for the contribution. This is a very interesting prototype and definitely a useful reference for how FastMCP-style servers can be plugged into an AgentGym-like environment. From what I understand, this PR mainly provides a framework and an example (e.g., the directional server with up/down/left/right actions) demonstrating how to adapt an MCP server into an AgentEnvironment. This is great as a conceptual demo, but I’m not sure whether it makes sense to merge directly into the main codebase, since it doesn’t currently integrate with any of the existing AgentGym environments (WebShop, BabyAI, TextCraft, etc.). I’d really love to discuss the broader direction with you: do you have any ideas or plans for adapting the existing AgentEnvironments to your MCP server design? I think shaping a consistent mapping from real environments to MCP tools could be extremely valuable, and I’m happy to explore that direction. |
|
Thanks for the input @SixPlusSeven67 I agree with your assessment. The current PR is a foundational prototype, but its real value will only be realized when it connects to the actual benchmarks hosted in AgentGym. I am very interested in contributing to the direction you mentioned: adapting existing AgentEnvironments to the MCP server design. Before I start implementing, I would value your opinion on the best architectural approach:
My goal is to help standardize the mapping from environments to tools for better portability, happy to align with whichever path fits the AgentGym roadmap best. |
Overview
An AgentGym environment where actions are determined by MCP servers you configure.
Instead of hardcoded tools, this environment's action space adapts based on which MCP servers you connect to. Configure servers via JSON, and the environment automatically uses their tools.
Concept
Example: Configure a directional server → Environment gains
up,down,left,rightactionsWhat's Included
Environment
Configuration
mcp.example.json- Define which servers to useExample Server
Utilities
Usage
1. Configure Servers
{ "mcpServers": { "directional": { "command": "uv", "args": ["run", "python", "-m", "examples.directional.server"], "url": "http://localhost:8001" } } }2. Run Environment
Internal Mode (built-in tools)
External Mode (configured servers)
3. Environment Adapts
The environment's
action_spaceautomatically reflects tools from your configured servers.Extending
Add your own MCP server:
examples/myserver/server.pywith FastMCPmcp.jsonNo environment code changes needed—just configuration.
Key Files
mcp_environment.py- Environment that reads from MCP serversmcp_client.py- Connects to servers via SSEmcp.example.json- Server configuration templateexamples/directional/- Example server implementationVerified
See
README.mdfor architecture •MIGRATION.mdfor integration details