Skip to main content
Glama
wu-yu-pei
by wu-yu-pei

register

Give your terminal a unique name to receive messages from other terminals.

Instructions

Register this terminal with a name (e.g. A1, A2). Other terminals can then send messages to this name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesTerminal name, e.g. A1, A2, dev, test

Implementation Reference

  • The MCP tool handler for 'register' - calls the terminal register function and starts the lifecycle.
    server.tool(
      "register",
      "Register this terminal with a name (e.g. A1, A2). Other terminals can then send messages to this name.",
      { name: nameSchema.describe("Terminal name, e.g. A1, A2, dev, test") },
      async ({ name }) => {
        const result = register(name, pid);
        if (!result.ok) {
          return { content: [{ type: "text", text: result.reason }] };
        }
        lifecycle.start(name);
        return {
          content: [
            {
              type: "text",
              text: `Registered as "${name}". Other terminals can now send messages to "${name}".`,
            },
          ],
        };
      },
  • Zod schema for the 'name' input parameter of the register tool.
    const nameSchema = z
      .string()
      .regex(NAME_PATTERN, "Name must match [A-Za-z0-9_-]{1,32}");
  • The actual registration logic: validates name, checks if name is already held by a live process, and writes the terminal record to disk atomically.
    export function register(name, pid, now = Date.now) {
      assertValidName(name);
      ensureDirs();
    
      const path = fileFor(name);
      const existing = /** @type {{pid?: number, heartbeat?: number} | null} */ (
        readJsonSafe(path)
      );
    
      if (existing && existing.pid && existing.pid !== pid) {
        const fresh =
          typeof existing.heartbeat === "number" &&
          now() - existing.heartbeat < STALE_AFTER_MS;
        if (fresh && isProcessAlive(String(existing.pid))) {
          return {
            ok: /** @type {const} */ (false),
            reason: `Name "${name}" is already held by pid ${existing.pid}.`,
          };
        }
      }
    
      writeJsonAtomic(path, {
        name,
        pid,
        registeredAt: existing?.pid === pid && /** @type {any} */ (existing).registeredAt
          ? /** @type {any} */ (existing).registeredAt
          : new Date(now()).toISOString(),
        heartbeat: now(),
      });
      return { ok: /** @type {const} */ (true) };
    }
  • src/tools.js:20-40 (registration)
    The registerTools function that registers the 'register' tool (and others) onto the MCP server via server.tool().
    export function registerTools(server, { pid = process.pid, lifecycle }) {
      server.tool(
        "register",
        "Register this terminal with a name (e.g. A1, A2). Other terminals can then send messages to this name.",
        { name: nameSchema.describe("Terminal name, e.g. A1, A2, dev, test") },
        async ({ name }) => {
          const result = register(name, pid);
          if (!result.ok) {
            return { content: [{ type: "text", text: result.reason }] };
          }
          lifecycle.start(name);
          return {
            content: [
              {
                type: "text",
                text: `Registered as "${name}". Other terminals can now send messages to "${name}".`,
              },
            ],
          };
        },
      );
  • Validates terminal names against the NAME_PATTERN regex used by the register tool.
    export function assertValidName(name) {
      if (typeof name !== "string" || !NAME_PATTERN.test(name)) {
        throw new Error(
          `Invalid terminal name: must match ${NAME_PATTERN} (got ${JSON.stringify(name)})`,
        );
      }
      return name;
    }
Behavior3/5

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

No annotations exist, so the description carries the burden. It explains that registration enables message reception but does not disclose side effects like overwriting existing registrations, idempotency, or required permissions. Moderate transparency.

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, both front-loaded with key information. No extraneous words, every sentence serves a purpose.

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?

For a simple one-parameter tool with no output schema, the description covers the action and its intended effect. Minor gap: it does not describe return values or error conditions, but the context is largely complete.

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 schema has 100% coverage and already includes a description for the 'name' parameter. The tool description adds examples but does not significantly extend meaning beyond what the schema provides. Baseline 3 is appropriate.

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 'Register this terminal with a name' and gives examples like A1, A2. It also explains the purpose: enabling other terminals to send messages to the registered name. This distinguishes it from siblings like send_message and get_messages.

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

Usage Guidelines3/5

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

The description implies that registration is a prerequisite for receiving messages, but does not explicitly state when to use this tool versus alternatives. It lacks explicit conditions or exclusions, such as when not to use it.

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/wu-yu-pei/mcp-terminal-share'

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