Skip to main content
Glama
beylessai

Hiworks Mail MCP

search_email

Search emails in Hiworks Mail by entering keywords, with options to filter results by username, password, and limit.

Instructions

하이웍스 이메일을 검색합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameNo
passwordNo
queryNo
limitNo

Implementation Reference

  • Full handler implementation for the 'search_email' tool. Connects to POP3 server, fetches headers of the most recent emails (ignores query, uses limit), parses with mailparser, formats dates to KST, sorts by date, returns JSON response.
    server.tool(
      'search_email',
      '하이웍스 이메일을 검색합니다.',
      searchEmailSchema,
      async ({ username, password, query, limit = 100 }) => {
        try {
          const client = await connectPOP3(username, password);
          
          // STAT으로 메일박스 상태 확인
          const stat = await client.STAT();
          
          // LIST로 각 메일의 크기 확인 (메시지 번호는 1부터 시작)
          const messageList = await client.LIST();
          const totalMessages = messageList.length;  // LIST 결과로 전체 메시지 수 계산
    
          // UIDL로 메일의 고유 ID 확인
          const uidList = await client.UIDL();
    
          const emails = [];
          const messagesToFetch = [];
    
          // 최신 메일 선택 (가장 높은 번호부터)
          const startIndex = Math.min(totalMessages, messageList[messageList.length - 1][0]);
          for (let i = startIndex; i > Math.max(1, startIndex - limit); i--) {
            if (messageList.some(([num]) => Number(num) === i)) {
              messagesToFetch.push(i);
            }
          }
    
          // 선택된 메일들의 정보 가져오기
          for (const msgNum of messagesToFetch) {
            try {
              // 먼저 TOP으로 헤더만 가져오기
              const messageTop = await client.TOP(msgNum, 0);
              const parsed = await simpleParser(messageTop);
              
              // KST로 변환된 날짜 사용
              const date = parsed.date ? formatDate(parsed.date) : formatDate(new Date());
              
              emails.push({
                id: parsed.messageId || String(msgNum),
                subject: parsed.subject || '(제목 없음)',
                from: Array.isArray(parsed.from) ? parsed.from[0]?.text || '' : parsed.from?.text || '',
                to: Array.isArray(parsed.to) ? parsed.to[0]?.text || '' : parsed.to?.text || '',
                date
              });
            } catch (err) {
              if (process.env.NODE_ENV === 'development') {
                log(`Error processing message ${msgNum}:`, err);
              }
            }
          }
    
          // KST 기준으로 정렬
          emails.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
    
          await client.QUIT();
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify({
                  success: true,
                  emails
                } as SearchEmailResponse)
              }
            ]
          };
        } catch (error: any) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify({
                  success: false,
                  emails: [],
                  error: error.message
                } as SearchEmailResponse)
              }
            ]
          };
        }
      }
    );
  • src/index.ts:89-101 (registration)
    Registration of 'search_email' tool in the MCP server's capabilities section for tool discovery by clients.
    search_email: {
      description: '하이웍스 이메일을 검색합니다.',
      parameters: {
        type: 'object',
        properties: {
          username: { type: 'string' },
          password: { type: 'string' },
          query: { type: 'string' },
          limit: { type: 'number' }
        },
        required: ['username', 'password']
      }
    },
  • Zod schema used for input validation in the search_email tool handler.
    const searchEmailSchema = {
      ...emailSchema,
      query: z.string().optional(),
      limit: z.number().optional()
    };
  • TypeScript interface defining the input parameters for search_email.
    export interface SearchEmailParams {
      username?: string;
      password?: string;
      query?: string;
      limit?: number;
    }
  • TypeScript interface defining the output response for search_email.
    export interface SearchEmailResponse {
      success: boolean;
      emails: Email[];
      error?: string;
    }
  • Helper function to establish POP3 connection, used by search_email handler.
    async function connectPOP3(username: string, password: string): Promise<Pop3Command> {
      const pop3Config = {
        user: username,
        password: password,
        host: config.pop3.host,
        port: config.pop3.port,
        tls: config.pop3.ssl,
        timeout: 60000
      };
      
      const client = new Pop3Command(pop3Config);
      return client;
    }
Behavior1/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 but fails to do so. It does not mention authentication needs (despite username/password parameters), rate limits, output format, or any behavioral traits. This leaves critical operational details unspecified.

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, efficient sentence with no wasted words. It is appropriately sized and front-loaded, stating the core action and system without unnecessary elaboration, making it highly concise.

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

Completeness1/5

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

Given the complexity of a search tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on authentication, search scope, result handling, and behavioral context, failing to provide sufficient information for effective tool use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description adds no meaning beyond the schema. It does not explain parameters like 'username', 'password', 'query', or 'limit', nor their roles or formats. For a tool with 4 parameters, this lack of semantic information is inadequate.

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

Purpose3/5

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

The description states the tool's purpose ('search emails') and specifies the system ('Hiworks'), which provides basic clarity. However, it lacks specificity about what aspects of emails are searched (e.g., subject, body, sender) and does not differentiate from sibling tools like 'read_email' or 'send_email', making it somewhat vague.

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?

No guidance is provided on when to use this tool versus alternatives such as 'read_email' or 'send_email'. The description implies usage for searching emails but offers no context on prerequisites, exclusions, or comparative scenarios, leaving the agent without direction on tool selection.

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/beylessai/hiworks-mcp'

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