Skip to main content
Glama
The-Focus-AI

Buttondown MCP Server

by The-Focus-AI

list_emails

Retrieve all newsletter emails from Buttondown, with optional filtering by draft, scheduled, or sent status.

Instructions

List all emails, optionally filtered by status (draft, scheduled, sent)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNoOptional status to filter emails by

Implementation Reference

  • The handler function that implements the logic for the 'list_emails' tool. It handles the optional status parameter, calls appropriate API methods, formats the email list, and returns a structured text response.
    async ({ status }) => {
      await this.ensureApiKey();
      let response;
    
      switch (status) {
        case "draft":
          response = await this.api.listDrafts();
          break;
        case "scheduled":
          response = await this.api.listScheduledEmails();
          break;
        case "sent":
          response = await this.api.listSentEmails();
          break;
        default:
          // If no status specified, list all drafts by default
          response = await this.api.listDrafts();
      }
    
      // Format the response to be more readable
      const formattedEmails = response.results.map((email) => ({
        id: email.id,
        subject: email.subject || "Untitled",
        status: email.status,
        created: email.creation_date,
        scheduled_for: email.scheduled_for || null,
        publish_date: email.publish_date || null,
        analytics: email.analytics
          ? {
              recipients: email.analytics.recipients,
              opens: email.analytics.opens,
              clicks: email.analytics.clicks,
            }
          : null,
      }));
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                total: response.count,
                emails: formattedEmails,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the list_emails tool, specifically the optional 'status' field.
    {
      status: z
        .enum(["draft", "scheduled", "sent"])
        .optional()
        .describe("Optional status to filter emails by"),
    },
  • Registration of the 'list_emails' tool on the MCP server, including name, description, schema, and handler reference.
    this.server.tool(
      "list_emails",
      "List all emails, optionally filtered by status (draft, scheduled, sent)",
      {
        status: z
          .enum(["draft", "scheduled", "sent"])
          .optional()
          .describe("Optional status to filter emails by"),
      },
      async ({ status }) => {
        await this.ensureApiKey();
        let response;
    
        switch (status) {
          case "draft":
            response = await this.api.listDrafts();
            break;
          case "scheduled":
            response = await this.api.listScheduledEmails();
            break;
          case "sent":
            response = await this.api.listSentEmails();
            break;
          default:
            // If no status specified, list all drafts by default
            response = await this.api.listDrafts();
        }
    
        // Format the response to be more readable
        const formattedEmails = response.results.map((email) => ({
          id: email.id,
          subject: email.subject || "Untitled",
          status: email.status,
          created: email.creation_date,
          scheduled_for: email.scheduled_for || null,
          publish_date: email.publish_date || null,
          analytics: email.analytics
            ? {
                recipients: email.analytics.recipients,
                opens: email.analytics.opens,
                clicks: email.analytics.clicks,
              }
            : null,
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  total: response.count,
                  emails: formattedEmails,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Helper method in ButtondownAPI to list draft emails, used when status is 'draft' or default.
    async listDrafts(): Promise<ButtondownEmailsResponse> {
      return this.request<ButtondownEmailsResponse>("/emails?status=draft");
    }
  • Helper method to list scheduled emails, used when status is 'scheduled'.
    async listScheduledEmails(): Promise<ButtondownEmailsResponse> {
      return this.request<ButtondownEmailsResponse>("/emails?status=scheduled");
    }
  • Helper method to list sent emails, used when status is 'sent'.
    async listSentEmails(): Promise<ButtondownEmailsResponse> {
      return this.request<ButtondownEmailsResponse>("/emails?status=sent");
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists emails with optional filtering, but doesn't cover critical aspects like whether this is a read-only operation, potential rate limits, authentication requirements, pagination behavior, or what the output format looks like. For a list tool with zero annotation coverage, this is a significant gap in 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?

The description is extremely concise with a single sentence that efficiently communicates the core functionality. Every word earns its place, and it's front-loaded with the main purpose. No wasted verbiage or unnecessary elaboration.

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

Completeness2/5

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

Given no annotations, no output schema, and a simple single-parameter tool, the description is incomplete. It doesn't address what the tool returns, how results are structured, whether there are limitations on the listing, or any behavioral aspects. For even a simple tool, more context about the operation would be helpful for an AI agent.

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?

Schema description coverage is 100%, with the single parameter 'status' fully documented in the schema including its enum values. The description adds minimal value beyond the schema by mentioning the optional status filtering, but doesn't provide additional context about parameter usage or implications. This meets the baseline for high schema coverage.

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 the tool's purpose with a specific verb ('List') and resource ('emails'), and mentions optional filtering by status. However, it doesn't explicitly differentiate from sibling tools like 'get_analytics' which might also retrieve email data, leaving some ambiguity about when to choose this tool over others.

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 usage for listing emails with optional status filtering, but provides no explicit guidance on when to use this tool versus alternatives like 'get_analytics' or 'create_draft'. It mentions the filtering capability but doesn't specify scenarios or exclusions, leaving usage context to inference.

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/The-Focus-AI/buttondown-mcp'

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