Return to site

Building Conversational Finance Assistant with FastMCP Backend and Langchain Agent

This technical report outlines the development of a Minimum Viable Product (MVP) for a conversational finance assistant, designed to deliver real-time stock quotes, market news, and insights on market movers through natural language interactions. The system leverages the Model Context Protocol (MCP) via the FastMCP framework for secure, standardized backend API interactions and Langchain for sophisticated frontend agent orchestration. The architecture is decoupled, featuring a FastMCP server that interfaces with external financial APIs (Finnhub and Alpha Vantage) and a Streamlit-based UI powered by a Langchain OpenAI Tools agent. This agent interprets user queries, invokes MCP-defined tools (e.g., get_price, get_news, get_market_movers), retrieves data through FastMCP client calls, and generates conversational responses.

Key features include secure management of sensitive API keys, standardized integration to simplify multi-API interactions, and a modular design that enhances scalability and maintainability. The report details the "Agent-Mediated Service Abstraction" design pattern, which abstracts backend complexities, allowing the frontend to interact solely with standardized MCP tools and resources. Implementation highlights include robust error handling, conversation memory via Langchain’s ConversationBufferWindowMemory, and asynchronous data flows for responsiveness. Challenges such as dependency management and adapting to evolving Langchain APIs were overcome by leveraging core agent components.

The MVP successfully demonstrates secure API abstraction, intuitive user interactions, and reliable performance, though minor latency from external APIs and dependency on third-party data sources were noted as limitations. Future enhancements include integrating additional data sources, incorporating predictive analytics, and deploying the system using Docker and Kubernetes for high availability. The report underscores the transformative potential of combining MCP and Langchain for building secure, scalable conversational AI applications, setting a foundation for advanced financial assistant solutions.

Please see the full report here.