home / mcp / mcp server with google ai studio

MCP Server with Google AI Studio

mcp-api-tools

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jamalexfo-mcp-api-tools": {
      "url": "https://placeholder.example.com/mcp",
      "headers": {
        "GOOGLE_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}

You have a Python FastAPI MCP server that smartly routes prompts to multiple tools and integrates Google Gemini AI Studio. It lets you perform weather queries, fetch news, search the web, look up dictionary definitions, and retrieve inspirational quotes, all through an auto-routing interface and a Gemini-powered chat experience. This server is designed to be easy to set up, extend, and use with an MCP client.

How to use

After you start both the FastAPI server and the optional Streamlit UI, you can interact with the MCP server through your MCP client or via the provided web interfaces. The Auto Tool Router will analyze prompts and delegate tasks to the most appropriate tool, while the Google Gemini AI integration lets you chat with Gemini for advanced reasoning and guidance. You can also use tools manually to query weather, fetch news, look up dictionary definitions, get quotes, or perform a web search. Use clear prompts like asking for the current weather in a city, the latest tech news, a word definition, a motivational quote, or a general web search.

To exercise the API surface, you can rely on the recommended UI flow for day-to-day tasks. Open the Streamlit UI to access the Auto Tool Router, Gemini chat, and Manual Tools, then choose the specific tool you want to use or ask the router to pick one for you.

How to install

Prerequisites: Python 3.8 or newer and pip installed on your system.

1. Get the code by downloading or cloning the project files to your machine.

2. Install dependencies.

pip install -r requirements.txt

Or install the dependencies manually if you prefer to specify them directly.

pip install fastapi uvicorn requests pydantic python-dotenv streamlit langchain-google-genai

3. Configure the Google API key. Create or edit a file named .env in the project root and set your key.

GOOGLE_API_KEY=your_actual_api_key_here

Ensure the API key is valid and active. Replace the placeholder with your actual key.

4. Start the FastAPI server.

uvicorn server:app --reload

The server runs at http://localhost:8000.

5. (Optional) Start the Streamlit UI for the visual interface.

streamlit run app.py

Additional notes and tips

Health check: you can verify the server is up by querying the root endpoint. It should indicate the server is running and ready.

If you encounter issues with API access, double-check that the .env file exists in the project root, the API key is correctly set, and there are no stray spaces around the key.

Common troubleshooting steps include ensuring the FastAPI server is running before launching the Streamlit UI, and confirming there are no typos in environment variable names.

API endpoints you can use

Auto Tool Router auto-selects the appropriate tool based on the prompt. You can send a prompt to the Auto Tool Router to get weather, news, dictionary definitions, quotes, or a web search, depending on the content.

Google Gemini LLM endpoint lets you chat directly with Gemini via a dedicated route for interactive queries.

Health check at the root path confirms the MCP server status.

Available tools

Auto Tool Router

Automatically routes prompts to the most suitable tool based on keywords in the prompt.

Weather Tool

Provides weather information for a specified city.

News Tool

Fetches news articles based on a topic or query.

Web Search Tool

Performs web searches to gather information.

Dictionary Tool

Looks up definitions for a given word.

Quotes Tool

Retrieves inspirational quotes.

Google Gemini Integration

Integrates Google Gemini AI Studio for interactive chat and reasoning.