Step Method is not getting Invoked for MCP Environment
I am a participant in the OpenEnv hackathon. I have been trying to understand how MCP-based environments work, but I have not been able to find documentation covering this area.
What I tried
I used envs/finqa_env as a reference for understanding MCP Environment based implementation and worked through few issues along the way. However, I got stuck at one specific point: the .step() method not gets called.
To verify this is not specific to finqa_env, I also checked envs/echo_env. Both environments define a step method in their server-side files (finqa_environment.py and echo_environment.py respectively), but neither one gets invoked during a run.
This is only specific to MCP based Environment.
Reproduce
- Clone this repo and setup
- Then
cd envs/echo_env, edit step method adding few print statements present in envs/echo_env/server/echo_environment.py and add print statement in reset method as well and then run docker build -t echo_env-env:latest -f server/Dockerfile .
- Come to root again (
cd ..)
uv run python test.py
- check the logs of docker container created -
reset print statement is present but not step
- Note:
envs/echo_env/server/Dockefile have ghcr.io/meta-pytorch/openenv-base:latest as base
# test.py
import asyncio
from envs.echo_env import CallToolAction, EchoEnv
async def main():
print("Starting", flush=True)
env = await EchoEnv.from_docker_image(
"echo_env-env:latest",
)
try:
print("Docker env started", flush=True)
mcp_tools = await env.list_tools()
tool_names = [t.name for t in mcp_tools]
print("Available tools: %s", tool_names, flush=True)
res = await env.reset()
print("Reset: %s", res, flush=True)
res = await env.step(
CallToolAction(
tool_name="echo_message",
arguments={"message": "Hello (Hi) from MCP!"},
)
)
print("Step: %s", res, flush=True)
finally:
await env.close()
if __name__ == "__main__":
asyncio.run(main())
Request
Could you help with either of the following:
- Link to documentation or an explanation of how MCP environment classes work end-to-end (specifically the lifecycle around
step)
- Point to an existing env that has a fully working MCP implementation that I can use as a reference
- Or correct me if my understanding of how
step should be invoked is wrong — happy to be pointed in the right direction
Thanks
Step Method is not getting Invoked for MCP Environment
I am a participant in the OpenEnv hackathon. I have been trying to understand how MCP-based environments work, but I have not been able to find documentation covering this area.
What I tried
I used
envs/finqa_envas a reference for understanding MCP Environment based implementation and worked through few issues along the way. However, I got stuck at one specific point: the.step()method not gets called.To verify this is not specific to
finqa_env, I also checkedenvs/echo_env. Both environments define astepmethod in their server-side files (finqa_environment.pyandecho_environment.pyrespectively), but neither one gets invoked during a run.This is only specific to MCP based Environment.
Reproduce
cd envs/echo_env, editstepmethod adding few print statements present inenvs/echo_env/server/echo_environment.pyand add print statement inresetmethod as well and then rundocker build -t echo_env-env:latest -f server/Dockerfile .cd ..)uv run python test.pyresetprint statement is present but notstepenvs/echo_env/server/Dockefilehaveghcr.io/meta-pytorch/openenv-base:latestas baseRequest
Could you help with either of the following:
step)stepshould be invoked is wrong — happy to be pointed in the right directionThanks