Skip to content

Help with MCP Environment #491

@nik-55

Description

@nik-55

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions