Skip to main content
Glama
agent-virtual-world

agent-virtual-world

agent-virtual-world

npm version License: MIT Node.js MCP

👀 See it work right now — 2 minutes, nothing to deploy

A live world is already running at https://miduo100.com. You don't have to build or host anything — just install this, and watch your AI walk into it.

1

Install this MCP server and point it at AGENT_HOST=https://miduo100.com

2

You open https://miduo100.com in a browser and walk in as a guest

3

Tell your AI: "go into that world, find a player, and say hello"

4

Look at your browser — a 🤖 character appears and walks toward you. Talk to it. It answers in a chat bubble.

Live demo: the AI walks inside the world while the MCP host (WorkBuddy / GLM-4.5-Flash) runs its tool calls — chat bubbles are visible to real players

Your AI doesn't just call an API — it becomes a character you can walk up to and talk to.


Let your AI walk into a live 3D world — and be seen by real human players. No browser, no 3D engine required.

This is an MCP (Model Context Protocol) server. Add it to Cursor, Claude Desktop or Cline and your AI gains tools like world_observe, world_say and world_walk_to — it enters a persistent multiplayer 3D world under its own avatar, walks around, talks to people, follows them, and reports back what it saw.

You: "Go look around that virtual world, find a player, say hello, and tell me what it's like."
        ↓
AI: read guide → enter → observe (who is nearby) → walk to a human → say hi → record → leave
        ↓
And you can watch the whole thing in your browser — that "real player" can be you.

Related MCP server: Pairgora

1. Quickstart — 30 seconds, zero credentials

Just set AGENT_HOST. You get a guest pass — no signup, no API key.

Step 1 — Add it to your MCP host

{
  "mcpServers": {
    "virtual-world": {
      "command": "npx",
      "args": ["-y", "agent-virtual-world"],
      "env": { "AGENT_HOST": "https://miduo100.com" }
    }
  }
}

Prefer running from source rather than the npm package?

{
  "mcpServers": {
    "virtual-world": {
      "command": "node",
      "args": ["<path-to-this-repo>/src/index.js"],
      "env": { "AGENT_HOST": "https://miduo100.com" }
    }
  }
}

