Skip to main content
Glama
kevinave

mujoco-arm-mcp

by kevinave

๐Ÿฆพ mujoco-arm-mcp

The agent is given no inverse kinematics โ€” only a forward tool. It has to work the answer out.

A two-joint arm in MuJoCo behind an MCP server, so an LLM agent can drive it โ€” and, given a target coordinate, must find the joint angles itself.

Python MuJoCo MCP CI License

Two targets, no inverse kinematics, six tool calls โ€” driven from the SDK with nobody typing.


The idea

Giving an agent a robot arm is easy. The interesting question is what you leave out.

This server exposes one way to act โ€” set two joint angles โ€” and one way to perceive โ€” read where the tip ended up. There is no move_to(x, z), no inverse-kinematics solver anywhere in the repository, and the link lengths are never disclosed. So "put the tip at x โ‰ˆ โˆ’0.50, z โ‰ˆ 0.62" has no lookup answer.

What the agent does with that is more interesting than groping around. In the run above it spends its second call on a deliberately orthogonal pose โ€” j1=0, j2=90 โ€” which separates the two links along different axes and exposes both lengths in a single reading, then solves the geometry it just measured. Six calls for two targets, and only one of them is an experiment.


Related MCP server: robot-mcp-server

Architecture

flowchart LR
    subgraph D["๐ŸŽฎ  drivers"]
        direction TB
        CLI["๐Ÿ’ฌ <b>chat.sh</b><br/><i>Codex CLI ยท you type</i>"]
        SDK["โš™๏ธ <b>arm_agent.mjs</b><br/><i>Codex SDK ยท nobody types</i>"]
    end

    MCP["๐Ÿงฉ <b>arm_mcp.py</b><br/>MCP server<br/><i>move_arm ยท get_state ยท reset</i>"]

    subgraph SIM["๐Ÿ”ฌ &nbsp;simulation"]
        direction TB
        VIEW["๐ŸชŸ <b>viewer_server.py</b><br/><i>MuJoCo window, smooth motion</i>"]
        HEAD["๐Ÿ–ฉ <b>headless MuJoCo</b><br/><i>fallback, numbers only</i>"]
    end

    CLI -- "stdio MCP" --> MCP
    SDK -- "stdio MCP" --> MCP
    MCP -- "socket :8899 ยท if running" --> VIEW
    MCP -. "otherwise" .-> HEAD

    style MCP fill:#efe6ff,stroke:#6E56CF
    style SIM fill:#fff4e6,stroke:#FF6B35
    style D fill:#e8f0fe,stroke:#4285f4
    style VIEW fill:#ffe8cc,stroke:#FF6B35

Two processes, not one: macOS requires the GUI to own the main thread, so the viewer cannot live inside the MCP server. They talk over a local socket, and the server works with or without it.


The tools

Tool

Signature

Returns

move_arm

(angle1_deg, angle2_deg)

tip position (x, z) after the move

get_state

()

current joint angles and tip position, without moving

reset

()

returns to the zero pose

Leaving the solver out is the design. The tool surface decides whether the agent is doing the work or just relaying arguments โ€” a move_to(x, z) tool would make every run one call long and show nothing.


python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

mjpython viewer_server.py                  # the live window (macOS needs mjpython for the GUI)
python test_client.py                      # protocol check: handshake, list tools, remote call
./chat.sh                                  # Codex CLI, interactive
npm install && node agent/arm_agent.mjs    # Codex SDK โ€” the run in the GIF
mjpython replay_viewer.py                  # replay the last run from trajectory.log

PYTHON=./.venv/bin/python overrides the interpreter passed to the agent. The MCP server is normally launched by the agent over stdio; running arm_mcp.py by hand just leaves it waiting on stdin.

Step by step, including how the GIF was produced, is in docs/running-the-demo.md.

=== Agent driven from code โ€” nobody typing ===

  Task     reach two targets, tolerance 0.05, max 4 moves each
  Targets  (x = -0.50, z = 0.62)  then  (x = 0.62, z = 0.35)
  Given    a forward tool only โ€” no IK, no link lengths

[agent] I'll probe the arm with decisive poses, infer only from the returned
        tip positions, and stay within the four-move limit per target.

   1  get_state
   2  move_arm   j1=    0.0   j2=   90.0

[agent] The probe exposed the two link contributions directly: 0.60 and 0.40.
        I'm using those observations for an exact large correction.

   3  move_arm   j1=  -68.1   j2=   76.2
   4  move_arm   j1=  -76.1   j2=   74.0

[agent] First target met.

  --  reset      ------- target 1 done, swinging back -------
   6  move_arm   j1=   31.5   j2=   84.7

[agent] Second target met. I found them by probing one orthogonal pose,
        inferring both link lengths and the base offset, then solving the
        observed geometry.

And the protocol-level check, python test_client.py:

Degrade, don't fail. The server tries the viewer socket with a one-second timeout and falls back to its own MuJoCo instance if nothing answers. The agent never sees the difference, so the window is a debugging convenience rather than a dependency.

Frame the socket messages. Commands are newline-terminated JSON and the reader keeps reading until it sees the newline. TCP does not preserve message boundaries, and "one recv returns one message" is a bug that only shows up under load.

One definition of the robot. The model XML, the forward kinematics and the socket helpers all live in arm_common.py. The XML was duplicated in three files before that; the moment it needed to change, that arrangement stopped working.

Interpolate in the viewer, not in the protocol. The server sends a target; the viewer walks 8% of the remaining distance per frame. Motion looks continuous without any command being about motion.

File

Role

arm_common.py

model XML, analytic forward kinematics, socket helpers โ€” the single definition

arm_mcp.py

the MCP server: three tools, viewer-or-headless routing, trajectory logging

viewer_server.py

the MuJoCo window; listens on :8899 and eases toward the target pose

replay_viewer.py

replays trajectory.log as one continuous motion

test_client.py

protocol-level client: handshake, list tools, remote call

tests/

holds fk() to MuJoCo's numbers and recv_json to its framing promise โ€” what CI runs

chat.sh

one command to start a Codex CLI session with the arm attached

agent/arm_agent.mjs

the same thing from the Codex SDK, streaming each tool call


Scope

Deliberately small: two joints, planar motion, no dynamics, no collisions, no gripper. It exists to make one thing easy to look at โ€” an agent closing a loop through tools โ€” not to be a robotics framework.

MIT ยฉ kevinave

A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    D
    maintenance
    A domain-agnostic MCP server for autonomous experimentation, generalizing Karpathy's autoresearch pattern into a reusable server that any AI agent can drive, pointed at any domain defined by a JSON configuration.
    3
    Apache 2.0
  • A
    license
    -
    quality
    C
    maintenance
    A FastMCP server exposing 22 tools for calendar, to-do, notes, web search, math, scratchpad, task queue, and sandboxed code execution, designed for safe RL training with structured outputs and FastMCP transforms.
    MIT

View all related MCP servers

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to control Unreal Eโ€ฆ

  • Agent Replay Debugger MCP โ€” record every agent step + deterministic replay. Step-debugger for

  • MCP server for Clipkit โ€” gives AI agents a video toolbox via the Clipkit schema.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kevinave/mujoco-arm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server