Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

search_contacts

Find contacts by name or email address. Returns matching contacts from your Fastmail address book.

Instructions

Search contacts by name or email

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string
limitNoMaximum number of results (default: 20)

Implementation Reference

  • The `searchContacts` method on the `ContactsCalendarClient` class. It checks permissions, then sends a JMAP request with ContactCard/query (filtering by text) and ContactCard/get to retrieve matching contacts.
    async searchContacts(query: string, limit: number = 20): Promise<any[]> {
      // Check permissions first
      const hasPermission = await this.checkContactsPermission();
      if (!hasPermission) {
        throw new Error('Contacts access not available. This account may not have JMAP contacts permissions enabled. Please check your Fastmail account settings or contact support to enable contacts API access.');
      }
    
      const session = await this.getSession();
      
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:contacts'],
        methodCalls: [
          ['ContactCard/query', {
            accountId: session.accountId,
            filter: { text: query },
            limit
          }, 'query'],
          ['ContactCard/get', {
            accountId: session.accountId,
            '#ids': { resultOf: 'query', name: 'ContactCard/query', path: '/ids' },
            properties: ['id', 'name', 'emails', 'phones', 'addresses', 'notes']
          }, 'contacts']
        ]
      };
    
      try {
        const response = await this.makeRequest(request);
        return this.getListResult(response, 1);
      } catch (error) {
        throw new Error(`Contact search not supported: ${error instanceof Error ? error.message : String(error)}. Try checking account permissions or enabling contacts API access in Fastmail settings.`);
      }
  • src/index.ts:1288-1303 (registration)
    The call tool handler that routes 'search_contacts' tool invocations. It extracts the query and limit from args, initializes the ContactsCalendarClient, and calls searchContacts on it.
    case 'search_contacts': {
      const { query, limit = 20 } = args as any;
      if (!query) {
        throw new McpError(ErrorCode.InvalidParams, 'query is required');
      }
      const contactsClient = initializeContactsCalendarClient();
      const contacts = await contactsClient.searchContacts(query, limit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(contacts, null, 2),
          },
        ],
      };
    }
  • The tool definition/schema for 'search_contacts' registered in the ListToolsRequestSchema handler. Specifies input parameters: query (string, required) and limit (number, default 20).
    {
      name: 'search_contacts',
      description: 'Search contacts by name or email',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query string',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results (default: 20)',
            default: 20,
          },
        },
        required: ['query'],
      },
    },
Behavior2/5

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

No annotations provided, and description does not disclose whether the tool is read-only, required permissions, rate limits, or side effects. Minimal behavioral info.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with verb and resource. No wasted words, but could include more detail without losing conciseness.

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?

No output schema, no annotations, and no description of return format, ordering, pagination, or result set details. Incomplete for a search tool.

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 coverage is 100% with both parameters described. Description adds no additional meaning beyond the schema entries; 'query' description is redundant.

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?

Clearly states verb 'search' and resource 'contacts', with specific search fields 'name or email'. Distinguishes from siblings like 'list_contacts' and 'get_contact'.

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?

Implies usage for searching by name/email, but lacks explicit guidance on when to use this tool vs alternatives like 'advanced_search' or 'list_contacts'.

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