Local Agentic AI · ReAct + Model Context Protocol · Built in Go

An agent that discovers its own tools at runtime.

A local-first agentic AI system in Go: an LLM-powered ReAct agent that reasons over PDFs, the web, and a MongoDB database — wired together through the Model Context Protocol. It runs fully local on Ollama by default and switches to Anthropic Claude with zero code change.

ReAct reasoning loop Dynamic tool discovery via MCP Dual backend · Ollama / Claude Standalone MongoDB MCP server
Dharmendra Yadav
Sr. Lead Engineer / Engineering Manager · Agentic AI Architect · Team Leadership & Delivery · AI-Augmented Product Engineering
Go
Single-language stack
2
Independent services
5
MongoDB ops over MCP
Local-first
Ollama default · Claude optional
Video overview

Decoding agentic AI

A short walkthrough of the ideas behind this project — the ReAct reasoning loop, the Model Context Protocol, and why the agent discovers its tools at runtime instead of hardcoding them.

Decoding Agentic AI — ReAct, MCP, and runtime tool discovery, explained.
Live UI

The agent in action

Ask a complex question and watch the ReAct loop work — the agent interleaves reasoning with tool calls across PDF retrieval and live web search, deciding when it has enough context to answer, and when to ask for more.

Agent recognizes a vague query and asks clarifying questions instead of hallucinating
Sound judgment — asks for context on vague queries instead of hallucinating
Agent produces a structured multi-step answer grounded via PDF and web tools
Grounded answer — multi-step ReAct reasoning, grounded via PDF + web tools
What it is

A ReAct agent that treats its toolbox as a protocol, not a hardcode

Most agents wire each capability in by hand. agentic-ai instead exposes its database as a standard MCP server and gives the agent a single mcp tool — the agent learns what that server can do at query time via tools/list. Add a capability to the server and the agent picks it up with no code change.

🔁

ReAct reasoning loop

Reason → Plan → Act → Observe → repeat. The agent thinks, picks an action, executes a tool, reads the observation, and iterates until it has a grounded final answer.

🔍

Dynamic tool discovery

The agent holds a single mcp umbrella tool and discovers concrete operations at runtime via the standard MCP tools/list action — no per-operation pre-registration.

🔌

Dual LLM backend

Local Ollama by default; Anthropic Claude when an API key, model, and credit balance are all configured. Both implement one LLMCaller interface — swap with config, not code.

📐

Tool schema registry

Every tool owns its full definition (name, description, input_schema) through a Schema() method. The registry compiles these into the system prompt — descriptions live in exactly one place.

🧩

Standard MCP, no coupling

The MongoDB server speaks plain MCP over SSE. Any compatible client — Claude Desktop, Cursor, or a custom agent — connects with no special headers or auth.

🗂️

Multi-source grounding

Beyond the database, the agent reasons over local PDF vector search and live web results via the Tavily API — choosing the right source per step.

Two independent services

Modules

The system is two decoupled Go services wired together over MCP — the agent (the brain and tools) and a standalone, general-purpose MongoDB MCP server.

🧠 agents/ ReAct agent · :8082

The reasoning core. On startup it connects to the MCP server, discovers available DB operations, and builds its system prompt dynamically from each tool's own schema. Runs the ReAct loop against Ollama or Claude and serves a query API + UI.

GoReActOllamaAnthropic ClaudePDF searchTavily
Browse agents/ →

🗄️ mcp/ MCP server · :8083 / SSE

A standalone Model Context Protocol server exposing a MongoDB database as MCP tools over HTTP/SSE. General-purpose — the CRUD tools operate on any collection and any document shape, nothing hardcoded to a schema. Connect any MCP client, agent-agnostic.

GoMCPMongoDBSSEClaude DesktopCursor
Browse mcp/ →
System design

How it all fits together

Two decoupled Go services and a pluggable LLM brain, joined by an open protocol. The agent reasons; the MCP server exposes data as discoverable tools; nothing is hardcoded between them.

agentic-ai system architecture: ReAct agent on port 8082 calling search_pdf, web_search, and a single mcp umbrella tool that connects over MCP/SSE to the MongoDB MCP server on port 8083, which performs CRUD against the agentic_mcps database. A pluggable LLM backend (Claude or Ollama) drives the ReAct loop.
System data-flow — ReAct agent, three tool sources, and a standalone MongoDB MCP server over SSE.

The ReAct loop, end to end

A single endpoint runs the full reason → act → observe cycle, discovering and calling tools over MCP until the LLM produces a grounded final answer.

ReAct loop sequence diagram: the user posts a query to the agent, which initializes and lists tools from the MCP server, then loops through Thought, Action, tool execution (local search_pdf/web_search or MCP tools/call to MongoDB), and Observation, before returning a final JSON answer.
Request lifecycle — discovery via tools/list, then iterative Thought → Action → Observation until the final answer.

Agent side

Embeds the query in a dynamically-built ReAct prompt, selects the LLM backend from config, and orchestrates tool calls. It knows MCP only as a black box — one mcp tool whose operations it discovers, never hardcodes.

MCP server side

Opens an SSE stream, advertises its tool catalog via tools/list, and executes tools/call requests as MongoDB CRUD against the agentic_mcps database — returning structured CallToolResult payloads.

Service ports

ServicePortEndpoint
ReAct agent8082POST /api/agent/query · UI at /
MCP server8083SSE at /sse
PDF search (external)8081POST /api/search
The agent's capabilities

Tools & data operations

Three tool sources feed the agent — two local, one discovered over MCP. The MongoDB operations below are advertised by the server at runtime and work against any collection.

Tool / OperationSourceWhat it does
search_pdfLocalVector search over PDF documents
web_searchTavily APILive web search for fresh information
list_collectionsMCP · discoveredList all collections with document counts
query_documentsMCP · discoveredQuery documents with an optional filter
insert_documentMCP · discoveredInsert a new document
update_documentMCP · discoveredUpdate matching documents
delete_documentMCP · discoveredDelete matching documents
Module architecture

The two services, up close

Two decoupled Go modules, each with its own data-flow: the ReAct agent that reasons and calls tools, and the standalone MongoDB MCP server it discovers them from.

agents module data-flow diagram
agents/ — ReAct agent + tool registry → search_pdf · web_search · mcp
mcp module data-flow diagram
mcp/ — clients over SSE → MCP server → MongoDB; tools discovered via tools/list
Engineering surface area

Technology stack

A Go-centric, local-first stack built around an open protocol — portable across LLM backends and MCP clients.

● Go 1.21+ ● Model Context Protocol ● MongoDB ● Ollama (local LLM) ● Anthropic Claude ● ReAct prompting ● Server-Sent Events ● Tavily web search ● PDF vector search ● JSON-RPC tool calls

Dig into the engineering

Full Go source, per-module READMEs, MCP client setup for Claude Desktop & Cursor, and architecture diagrams live in the repository.