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

send_message

Send a message to another terminal on the same machine, including a summary and content. The recipient retrieves it with get_messages.

Instructions

Send a message to another terminal. The target terminal can read it with get_messages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromYesYour terminal name (the sender)
toYesTarget terminal name (the receiver)
summaryYesBrief summary of the message
contentYesThe full message content to share

Implementation Reference

  • src/tools.js:64-96 (registration)
    Tool 'send_message' is registered with MCP server via server.tool(), defining the schema (from, to, summary, content) and the handler callback.
    server.tool(
      "send_message",
      "Send a message to another terminal. The target terminal can read it with get_messages.",
      {
        from: nameSchema.describe("Your terminal name (the sender)"),
        to: nameSchema.describe("Target terminal name (the receiver)"),
        summary: z
          .string()
          .max(MAX_SUMMARY_BYTES, `Summary must be <= ${MAX_SUMMARY_BYTES} bytes`)
          .describe("Brief summary of the message"),
        content: z
          .string()
          .max(MAX_CONTENT_BYTES, `Content must be <= ${MAX_CONTENT_BYTES} bytes`)
          .describe("The full message content to share"),
      },
      async ({ from, to, summary, content }) => {
        try {
          const { sentAt } = send({ from, to, summary, content });
          return {
            content: [
              {
                type: "text",
                text: `Message sent to "${to}" at ${sentAt}.\nSummary: ${summary}\nSize: ${content.length} chars`,
              },
            ],
          };
        } catch (err) {
          return {
            content: [{ type: "text", text: `Failed to send: ${errorMessage(err)}` }],
          };
        }
      },
    );
  • The actual send() function validates inputs, writes the message as a JSON file atomically to disk, enforces queue caps, and returns the sent timestamp.
    export function send({ from, to, summary, content }, now = Date.now) {
      assertValidName(from);
      assertValidName(to);
      assertSummarySize(summary);
      assertContentSize(content);
      ensureDirs();
    
      const timestamp = now();
      const suffix = randomBytes(4).toString("hex");
      const filename = `${filePrefix(to)}${String(timestamp).padStart(15, "0")}_${suffix}.json`;
      const path = join(messagesDir(), filename);
    
      writeJsonAtomic(path, {
        from,
        to,
        summary,
        content,
        sentAt: new Date(timestamp).toISOString(),
      });
    
      enforceQueueCap(to);
      return { filename, sentAt: new Date(timestamp).toISOString() };
    }
  • Input schema for send_message: 'from' and 'to' use nameSchema (regex validated), 'summary' capped at MAX_SUMMARY_BYTES, 'content' capped at MAX_CONTENT_BYTES.
    {
      from: nameSchema.describe("Your terminal name (the sender)"),
      to: nameSchema.describe("Target terminal name (the receiver)"),
      summary: z
        .string()
        .max(MAX_SUMMARY_BYTES, `Summary must be <= ${MAX_SUMMARY_BYTES} bytes`)
        .describe("Brief summary of the message"),
      content: z
        .string()
        .max(MAX_CONTENT_BYTES, `Content must be <= ${MAX_CONTENT_BYTES} bytes`)
        .describe("The full message content to share"),
    },
  • assertValidName() validates that terminal names match the pattern [A-Za-z0-9_-]{1,32}, used by send() to validate 'from' and 'to'.
    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;
    }
  • writeJsonAtomic() writes data to a temp file then atomically renames it, used by send() to persist the message file.
    export function writeJsonAtomic(filePath, data) {
      const dir = dirname(filePath);
      const tmp = join(dir, `.tmp-${randomBytes(6).toString("hex")}`);
      writeFileSync(tmp, JSON.stringify(data, null, 2), "utf-8");
      try {
        renameSync(tmp, filePath);
      } catch (err) {
        try {
          unlinkSync(tmp);
        } catch {
          // best effort
        }
        throw err;
      }
    }
    
    /**
     * @param {string} filePath
     * @returns {unknown | null}
     */
    export function readJsonSafe(filePath) {
      try {
        return JSON.parse(readFileSync(filePath, "utf-8"));
      } catch {
        return null;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states that the tool sends a message but omits important behavioral details such as whether the sender must be registered, persistence of messages, rate limits, or confirmation of delivery.

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 extremely concise with two sentences, no wasted words, and the action verb is front-loaded. It efficiently conveys the core functionality.

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

Completeness3/5

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

Given the simple parameter structure (all required, no nested objects, no output schema) and absence of annotations, the description is minimally adequate. It covers the basic action but leaves out behavioral context like success/error responses or authentication requirements.

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 100% coverage with thorough descriptions for all 4 parameters. The tool description adds no extra meaning beyond the schema, so a baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states 'Send a message to another terminal' with a specific verb and resource, and it distinguishes the tool from its sibling 'get_messages' by noting the target can read with that tool. However, it does not explicitly differentiate from other siblings like 'register' or 'list_terminals'.

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

Usage Guidelines2/5

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

The description hints at using 'get_messages' for reading but provides no explicit guidance on when to use or avoid 'send_message' itself. There is no mention of prerequisites, limitations, or alternatives.

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