Gemini CLI - Your Personal AI Investment Advisor

Unlocking Financial Insights with Gemini CLI and MCP Servers

The world of finance is complex, volatile, and often intimidating. From deciphering market trends to evaluating individual stocks, making informed investment decisions can feel like a full-time job. What if you could have a tireless, intelligent assistant by your side, sifting through data, analyzing performance, and even offering strategic insights?

Good news: Google recently launched the Gemini CLI open source agent. There is a generous usage tier available for free - "60 model requests per minute and 1,000 requests per day at no charge". With the power of Google's Gemini CLI and a custom setup of Model Context Protocol (MCP) servers, that future is not only possible, it's within your reach right now. Forget expensive subscriptions or black-box algorithms – we're talking about building your own sophisticated AI investment advisor.


The Brains Behind the Brawn: Gemini CLI Meets MCP

At the heart of this AI investment advisor lies the Gemini Command Line Interface (CLI), a powerful tool that allows you to interact directly with Google's Gemini models. But Gemini, while incredibly capable, is a generalist. To turn it into a financial wizard, we need to equip it with specialized knowledge and tools. This is where MCP (Model Context Protocol) servers come into play.

Think of MCP servers as specialized "plugins" or "skills" for your AI. Each server is designed to perform a specific task or access a particular type of information. By orchestrating these servers, we can empower Gemini to perform incredibly complex, multi-faceted financial analysis. In most cases, these MCP servers act as a scaffolding over API's or Databases.


My Setup: A Glimpse Under the Hood

I've been experimenting with this exact setup, running the Gemini CLI within WSL (Windows Subsystem for Linux) on my Windows machine. This provides a robust Linux environment while still leveraging the convenience of Windows. Here's a peek at the MCP servers I'm currently running, transforming my Gemini CLI into a useful financial analyst. Install the below MCP server and configure them in the settings.json for the Gemini CLI. 

"mcpServers": {
  "context7": {
    "command": "npx",
    "args": ["-y", "@upstash/context7-mcp"]
  },
  "sequential-thinking": {
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
  },
  "basic-memory": {
    "command": "uvx",
    "args": ["basic-memory", "mcp"]
  },
  "stock-analyzer": {
    "command": "uv",
    "args": [
      "--directory",
      "<absolute path>/mcp-trader",
      "run",
      "mcp-trader"
    ],
    "env": {
      "TIINGO_API_KEY": "YOUR_TIINGO_API_KEY_HERE" 
    }
  },
  "financial-hub": {
    "command": "uv",
    "args": [
      "--directory",
      "<absolute path>/mcp-finnhub",
"run", "fastmcp", "run", "server.py" ] }, "financial-modelling-prep": { "command": "<absolute path>/fmp-mcp-server/.venv/bin/python",
"args": ["<absolute path>/fmp-mcp-server/src/server.py"]
}, "quickchart": { "command": "npx", "args": ["-y", "@gongrzhe/quickchart-mcp-server"] }, "code-runner": { "command": "npx", "args": ["-y", "mcp-server-code-runner@latest"] }, "powerpoint": { "command": "uvx", "args": ["--from", "office-powerpoint-mcp-server", "ppt_mcp_server"], "env": {} }, "markdown2pdf": { "command": "node", "args": ["<absolute path>/markdown2pdf-mcp/build/index.js"],
"env": { "M2P_OUTPUT_DIR": "<absolute path>/workspace/stocks"
} } }

