A lightweight, tool-augmented AI agent powered by GPT-4o and the Model Context Protocol.
Think → Plan → Act → Observe → Answer
A reasoning loop that connects an LLM to the real world through pluggable tools — both local and remote.
Agent MCP is a minimal yet powerful autonomous agent that:
- Receives a natural language query from the user
- Plans a sequence of tool calls using GPT-4o (with structured JSON reasoning)
- Executes tools one by one — calculators, web search, file I/O, chart generation, and more
- Observes each tool's output and feeds it back into the reasoning loop
- Answers with a final, human-friendly response
It supports both local tools (bundled in the project) and remote tools discovered dynamically via a Model Context Protocol (MCP) server — making it easily extensible without touching the agent core.
┌─────────────────────┐
│ User Query │
└─────────┬───────────┘
▼
┌─────────────────────┐
│ Agent Runner │
│ (think → act loop) │
└─────────┬───────────┘
│
┌──────────────┼──────────────┐
▼ ▼ ▼
┌─────────────┐ ┌───────────┐ ┌─────────────┐
│ Local Tools │ │ LLM API │ │ MCP Server │
│ (calc, io…) │ │ (GPT-4o) │ │ (remote) │
└─────────────┘ └───────────┘ └──────┬──────┘
│
┌────────┴────────┐
│ Remote Tools │
│ (prometheus, │
│ weather, etc.) │
└─────────────────┘
| Tool | Description |
|---|---|
echo |
Echoes input back — useful for testing |
calc |
Evaluates mathematical expressions |
search |
Performs web searches |
file |
Reads and writes local files |
current_time |
Returns the current date and time |
graph |
Generates charts (bar, pie, line) as PNG images |
mcp_proxy |
Bridges any remote MCP tool into the local agent |
Remote tools (Prometheus queries, weather data, etc.) are auto-discovered from the MCP server at startup.
agent-mcp/
├── agent.py # Core agent loop (think → act → observe)
├── cli.py # Interactive CLI interface
├── llm.py # Minimal OpenAI GPT-4o wrapper (zero dependencies)
├── mcp/
│ ├── server.py # FastMCP server (exposes remote tools)
│ └── tools/ # MCP tool definitions (prometheus, weather)
├── tools/
│ ├── __init__.py # Tool registry & discovery
│ ├── calc_tool.py # Math expression evaluator
│ ├── current_time_tool.py
│ ├── echo_tool.py
│ ├── file_tool.py # File read/write operations
│ ├── graph_tool.py # Chart generation (matplotlib)
│ ├── mcp_proxy_tool.py # Remote MCP tool proxy
│ └── search_tool.py # Web search integration
├── tests/
│ └── test_agent_basic.py
├── requirements.txt
└── TODO.md
- Python 3.10+ (3.13 recommended)
- An OpenAI API key (
OPENAI_API_KEY)
# Clone the repository
git clone https://github.com/Samanosukeh/agent-mcp.git
cd agent-mcp
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtCreate a .env file in the project root:
OPENAI_API_KEY=your-openai-api-key
MCP_API_KEY=changeme
MCP_URL=http://127.0.0.1:8000/mcp
MCP_URLis optional — if omitted, the agent runs with local tools only.
python -m mcp.server
# or directly with uvicorn:
uvicorn mcp.server:app --host 127.0.0.1 --port 8000The server exposes:
/mcp— MCP protocol endpoint/mcp/overview— lists all registered remote tools
# Interactive CLI
python cli.py
# With a custom prompt file
python cli.py -p my_prompt.txtQuery> What time is it?
Query> Calculate 2^10 + 37 * 4
Query> Generate a pie chart with data [10, 30, 25, 35] and labels ["A", "B", "C", "D"]
Query> Run the Prometheus query 'avg_over_time(cpu_usage[1h])'
Query> What's the weather in São Paulo?
python -m pytest tests/To ensure code quality, set up pre-commit hooks:
pip install pre-commit
pre-commit installThis runs linting checks (flake8) automatically on every commit.
- ChromaDB vector store for long-term memory
- Conversation persistence via
conversation_id - Web frontend for browser-based interaction
- Customizable agent strategies (decision modes, tool prioritization)
- Colored, human-friendly log output
Built with curiosity and coffee ☕