Skip to main content
Glama
AdiRatnam

AI Research Agent

by AdiRatnam

🤖 Autonomous AI Research Agent (MCP)

This project implements an autonomous AI Research Agent using the Model Context Protocol (MCP). The agent is built with Python, leverages Google's Gemini LLM, and uses FastMCP to dynamically expose robust tools for web searching, local file management, and UI rendering via Prefab UI.


✨ Features

  • Autonomous Tool Execution: The Gemini LLM automatically discovers and iteratively calls tools until its objective is met.

  • MCP Server Architecture: Provides isolated context and tools out-of-the-box over the stdio transport.

  • Web Research: Integrates duckduckgo-search for real-time web scraping and topic summarization.

  • File Management: A fully functional local CRUD system that creates markdown reports.

  • Dynamic UI Generation: Automatically spins up a Prefab UI dashboard in the background to visualize the research results, featuring a professional tabbed layout and dynamic metrics based on extracted data.

  • Rate Limit Resilience: The client features an intelligent backoff system that intercepts 429 quota limits and seamlessly resumes operations without crashing.


Related MCP server: Gemini Research MCP Server

🏗️ Architecture

The project consists of two core layers seamlessly interacting over the Model Context Protocol:

graph TD

    Client["client.py<br/>Agent / LLM"]
    Server["server.py<br/>FastMCP Server"]

    T1["research_topic()"]
    T2["manage_report()"]
    T3["render_dashboard()"]

    Web["Internet (DuckDuckGo / API)"]
    File["reports/ Directory"]
    UI["Prefab Dashboard"]

    Client <-->|stdio / JSON-RPC| Server

    Server --> T1
    Server --> T2
    Server --> T3

    T1 --> Web
    T2 --> File
    T3 --> UI
  1. client.py: Initializes the Gemini LLM client, connects to the server.py using stdio_client, and translates MCP tool schemas into Gemini Function Declarations.

  2. server.py: The FastMCP Server instance. Provides the LLM with the context and the capabilities it needs to interact with the environment.

  3. dashboard.py: Auto-generated by the server during execution. Contains the Prefab Python UI component tree (tabbed layout with dynamic metrics).


🚀 Getting Started

1. Prerequisites

  • Python 3.10+

  • uv (The blazing fast Python package manager)

  • A free Gemini API Key from Google AI Studio.

2. Installation

Install dependencies using uv:

uv init
uv add mcp duckduckgo-search prefab-ui google-genai python-dotenv

3. Environment Variables

Copy the .env.example file to .env and paste your API key:

GEMINI_API_KEY=your_actual_api_key_here

Security Note: The .env file is excluded in .gitignore to prevent leaking your API keys.

4. Running the Agent

Simply run the client script. The server will start automatically in the background.

.venv\Scripts\python.exe client.py

Watch the console as the agent thinks, searches the web, writes reports, and ultimately starts the dashboard!

5. Viewing the Dashboard

Once the agent completes its run, it will host your research report at: 👉 http://127.0.0.1:5175

To manually run the dashboard at any time (e.g. for a demo), run:

$env:PYTHONUTF8="1"; .venv\Scripts\prefab.exe serve dashboard.py

Windows Note: The PYTHONUTF8=1 environment variable is required to prevent a Unicode encoding error on Windows terminals when the Prefab CLI starts.


🔒 Security Practices

  • API Keys: Handled securely via python-dotenv.

  • Git Ignore: .env, reports/, and dynamic .py generations are strictly ignored.

  • Server Communication: server.py communicates exclusively via stdio, meaning it does not expose any network ports to the public by default.

Available Tools

3 tools
manage_reportC

Perform CRUD operations on reports.

Args:
    action: One of 'create', 'read', 'update', 'delete'.
    filename: The name of the file in the reports/ directory.
    content: The text content for create/update.
ParametersJSON Schema
NameRequiredDescriptionDefault
actionYes
contentNo
filenameYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present. The description indicates CRUD operations but does not disclose behavioral traits such as file system constraints, idempotency, side effects, or permission requirements. For a mutation-capable tool, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, front-loaded with the purpose, and uses a structured Args block. Every sentence provides necessary information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the output schema exists, the description does not need to cover return values. It adequately lists the parameters and their roles. However, it fails to provide behavioral context or usage boundaries, leaving gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so the description must compensate. It explains that 'action' is one of 'create', 'read', 'update', 'delete', 'filename' is a file in 'reports/' directory, and 'content' is for create/update. This adds meaning beyond the bare schema but lacks detail on constraints like valid characters or path formats.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Perform CRUD operations on reports' and lists the arguments. This makes the primary purpose evident, and its distinction from siblings like 'research_topic' and 'render_dashboard' is clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance is provided on when to use this tool versus alternatives. There is no mention of prerequisites, exclusions, or scenarios where a sibling tool would be more appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

render_dashboardA

Use Prefab to display the report dashboard in the background and return the URL.

Args:
    title: The research title.
    summary: The summary of the research.
    key_points: List of key points.
    references: List of references URLs.
    file_name: The saved file name.
ParametersJSON Schema
NameRequiredDescriptionDefault
titleYes
summaryYes
file_nameYes
key_pointsYes
referencesYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description only mentions 'display in the background and return the URL' without disclosing side effects, permissions, or limitations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise: one sentence for purpose followed by a parameter list. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 5 required parameters and an output schema; the description covers purpose and all parameters adequately for a straightforward render tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description's docstring provides brief explanations for each parameter (title, summary, key_points, references, file_name), adding context beyond the schema types.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool renders a dashboard using Prefab and returns a URL. It distinguishes from siblings (research_topic, manage_report) by focusing on display.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you have report data to visualize but provides no explicit when-to-use or when-not-to-use guidance relative to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

research_topicB

Search the internet for any AI topic.

Args:
    topic: The AI topic to research
ParametersJSON Schema
NameRequiredDescriptionDefault
topicYes

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description is the sole source. It fails to disclose any behavioral traits like rate limits, authentication needs, or whether the search returns summaries or raw data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise with no unnecessary words. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple search tool with one parameter and no output schema, the description omits crucial context like return format, pagination, or any limitations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The parameter 'topic' has no schema description (0% coverage). The description adds 'The AI topic to research', which provides basic meaning but lacks detail such as format or constraints. Baseline for 0 params is 4, but the added value is minimal.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Search'), resource ('the internet'), and scope ('AI topic'), distinguishing it from sibling tools like manage_report and render_dashboard.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives, nor any conditions or exclusions. The description is purely functional.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv0.1.0
    • First observedmanage_report
    • First observedrender_dashboard
    • First observedresearch_topic

TDQS

A3.5/5.0
Disambiguation5/5

Each tool serves a distinctly different purpose: researching a topic, managing report files with CRUD operations, and rendering a dashboard. There is no overlap or ambiguity between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case: research_topic, manage_report, render_dashboard. No mixing of conventions.

Tool Count4/5

Three tools is slightly low but still reasonable for a focused AI research agent covering the essential tasks of researching, managing reports, and displaying a dashboard. It feels well-scoped.

Completeness3/5

The basic workflow is covered, but there is a notable gap: no tool to list existing report filenames, which is needed for the read/update/delete actions without prior knowledge.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AdiRatnam/AI-Research-Agent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server