Let's break down what each of these powerful MCP servers brings to the table:

  • sequential-thinking: This is crucial for enhancing Gemini's ability to maintain context over longer conversations and engage in multi-step logical reasoning – essential for complex financial inquiries.

  • basic-memory: Allows Gemini to remember past interactions and information, building a more personalized and consistent advisory experience.

  • stock-analyzer (powered by Tiingo): This is where the real-time stock data comes in. It enables Gemini to fetch up-to-the-minute stock prices, historical data, and other critical metrics.

  • financial-hub (likely Finnhub integration) & financial-modelling-prep: These MCP servers provide access to a vast array of fundamental financial data, including company financials, earnings reports, analyst ratings, and more. This is key for in-depth company analysis.

  • quickchart: Imagine asking Gemini to "show me a chart of Apple's stock performance over the last year" and instantly getting a visual representation. This MCP server makes that a reality.

  • code-runner: For more advanced statistical analysis or custom data processing, Gemini can leverage this MCP server to execute code, providing unparalleled flexibility.

  • powerpoint & markdown2pdf: These MCP servers are nifty tools for presentation and reporting. Gemini can potentially generate a quick summary report of your portfolio or a detailed analysis of a target stock, ready for sharing or printing.

  • context7: This fetches the latest documentation of the software libraries. It ensures that any code written by Gemini is accurate and minimzes errors.


What Can Your AI Investment Advisor Do?

With this powerful combination, your Gemini-powered AI investgment advisor also needs guidelines on how to leverage these tools. Here is a sample GEMINI.md template. 

Project Guidelines
This document contains critical information about working with this project.
Follow these guidelines precisely.

You have the following tools:
sequential-thinking:
A detailed tool for dynamic and reflective problem-solving through thoughts.
This tool helps analyze problems through a flexible thinking process that can adapt
and evolve.
Each thought can build on, question, or revise previous insights as understanding
deepens.
When the user asks an open ended or vague question, use the sequential thinking tool
always.

basic-memory:
Use this tool to search, store, retrieve, update notes.
Whenever a chart is downloaded as an image, always update the relevant note with
the link to the image.

stock-analyzer:
Analyse a stock from multiple perspectives.

financial-hub:
Use this tool to get all the stock fundamentals, news and market trends.

financial-modelling-prep:
Get advanced market and stock details.

quickchart:
Use this tool to generate charts.
Once the chart is created, run the wget command in shell to download the chart as
an image.

powerpoint:
Use this tool to create powerpoint slides. If no template is provided,
use the professional or minimal templates.
Ensure that all the powerpoints created are formatted with the optimal font and
font size. The presentation type is always business.

code-runner:
When ad-hoc calculations are required, use python to write the calculations execute
them using this tool.
Use the below Code Quality guidelines -
Type hints required for all code
Public APIs must have docstrings
Functions must be focused and small
Follow existing patterns exactly
Line length: 88 chars maximum
Testing Requirements

Code Style should be -
PEP 8 naming (snake_case for functions/variables)
Class names in PascalCase
Constants in UPPER_SNAKE_CASE
Document with docstrings
Use f-strings for formatting
For commits fixing bugs or adding features based on user reports add:

markdown2pdf:
Convert the notes to pdf using this tool.

context7:
Use this tool to get the latest documentation on a python library.


Getting started

Follow the installation instructions from github. Once you have configured the settings.json and GEMINI.md, you can run the CLI. You will notice the message that Gemini is now ready to go with the instructions provided and the 10 MCP servers.



Now, use Ctrl+T to view all the MCP server, their status and the tools available. For sake of brevity a few of the MCP servers are show below.



Provide real-time stock quotes and historical data.
Let's use Google as a test case for all our analysis. You can type in a prompt - "
get basic fundamentals of GOOG".


After confirming the tool execution, the results are displayed in the Gemini CLI. One can see the "raw data" as well as the summary from Gemini.



Analyze key performance indicators.
Next, type in the prompt - "analyze the technical setup of GOOG". Again, a different tool asks for permission.


Once, the tool runs, the technical analysis results are shown. Not bad.


Summarize news and sentiment around specific stocks or sectors.

Now, let's ask for "get the latest market news on tech stocks".


Once the tool confirmation is provided, the news is retrieved from the MCP Servers/API's.


In addition, Gemini also recommends and alternate stock for analysis. We can accept Gemini's suggestion to compare Google with another technology stock such as Microsoft (MSFT).


Again, the same fundamental and technical analysis is done on MSFT.


As a bonus, we can also get the broader market moves for the day.


Generate charts and visualizations of financial data.
We can now try to visualize the data a bit better by asking - "what time series data do we have available for GOOG and MSFT". 


Based on the data already retrieved, charts can also now be created.


