Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

get_thread

Retrieve all emails in a conversation thread by providing the thread ID.

Instructions

Get all emails in a conversation thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
threadIdYesID of the thread/conversation

Implementation Reference

  • src/index.ts:812-825 (registration)
    Tool registration in ListToolsRequestSchema: defines name 'get_thread' with description 'Get all emails in a conversation thread' and input schema requiring threadId.
    {
      name: 'get_thread',
      description: 'Get all emails in a conversation thread',
      inputSchema: {
        type: 'object',
        properties: {
          threadId: {
            type: 'string',
            description: 'ID of the thread/conversation',
          },
        },
        required: ['threadId'],
      },
    },
  • Tool handler in CallToolRequestSchema: extracts threadId from args, initializes JmapClient, calls client.getThread(threadId), and returns the thread data as JSON.
    case 'get_thread': {
      const { threadId } = args as any;
      if (!threadId) {
        throw new McpError(ErrorCode.InvalidParams, 'threadId is required');
      }
      const client = initializeClient();
      try {
        const thread = await client.getThread(threadId);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(thread, null, 2),
            },
          ],
        };
      } catch (error) {
        // Provide helpful error information
        throw new McpError(ErrorCode.InternalError, `Thread access failed: ${redactBearerTokens(error instanceof Error ? error.message : String(error))}`);
      }
    }
  • The actual implementation of getThread() on JmapClient: accepts a threadId (or emailId to resolve), calls Thread/get JMAP method, then Email/get to fetch all emails in the thread.
    async getThread(threadId: string): Promise<any[]> {
      const session = await this.getSession();
    
      // First, check if threadId is actually an email ID and resolve the thread
      let actualThreadId = threadId;
      
      // Try to get the email first to see if we need to resolve thread ID
      try {
        const emailRequest: JmapRequest = {
          using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
          methodCalls: [
            ['Email/get', {
              accountId: session.accountId,
              ids: [threadId],
              properties: ['threadId']
            }, 'checkEmail']
          ]
        };
        
        const emailResponse = await this.makeRequest(emailRequest);
        const email = this.getListResult(emailResponse, 0)[0];
    
        if (email && email.threadId) {
          actualThreadId = email.threadId;
        }
      } catch (error) {
        // If email lookup fails, assume threadId is correct
      }
    
      // Use Thread/get with the resolved thread ID
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Thread/get', {
            accountId: session.accountId,
            ids: [actualThreadId]
          }, 'getThread'],
          ['Email/get', {
            accountId: session.accountId,
            '#ids': { resultOf: 'getThread', name: 'Thread/get', path: '/list/*/emailIds' },
            properties: ['id', 'subject', 'from', 'to', 'cc', 'replyTo', 'receivedAt', 'preview', 'hasAttachment', 'keywords', 'threadId']
          }, 'emails']
        ]
      };
    
      const response = await this.makeRequest(request);
      const threadResult = this.getMethodResult(response, 0);
    
      // Check if thread was found
      if (threadResult.notFound && threadResult.notFound.includes(actualThreadId)) {
        throw new Error(`Thread with ID '${actualThreadId}' not found`);
      }
    
      return this.getListResult(response, 1);
    }
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as authentication requirements, rate limits, or error handling for invalid thread IDs. The agent has no insight into potential side effects or constraints.

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 a single, concise sentence. Every word is informative, with no unnecessary content. Ideal for a straightforward tool.

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 simplicity (one parameter, no output schema), the description is minimally adequate. However, it lacks details on return format (e.g., order of emails, fields included) and does not explain what 'all emails' entails for large threads.

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 covers 100% of parameters with a description for 'threadId'. The tool description adds no additional meaning beyond 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 action 'get' and the resource 'all emails in a conversation thread', distinguishing it from siblings like 'get_email' (single email) and 'list_emails' (listing emails without thread context).

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?

No explicit when-to-use or when-not-to-use guidance is provided. The description implies use for retrieving entire threads, but alternatives like 'get_email' or 'search_emails' are not discussed. Minimal guidance.

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/owen-nash/fastmail-mcp'

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