33 lines
894 B
Python
33 lines
894 B
Python
"""
|
|
MCP Server exposing search and read tools for the indexed emails.
|
|
"""
|
|
|
|
import os
|
|
from fastmcp import FastMCP
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
# Initialize FastMCP server
|
|
mcp = FastMCP("mcp-maildir")
|
|
|
|
@mcp.tool()
|
|
def search_emails(query: str, sender: str | None = None, start_date: str | None = None, end_date: str | None = None):
|
|
"""
|
|
Performs a hybrid search (Semantic + Exact filtering on metadata).
|
|
"""
|
|
# TODO: Implement Qdrant search
|
|
return f"Searching for '{query}'..."
|
|
|
|
@mcp.tool()
|
|
def read_email(message_id: str):
|
|
"""
|
|
Returns the full text content (cleaned of HTML) of a specific email.
|
|
"""
|
|
# TODO: Implement fetching email by message_id
|
|
return f"Reading email {message_id}..."
|
|
|
|
if __name__ == "__main__":
|
|
# Start the MCP server using SSE (Server-Sent Events) over HTTP
|
|
mcp.run(transport="sse", host="0.0.0.0", port=8000)
|