"""Main MCP server application.
This server exposes two tools for text analysis and document search.
"""
from fastmcp import FastMCP
from mcp_server.config.settings import config
from mcp_server.schemas import AnswerWithCitations, TextProfile
from mcp_server.tools.corpus_answer import corpus_answer
from mcp_server.tools.text_profile import text_profile
# Initialize the MCP server
mcp = FastMCP(name=config.app_name, instructions=config.app_instructions)
@mcp.tool
def corpus_answer_tool(query: str) -> AnswerWithCitations:
"""Answer a question using the local corpus with citations.
Args:
query: The question or search query
Returns:
AnswerWithCitations: Answer with supporting source documents
"""
return corpus_answer(query)
@mcp.tool
def text_profile_tool(text_or_doc_id: str) -> TextProfile:
"""Compute text analytics for a document or raw text.
Args:
text_or_doc_id: Either a document ID (filename) or raw text to analyze
Returns:
TextProfile: Complete text analytics profile including readability,
sentiment, keywords, and linguistic features
"""
return text_profile(text_or_doc_id)
if __name__ == "__main__":
# Run the server
# For testing with MCP Inspector, use stdio transport (default)
# For production deployment, you can use: transport="http"
import sys
if "--http" in sys.argv:
# HTTP transport for production
mcp.run(transport="http", host=config.host, port=config.port)
else:
# STDIO transport for testing with MCP Inspector (default)
mcp.run(transport="stdio")