Even offer preliminary insights into potential investment strategies 

Now, let's ask for the "based on the data, what is the investment recommendation between these stocks"


Gemini CLI is able to give recommendations grounded on the stock fundamentals and technical analysis already performed in earlier steps.


Going a little deeper, let's ask for - "calculate the position size for Google".


Gemini CLI asks for inputs to calculate the position size.


It uses the relevant tools to provide the "position size" recommendations.


Create reports and presentations on demand

Now that we have done all the analysis, let's create a presentation - "create a presentation with all the analysis done so far and add the charts as well". The relevant tool now proceeds to create the presentation with all the details and charts.


The presentation is now created and it can be accessed here.



The Future of Personal Finance is Agentic

This isn't about replacing human financial advisors entirely, but about democratizing access to powerful analytical tools for retail and institutional investors alike. Imagine being able to quickly validate an investment idea, get a second opinion on a stock, or simply stay better informed about your portfolio – all through a natural language interface.

The setup might seem a bit technical at first, especially for those new to command-line tools or development environments. However, the open-source nature of many MCP servers and the clear documentation available for Gemini CLI make this an incredibly rewarding journey for anyone willing to dive in.

Also, the cost to setup the Gemini CLI and the associated MCP Servers and API's is zero, so any returns you make on your investments is all profit!

Are you ready to take control of your financial future with the power of AI? The tools are available, the potential is immense, and the learning curve is an investment in itself. Start exploring the Gemini CLI and the exciting world of MCP servers today – your personal AI investment advisor awaits. 

Enjoy learning the world of agents and happy investing!


Disclaimer: This content does NOT constitute financial advice, investment recommendations, or a solicitation to buy or sell any securities or financial products. Key Considerations and Risks:

  • Not Personalized Financial Advice: The examples and discussions herein do not consider your individual financial situation, investment objectives, risk tolerance, or specific needs. Investing decisions should always be tailored to your unique circumstances.
  • Investment Risks: All investments involve inherent risks, including the potential for loss of principal. The value of investments can fluctuate significantly due to market volatility, economic conditions, company-specific factors, and other unforeseen events. There is no guarantee that any investment strategy, even one informed by AI, will be profitable.
  • Past Performance Not Indicative of Future Results: Any historical data, analysis, or simulated performance presented or generated by the described AI setup is for illustrative purposes only and should not be considered a reliable indicator of future investment results.
  • AI Limitations and Errors: While powerful, AI models, including Gemini and the MCP servers, are based on algorithms and data. They can make errors, produce incomplete or biased information, or misinterpret complex financial nuances. The data sources used by the MCP servers (e.g., Tiingo, Finnhub) may also have their own limitations or delays. Always exercise your own independent judgment and critical thinking when using AI-generated insights.
  • No Guarantee of Accuracy or Completeness: We strive for accuracy in our content, but we make no warranties or representations, express or implied, regarding the completeness, accuracy, reliability, or suitability of any information presented. Financial markets are dynamic, and information can become outdated rapidly.
  • Human Oversight is Crucial: The AI setup described is a tool to assist with analysis, not a replacement for human expertise, due diligence, or professional financial advice. You are solely responsible for all investment decisions you make.
  • Tax and Legal Implications: Investment decisions can have tax and legal implications. You should consult with qualified tax and legal professionals for advice relevant to your specific situation.
  • Third-Party Services and APIs: The MCP servers leverage various third-party services and APIs (e.g., Tiingo). Your use of these services may be subject to their respective terms of service, privacy policies, and potential costs. We are not responsible for the performance or policies of these third-party providers.
  • Your Responsibility: By reading this blog post and considering the concepts presented, you acknowledge and agree that you are solely responsible for any investment decisions you make. You assume all risks associated with your financial actions and will not hold the author, blog, or any associated entities liable for any losses or damages incurred.
  • Always consult with a qualified and licensed financial advisor, investment professional, or other relevant expert before making any investment decisions.

Comments

Popular posts from this blog

The Many Faces of Val Kilmer

Meta Prompting for Success

Book Review - The Price of Being Fair