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

get_messages

Read messages sent to your terminal. Optionally delete them after retrieval to manage storage.

Instructions

Read messages sent to this terminal. Returns all messages and optionally deletes them after reading.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
terminal_nameYesYour terminal name
delete_after_readNoDelete messages after reading (default: true)

Implementation Reference

  • src/tools.js:98-119 (registration)
    Registration of the "get_messages" tool on the MCP server. It accepts terminal_name (required) and delete_after_read (boolean, default true) inputs and calls the list() function from messages.js.
    server.tool(
      "get_messages",
      "Read messages sent to this terminal. Returns all messages and optionally deletes them after reading.",
      {
        terminal_name: nameSchema.describe("Your terminal name"),
        delete_after_read: z
          .boolean()
          .default(true)
          .describe("Delete messages after reading (default: true)"),
      },
      async ({ terminal_name, delete_after_read }) => {
        const messages = list(terminal_name, { deleteAfterRead: delete_after_read });
        if (messages.length === 0) {
          return {
            content: [{ type: "text", text: `No messages for "${terminal_name}".` }],
          };
        }
        return {
          content: [{ type: "text", text: renderMessages(terminal_name, messages) }],
        };
      },
    );
  • Handler function for get_messages: calls list(terminal_name, { deleteAfterRead }) from messages.js, returns formatted messages or a 'no messages' response.
    async ({ terminal_name, delete_after_read }) => {
      const messages = list(terminal_name, { deleteAfterRead: delete_after_read });
      if (messages.length === 0) {
        return {
          content: [{ type: "text", text: `No messages for "${terminal_name}".` }],
        };
      }
      return {
        content: [{ type: "text", text: renderMessages(terminal_name, messages) }],
      };
    },
  • Helper renderMessages() formats the list of messages into a human-readable text response.
    function renderMessages(to, messages) {
      const parts = messages.map(
        (m, i) =>
          `--- Message ${i + 1} ---\nFrom: ${m.from ?? "?"}\nTime: ${m.sentAt ?? "?"}\nSummary: ${m.summary ?? ""}\n\n${m.content ?? ""}`,
      );
      return `${messages.length} message(s) for "${to}":\n\n${parts.join("\n\n")}`;
    }
  • The core list() function from messages.js that reads all stored messages for a recipient, filters out stale ones, optionally deletes them after reading, and returns the result.
    export function list(to, { deleteAfterRead = false } = {}, now = Date.now) {
      assertValidName(to);
      ensureDirs();
    
      const prefix = filePrefix(to);
      let entries;
      try {
        entries = readdirSync(messagesDir()).filter(
          (f) => f.startsWith(prefix) && f.endsWith(".json"),
        );
      } catch {
        return [];
      }
      entries.sort();
    
      const out = [];
      const cutoff = now() - MESSAGE_TTL_MS;
    
      for (const file of entries) {
        const path = join(messagesDir(), file);
        const data = /** @type {{from?: string, sentAt?: string, summary?: string, content?: string} | null} */ (
          readJsonSafe(path)
        );
        if (!data) {
          tryUnlink(path);
          continue;
        }
        const sentMs = data.sentAt ? Date.parse(data.sentAt) : NaN;
        if (Number.isFinite(sentMs) && sentMs < cutoff) {
          tryUnlink(path);
          continue;
        }
        out.push({ file, ...data });
      }
    
      if (deleteAfterRead) {
        for (const m of out) {
          tryUnlink(join(messagesDir(), m.file));
        }
      }
    
      return out;
    }
  • Input schema for get_messages: terminal_name (validated name pattern) and delete_after_read (boolean, defaults to true).
    terminal_name: nameSchema.describe("Your terminal name"),
    delete_after_read: z
      .boolean()
      .default(true)
      .describe("Delete messages after reading (default: true)"),
Behavior3/5

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

With no annotations, the description must carry the full burden. It discloses the core behavior (read and optionally delete) but does not mention potential side effects, rate limits, or authentication needs.

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 very concise at two short sentences, with no unnecessary words or repetition. It is front-loaded with the main action.

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?

The description omits the return format, which is important since there is no output schema. While the tool is simple, more detail on what 'returns all messages' means (e.g., array of strings) would improve completeness.

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 covers 100% of parameters with descriptions. The tool description adds no additional meaning beyond what is already in the schema, so baseline score of 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 the tool reads messages and optionally deletes them. It distinguishes from siblings like list_terminals, register, send_message, and watch_messages by focusing on reading and optional deletion.

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 this tool is for one-time reading of messages, but it does not explicitly guide when to use this tool versus watch_messages for continuous monitoring, nor does it mention 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