Skip to main content
Glama

mgba_ping

Verify that the mGBA emulator is running with the Lua bridge loaded; receive 'pong' if connected.

Instructions

Check connectivity to the mGBA bridge. Returns 'pong' if the emulator is running and the Lua bridge is loaded.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Tool definition for mgba_ping, including its schema (name, description, empty inputSchema).
    const TOOLS: Tool[] = [
      {
        name: "mgba_ping",
        description: "Check connectivity to the mGBA bridge. Returns 'pong' if the emulator is running and the Lua bridge is loaded.",
        inputSchema: { type: "object", properties: {} },
      },
  • Handler for the mgba_ping tool. Calls the mGBA bridge with method 'ping' and returns the result as text.
    case "mgba_ping": {
      const r = await mgba.call<string>("ping");
      return ok(r);
    }
  • src/tools.ts:258-261 (registration)
    Registration of all tools via ListToolsRequestSchema and CallToolRequestSchema handlers on the server.
    export function registerTools(server: Server, mgba: MgbaClient): void {
      server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
    
      server.setRequestHandler(CallToolRequestSchema, async (req) => {
  • Helper function 'ok' that wraps a text string into the MCP content response format.
    function ok(text: string) {
      return { content: [{ type: "text" as const, text }] };
    }
  • The MgbaClient.call() method that sends an RPC request (e.g., 'ping') over TCP socket and returns the result.
    async call<T = unknown>(
      method: string,
      params?: Record<string, unknown>,
    ): Promise<T> {
      // Lazy (re)connect — bridge.lua reloads kill the socket, and the user
      // shouldn't have to restart the MCP host every time they edit the script.
      if (!this.socket || this.socket.destroyed) {
        try {
          await this.connect();
        } catch (err) {
          throw new Error(
            `Cannot reach mGBA bridge at ${this.host}:${this.port}. ` +
            `Make sure mGBA is running with bridge.lua loaded (Tools > Scripting). ` +
            `Underlying error: ${(err as Error).message}`,
          );
        }
      }
    
      return new Promise<T>((resolve, reject) => {
        const sock = this.socket;
        if (!sock) {
          reject(new Error("socket vanished after connect"));
          return;
        }
    
        const id = this.nextId++;
        this.pending.set(id, (resp) => {
          if (resp.error) {
            reject(new Error(`mGBA RPC error [${resp.error.code}]: ${resp.error.message}`));
          } else {
            resolve(resp.result as T);
          }
        });
    
        const msg = JSON.stringify({ id, method, params: params ?? {} }) + "\n";
        sock.write(msg, (err) => {
          if (err) {
            this.pending.delete(id);
            reject(err);
          }
        });
      });
    }
Behavior4/5

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

Describes expected output ('pong') and conditions (emulator running, Lua bridge loaded). No annotations exist, so description bears full burden; it is sufficient for a simple ping operation.

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?

Two sentences, front-loaded with purpose, no extraneous information. Efficient and clear.

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

Completeness5/5

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

Complete for a ping tool: describes input (none), output, and condition. No output schema needed; description covers all necessary context.

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

Parameters4/5

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

No parameters, so schema coverage is 100%. Baseline of 4 for zero-parameter tools is appropriate; description adds no extra parameter meaning but is acceptable.

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?

Clearly states 'Check connectivity' as the purpose and distinguishes from sibling tools that perform emulator control or data access. Returns specific response 'pong' under defined conditions.

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?

Implicitly guides usage as a health check before other operations, but lacks explicit alternative comparisons. Uniqueness of purpose makes usage clear.

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/dmang-dev/mcp-mgba'

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