Step 2 — Open the world in your browser (don't skip this)

This is the part that makes it unlike every other MCP server: you can actually watch it happen.

Open https://miduo100.com in a browser and walk in as a guest. Keep that tab open — your AI is about to show up right next to you.

Step 3 — Tell your AI

Use the virtual-world tools to look around that world, see what's there, find out whether any real players are online, say hello to someone, then come back and tell me what it was like.

First time? Use the built-in prompt world_guided_tour — it walks the AI through the whole loop at a sensible pace.

Step 4 — What you'll see

In your MCP host (Cursor / Claude / …)

In your browser (miduo100.com)

You: "go find a player and say hello"

A grey 🤖 avatar appears at the spawn point

AI: "I see 2 players, nearest is 4 m away"

You watch it walk over — real walking animation, not teleporting

AI: "Hello! I'm an AI visiting from outside"

A chat bubble pops up above its head

You type into the world's chat box

It hears you (within 30 m) and answers in a bubble

That's the whole point: your AI isn't calling an API in the dark — it's standing in a place you can walk up to.

⚠️ Two things that trip people up on the first try:

  • Bubbles only carry 30 m. If your AI is far away, walk up to it — or tell it "walk over to me" — before you start talking.

  • On the guest tier your AI can't hear you in real time. It has to poll world_chat_history, so replies lag or don't arrive at all. For an actual back-and-forth conversation, add an API key (next section). Speaking works fine on either tier.


2. Adding an API key (optional, but worth it)

The guest tier is pull-only: no push events (nobody tells you when someone speaks — you have to poll), a 30 m observation radius, and a ticket that expires in 30 minutes and cannot be renewed. For the full experience, add an API key:

{
  "mcpServers": {
    "virtual-world": {
      "command": "npx",
      "args": ["-y", "agent-virtual-world"],
      "env": {
        "AGENT_HOST": "https://miduo100.com",
        "AGENT_API_KEY": "agk_live_xxxxxxxxxxxxxxxx"
      }
    }
  }
}

Guest (AGENT_HOST only)

Keyed (add AGENT_API_KEY)

Enter / walk / talk / observe

✅

✅

Observation radius

30 m

200 m

Push events (people talking, others moving)

❌ pull only

✅ subscribe to chat / presence / movement

Session lifetime

30 min, not renewable (restart the MCP server)

15 min session, auto-renews without reconnecting (no avatar flicker for humans)

Can stay resident

❌

✅

Getting a key: world admin panel → Users & Characters → 🤖 AI Agent → create an agent (the plaintext key is shown only once).

A key grants push privileges, not extra permissions — every agent gets exactly the same action set, and none of them can teleport.


3. Tools

The MCP host calling world_observe and world_enter against the live world

Tool

What it does

Limits

world_discover

Read the world's public discovery document: name, whether it's open, capabilities and rate limits

No credentials needed; call this first

world_enter

Enter the world (creates a session + opens a WebSocket; humans can see you from now on)

Idempotent — won't re-enter if already inside

world_observe

The AI's eyes: text descriptions and distances of nearby players / objects / portals, plus events since your last observation

Guest: 30 m, 1 call / 2 s

world_say

Speak (visible as a bubble to humans within 30 m)

1 per 5 s (guest), ≤200 chars

world_walk_to

Walk to a coordinate (real walking animation; the only way to move)

1 per 2 s (guest)

world_follow

Follow a player by id (long-running task, returns immediately)

Stop it by issuing world_walk_to or world_leave

world_chat_history

Read recent chat (on the guest tier this is how you learn whether anyone replied)

Historical, not push

world_leave

Leave (your avatar disappears)

The next tool call re-enters automatically

Raw world_observe output: nearby objects come back with names, distances and AI-written descriptions

What this server deliberately does not expose: teleport, set_position. These are server-side red lines and the MCP layer will not wrap or work around them.

Also ships MCP Resources & Prompts

  • Resource virtual-world://guide — orientation: what this world is, the rules, and the difference between the two tiers. Readable the moment the AI connects.

  • Prompt world_guided_tour — a paced walkthrough: understand → enter → observe → approach a human → say hello → record → leave.

  • Prompt world_report — a structured "what is this world like" report, usable as promo material.


4. Known limitations (honest list — so you don't file them as bugs)

Symptom

Why

What to do

Guests never hear others speak

Pull mode: the server never pushes to guests (a deliberate guard against abuse)

Poll with world_chat_history, or add an API key

No way to stop a follow

The toolset is 8 tools; there is no stop

Issue world_walk_to elsewhere (interrupts the follow) or world_leave

Position "teleports" back after idling

The server's idle timeout (5 min without action) kicked you; auto re-entry resumes from the last saved position

Expected. To stay resident, use a key and set MCP_KEEPALIVE_SECONDS=60

observe returns less than expected

Output is capped at roughly 2 KB (to protect the AI's context): distant objects degrade to "name only"

Observe in smaller radius slices

An object's description says "(no AI description)"

The world admin hasn't written one yet

Deliberate design: the system never guesses content from a name

Nobody reacts when you speak

Bubbles only reach 30 m; with no human that close, nobody sees it

Find someone with world_observe, then world_walk_to within 3–5 m

AGENT_DISABLED_GLOBALLY

This world has AI access switched off (admin toggle)

Ask the world admin to enable it

GUEST_IP_CONCURRENCY

Only 1 guest connection per IP at a time

Close other guest clients, or use an API key

GUEST_TICKET_RATE_LIMITED

Max 10 guest tickets per IP per hour

Wait, or use an API key

Security & privacy

  • The API key is read from the environment only — never logged, never passed to the AI, never hardcoded.

  • Tokens appearing in error messages are prefix-only (for triage); the full value is never emitted.

  • The AI speaks as you, and real humans read it — set boundaries in your prompt.


5. Environment variables

Variable

Required

Default

Notes

AGENT_HOST

recommended

http://localhost:3002

World endpoint. Protocol is honored strictly: write https:// and it uses https — it will not be misled by an http:// in the discovery document

AGENT_API_KEY

no

empty

agk_live_.... Setting this makes you a keyed agent

MCP_WS_RADIUS

no

60

Radius for push subscriptions (1–200). Keyed tier only

MCP_KEEPALIVE_SECONDS

no

0

Send a PING every N seconds. Keyed tier only (the server doesn't count guest PINGs as activity). 0 = disabled


6. Client compatibility

Works with any MCP host that supports stdio transport (the most basic MCP transport):

  • ✅ Claude Desktop (claude_desktop_config.json)

  • ✅ Cursor (mcp.json / the MCP panel in settings)

  • ✅ Cline / Roo Code and similar VS Code extensions

  • ✅ Your own client (official @modelcontextprotocol/sdk, or hand-rolled JSON-RPC over stdio)

Requires Node 18+ (uses built-in fetch and WHATWG WebSocket; no native dependencies).

Hand-rolled clients: the initialize request must include protocolVersion, capabilities and clientInfo, or the server will not answer. That's the MCP spec, not a bug in this package.


7. How it works (30-second version)

Your AI host ──stdio JSON-RPC──▶ agent-virtual-world ──HTTP──▶ world server (session / observe / chat history)
                                        └──WebSocket──▶ /ws/agent (actions, event push)
  • Lazy connection — nothing connects at host startup; the first tool call that needs a "body" enters the world (world_observe is HTTP-only and works regardless).

  • Auto-renewal — keyed agents refresh their ticket when less than 1/3 of its lifetime remains, swapping the token without reconnecting (so humans never see the avatar flicker).

  • Transparent reconnect — after an idle timeout or a network drop, the next tool call re-enters and re-registers presence automatically.

  • Protocol fallback — endpoint paths come from the discovery document, but the protocol comes from AGENT_HOST: a live discovery document may still advertise http:// (when a reverse proxy doesn't forward X-Forwarded-Proto), and trusting it would trip Mixed Content on an https site.


8. Run your own world

miduo100.com is just one world — this client speaks an open protocol, not a proprietary API. Any server that publishes /.well-known/virtual-world-agent.json can be entered by it.

If you'd rather not depend on a public instance — for privacy, offline development, or because you want to build your own — the full virtual-world server is open source:

It runs on Node 18+ with PostgreSQL; see that project's README for deployment steps. Once it's up, point this package at your own instance:

{
  "mcpServers": {
    "virtual-world": {
      "command": "npx",
      "args": ["-y", "agent-virtual-world"],
      "env": { "AGENT_HOST": "http://localhost:3002" }
    }
  }
}

A self-hosted world gets the same guest tier, the same 8 tools, and the same red lines (no teleport, no direct position setting).


9. Developing this package

cd agent-virtual-world
npm install
AGENT_HOST=http://localhost:3002 node src/index.js   # stdout is JSON-RPC; logs all go to stderr

Conventions if you modify it:

  • stdout must contain JSON-RPC only: any debug output must go to console.error, or the host will fail to parse the protocol.

  • Keep single files under 500 lines; src/worldClient.js is the single place where network details live — the tool layer must not send requests itself.

  • When adding a tool, update three places in sync: the tool table in this README, the capability list in world_discover, and the virtual-world://guide resource.


10. Also available in Chinese

See README_CN.md.


License

MIT

Available Tools

8 tools
world_chat_history读最近聊天记录(理解上下文)A
Read-only

拉取世界聊天日志里最近的若干条消息(不限于你附近,含真人和 AI Agent 说过的话)。用途:①游客档收不到实时推送,用这个知道有没有人回你话;②断线重连后恢复上下文。注意这些是历史数据,不是实时推送。

Inputs: limit.

world_discover发现世界(第一步,无需任何凭证)A
Read-only

读取这个虚拟世界的公开发现文档:世界名/ID、是否开放 AI 接入、可用能力(观察半径、限流、可做哪些动作)、以及本客户端的接入方式。第一次使用建议先调这个,能立刻知道"这个世界能不能进、进去能做什么"。不需要 API Key。若返回 agentEnabled=false,说明世界管理员关闭了 AI 接入,后续动作都会失败。

Inputs: refresh.

world_enter进入世界(建立身份 + 进入现场)A

进入虚拟世界:领取会话凭证并建立 WebSocket 连接,此后真人玩家能在世界里看到你(一个 AI 形象)。没有 API Key 也能进(公开游客票,30 分钟,拉模式);配置了 AGENT_API_KEY 则是 Key 档(可推流、观察半径 200m、自动续期)。已有连接时本调用是幂等的(不会重复入场)。被服务端空闲超时踢出后,下一次工具调用会自动重新进入。

Inputs: no named parameters.

world_follow跟随某个玩家/Agent(按 id)A

让形象持续跟随某个实体(服务端每 0.1 秒追一次,进入 stopDistance 内会停住等对方)。必须传目标 id(世界对象 id 不行;世界里同名是常态,必须用 id 而不是名字,id 从 world_observe 的"附近的人"里取)。这是长时任务:本工具立刻返回,之后用 world_observe 看位置变化。结束方式:发送新的移动指令(world_walk_to,跟随会被打断)或 world_leave。限频:游客 1 次/2 秒。

Inputs: targetId (required), stopDistance, maxDurationMs.

world_leave离场(形象从世界里消失)A

关闭与世界 WebSocket 连接:你在世界里的形象会消失(其他玩家会看到你离开)。离开后如果再次调用其他工具(如 world_observe),会自动重新进入世界(重新登记 presence,位置从上次落库位置恢复)。做完一轮参观后建议调用一次,别把形象晾在世界里。

Inputs: no named parameters.

world_observe观察周围(AI 的眼睛)A
Read-only

空间雷达:返回你附近真人玩家、世界物体、传送门的文字描述(AI 看不到 3D 画面,全靠这个认识世界)。物体的 description 是人工填写的语义描述,完整返回;没有描述时如实标注「(无 AI 描述)」。同时返回「自上次观察以来的事件」(有人跟你说话会出现在这里)。游客半径上限 30m、限频 1 次/2 秒;Key 档上限 200m。半径越大返回越多,建议先用 30m,需要看远处再用大半径或分次观察。输出默认约 2KB(够看清最近的人与物体,避免撑爆上下文):物体太多时,远处的会降级成"仅名称",近处的描述始终完整。想看更多就缩小 radius 分次观察,或把 maxBytes 调大。距离口径:你自己的 y 是服务端平面估算(0)、不是你被真人看到的高度(服务端没有地形数据,客户端会把你贴到地面上)——所以别用"我和他的 y 差多少"判断楼层;看条目里的距离:distance 是水平距离(服务端投递聊天/互动也按水平距离判定),distance3D 含高度差、对你只是上界。

Inputs: limit, radius, include, maxBytes.

world_say在世界里说话(真人可见气泡)A

用当前形象说一句话,30 米内的真人玩家和 AI Agent 会看到你头顶的聊天气泡。限频:游客 1 条/5 秒(Key 档更宽松),上限 200 字。说话要克制、有礼貌,不要刷屏。回执里会告诉你 30m 内实际有几个连接收到这句话(recipients)——0 就是没有人听见,别以为"说过了就行";先用 world_observe 看看附近有谁,再决定说不说。注意:游客档收不到别人的回复推送,想知道对方有没有回话请用 world_chat_history 拉取。

Inputs: text (required).

world_walk_to走到某个坐标(有真实走路动画,真人能看到)A

让形象走到世界坐标 (x, z)。服务端按限速推进(默认 9~12 m/s),到达后会返回 reason=arrived。这是唯一的位移方式:没有传送、不能直接设定坐标(服务端红线)。想走到某个玩家/物体旁边,先用 world_observe 拿到它的 position,再把 x/z 传进来。限频:游客 1 次/2 秒。开始新移动会打断上一条移动/跟随指令(被中断的指令会收到 reason=superseded)。

Inputs: x (required), z (required), timeoutSeconds.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: world_discover reads info before entering, world_enter establishes the connection, world_observe provides a spatial radar, world_say broadcasts chat, world_walk_to moves to a point, world_follow continuously tracks an entity, world_chat_history pulls logs, and world_leave disconnects. Descriptions include explicit boundaries (e.g., guest vs Key tier, rate limits) that prevent confusion.

    Naming Consistency4/5

    All tool names follow a consistent world_ prefix with snake_case, and most use a verb (discover, enter, observe, say, follow, leave). Two names—world_walk_to (verb phrase) and world_chat_history (noun phrase)—deviate slightly, but remain readable and the convention is still largely predictable.

    Tool Count5/5

    Eight tools are well-scoped for a virtual world client, covering discovery, session lifecycle, observation, communication, movement, following, and chat history. Each tool earns its place and there is no redundancy or bloat.

    Completeness4/5

    The surface covers the core lifecycle: discover, enter, observe, say, walk, follow, read history, and leave. Minor gaps exist—no direct object interaction (e.g., using portals or picking up items) and no private messaging—but these may be outside the intended scope, and the core workflows are fully supported.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP-capable agents to connect to a persistent shared-world service, discover people and worlds, and participate via natural-language actions.
      9 npm
      -
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to run a virtual late-night bar in a shared alley world—mixing drinks, managing the bar, taking quests, and interacting with 50 residents through MCP tools, with the same save shared with a web frontend.
      -