[Hands-on] Building an MCP-powered Financial Analyst

100% local.

👉
Hey! Enjoy our free data science newsletter! Subscribe below and receive a free data science PDF (530+ pages) with 150+ core data science and machine learning lessons.

TODAY'S ISSUE

TODAY’S DAILY DOSE OF DATA SCIENCE

[Hands-on] Building an MCP-powered Financial Analyst

We just put together another MCP demo. It is a financial analyst that connects to your Cursor/Claude and answers finance-related queries.

The video below depicts a quick demo of what we're building!

0:00
/0:32

Tech stack:

  • CrewAI for multi-agent orchestration.
  • Ollama to locally serve DeepSeek-R1 LLM.
  • Cursor as the MCP host.

System overview:

  • The user submits a query.
  • The MCP agent kicks off the financial analyst crew.
  • The Crew conducts research and creates an executable script.
  • The agent runs the script to generate an analysis plot.

​You can find the code in this GitHub repo →​

Let's build it!

Code walkthrough

An MCP-powered Financial Analyst​

Let’s implement this!

Setup LLM

We will use Deepseek-R1 as the LLM, served locally using Ollama.

Let’s set up the Crew now.

Query parser Agent

This agent accepts a natural language query and extracts structured output using Pydantic.

This guarantees clean and structured inputs for further processing!

Code Writer Agent

This agent writes Python code to visualize stock data using Pandas, Matplotlib, and Yahoo Finance libraries.

Code Executor Agent

This agent reviews and executes the generated Python code for stock data visualization.

It uses the Code Interpreter tool by CrewAI to execute the code in a secure sandbox environment.

Setup Crew and Kickoff

Once we have our agents and their tasks defined, we set up and kick off our financial analysis crew to get the result shown below!

Create MCP Server

Now, we encapsulate our financial analyst within an MCP tool and add two more tools to enhance the user experience.

  • save_code -> Saves generated code to local directory
  • run_code_and_show_plot -> Executes the code and generates a plot

Integrate MCP server with Cursor

Go to: File → Preferences → Cursor Settings → MCP → Add new global MCP server.

In the JSON file, add what’s shown below 👇

Done! Our financial analyst MCP server is live and connected to Cursor!

You can chat with it about stock data, ask it to create plots, etc. The video at the top gives you a walk-through.

​You can find the code in this GitHub repo →​

Thanks for reading!

THAT'S A WRAP

No-Fluff Industry ML resources to

Succeed in DS/ML roles

At the end of the day, all businesses care about impact. That’s it!

  • Can you reduce costs?
  • Drive revenue?
  • Can you scale ML models?
  • Predict trends before they happen?

We have discussed several other topics (with implementations) in the past that align with such topics.

Here are some of them:

  • Learn sophisticated graph architectures and how to train them on graph data in this crash course.
  • So many real-world NLP systems rely on pairwise context scoring. Learn scalable approaches here.
  • Run large models on small devices using Quantization techniques.
  • Learn how to generate prediction intervals or sets with strong statistical guarantees for increasing trust using Conformal Predictions.
  • Learn how to identify causal relationships and answer business questions using causal inference in this crash course.
  • Learn how to scale and implement ML model training in this practical guide.
  • Learn 5 techniques with implementation to reliably test ML models in production.
  • Learn how to build and implement privacy-first ML systems using Federated Learning.
  • Learn 6 techniques with implementation to compress ML models.

All these resources will help you cultivate key skills that businesses and companies care about the most.

Our newsletter puts your products and services directly in front of an audience that matters — thousands of leaders, senior data scientists, machine learning engineers, data analysts, etc., around the world.

Get in touch today →


Join the Daily Dose of Data Science Today!

A daily column with insights, observations, tutorials, and best practices on data science.

Get Started!
Join the Daily Dose of Data Science Today!

Great! You’ve successfully signed up. Please check your email.

Welcome back! You've successfully signed in.

You've successfully subscribed to Daily Dose of Data Science.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.