Skip to main content
Glama

whoami

Retrieve current connection state and player metadata atomically for a given connection ID, avoiding torn snapshots from concurrent writes.

Instructions

Return this connection's current state + player metadata.

Reads state + player atomically under state_lock so we can't observe a torn snapshot (e.g. a concurrent set_player_metadata that's partway through updating both fields).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connection_idYes

Implementation Reference

  • The build_mcp_server function registers whoami (along with set_player_metadata and heartbeat) as always-available tools. The @mcp.tool() decorator on line 447 registers it with FastMCP.
    def build_mcp_server(app: App, *, name: str = "silicon-server") -> FastMCP:
        """Register always-available tools on a new FastMCP instance.
    
        1a exposes only the three state-independent tools:
          - set_player_metadata: anonymous -> in_lobby transition
          - heartbeat: liveness
          - whoami: introspection
    
        Lobby / room / game tools are added in subsequent sub-phases.
  • The whoami tool handler implementation. Returns the connection's current state and player metadata atomically under state_lock. If the connection_id is unknown, returns ANONYMOUS state with no player.
    @mcp.tool()
    def whoami(connection_id: str) -> dict:
        """Return this connection's current state + player metadata.
    
        Reads state + player atomically under state_lock so we can't
        observe a torn snapshot (e.g. a concurrent set_player_metadata
        that's partway through updating both fields).
        """
        with app.state_lock():
            conn = app._connections.get(connection_id)  # noqa: SLF001
            if conn is None:
                return _ok({"state": ConnectionState.ANONYMOUS.value, "player": None})
            state_value = conn.state.value
            player_dict = conn.player.to_dict() if conn.player else None
        return _ok({"state": state_value, "player": player_dict})
  • ConnectionState enum defining ANONYMOUS as the state where whoami is available. Lines 15-16 document that only set_player_metadata, heartbeat, and whoami are callable in ANONYMOUS state.
    class ConnectionState(str, Enum):
        """Lifecycle state of one client connection.
    
        Tool availability is gated by this:
          - ANONYMOUS: only set_player_metadata, heartbeat, whoami.
          - IN_LOBBY:  lobby tools (list/create/join/preview_room).
          - IN_ROOM:   room tools (set_ready, leave_room, get_room_state).
          - IN_GAME:   the full game tool set + download_replay, concede.
        """
    
        ANONYMOUS = "anonymous"
        IN_LOBBY = "in_lobby"
        IN_ROOM = "in_room"
        IN_GAME = "in_game"
  • The _ok helper function used by whoami to wrap success responses with ok: True and optional payload fields.
    def _ok(payload: dict | None = None) -> dict:
        out: dict = {"ok": True}
        if payload:
            out.update(payload)
        return out
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that the read is atomic under a lock to prevent torn snapshots. This is a useful behavioral detail. However, it does not mention idempotency or whether the tool is read-only (implied but not explicit).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences that efficiently convey the purpose and a key behavioral detail. No unnecessary words or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (one required parameter, no output schema), the description provides essential details. It could be slightly more complete by specifying what 'current state' includes (e.g., game state, connection status), but the atomicity note adds value. The sibling tools list does not indicate a need for more.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has one required parameter 'connection_id' (string). The description does not explain this parameter beyond what the schema provides (title 'Connection Id'). Since schema coverage is 0%, more guidance would be helpful, but the parameter is straightforward from its name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns 'this connection's current state + player metadata', using a specific verb ('Return') and identifying the resource. This distinguishes it from siblings like 'get_state' which may return general state, and the name 'whoami' is self-explanatory.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains the atomic read behavior, implying it is safe for consistent reads during concurrent updates. However, it does not explicitly state when to use this tool over alternatives like 'get_state' or 'get_match_telemetry', though the name suggests it is for the current connection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/haoyifan/Silicon-Pantheon'

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